135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
ret |= c + 10 - 'A';
else
return 0xFFFF;
}
return ret;
}
static inline OFString *
parseString(const char **pointer, const char *stop, size_t *line)
{
char *buffer;
size_t i = 0;
char delimiter = **pointer;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
ret |= c + 10 - 'A';
else
return 0xFFFF;
}
return ret;
}
static inline OFChar16
parseHexEscape(const char *pointer, const char *stop)
{
OFChar16 ret = 0;
if (pointer + 3 >= stop)
return 0xFFFF;
if (pointer[0] != '\\' || pointer[1] != 'x')
return 0xFFFF;
for (uint8_t i = 0; i < 2; i++) {
char c = pointer[i + 2];
ret <<= 4;
if (c >= '0' && c <= '9')
ret |= c - '0';
else if (c >= 'a' && c <= 'f')
ret |= c + 10 - 'a';
else if (c >= 'A' && c <= 'F')
ret |= c + 10 - 'A';
else
return 0xFFFF;
}
return ret;
}
static inline OFString *
parseString(const char **pointer, const char *stop, size_t *line)
{
char *buffer;
size_t i = 0;
char delimiter = **pointer;
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
OFFreeMemory(buffer);
return nil;
}
i += l;
*pointer += 11;
break;
case '\r':
(*pointer)++;
if (*pointer < stop && **pointer == '\n') {
(*pointer)++;
(*line)++;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
OFFreeMemory(buffer);
return nil;
}
i += l;
*pointer += 11;
break;
case 'x':
c1 = parseHexEscape(*pointer - 1, stop);
if (c1 == 0xFFFF) {
OFFreeMemory(buffer);
return nil;
}
l = _OFUTF8StringEncode(c1, buffer + i);
if (l == 0) {
OFFreeMemory(buffer);
return nil;
}
i += l;
*pointer += 3;
break;
case '\r':
(*pointer)++;
if (*pointer < stop && **pointer == '\n') {
(*pointer)++;
(*line)++;
|