line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
Copyright (C) 2016-2017 Alexander Borisov |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
5
|
|
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public |
6
|
|
|
|
|
|
|
License as published by the Free Software Foundation; either |
7
|
|
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful, |
10
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12
|
|
|
|
|
|
|
Lesser General Public License for more details. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public |
15
|
|
|
|
|
|
|
License along with this library; if not, write to the Free Software |
16
|
|
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Author: lex.borisov@gmail.com (Alexander Borisov) |
19
|
|
|
|
|
|
|
*/ |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#include "mycss/tokenizer_global.h" |
22
|
|
|
|
|
|
|
#include "mycss/tokenizer_resource.h" |
23
|
|
|
|
|
|
|
#include "mycore/utils/resources.h" |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
26
|
|
|
|
|
|
|
//// Global back |
27
|
|
|
|
|
|
|
//// |
28
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
29
|
1
|
|
|
|
|
|
size_t mycss_tokenizer_global_back(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
30
|
|
|
|
|
|
|
{ |
31
|
1
|
50
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
34
|
1
|
|
|
|
|
|
return css_offset; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
38
|
|
|
|
|
|
|
//// Consume a numeric |
39
|
|
|
|
|
|
|
//// |
40
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
41
|
2
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_numeric(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
42
|
|
|
|
|
|
|
{ |
43
|
2
|
50
|
|
|
|
|
if(css[css_offset] == '%') |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
|
|
|
css_offset++; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
48
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_PERCENTAGE; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
53
|
0
|
|
|
|
|
|
return css_offset; |
54
|
|
|
|
|
|
|
} |
55
|
2
|
50
|
|
|
|
|
else if(css[css_offset] == '-') { |
56
|
0
|
|
|
|
|
|
css_offset++; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_MINUS; |
59
|
|
|
|
|
|
|
} |
60
|
2
|
50
|
|
|
|
|
else if(css[css_offset] == '\\') { |
61
|
0
|
|
|
|
|
|
css_offset++; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_RSOLIDUS; |
64
|
|
|
|
|
|
|
} |
65
|
2
|
100
|
|
|
|
|
else if(mycss_begin_chars_state_map[ (const unsigned char)(css[css_offset]) ] == MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT) { |
66
|
1
|
|
|
|
|
|
css_offset++; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_DIMENSION; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME; |
71
|
1
|
|
|
|
|
|
entry->state_back = MyCSS_TOKENIZER_GLOBAL_BACK; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else |
74
|
|
|
|
|
|
|
{ |
75
|
1
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
76
|
1
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_NUMBER; |
77
|
|
|
|
|
|
|
|
78
|
1
|
50
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
|
return css_offset; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_numeric_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
0
|
|
|
|
|
if(mycss_begin_chars_state_map[ (const unsigned char)(css[css_offset]) ] == MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT) { |
89
|
0
|
|
|
|
|
|
css_offset++; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_DIMENSION; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME; |
94
|
0
|
|
|
|
|
|
entry->state_back = MyCSS_TOKENIZER_GLOBAL_BACK; |
95
|
|
|
|
|
|
|
} |
96
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '\\') { |
97
|
0
|
|
|
|
|
|
css_offset++; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_MINUS_RSOLIDUS; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1; |
103
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_NUMBER; |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
108
|
0
|
|
|
|
|
|
css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return css_offset; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_numeric_minus_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
115
|
|
|
|
|
|
|
{ |
116
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 2; |
118
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_NUMBER; |
119
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
123
|
0
|
|
|
|
|
|
css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 2); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
else { |
126
|
0
|
|
|
|
|
|
css_offset++; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_DIMENSION; |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME; |
131
|
0
|
|
|
|
|
|
entry->state_back = MyCSS_TOKENIZER_GLOBAL_BACK; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
return css_offset; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_numeric_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
138
|
|
|
|
|
|
|
{ |
139
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1; |
141
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_NUMBER; |
142
|
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
146
|
0
|
|
|
|
|
|
css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
else { |
149
|
0
|
|
|
|
|
|
css_offset++; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_DIMENSION; |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME; |
154
|
0
|
|
|
|
|
|
entry->state_back = MyCSS_TOKENIZER_GLOBAL_BACK; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
return css_offset; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
161
|
|
|
|
|
|
|
//// Consume a number |
162
|
|
|
|
|
|
|
//// |
163
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
164
|
2
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_number_digit(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
165
|
|
|
|
|
|
|
{ |
166
|
2
|
50
|
|
|
|
|
while(css_offset < css_size) |
167
|
|
|
|
|
|
|
{ |
168
|
2
|
100
|
|
|
|
|
if(css[css_offset] < '0' || css[css_offset] > '9') |
|
|
50
|
|
|
|
|
|
169
|
|
|
|
|
|
|
{ |
170
|
2
|
50
|
|
|
|
|
if(css[css_offset] == '.') { |
171
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DOT; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
css_offset++; |
174
|
0
|
|
|
|
|
|
break; |
175
|
|
|
|
|
|
|
} |
176
|
2
|
50
|
|
|
|
|
else if(css[css_offset] == 'E' || css[css_offset] == 'e') { |
|
|
50
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E; |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
css_offset++; |
180
|
0
|
|
|
|
|
|
break; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
else { |
183
|
2
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
184
|
|
|
|
|
|
|
|
185
|
2
|
|
|
|
|
|
entry->state = entry->state_back; |
186
|
2
|
|
|
|
|
|
break; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
css_offset++; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
2
|
|
|
|
|
|
return css_offset; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_number_dot(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
197
|
|
|
|
|
|
|
{ |
198
|
0
|
0
|
|
|
|
|
if(css[css_offset] >= '0' && css[css_offset] <= '9') { |
|
|
0
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DECIMAL; |
200
|
0
|
|
|
|
|
|
css_offset++; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
else { |
203
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1; |
204
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
return css_offset; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_number_decimal(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
211
|
|
|
|
|
|
|
{ |
212
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
213
|
|
|
|
|
|
|
{ |
214
|
0
|
0
|
|
|
|
|
if(css[css_offset] < '0' || css[css_offset] > '9') |
|
|
0
|
|
|
|
|
|
215
|
|
|
|
|
|
|
{ |
216
|
0
|
0
|
|
|
|
|
if(css[css_offset] == 'E' || css[css_offset] == 'e') { |
|
|
0
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E; |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
css_offset++; |
220
|
0
|
|
|
|
|
|
break; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
else { |
223
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
224
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
225
|
0
|
|
|
|
|
|
break; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
css_offset++; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
return css_offset; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_number_e(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
236
|
|
|
|
|
|
|
{ |
237
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '+' || css[css_offset] == '-') { |
|
|
0
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E_PLUS_MINUS; |
239
|
0
|
|
|
|
|
|
css_offset++; |
240
|
|
|
|
|
|
|
} |
241
|
0
|
0
|
|
|
|
|
else if(css[css_offset] >= '0' && css[css_offset] <= '9') { |
|
|
0
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E_DECIMAL; |
243
|
0
|
|
|
|
|
|
css_offset++; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
else { |
246
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1; |
247
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
return css_offset; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_number_e_plus_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
254
|
|
|
|
|
|
|
{ |
255
|
0
|
0
|
|
|
|
|
if(css[css_offset] >= '0' && css[css_offset] <= '9') { |
|
|
0
|
|
|
|
|
|
256
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E_DECIMAL; |
257
|
0
|
|
|
|
|
|
css_offset++; |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
else { |
260
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 2; |
261
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
return css_offset; |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_number_e_decimal(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
268
|
|
|
|
|
|
|
{ |
269
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
270
|
|
|
|
|
|
|
{ |
271
|
0
|
0
|
|
|
|
|
if(css[css_offset] < '0' || css[css_offset] > '9') |
|
|
0
|
|
|
|
|
|
272
|
|
|
|
|
|
|
{ |
273
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
274
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
275
|
0
|
|
|
|
|
|
break; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
css_offset++; |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
0
|
|
|
|
|
|
return css_offset; |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
285
|
|
|
|
|
|
|
//// Consume a url token |
286
|
|
|
|
|
|
|
//// |
287
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
288
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_url(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
289
|
|
|
|
|
|
|
{ |
290
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
291
|
|
|
|
|
|
|
{ |
292
|
0
|
0
|
|
|
|
|
if(css[css_offset] != '\r' && css[css_offset] != 0x0C && |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
293
|
0
|
0
|
|
|
|
|
css[css_offset] != '\n' && css[css_offset] != '\t' && css[css_offset] != ' ') |
|
|
0
|
|
|
|
|
|
294
|
|
|
|
|
|
|
{ |
295
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '"') { |
296
|
0
|
|
|
|
|
|
css_offset++; |
297
|
|
|
|
|
|
|
|
298
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED; |
299
|
0
|
|
|
|
|
|
entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_URL_STRING_BACK; |
300
|
|
|
|
|
|
|
|
301
|
0
|
|
|
|
|
|
token->begin = entry->current_buffer->offset + css_offset; |
302
|
0
|
|
|
|
|
|
break; |
303
|
|
|
|
|
|
|
} |
304
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '\'') { |
305
|
0
|
|
|
|
|
|
css_offset++; |
306
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED; |
308
|
0
|
|
|
|
|
|
entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_URL_STRING_BACK; |
309
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
token->begin = entry->current_buffer->offset + css_offset; |
311
|
0
|
|
|
|
|
|
break; |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER; |
315
|
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
|
token->begin = entry->current_buffer->offset + css_offset; |
317
|
0
|
|
|
|
|
|
break; |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
++css_offset; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
|
return css_offset; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_url_string_back(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
327
|
|
|
|
|
|
|
{ |
328
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_BAD_STRING) |
329
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_BAD_URL; |
330
|
|
|
|
|
|
|
else |
331
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER_WHITESPACE; |
332
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
|
return css_offset; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_url_after(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
337
|
|
|
|
|
|
|
{ |
338
|
0
|
|
|
|
|
|
const unsigned char *u_css = (const unsigned char*)css; |
339
|
|
|
|
|
|
|
|
340
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
341
|
|
|
|
|
|
|
{ |
342
|
0
|
0
|
|
|
|
|
if(css[css_offset] == ')') { |
343
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
344
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_URL; |
345
|
|
|
|
|
|
|
|
346
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
347
|
|
|
|
|
|
|
|
348
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
349
|
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
css_offset++; |
351
|
0
|
|
|
|
|
|
break; |
352
|
|
|
|
|
|
|
} |
353
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '\r' || css[css_offset] == 0x0C || |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
354
|
0
|
0
|
|
|
|
|
css[css_offset] == '\n' || css[css_offset] == '\t' || css[css_offset] == ' ') |
|
|
0
|
|
|
|
|
|
355
|
|
|
|
|
|
|
{ |
356
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER_WHITESPACE; |
357
|
|
|
|
|
|
|
|
358
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
359
|
|
|
|
|
|
|
|
360
|
0
|
|
|
|
|
|
css_offset++; |
361
|
0
|
|
|
|
|
|
break; |
362
|
|
|
|
|
|
|
} |
363
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '"' || css[css_offset] == '\'' || css[css_offset] == '(' || |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
364
|
|
|
|
|
|
|
// non-printable code point |
365
|
0
|
0
|
|
|
|
|
u_css[css_offset] == 0x00 || u_css[css_offset] == 0x08 || u_css[css_offset] == 0x0B || |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
366
|
0
|
0
|
|
|
|
|
u_css[css_offset] == 0x7F || (u_css[css_offset] >= 0x0E && u_css[css_offset] <= 0x1F)) |
|
|
0
|
|
|
|
|
|
367
|
|
|
|
|
|
|
{ |
368
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_BAD_URL; |
369
|
|
|
|
|
|
|
|
370
|
0
|
|
|
|
|
|
css_offset++; |
371
|
0
|
|
|
|
|
|
break; |
372
|
|
|
|
|
|
|
} |
373
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '\\') { |
374
|
0
|
|
|
|
|
|
css_offset++; |
375
|
|
|
|
|
|
|
|
376
|
0
|
|
|
|
|
|
break; |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
|
++css_offset; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
0
|
|
|
|
|
|
return css_offset; |
383
|
|
|
|
|
|
|
} |
384
|
|
|
|
|
|
|
|
385
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_url_after_whitespace(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
386
|
|
|
|
|
|
|
{ |
387
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
388
|
|
|
|
|
|
|
{ |
389
|
0
|
0
|
|
|
|
|
if(css[css_offset] != '\r' && css[css_offset] != 0x0C && |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
390
|
0
|
0
|
|
|
|
|
css[css_offset] != '\n' && css[css_offset] != '\t' && css[css_offset] != ' ') |
|
|
0
|
|
|
|
|
|
391
|
|
|
|
|
|
|
{ |
392
|
0
|
0
|
|
|
|
|
if(css[css_offset] == ')') { |
393
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_URL; |
394
|
|
|
|
|
|
|
|
395
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
396
|
|
|
|
|
|
|
|
397
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
398
|
|
|
|
|
|
|
|
399
|
0
|
|
|
|
|
|
css_offset++; |
400
|
0
|
|
|
|
|
|
break; |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_BAD_URL; |
404
|
0
|
|
|
|
|
|
break; |
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
0
|
|
|
|
|
|
++css_offset; |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
|
410
|
0
|
|
|
|
|
|
return css_offset; |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_url_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
414
|
|
|
|
|
|
|
{ |
415
|
0
|
0
|
|
|
|
|
if(css[css_offset] != '\n' && css[css_offset] != '\r' && css[css_offset] != 0x0C) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
416
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER; |
417
|
0
|
|
|
|
|
|
return (css_offset + 1); |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
|
420
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_BAD_URL; |
421
|
|
|
|
|
|
|
|
422
|
0
|
|
|
|
|
|
return css_offset; |
423
|
|
|
|
|
|
|
} |
424
|
|
|
|
|
|
|
|
425
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_bad_url(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
426
|
|
|
|
|
|
|
{ |
427
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
428
|
|
|
|
|
|
|
{ |
429
|
0
|
0
|
|
|
|
|
if(css[css_offset] == ')') { |
430
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
431
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_BAD_URL; |
432
|
|
|
|
|
|
|
|
433
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
434
|
|
|
|
|
|
|
|
435
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
436
|
|
|
|
|
|
|
|
437
|
0
|
|
|
|
|
|
css_offset++; |
438
|
0
|
|
|
|
|
|
break; |
439
|
|
|
|
|
|
|
} |
440
|
|
|
|
|
|
|
// else if(css[css_offset] == '\\') { |
441
|
|
|
|
|
|
|
// css_offset++; |
442
|
|
|
|
|
|
|
// break; |
443
|
|
|
|
|
|
|
// } |
444
|
|
|
|
|
|
|
|
445
|
0
|
|
|
|
|
|
++css_offset; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
0
|
|
|
|
|
|
return css_offset; |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
452
|
|
|
|
|
|
|
//// Consume a string token |
453
|
|
|
|
|
|
|
//// |
454
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
455
|
7
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_string_double_quoted(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
456
|
|
|
|
|
|
|
{ |
457
|
63
|
50
|
|
|
|
|
while(css_offset < css_size) |
458
|
|
|
|
|
|
|
{ |
459
|
63
|
100
|
|
|
|
|
if(css[css_offset] == '"') |
460
|
|
|
|
|
|
|
{ |
461
|
7
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_STRING; |
462
|
7
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
// skip QUOTATION MARK (") |
465
|
7
|
|
|
|
|
|
++css_offset; |
466
|
7
|
|
|
|
|
|
entry->state = entry->state_back; |
467
|
7
|
|
|
|
|
|
break; |
468
|
|
|
|
|
|
|
} |
469
|
56
|
50
|
|
|
|
|
else if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
470
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_BAD_STRING; |
471
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
472
|
|
|
|
|
|
|
|
473
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
474
|
0
|
|
|
|
|
|
break; |
475
|
|
|
|
|
|
|
} |
476
|
56
|
50
|
|
|
|
|
else if(css[css_offset] == '\\') { |
477
|
0
|
|
|
|
|
|
css_offset++; |
478
|
|
|
|
|
|
|
|
479
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED_RSOLIDUS; |
480
|
0
|
|
|
|
|
|
break; |
481
|
|
|
|
|
|
|
} |
482
|
|
|
|
|
|
|
|
483
|
56
|
|
|
|
|
|
++css_offset; |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
|
486
|
7
|
|
|
|
|
|
return css_offset; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_string_double_quoted_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
490
|
|
|
|
|
|
|
{ |
491
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\r') |
492
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED_RSOLIDUS_R; |
493
|
|
|
|
|
|
|
else |
494
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED; |
495
|
|
|
|
|
|
|
|
496
|
0
|
|
|
|
|
|
css_offset++; |
497
|
0
|
|
|
|
|
|
return css_offset; |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
|
500
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_string_double_quoted_rsolidus_r(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
501
|
|
|
|
|
|
|
{ |
502
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\n') |
503
|
0
|
|
|
|
|
|
css_offset++; |
504
|
|
|
|
|
|
|
|
505
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED; |
506
|
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
|
return css_offset; |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_string_single_quoted(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
511
|
|
|
|
|
|
|
{ |
512
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
513
|
|
|
|
|
|
|
{ |
514
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\'') |
515
|
|
|
|
|
|
|
{ |
516
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_STRING; |
517
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
// skip APOSTROPHE (') |
520
|
0
|
|
|
|
|
|
++css_offset; |
521
|
|
|
|
|
|
|
|
522
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
523
|
0
|
|
|
|
|
|
break; |
524
|
|
|
|
|
|
|
} |
525
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
526
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_BAD_STRING; |
527
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
528
|
|
|
|
|
|
|
|
529
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
530
|
0
|
|
|
|
|
|
break; |
531
|
|
|
|
|
|
|
} |
532
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '\\') { |
533
|
0
|
|
|
|
|
|
css_offset++; |
534
|
|
|
|
|
|
|
|
535
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED_RSOLIDUS; |
536
|
0
|
|
|
|
|
|
break; |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
|
539
|
0
|
|
|
|
|
|
++css_offset; |
540
|
|
|
|
|
|
|
} |
541
|
|
|
|
|
|
|
|
542
|
0
|
|
|
|
|
|
return css_offset; |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_string_single_quoted_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
546
|
|
|
|
|
|
|
{ |
547
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\r') |
548
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED_RSOLIDUS_R; |
549
|
|
|
|
|
|
|
else |
550
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED; |
551
|
|
|
|
|
|
|
|
552
|
0
|
|
|
|
|
|
css_offset++; |
553
|
0
|
|
|
|
|
|
return css_offset; |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
|
556
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_string_single_quoted_rsolidus_r(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
557
|
|
|
|
|
|
|
{ |
558
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\n') |
559
|
0
|
|
|
|
|
|
css_offset++; |
560
|
|
|
|
|
|
|
|
561
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED; |
562
|
|
|
|
|
|
|
|
563
|
0
|
|
|
|
|
|
return css_offset; |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
567
|
|
|
|
|
|
|
//// Consume an ident-like token |
568
|
|
|
|
|
|
|
//// |
569
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
570
|
36
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_ident(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
571
|
|
|
|
|
|
|
{ |
572
|
36
|
100
|
|
|
|
|
if(css[css_offset] == '(') |
573
|
|
|
|
|
|
|
{ |
574
|
1
|
50
|
|
|
|
|
if(mycss_tokenizer_token_strcasecmp(entry, token, "url", 3) == 0) { |
575
|
0
|
|
|
|
|
|
css_offset++; |
576
|
|
|
|
|
|
|
|
577
|
0
|
|
|
|
|
|
token->begin = css_offset; |
578
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_URL; |
579
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_URL; |
580
|
|
|
|
|
|
|
} |
581
|
|
|
|
|
|
|
else { |
582
|
1
|
|
|
|
|
|
css_offset++; |
583
|
|
|
|
|
|
|
|
584
|
1
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_FUNCTION; |
585
|
|
|
|
|
|
|
|
586
|
1
|
50
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
587
|
|
|
|
|
|
|
|
588
|
1
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
589
|
|
|
|
|
|
|
} |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
else { |
592
|
35
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_IDENT; |
593
|
|
|
|
|
|
|
|
594
|
35
|
50
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
595
|
|
|
|
|
|
|
|
596
|
35
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
597
|
|
|
|
|
|
|
} |
598
|
|
|
|
|
|
|
|
599
|
36
|
|
|
|
|
|
return css_offset; |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
603
|
|
|
|
|
|
|
//// Consume a name |
604
|
|
|
|
|
|
|
//// |
605
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
606
|
146
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_name(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
607
|
|
|
|
|
|
|
{ |
608
|
146
|
|
|
|
|
|
const unsigned char *u_css = (const unsigned char*)css; |
609
|
|
|
|
|
|
|
|
610
|
601
|
100
|
|
|
|
|
while(css_offset < css_size) |
611
|
|
|
|
|
|
|
{ |
612
|
492
|
100
|
|
|
|
|
if(mycss_chars_name_code_point_map[ u_css[css_offset] ] == 0xff) |
613
|
|
|
|
|
|
|
{ |
614
|
37
|
50
|
|
|
|
|
if(css[css_offset] == '\\') { |
615
|
0
|
|
|
|
|
|
++css_offset; |
616
|
|
|
|
|
|
|
|
617
|
0
|
0
|
|
|
|
|
if(css_offset >= css_size) { |
618
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME_RSOLIDUS; |
619
|
0
|
|
|
|
|
|
break; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
623
|
0
|
|
|
|
|
|
--css_offset; |
624
|
|
|
|
|
|
|
|
625
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
626
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
627
|
|
|
|
|
|
|
|
628
|
0
|
|
|
|
|
|
break; |
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
else { |
632
|
37
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
633
|
37
|
|
|
|
|
|
entry->state = entry->state_back; |
634
|
|
|
|
|
|
|
|
635
|
37
|
|
|
|
|
|
break; |
636
|
|
|
|
|
|
|
} |
637
|
|
|
|
|
|
|
} |
638
|
|
|
|
|
|
|
|
639
|
455
|
|
|
|
|
|
css_offset++; |
640
|
|
|
|
|
|
|
} |
641
|
|
|
|
|
|
|
|
642
|
146
|
|
|
|
|
|
return css_offset; |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
|
645
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_name_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
646
|
|
|
|
|
|
|
{ |
647
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1; |
649
|
0
|
|
|
|
|
|
entry->state = entry->state_back; |
650
|
|
|
|
|
|
|
|
651
|
0
|
|
|
|
|
|
return mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1); |
652
|
|
|
|
|
|
|
} |
653
|
|
|
|
|
|
|
else { |
654
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME; |
655
|
0
|
|
|
|
|
|
css_offset++; |
656
|
|
|
|
|
|
|
} |
657
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
|
return css_offset; |
659
|
|
|
|
|
|
|
} |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
662
|
|
|
|
|
|
|
//// Consume a unicode-range token |
663
|
|
|
|
|
|
|
//// |
664
|
|
|
|
|
|
|
///////////////////////////////////////////////////////// |
665
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_unicode_range_before(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
666
|
|
|
|
|
|
|
{ |
667
|
0
|
|
|
|
|
|
entry->help_counter = 0; |
668
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE; |
669
|
|
|
|
|
|
|
|
670
|
0
|
|
|
|
|
|
return css_offset; |
671
|
|
|
|
|
|
|
} |
672
|
|
|
|
|
|
|
|
673
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_unicode_range(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
674
|
|
|
|
|
|
|
{ |
675
|
0
|
|
|
|
|
|
const unsigned char *u_css = (const unsigned char*)css; |
676
|
|
|
|
|
|
|
|
677
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
678
|
|
|
|
|
|
|
{ |
679
|
0
|
0
|
|
|
|
|
if(mycore_string_chars_hex_map[ u_css[css_offset] ] != 0xff) |
680
|
|
|
|
|
|
|
{ |
681
|
0
|
|
|
|
|
|
entry->help_counter++; |
682
|
|
|
|
|
|
|
|
683
|
0
|
0
|
|
|
|
|
if(entry->help_counter == 6) { |
684
|
0
|
|
|
|
|
|
css_offset++; |
685
|
|
|
|
|
|
|
|
686
|
0
|
|
|
|
|
|
entry->help_counter = 0; |
687
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_MINUS; |
688
|
|
|
|
|
|
|
|
689
|
0
|
|
|
|
|
|
break; |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
} |
692
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '?') { |
693
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_QUESTION; |
694
|
0
|
|
|
|
|
|
break; |
695
|
|
|
|
|
|
|
} |
696
|
0
|
0
|
|
|
|
|
else if(css[css_offset] == '-') { |
697
|
0
|
|
|
|
|
|
css_offset++; |
698
|
|
|
|
|
|
|
|
699
|
0
|
|
|
|
|
|
entry->help_counter = 0; |
700
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_MINUS; |
701
|
0
|
|
|
|
|
|
break; |
702
|
|
|
|
|
|
|
} |
703
|
|
|
|
|
|
|
else { |
704
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
705
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_UNICODE_RANGE; |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
// TODO |
708
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
709
|
|
|
|
|
|
|
|
710
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
711
|
0
|
|
|
|
|
|
break; |
712
|
|
|
|
|
|
|
} |
713
|
|
|
|
|
|
|
|
714
|
0
|
|
|
|
|
|
css_offset++; |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
|
717
|
0
|
|
|
|
|
|
return css_offset; |
718
|
|
|
|
|
|
|
} |
719
|
|
|
|
|
|
|
|
720
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_unicode_range_question(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
721
|
|
|
|
|
|
|
{ |
722
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
723
|
|
|
|
|
|
|
{ |
724
|
0
|
0
|
|
|
|
|
if(css[css_offset] == '?') { |
725
|
0
|
|
|
|
|
|
entry->help_counter++; |
726
|
|
|
|
|
|
|
|
727
|
0
|
0
|
|
|
|
|
if(entry->help_counter == 6) { |
728
|
0
|
|
|
|
|
|
css_offset++; |
729
|
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
731
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_UNICODE_RANGE; |
732
|
|
|
|
|
|
|
|
733
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
734
|
|
|
|
|
|
|
|
735
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
736
|
0
|
|
|
|
|
|
break; |
737
|
|
|
|
|
|
|
} |
738
|
|
|
|
|
|
|
} |
739
|
|
|
|
|
|
|
else { |
740
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
741
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_UNICODE_RANGE; |
742
|
|
|
|
|
|
|
|
743
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
744
|
|
|
|
|
|
|
|
745
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
746
|
0
|
|
|
|
|
|
break; |
747
|
|
|
|
|
|
|
} |
748
|
|
|
|
|
|
|
|
749
|
0
|
|
|
|
|
|
css_offset++; |
750
|
|
|
|
|
|
|
} |
751
|
|
|
|
|
|
|
|
752
|
0
|
|
|
|
|
|
return css_offset; |
753
|
|
|
|
|
|
|
} |
754
|
|
|
|
|
|
|
|
755
|
0
|
|
|
|
|
|
size_t mycss_tokenizer_global_state_unicode_range_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size) |
756
|
|
|
|
|
|
|
{ |
757
|
0
|
|
|
|
|
|
const unsigned char *u_css = (const unsigned char*)css; |
758
|
|
|
|
|
|
|
|
759
|
0
|
0
|
|
|
|
|
while(css_offset < css_size) |
760
|
|
|
|
|
|
|
{ |
761
|
0
|
0
|
|
|
|
|
if(mycore_string_chars_hex_map[ u_css[css_offset] ] != 0xff) |
762
|
|
|
|
|
|
|
{ |
763
|
0
|
|
|
|
|
|
entry->help_counter++; |
764
|
|
|
|
|
|
|
|
765
|
0
|
0
|
|
|
|
|
if(entry->help_counter == 6) { |
766
|
0
|
|
|
|
|
|
css_offset++; |
767
|
|
|
|
|
|
|
|
768
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_MINUS; |
769
|
0
|
|
|
|
|
|
break; |
770
|
|
|
|
|
|
|
} |
771
|
|
|
|
|
|
|
} |
772
|
|
|
|
|
|
|
else { |
773
|
0
|
0
|
|
|
|
|
if(entry->help_counter == 0) { |
774
|
0
|
|
|
|
|
|
token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1; |
775
|
0
|
|
|
|
|
|
css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1); |
776
|
|
|
|
|
|
|
} |
777
|
|
|
|
|
|
|
else { |
778
|
0
|
|
|
|
|
|
token->length = (entry->current_buffer->offset + css_offset) - token->begin; |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
|
781
|
0
|
|
|
|
|
|
token->type = MyCSS_TOKEN_TYPE_UNICODE_RANGE; |
782
|
|
|
|
|
|
|
|
783
|
0
|
0
|
|
|
|
|
MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token); |
784
|
|
|
|
|
|
|
|
785
|
0
|
|
|
|
|
|
entry->state = MyCSS_TOKENIZER_STATE_DATA; |
786
|
0
|
|
|
|
|
|
break; |
787
|
|
|
|
|
|
|
} |
788
|
|
|
|
|
|
|
|
789
|
0
|
|
|
|
|
|
css_offset++; |
790
|
|
|
|
|
|
|
} |
791
|
|
|
|
|
|
|
|
792
|
0
|
|
|
|
|
|
return css_offset; |
793
|
|
|
|
|
|
|
} |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
|