nokolexbor 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/nokolexbor/extconf.rb +12 -6
- data/ext/nokolexbor/libxml/SAX2.h +4 -4
- data/ext/nokolexbor/libxml/chvalid.h +21 -21
- data/ext/nokolexbor/libxml/dict.h +13 -13
- data/ext/nokolexbor/libxml/globals.h +202 -202
- data/ext/nokolexbor/libxml/hash.h +25 -25
- data/ext/nokolexbor/libxml/parser.h +5 -5
- data/ext/nokolexbor/libxml/parserInternals.h +4 -4
- data/ext/nokolexbor/libxml/pattern.h +14 -14
- data/ext/nokolexbor/libxml/threads.h +15 -15
- data/ext/nokolexbor/libxml/tree.h +5 -5
- data/ext/nokolexbor/libxml/xmlerror.h +5 -5
- data/ext/nokolexbor/libxml/xmlmemory.h +16 -16
- data/ext/nokolexbor/libxml/xmlstring.h +30 -30
- data/ext/nokolexbor/libxml/xpath.h +43 -43
- data/ext/nokolexbor/libxml/xpathInternals.h +128 -128
- data/ext/nokolexbor/memory.c +7 -0
- data/ext/nokolexbor/nl_document.c +11 -1
- data/ext/nokolexbor/nl_node.c +37 -16
- data/ext/nokolexbor/nl_node_set.c +23 -9
- data/ext/nokolexbor/nl_xpath_context.c +19 -14
- data/ext/nokolexbor/private/buf.h +1 -1
- data/ext/nokolexbor/private/error.h +3 -3
- data/ext/nokolexbor/xml_SAX2.c +8 -8
- data/ext/nokolexbor/xml_buf.c +19 -19
- data/ext/nokolexbor/xml_chvalid.c +25 -25
- data/ext/nokolexbor/xml_dict.c +69 -69
- data/ext/nokolexbor/xml_encoding.c +2 -2
- data/ext/nokolexbor/xml_error.c +51 -51
- data/ext/nokolexbor/xml_globals.c +329 -329
- data/ext/nokolexbor/xml_hash.c +131 -131
- data/ext/nokolexbor/xml_memory.c +25 -25
- data/ext/nokolexbor/xml_parser.c +3 -3
- data/ext/nokolexbor/xml_parserInternals.c +15 -15
- data/ext/nokolexbor/xml_pattern.c +103 -103
- data/ext/nokolexbor/xml_string.c +93 -93
- data/ext/nokolexbor/xml_threads.c +61 -61
- data/ext/nokolexbor/xml_tree.c +12 -12
- data/ext/nokolexbor/xml_xpath.c +1194 -1203
- data/lib/nokolexbor/version.rb +1 -1
- data/patches/0003-lexbor-attach-template-content-to-self.patch +13 -0
- metadata +2 -2
data/ext/nokolexbor/xml_string.c
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
************************************************************************/
|
34
34
|
|
35
35
|
/**
|
36
|
-
*
|
36
|
+
* nl_xmlStrndup:
|
37
37
|
* @cur: the input xmlChar *
|
38
38
|
* @len: the len of @cur
|
39
39
|
*
|
@@ -42,11 +42,11 @@
|
|
42
42
|
* Returns a new xmlChar * or NULL
|
43
43
|
*/
|
44
44
|
xmlChar *
|
45
|
-
|
45
|
+
nl_xmlStrndup(const xmlChar *cur, int len) {
|
46
46
|
xmlChar *ret;
|
47
47
|
|
48
48
|
if ((cur == NULL) || (len < 0)) return(NULL);
|
49
|
-
ret = (xmlChar *)
|
49
|
+
ret = (xmlChar *) nl_xmlMallocAtomic((size_t) len + 1);
|
50
50
|
if (ret == NULL) {
|
51
51
|
xmlErrMemory(NULL, NULL);
|
52
52
|
return(NULL);
|
@@ -57,7 +57,7 @@ xmlStrndup(const xmlChar *cur, int len) {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
/**
|
60
|
-
*
|
60
|
+
* nl_xmlStrdup:
|
61
61
|
* @cur: the input xmlChar *
|
62
62
|
*
|
63
63
|
* a strdup for array of xmlChar's. Since they are supposed to be
|
@@ -67,16 +67,16 @@ xmlStrndup(const xmlChar *cur, int len) {
|
|
67
67
|
* Returns a new xmlChar * or NULL
|
68
68
|
*/
|
69
69
|
xmlChar *
|
70
|
-
|
70
|
+
nl_xmlStrdup(const xmlChar *cur) {
|
71
71
|
const xmlChar *p = cur;
|
72
72
|
|
73
73
|
if (cur == NULL) return(NULL);
|
74
74
|
while (*p != 0) p++; /* non input consuming */
|
75
|
-
return(
|
75
|
+
return(nl_xmlStrndup(cur, p - cur));
|
76
76
|
}
|
77
77
|
|
78
78
|
/**
|
79
|
-
*
|
79
|
+
* nl_xmlCharStrndup:
|
80
80
|
* @cur: the input char *
|
81
81
|
* @len: the len of @cur
|
82
82
|
*
|
@@ -86,12 +86,12 @@ xmlStrdup(const xmlChar *cur) {
|
|
86
86
|
*/
|
87
87
|
|
88
88
|
xmlChar *
|
89
|
-
|
89
|
+
nl_xmlCharStrndup(const char *cur, int len) {
|
90
90
|
int i;
|
91
91
|
xmlChar *ret;
|
92
92
|
|
93
93
|
if ((cur == NULL) || (len < 0)) return(NULL);
|
94
|
-
ret = (xmlChar *)
|
94
|
+
ret = (xmlChar *) nl_xmlMallocAtomic((size_t) len + 1);
|
95
95
|
if (ret == NULL) {
|
96
96
|
xmlErrMemory(NULL, NULL);
|
97
97
|
return(NULL);
|
@@ -106,7 +106,7 @@ xmlCharStrndup(const char *cur, int len) {
|
|
106
106
|
}
|
107
107
|
|
108
108
|
/**
|
109
|
-
*
|
109
|
+
* nl_xmlCharStrdup:
|
110
110
|
* @cur: the input char *
|
111
111
|
*
|
112
112
|
* a strdup for char's to xmlChar's
|
@@ -115,16 +115,16 @@ xmlCharStrndup(const char *cur, int len) {
|
|
115
115
|
*/
|
116
116
|
|
117
117
|
xmlChar *
|
118
|
-
|
118
|
+
nl_xmlCharStrdup(const char *cur) {
|
119
119
|
const char *p = cur;
|
120
120
|
|
121
121
|
if (cur == NULL) return(NULL);
|
122
122
|
while (*p != '\0') p++; /* non input consuming */
|
123
|
-
return(
|
123
|
+
return(nl_xmlCharStrndup(cur, p - cur));
|
124
124
|
}
|
125
125
|
|
126
126
|
/**
|
127
|
-
*
|
127
|
+
* nl_xmlStrcmp:
|
128
128
|
* @str1: the first xmlChar *
|
129
129
|
* @str2: the second xmlChar *
|
130
130
|
*
|
@@ -134,7 +134,7 @@ xmlCharStrdup(const char *cur) {
|
|
134
134
|
*/
|
135
135
|
|
136
136
|
int
|
137
|
-
|
137
|
+
nl_xmlStrcmp(const xmlChar *str1, const xmlChar *str2) {
|
138
138
|
if (str1 == str2) return(0);
|
139
139
|
if (str1 == NULL) return(-1);
|
140
140
|
if (str2 == NULL) return(1);
|
@@ -150,18 +150,18 @@ xmlStrcmp(const xmlChar *str1, const xmlChar *str2) {
|
|
150
150
|
}
|
151
151
|
|
152
152
|
/**
|
153
|
-
*
|
153
|
+
* nl_xmlStrEqual:
|
154
154
|
* @str1: the first xmlChar *
|
155
155
|
* @str2: the second xmlChar *
|
156
156
|
*
|
157
157
|
* Check if both strings are equal of have same content.
|
158
|
-
* Should be a bit more readable and faster than
|
158
|
+
* Should be a bit more readable and faster than nl_xmlStrcmp()
|
159
159
|
*
|
160
160
|
* Returns 1 if they are equal, 0 if they are different
|
161
161
|
*/
|
162
162
|
|
163
163
|
int
|
164
|
-
|
164
|
+
nl_xmlStrEqual(const xmlChar *str1, const xmlChar *str2) {
|
165
165
|
if (str1 == str2) return(1);
|
166
166
|
if (str1 == NULL) return(0);
|
167
167
|
if (str2 == NULL) return(0);
|
@@ -176,7 +176,7 @@ xmlStrEqual(const xmlChar *str1, const xmlChar *str2) {
|
|
176
176
|
}
|
177
177
|
|
178
178
|
/**
|
179
|
-
*
|
179
|
+
* nl_xmlStrQEqual:
|
180
180
|
* @pref: the prefix of the QName
|
181
181
|
* @name: the localname of the QName
|
182
182
|
* @str: the second xmlChar *
|
@@ -187,8 +187,8 @@ xmlStrEqual(const xmlChar *str1, const xmlChar *str2) {
|
|
187
187
|
*/
|
188
188
|
|
189
189
|
int
|
190
|
-
|
191
|
-
if (pref == NULL) return(
|
190
|
+
nl_xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str) {
|
191
|
+
if (pref == NULL) return(nl_xmlStrEqual(name, str));
|
192
192
|
if (name == NULL) return(0);
|
193
193
|
if (str == NULL) return(0);
|
194
194
|
|
@@ -203,7 +203,7 @@ xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str) {
|
|
203
203
|
}
|
204
204
|
|
205
205
|
/**
|
206
|
-
*
|
206
|
+
* nl_xmlStrncmp:
|
207
207
|
* @str1: the first xmlChar *
|
208
208
|
* @str2: the second xmlChar *
|
209
209
|
* @len: the max comparison length
|
@@ -214,7 +214,7 @@ xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str) {
|
|
214
214
|
*/
|
215
215
|
|
216
216
|
int
|
217
|
-
|
217
|
+
nl_xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len) {
|
218
218
|
if (len <= 0) return(0);
|
219
219
|
if (str1 == str2) return(0);
|
220
220
|
if (str1 == NULL) return(-1);
|
@@ -266,7 +266,7 @@ static const xmlChar casemap[256] = {
|
|
266
266
|
};
|
267
267
|
|
268
268
|
/**
|
269
|
-
*
|
269
|
+
* nl_xmlStrcasecmp:
|
270
270
|
* @str1: the first xmlChar *
|
271
271
|
* @str2: the second xmlChar *
|
272
272
|
*
|
@@ -276,7 +276,7 @@ static const xmlChar casemap[256] = {
|
|
276
276
|
*/
|
277
277
|
|
278
278
|
int
|
279
|
-
|
279
|
+
nl_xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2) {
|
280
280
|
register int tmp;
|
281
281
|
|
282
282
|
if (str1 == str2) return(0);
|
@@ -290,7 +290,7 @@ xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2) {
|
|
290
290
|
}
|
291
291
|
|
292
292
|
/**
|
293
|
-
*
|
293
|
+
* nl_xmlStrncasecmp:
|
294
294
|
* @str1: the first xmlChar *
|
295
295
|
* @str2: the second xmlChar *
|
296
296
|
* @len: the max comparison length
|
@@ -301,7 +301,7 @@ xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2) {
|
|
301
301
|
*/
|
302
302
|
|
303
303
|
int
|
304
|
-
|
304
|
+
nl_xmlStrncasecmp(const xmlChar *str1, const xmlChar *str2, int len) {
|
305
305
|
register int tmp;
|
306
306
|
|
307
307
|
if (len <= 0) return(0);
|
@@ -316,7 +316,7 @@ xmlStrncasecmp(const xmlChar *str1, const xmlChar *str2, int len) {
|
|
316
316
|
}
|
317
317
|
|
318
318
|
/**
|
319
|
-
*
|
319
|
+
* nl_xmlStrchr:
|
320
320
|
* @str: the xmlChar * array
|
321
321
|
* @val: the xmlChar to search
|
322
322
|
*
|
@@ -326,7 +326,7 @@ xmlStrncasecmp(const xmlChar *str1, const xmlChar *str2, int len) {
|
|
326
326
|
*/
|
327
327
|
|
328
328
|
const xmlChar *
|
329
|
-
|
329
|
+
nl_xmlStrchr(const xmlChar *str, xmlChar val) {
|
330
330
|
if (str == NULL) return(NULL);
|
331
331
|
while (*str != 0) { /* non input consuming */
|
332
332
|
if (*str == val) return((xmlChar *) str);
|
@@ -336,7 +336,7 @@ xmlStrchr(const xmlChar *str, xmlChar val) {
|
|
336
336
|
}
|
337
337
|
|
338
338
|
/**
|
339
|
-
*
|
339
|
+
* nl_xmlStrstr:
|
340
340
|
* @str: the xmlChar * array (haystack)
|
341
341
|
* @val: the xmlChar to search (needle)
|
342
342
|
*
|
@@ -346,17 +346,17 @@ xmlStrchr(const xmlChar *str, xmlChar val) {
|
|
346
346
|
*/
|
347
347
|
|
348
348
|
const xmlChar *
|
349
|
-
|
349
|
+
nl_xmlStrstr(const xmlChar *str, const xmlChar *val) {
|
350
350
|
int n;
|
351
351
|
|
352
352
|
if (str == NULL) return(NULL);
|
353
353
|
if (val == NULL) return(NULL);
|
354
|
-
n =
|
354
|
+
n = nl_xmlStrlen(val);
|
355
355
|
|
356
356
|
if (n == 0) return(str);
|
357
357
|
while (*str != 0) { /* non input consuming */
|
358
358
|
if (*str == *val) {
|
359
|
-
if (!
|
359
|
+
if (!nl_xmlStrncmp(str, val, n)) return((const xmlChar *) str);
|
360
360
|
}
|
361
361
|
str++;
|
362
362
|
}
|
@@ -364,7 +364,7 @@ xmlStrstr(const xmlChar *str, const xmlChar *val) {
|
|
364
364
|
}
|
365
365
|
|
366
366
|
/**
|
367
|
-
*
|
367
|
+
* nl_xmlStrcasestr:
|
368
368
|
* @str: the xmlChar * array (haystack)
|
369
369
|
* @val: the xmlChar to search (needle)
|
370
370
|
*
|
@@ -374,24 +374,24 @@ xmlStrstr(const xmlChar *str, const xmlChar *val) {
|
|
374
374
|
*/
|
375
375
|
|
376
376
|
const xmlChar *
|
377
|
-
|
377
|
+
nl_xmlStrcasestr(const xmlChar *str, const xmlChar *val) {
|
378
378
|
int n;
|
379
379
|
|
380
380
|
if (str == NULL) return(NULL);
|
381
381
|
if (val == NULL) return(NULL);
|
382
|
-
n =
|
382
|
+
n = nl_xmlStrlen(val);
|
383
383
|
|
384
384
|
if (n == 0) return(str);
|
385
385
|
while (*str != 0) { /* non input consuming */
|
386
386
|
if (casemap[*str] == casemap[*val])
|
387
|
-
if (!
|
387
|
+
if (!nl_xmlStrncasecmp(str, val, n)) return(str);
|
388
388
|
str++;
|
389
389
|
}
|
390
390
|
return(NULL);
|
391
391
|
}
|
392
392
|
|
393
393
|
/**
|
394
|
-
*
|
394
|
+
* nl_xmlStrsub:
|
395
395
|
* @str: the xmlChar * array (haystack)
|
396
396
|
* @start: the index of the first char (zero based)
|
397
397
|
* @len: the length of the substring
|
@@ -402,7 +402,7 @@ xmlStrcasestr(const xmlChar *str, const xmlChar *val) {
|
|
402
402
|
*/
|
403
403
|
|
404
404
|
xmlChar *
|
405
|
-
|
405
|
+
nl_xmlStrsub(const xmlChar *str, int start, int len) {
|
406
406
|
int i;
|
407
407
|
|
408
408
|
if (str == NULL) return(NULL);
|
@@ -414,11 +414,11 @@ xmlStrsub(const xmlChar *str, int start, int len) {
|
|
414
414
|
str++;
|
415
415
|
}
|
416
416
|
if (*str == 0) return(NULL);
|
417
|
-
return(
|
417
|
+
return(nl_xmlStrndup(str, len));
|
418
418
|
}
|
419
419
|
|
420
420
|
/**
|
421
|
-
*
|
421
|
+
* nl_xmlStrlen:
|
422
422
|
* @str: the xmlChar * array
|
423
423
|
*
|
424
424
|
* length of a xmlChar's string
|
@@ -427,13 +427,13 @@ xmlStrsub(const xmlChar *str, int start, int len) {
|
|
427
427
|
*/
|
428
428
|
|
429
429
|
int
|
430
|
-
|
430
|
+
nl_xmlStrlen(const xmlChar *str) {
|
431
431
|
size_t len = str ? strlen((const char *)str) : 0;
|
432
432
|
return(len > INT_MAX ? 0 : len);
|
433
433
|
}
|
434
434
|
|
435
435
|
/**
|
436
|
-
*
|
436
|
+
* nl_xmlStrncat:
|
437
437
|
* @cur: the original xmlChar * array
|
438
438
|
* @add: the xmlChar * array added
|
439
439
|
* @len: the length of @add
|
@@ -447,7 +447,7 @@ xmlStrlen(const xmlChar *str) {
|
|
447
447
|
*/
|
448
448
|
|
449
449
|
xmlChar *
|
450
|
-
|
450
|
+
nl_xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
|
451
451
|
int size;
|
452
452
|
xmlChar *ret;
|
453
453
|
|
@@ -456,12 +456,12 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
|
|
456
456
|
if (len < 0)
|
457
457
|
return(NULL);
|
458
458
|
if (cur == NULL)
|
459
|
-
return(
|
459
|
+
return(nl_xmlStrndup(add, len));
|
460
460
|
|
461
|
-
size =
|
461
|
+
size = nl_xmlStrlen(cur);
|
462
462
|
if ((size < 0) || (size > INT_MAX - len))
|
463
463
|
return(NULL);
|
464
|
-
ret = (xmlChar *)
|
464
|
+
ret = (xmlChar *) nl_xmlRealloc(cur, (size_t) size + len + 1);
|
465
465
|
if (ret == NULL) {
|
466
466
|
xmlErrMemory(NULL, NULL);
|
467
467
|
return(cur);
|
@@ -472,39 +472,39 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
|
|
472
472
|
}
|
473
473
|
|
474
474
|
/**
|
475
|
-
*
|
475
|
+
* nl_xmlStrncatNew:
|
476
476
|
* @str1: first xmlChar string
|
477
477
|
* @str2: second xmlChar string
|
478
478
|
* @len: the len of @str2 or < 0
|
479
479
|
*
|
480
|
-
* same as
|
480
|
+
* same as nl_xmlStrncat, but creates a new string. The original
|
481
481
|
* two strings are not freed. If @len is < 0 then the length
|
482
482
|
* will be calculated automatically.
|
483
483
|
*
|
484
484
|
* Returns a new xmlChar * or NULL
|
485
485
|
*/
|
486
486
|
xmlChar *
|
487
|
-
|
487
|
+
nl_xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
|
488
488
|
int size;
|
489
489
|
xmlChar *ret;
|
490
490
|
|
491
491
|
if (len < 0) {
|
492
|
-
len =
|
492
|
+
len = nl_xmlStrlen(str2);
|
493
493
|
if (len < 0)
|
494
494
|
return(NULL);
|
495
495
|
}
|
496
496
|
if ((str2 == NULL) || (len == 0))
|
497
|
-
return(
|
497
|
+
return(nl_xmlStrdup(str1));
|
498
498
|
if (str1 == NULL)
|
499
|
-
return(
|
499
|
+
return(nl_xmlStrndup(str2, len));
|
500
500
|
|
501
|
-
size =
|
501
|
+
size = nl_xmlStrlen(str1);
|
502
502
|
if ((size < 0) || (size > INT_MAX - len))
|
503
503
|
return(NULL);
|
504
|
-
ret = (xmlChar *)
|
504
|
+
ret = (xmlChar *) nl_xmlMalloc((size_t) size + len + 1);
|
505
505
|
if (ret == NULL) {
|
506
506
|
xmlErrMemory(NULL, NULL);
|
507
|
-
return(
|
507
|
+
return(nl_xmlStrndup(str1, size));
|
508
508
|
}
|
509
509
|
memcpy(ret, str1, size);
|
510
510
|
memcpy(&ret[size], str2, len);
|
@@ -513,7 +513,7 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
|
|
513
513
|
}
|
514
514
|
|
515
515
|
/**
|
516
|
-
*
|
516
|
+
* nl_xmlStrcat:
|
517
517
|
* @cur: the original xmlChar * array
|
518
518
|
* @add: the xmlChar * array added
|
519
519
|
*
|
@@ -525,19 +525,19 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
|
|
525
525
|
* @cur is reallocated and should not be freed.
|
526
526
|
*/
|
527
527
|
xmlChar *
|
528
|
-
|
528
|
+
nl_xmlStrcat(xmlChar *cur, const xmlChar *add) {
|
529
529
|
const xmlChar *p = add;
|
530
530
|
|
531
531
|
if (add == NULL) return(cur);
|
532
532
|
if (cur == NULL)
|
533
|
-
return(
|
533
|
+
return(nl_xmlStrdup(add));
|
534
534
|
|
535
535
|
while (*p != 0) p++; /* non input consuming */
|
536
|
-
return(
|
536
|
+
return(nl_xmlStrncat(cur, add, p - add));
|
537
537
|
}
|
538
538
|
|
539
539
|
/**
|
540
|
-
*
|
540
|
+
* nl_xmlStrPrintf:
|
541
541
|
* @buf: the result buffer.
|
542
542
|
* @len: the result buffer length.
|
543
543
|
* @msg: the message with printf formatting.
|
@@ -548,7 +548,7 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) {
|
|
548
548
|
* Returns the number of characters written to @buf or -1 if an error occurs.
|
549
549
|
*/
|
550
550
|
int XMLCDECL
|
551
|
-
|
551
|
+
nl_xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...) {
|
552
552
|
va_list args;
|
553
553
|
int ret;
|
554
554
|
|
@@ -565,7 +565,7 @@ xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...) {
|
|
565
565
|
}
|
566
566
|
|
567
567
|
/**
|
568
|
-
*
|
568
|
+
* nl_xmlStrVPrintf:
|
569
569
|
* @buf: the result buffer.
|
570
570
|
* @len: the result buffer length.
|
571
571
|
* @msg: the message with printf formatting.
|
@@ -576,7 +576,7 @@ xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...) {
|
|
576
576
|
* Returns the number of characters written to @buf or -1 if an error occurs.
|
577
577
|
*/
|
578
578
|
int
|
579
|
-
|
579
|
+
nl_xmlStrVPrintf(xmlChar *buf, int len, const char *msg, va_list ap) {
|
580
580
|
int ret;
|
581
581
|
|
582
582
|
if((buf == NULL) || (msg == NULL)) {
|
@@ -606,7 +606,7 @@ xmlStrVPrintf(xmlChar *buf, int len, const char *msg, va_list ap) {
|
|
606
606
|
|
607
607
|
|
608
608
|
/**
|
609
|
-
*
|
609
|
+
* nl_xmlUTF8Size:
|
610
610
|
* @utf: pointer to the UTF8 character
|
611
611
|
*
|
612
612
|
* calculates the internal size of a UTF8 character
|
@@ -614,7 +614,7 @@ xmlStrVPrintf(xmlChar *buf, int len, const char *msg, va_list ap) {
|
|
614
614
|
* returns the numbers of bytes in the character, -1 on format error
|
615
615
|
*/
|
616
616
|
int
|
617
|
-
|
617
|
+
nl_xmlUTF8Size(const xmlChar *utf) {
|
618
618
|
xmlChar mask;
|
619
619
|
int len;
|
620
620
|
|
@@ -636,27 +636,27 @@ xmlUTF8Size(const xmlChar *utf) {
|
|
636
636
|
}
|
637
637
|
|
638
638
|
/**
|
639
|
-
*
|
639
|
+
* nl_xmlUTF8Charcmp:
|
640
640
|
* @utf1: pointer to first UTF8 char
|
641
641
|
* @utf2: pointer to second UTF8 char
|
642
642
|
*
|
643
643
|
* compares the two UCS4 values
|
644
644
|
*
|
645
|
-
* returns result of the compare as with
|
645
|
+
* returns result of the compare as with nl_xmlStrncmp
|
646
646
|
*/
|
647
647
|
int
|
648
|
-
|
648
|
+
nl_xmlUTF8Charcmp(const xmlChar *utf1, const xmlChar *utf2) {
|
649
649
|
|
650
650
|
if (utf1 == NULL ) {
|
651
651
|
if (utf2 == NULL)
|
652
652
|
return 0;
|
653
653
|
return -1;
|
654
654
|
}
|
655
|
-
return
|
655
|
+
return nl_xmlStrncmp(utf1, utf2, nl_xmlUTF8Size(utf1));
|
656
656
|
}
|
657
657
|
|
658
658
|
/**
|
659
|
-
*
|
659
|
+
* nl_xmlUTF8Strlen:
|
660
660
|
* @utf: a sequence of UTF-8 encoded bytes
|
661
661
|
*
|
662
662
|
* compute the length of an UTF8 string, it doesn't do a full UTF8
|
@@ -665,7 +665,7 @@ xmlUTF8Charcmp(const xmlChar *utf1, const xmlChar *utf2) {
|
|
665
665
|
* Returns the number of characters in the string or -1 in case of error
|
666
666
|
*/
|
667
667
|
int
|
668
|
-
|
668
|
+
nl_xmlUTF8Strlen(const xmlChar *utf) {
|
669
669
|
size_t ret = 0;
|
670
670
|
|
671
671
|
if (utf == NULL)
|
@@ -697,7 +697,7 @@ xmlUTF8Strlen(const xmlChar *utf) {
|
|
697
697
|
}
|
698
698
|
|
699
699
|
/**
|
700
|
-
*
|
700
|
+
* nl_xmlGetUTF8Char:
|
701
701
|
* @utf: a sequence of UTF-8 encoded bytes
|
702
702
|
* @len: a pointer to the minimum number of bytes present in
|
703
703
|
* the sequence. This is used to assure the next character
|
@@ -709,7 +709,7 @@ xmlUTF8Strlen(const xmlChar *utf) {
|
|
709
709
|
* the actual number of bytes consumed (0 in case of error)
|
710
710
|
*/
|
711
711
|
int
|
712
|
-
|
712
|
+
nl_xmlGetUTF8Char(const unsigned char *utf, int *len) {
|
713
713
|
unsigned int c;
|
714
714
|
|
715
715
|
if (utf == NULL)
|
@@ -767,7 +767,7 @@ error:
|
|
767
767
|
}
|
768
768
|
|
769
769
|
/**
|
770
|
-
*
|
770
|
+
* nl_xmlCheckUTF8:
|
771
771
|
* @utf: Pointer to putative UTF-8 encoded string.
|
772
772
|
*
|
773
773
|
* Checks @utf for being valid UTF-8. @utf is assumed to be
|
@@ -780,7 +780,7 @@ error:
|
|
780
780
|
* Return value: true if @utf is valid.
|
781
781
|
**/
|
782
782
|
int
|
783
|
-
|
783
|
+
nl_xmlCheckUTF8(const unsigned char *utf)
|
784
784
|
{
|
785
785
|
int ix;
|
786
786
|
unsigned char c;
|
@@ -822,7 +822,7 @@ xmlCheckUTF8(const unsigned char *utf)
|
|
822
822
|
}
|
823
823
|
|
824
824
|
/**
|
825
|
-
*
|
825
|
+
* nl_xmlUTF8Strsize:
|
826
826
|
* @utf: a sequence of UTF-8 encoded bytes
|
827
827
|
* @len: the number of characters in the array
|
828
828
|
*
|
@@ -834,7 +834,7 @@ xmlCheckUTF8(const unsigned char *utf)
|
|
834
834
|
*/
|
835
835
|
|
836
836
|
int
|
837
|
-
|
837
|
+
nl_xmlUTF8Strsize(const xmlChar *utf, int len) {
|
838
838
|
const xmlChar *ptr=utf;
|
839
839
|
int ch;
|
840
840
|
size_t ret;
|
@@ -860,7 +860,7 @@ xmlUTF8Strsize(const xmlChar *utf, int len) {
|
|
860
860
|
|
861
861
|
|
862
862
|
/**
|
863
|
-
*
|
863
|
+
* nl_xmlUTF8Strndup:
|
864
864
|
* @utf: the input UTF8 *
|
865
865
|
* @len: the len of @utf (in chars)
|
866
866
|
*
|
@@ -869,13 +869,13 @@ xmlUTF8Strsize(const xmlChar *utf, int len) {
|
|
869
869
|
* Returns a new UTF8 * or NULL
|
870
870
|
*/
|
871
871
|
xmlChar *
|
872
|
-
|
872
|
+
nl_xmlUTF8Strndup(const xmlChar *utf, int len) {
|
873
873
|
xmlChar *ret;
|
874
874
|
int i;
|
875
875
|
|
876
876
|
if ((utf == NULL) || (len < 0)) return(NULL);
|
877
|
-
i =
|
878
|
-
ret = (xmlChar *)
|
877
|
+
i = nl_xmlUTF8Strsize(utf, len);
|
878
|
+
ret = (xmlChar *) nl_xmlMallocAtomic((size_t) i + 1);
|
879
879
|
if (ret == NULL) {
|
880
880
|
return(NULL);
|
881
881
|
}
|
@@ -885,7 +885,7 @@ xmlUTF8Strndup(const xmlChar *utf, int len) {
|
|
885
885
|
}
|
886
886
|
|
887
887
|
/**
|
888
|
-
*
|
888
|
+
* nl_xmlUTF8Strpos:
|
889
889
|
* @utf: the input UTF8 *
|
890
890
|
* @pos: the position of the desired UTF8 char (in chars)
|
891
891
|
*
|
@@ -895,7 +895,7 @@ xmlUTF8Strndup(const xmlChar *utf, int len) {
|
|
895
895
|
* Returns a pointer to the UTF8 character or NULL
|
896
896
|
*/
|
897
897
|
const xmlChar *
|
898
|
-
|
898
|
+
nl_xmlUTF8Strpos(const xmlChar *utf, int pos) {
|
899
899
|
int ch;
|
900
900
|
|
901
901
|
if (utf == NULL) return(NULL);
|
@@ -917,7 +917,7 @@ xmlUTF8Strpos(const xmlChar *utf, int pos) {
|
|
917
917
|
}
|
918
918
|
|
919
919
|
/**
|
920
|
-
*
|
920
|
+
* nl_xmlUTF8Strloc:
|
921
921
|
* @utf: the input UTF8 *
|
922
922
|
* @utfchar: the UTF8 character to be found
|
923
923
|
*
|
@@ -927,15 +927,15 @@ xmlUTF8Strpos(const xmlChar *utf, int pos) {
|
|
927
927
|
* or -1 if not found
|
928
928
|
*/
|
929
929
|
int
|
930
|
-
|
930
|
+
nl_xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar) {
|
931
931
|
size_t i;
|
932
932
|
int size;
|
933
933
|
int ch;
|
934
934
|
|
935
935
|
if (utf==NULL || utfchar==NULL) return -1;
|
936
|
-
size =
|
936
|
+
size = nl_xmlUTF8Strsize(utfchar, 1);
|
937
937
|
for(i=0; (ch=*utf) != 0; i++) {
|
938
|
-
if (
|
938
|
+
if (nl_xmlStrncmp(utf, utfchar, size)==0)
|
939
939
|
return(i > INT_MAX ? 0 : i);
|
940
940
|
utf++;
|
941
941
|
if ( ch & 0x80 ) {
|
@@ -952,7 +952,7 @@ xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar) {
|
|
952
952
|
return(-1);
|
953
953
|
}
|
954
954
|
/**
|
955
|
-
*
|
955
|
+
* nl_xmlUTF8Strsub:
|
956
956
|
* @utf: a sequence of UTF-8 encoded bytes
|
957
957
|
* @start: relative pos of first char
|
958
958
|
* @len: total number to copy
|
@@ -965,7 +965,7 @@ xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar) {
|
|
965
965
|
*/
|
966
966
|
|
967
967
|
xmlChar *
|
968
|
-
|
968
|
+
nl_xmlUTF8Strsub(const xmlChar *utf, int start, int len) {
|
969
969
|
int i;
|
970
970
|
int ch;
|
971
971
|
|
@@ -989,7 +989,7 @@ xmlUTF8Strsub(const xmlChar *utf, int start, int len) {
|
|
989
989
|
}
|
990
990
|
}
|
991
991
|
|
992
|
-
return(
|
992
|
+
return(nl_xmlUTF8Strndup(utf, len));
|
993
993
|
}
|
994
994
|
|
995
995
|
/**
|
@@ -1026,11 +1026,11 @@ xmlEscapeFormatString(xmlChar **msg)
|
|
1026
1026
|
if ((count > INT_MAX) || (msgLen > INT_MAX - count))
|
1027
1027
|
return(NULL);
|
1028
1028
|
resultLen = msgLen + count + 1;
|
1029
|
-
result = (xmlChar *)
|
1029
|
+
result = (xmlChar *) nl_xmlMallocAtomic(resultLen);
|
1030
1030
|
if (result == NULL) {
|
1031
1031
|
/* Clear *msg to prevent format string vulnerabilities in
|
1032
1032
|
out-of-memory situations. */
|
1033
|
-
|
1033
|
+
nl_xmlFree(*msg);
|
1034
1034
|
*msg = NULL;
|
1035
1035
|
xmlErrMemory(NULL, NULL);
|
1036
1036
|
return(NULL);
|
@@ -1043,7 +1043,7 @@ xmlEscapeFormatString(xmlChar **msg)
|
|
1043
1043
|
}
|
1044
1044
|
result[resultLen - 1] = '\0';
|
1045
1045
|
|
1046
|
-
|
1046
|
+
nl_xmlFree(*msg);
|
1047
1047
|
*msg = result;
|
1048
1048
|
|
1049
1049
|
return *msg;
|