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
@@ -14,7 +14,7 @@
|
|
14
14
|
/*
|
15
15
|
* TODO:
|
16
16
|
* - compilation flags to check for specific syntaxes
|
17
|
-
* using flags of
|
17
|
+
* using flags of nl_xmlPatterncompile()
|
18
18
|
* - making clear how pattern starting with / or . need to be handled,
|
19
19
|
* currently push(NULL, NULL) means a reset of the streaming context
|
20
20
|
* and indicating we are on / (the document node), probably need
|
@@ -81,10 +81,10 @@
|
|
81
81
|
|
82
82
|
#define XML_PAT_COPY_NSNAME(c, r, nsname) \
|
83
83
|
if ((c)->comp->dict) \
|
84
|
-
r = (xmlChar *)
|
85
|
-
else r =
|
84
|
+
r = (xmlChar *) nl_xmlDictLookup((c)->comp->dict, BAD_CAST nsname, -1); \
|
85
|
+
else r = nl_xmlStrdup(BAD_CAST nsname);
|
86
86
|
|
87
|
-
#define XML_PAT_FREE_STRING(c, r) if ((c)->comp->dict == NULL)
|
87
|
+
#define XML_PAT_FREE_STRING(c, r) if ((c)->comp->dict == NULL) nl_xmlFree(r);
|
88
88
|
|
89
89
|
typedef struct _xmlStreamStep xmlStreamStep;
|
90
90
|
typedef xmlStreamStep *xmlStreamStepPtr;
|
@@ -203,7 +203,7 @@ static xmlPatternPtr
|
|
203
203
|
xmlNewPattern(void) {
|
204
204
|
xmlPatternPtr cur;
|
205
205
|
|
206
|
-
cur = (xmlPatternPtr)
|
206
|
+
cur = (xmlPatternPtr) nl_xmlMalloc(sizeof(xmlPattern));
|
207
207
|
if (cur == NULL) {
|
208
208
|
ERROR(NULL, NULL, NULL,
|
209
209
|
"xmlNewPattern : malloc failed\n");
|
@@ -211,9 +211,9 @@ xmlNewPattern(void) {
|
|
211
211
|
}
|
212
212
|
memset(cur, 0, sizeof(xmlPattern));
|
213
213
|
cur->maxStep = 10;
|
214
|
-
cur->steps = (xmlStepOpPtr)
|
214
|
+
cur->steps = (xmlStepOpPtr) nl_xmlMalloc(cur->maxStep * sizeof(xmlStepOp));
|
215
215
|
if (cur->steps == NULL) {
|
216
|
-
|
216
|
+
nl_xmlFree(cur);
|
217
217
|
ERROR(NULL, NULL, NULL,
|
218
218
|
"xmlNewPattern : malloc failed\n");
|
219
219
|
return(NULL);
|
@@ -222,14 +222,14 @@ xmlNewPattern(void) {
|
|
222
222
|
}
|
223
223
|
|
224
224
|
/**
|
225
|
-
*
|
225
|
+
* nl_xmlFreePattern:
|
226
226
|
* @comp: an XSLT comp
|
227
227
|
*
|
228
228
|
* Free up the memory allocated by @comp
|
229
229
|
*/
|
230
230
|
void
|
231
|
-
|
232
|
-
|
231
|
+
nl_xmlFreePattern(xmlPatternPtr comp) {
|
232
|
+
nl_xmlFreePatternList(comp);
|
233
233
|
}
|
234
234
|
|
235
235
|
static void
|
@@ -242,34 +242,34 @@ xmlFreePatternInternal(xmlPatternPtr comp) {
|
|
242
242
|
if (comp->stream != NULL)
|
243
243
|
xmlFreeStreamComp(comp->stream);
|
244
244
|
if (comp->pattern != NULL)
|
245
|
-
|
245
|
+
nl_xmlFree((xmlChar *)comp->pattern);
|
246
246
|
if (comp->steps != NULL) {
|
247
247
|
if (comp->dict == NULL) {
|
248
248
|
for (i = 0;i < comp->nbStep;i++) {
|
249
249
|
op = &comp->steps[i];
|
250
250
|
if (op->value != NULL)
|
251
|
-
|
251
|
+
nl_xmlFree((xmlChar *) op->value);
|
252
252
|
if (op->value2 != NULL)
|
253
|
-
|
253
|
+
nl_xmlFree((xmlChar *) op->value2);
|
254
254
|
}
|
255
255
|
}
|
256
|
-
|
256
|
+
nl_xmlFree(comp->steps);
|
257
257
|
}
|
258
258
|
if (comp->dict != NULL)
|
259
|
-
|
259
|
+
nl_xmlDictFree(comp->dict);
|
260
260
|
|
261
261
|
memset(comp, -1, sizeof(xmlPattern));
|
262
|
-
|
262
|
+
nl_xmlFree(comp);
|
263
263
|
}
|
264
264
|
|
265
265
|
/**
|
266
|
-
*
|
266
|
+
* nl_xmlFreePatternList:
|
267
267
|
* @comp: an XSLT comp list
|
268
268
|
*
|
269
269
|
* Free up the memory allocated by all the elements of @comp
|
270
270
|
*/
|
271
271
|
void
|
272
|
-
|
272
|
+
nl_xmlFreePatternList(xmlPatternPtr comp) {
|
273
273
|
xmlPatternPtr cur;
|
274
274
|
|
275
275
|
while (comp != NULL) {
|
@@ -299,7 +299,7 @@ xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict,
|
|
299
299
|
if (pattern == NULL)
|
300
300
|
return(NULL);
|
301
301
|
|
302
|
-
cur = (xmlPatParserContextPtr)
|
302
|
+
cur = (xmlPatParserContextPtr) nl_xmlMalloc(sizeof(xmlPatParserContext));
|
303
303
|
if (cur == NULL) {
|
304
304
|
ERROR(NULL, NULL, NULL,
|
305
305
|
"xmlNewPatParserContext : malloc failed\n");
|
@@ -332,7 +332,7 @@ xmlFreePatParserContext(xmlPatParserContextPtr ctxt) {
|
|
332
332
|
if (ctxt == NULL)
|
333
333
|
return;
|
334
334
|
memset(ctxt, -1, sizeof(xmlPatParserContext));
|
335
|
-
|
335
|
+
nl_xmlFree(ctxt);
|
336
336
|
}
|
337
337
|
|
338
338
|
/**
|
@@ -353,7 +353,7 @@ xmlPatternAdd(xmlPatParserContextPtr ctxt ATTRIBUTE_UNUSED,
|
|
353
353
|
{
|
354
354
|
if (comp->nbStep >= comp->maxStep) {
|
355
355
|
xmlStepOpPtr temp;
|
356
|
-
temp = (xmlStepOpPtr)
|
356
|
+
temp = (xmlStepOpPtr) nl_xmlRealloc(comp->steps, comp->maxStep * 2 *
|
357
357
|
sizeof(xmlStepOp));
|
358
358
|
if (temp == NULL) {
|
359
359
|
ERROR(ctxt, NULL, NULL,
|
@@ -424,7 +424,7 @@ xmlReversePattern(xmlPatternPtr comp) {
|
|
424
424
|
}
|
425
425
|
if (comp->nbStep >= comp->maxStep) {
|
426
426
|
xmlStepOpPtr temp;
|
427
|
-
temp = (xmlStepOpPtr)
|
427
|
+
temp = (xmlStepOpPtr) nl_xmlRealloc(comp->steps, comp->maxStep * 2 *
|
428
428
|
sizeof(xmlStepOp));
|
429
429
|
if (temp == NULL) {
|
430
430
|
ERROR(ctxt, NULL, NULL,
|
@@ -468,12 +468,12 @@ xmlPatPushState(xmlStepStates *states, int step, lxb_dom_node_t_ptr node) {
|
|
468
468
|
if ((states->states == NULL) || (states->maxstates <= 0)) {
|
469
469
|
states->maxstates = 4;
|
470
470
|
states->nbstates = 0;
|
471
|
-
states->states =
|
471
|
+
states->states = nl_xmlMalloc(4 * sizeof(xmlStepState));
|
472
472
|
}
|
473
473
|
else if (states->maxstates <= states->nbstates) {
|
474
474
|
xmlStepState *tmp;
|
475
475
|
|
476
|
-
tmp = (xmlStepStatePtr)
|
476
|
+
tmp = (xmlStepStatePtr) nl_xmlRealloc(states->states,
|
477
477
|
2 * states->maxstates * sizeof(xmlStepState));
|
478
478
|
if (tmp == NULL)
|
479
479
|
return(-1);
|
@@ -495,7 +495,7 @@ xmlPatPushState(xmlStepStates *states, int step, lxb_dom_node_t_ptr node) {
|
|
495
495
|
************************************************************************/
|
496
496
|
|
497
497
|
#define TODO \
|
498
|
-
|
498
|
+
nl_xmlGenericError(nl_xmlGenericErrorContext, \
|
499
499
|
"Unimplemented block at %s:%d\n", \
|
500
500
|
__FILE__, __LINE__);
|
501
501
|
#define CUR (*ctxt->cur)
|
@@ -545,38 +545,38 @@ xmlPatScanLiteral(xmlPatParserContextPtr ctxt) {
|
|
545
545
|
if (CUR == '"') {
|
546
546
|
NEXT;
|
547
547
|
cur = q = CUR_PTR;
|
548
|
-
val =
|
548
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
549
549
|
while ((IS_CHAR(val)) && (val != '"')) {
|
550
550
|
cur += len;
|
551
|
-
val =
|
551
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
552
552
|
}
|
553
553
|
if (!IS_CHAR(val)) {
|
554
554
|
ctxt->error = 1;
|
555
555
|
return(NULL);
|
556
556
|
} else {
|
557
557
|
if (ctxt->dict)
|
558
|
-
ret = (xmlChar *)
|
558
|
+
ret = (xmlChar *) nl_xmlDictLookup(ctxt->dict, q, cur - q);
|
559
559
|
else
|
560
|
-
ret =
|
560
|
+
ret = nl_xmlStrndup(q, cur - q);
|
561
561
|
}
|
562
562
|
cur += len;
|
563
563
|
CUR_PTR = cur;
|
564
564
|
} else if (CUR == '\'') {
|
565
565
|
NEXT;
|
566
566
|
cur = q = CUR_PTR;
|
567
|
-
val =
|
567
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
568
568
|
while ((IS_CHAR(val)) && (val != '\'')) {
|
569
569
|
cur += len;
|
570
|
-
val =
|
570
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
571
571
|
}
|
572
572
|
if (!IS_CHAR(val)) {
|
573
573
|
ctxt->error = 1;
|
574
574
|
return(NULL);
|
575
575
|
} else {
|
576
576
|
if (ctxt->dict)
|
577
|
-
ret = (xmlChar *)
|
577
|
+
ret = (xmlChar *) nl_xmlDictLookup(ctxt->dict, q, cur - q);
|
578
578
|
else
|
579
|
-
ret =
|
579
|
+
ret = nl_xmlStrndup(q, cur - q);
|
580
580
|
}
|
581
581
|
cur += len;
|
582
582
|
CUR_PTR = cur;
|
@@ -612,7 +612,7 @@ xmlPatScanName(xmlPatParserContextPtr ctxt) {
|
|
612
612
|
SKIP_BLANKS;
|
613
613
|
|
614
614
|
cur = q = CUR_PTR;
|
615
|
-
val =
|
615
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
616
616
|
if (!IS_LETTER(val) && (val != '_') && (val != ':'))
|
617
617
|
return(NULL);
|
618
618
|
|
@@ -622,12 +622,12 @@ xmlPatScanName(xmlPatParserContextPtr ctxt) {
|
|
622
622
|
(IS_COMBINING(val)) ||
|
623
623
|
(IS_EXTENDER(val))) {
|
624
624
|
cur += len;
|
625
|
-
val =
|
625
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
626
626
|
}
|
627
627
|
if (ctxt->dict)
|
628
|
-
ret = (xmlChar *)
|
628
|
+
ret = (xmlChar *) nl_xmlDictLookup(ctxt->dict, q, cur - q);
|
629
629
|
else
|
630
|
-
ret =
|
630
|
+
ret = nl_xmlStrndup(q, cur - q);
|
631
631
|
CUR_PTR = cur;
|
632
632
|
return(ret);
|
633
633
|
}
|
@@ -650,7 +650,7 @@ xmlPatScanNCName(xmlPatParserContextPtr ctxt) {
|
|
650
650
|
SKIP_BLANKS;
|
651
651
|
|
652
652
|
cur = q = CUR_PTR;
|
653
|
-
val =
|
653
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
654
654
|
if (!IS_LETTER(val) && (val != '_'))
|
655
655
|
return(NULL);
|
656
656
|
|
@@ -660,12 +660,12 @@ xmlPatScanNCName(xmlPatParserContextPtr ctxt) {
|
|
660
660
|
(IS_COMBINING(val)) ||
|
661
661
|
(IS_EXTENDER(val))) {
|
662
662
|
cur += len;
|
663
|
-
val =
|
663
|
+
val = nl_xmlStringCurrentChar(NULL, cur, &len);
|
664
664
|
}
|
665
665
|
if (ctxt->dict)
|
666
|
-
ret = (xmlChar *)
|
666
|
+
ret = (xmlChar *) nl_xmlDictLookup(ctxt->dict, q, cur - q);
|
667
667
|
else
|
668
|
-
ret =
|
668
|
+
ret = nl_xmlStrndup(q, cur - q);
|
669
669
|
CUR_PTR = cur;
|
670
670
|
return(ret);
|
671
671
|
}
|
@@ -745,7 +745,7 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
|
|
745
745
|
XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE);
|
746
746
|
} else {
|
747
747
|
for (i = 0;i < ctxt->nb_namespaces;i++) {
|
748
|
-
if (
|
748
|
+
if (nl_xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) {
|
749
749
|
XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i])
|
750
750
|
break;
|
751
751
|
}
|
@@ -867,7 +867,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
|
|
867
867
|
XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE)
|
868
868
|
} else {
|
869
869
|
for (i = 0;i < ctxt->nb_namespaces;i++) {
|
870
|
-
if (
|
870
|
+
if (nl_xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) {
|
871
871
|
XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i])
|
872
872
|
break;
|
873
873
|
}
|
@@ -897,7 +897,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
|
|
897
897
|
}
|
898
898
|
} else {
|
899
899
|
NEXT;
|
900
|
-
if (
|
900
|
+
if (nl_xmlStrEqual(name, (const xmlChar *) "child")) {
|
901
901
|
XML_PAT_FREE_STRING(ctxt, name);
|
902
902
|
name = xmlPatScanName(ctxt);
|
903
903
|
if (name == NULL) {
|
@@ -934,7 +934,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
|
|
934
934
|
XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE)
|
935
935
|
} else {
|
936
936
|
for (i = 0;i < ctxt->nb_namespaces;i++) {
|
937
|
-
if (
|
937
|
+
if (nl_xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) {
|
938
938
|
XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i])
|
939
939
|
break;
|
940
940
|
}
|
@@ -965,7 +965,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
|
|
965
965
|
} else
|
966
966
|
PUSH(XML_OP_CHILD, name, NULL);
|
967
967
|
return;
|
968
|
-
} else if (
|
968
|
+
} else if (nl_xmlStrEqual(name, (const xmlChar *) "attribute")) {
|
969
969
|
XML_PAT_FREE_STRING(ctxt, name)
|
970
970
|
name = NULL;
|
971
971
|
if (XML_STREAM_XS_IDC_SEL(ctxt->comp)) {
|
@@ -1280,16 +1280,16 @@ xmlNewStreamComp(int size) {
|
|
1280
1280
|
if (size < 4)
|
1281
1281
|
size = 4;
|
1282
1282
|
|
1283
|
-
cur = (xmlStreamCompPtr)
|
1283
|
+
cur = (xmlStreamCompPtr) nl_xmlMalloc(sizeof(xmlStreamComp));
|
1284
1284
|
if (cur == NULL) {
|
1285
1285
|
ERROR(NULL, NULL, NULL,
|
1286
1286
|
"xmlNewStreamComp: malloc failed\n");
|
1287
1287
|
return(NULL);
|
1288
1288
|
}
|
1289
1289
|
memset(cur, 0, sizeof(xmlStreamComp));
|
1290
|
-
cur->steps = (xmlStreamStepPtr)
|
1290
|
+
cur->steps = (xmlStreamStepPtr) nl_xmlMalloc(size * sizeof(xmlStreamStep));
|
1291
1291
|
if (cur->steps == NULL) {
|
1292
|
-
|
1292
|
+
nl_xmlFree(cur);
|
1293
1293
|
ERROR(NULL, NULL, NULL,
|
1294
1294
|
"xmlNewStreamComp: malloc failed\n");
|
1295
1295
|
return(NULL);
|
@@ -1309,10 +1309,10 @@ static void
|
|
1309
1309
|
xmlFreeStreamComp(xmlStreamCompPtr comp) {
|
1310
1310
|
if (comp != NULL) {
|
1311
1311
|
if (comp->steps != NULL)
|
1312
|
-
|
1312
|
+
nl_xmlFree(comp->steps);
|
1313
1313
|
if (comp->dict != NULL)
|
1314
|
-
|
1315
|
-
|
1314
|
+
nl_xmlDictFree(comp->dict);
|
1315
|
+
nl_xmlFree(comp);
|
1316
1316
|
}
|
1317
1317
|
}
|
1318
1318
|
|
@@ -1333,7 +1333,7 @@ xmlStreamCompAddStep(xmlStreamCompPtr comp, const xmlChar *name,
|
|
1333
1333
|
xmlStreamStepPtr cur;
|
1334
1334
|
|
1335
1335
|
if (comp->nbStep >= comp->maxStep) {
|
1336
|
-
cur = (xmlStreamStepPtr)
|
1336
|
+
cur = (xmlStreamStepPtr) nl_xmlRealloc(comp->steps,
|
1337
1337
|
comp->maxStep * 2 * sizeof(xmlStreamStep));
|
1338
1338
|
if (cur == NULL) {
|
1339
1339
|
ERROR(NULL, NULL, NULL,
|
@@ -1388,7 +1388,7 @@ xmlStreamCompile(xmlPatternPtr comp) {
|
|
1388
1388
|
return(-1);
|
1389
1389
|
if (comp->dict != NULL) {
|
1390
1390
|
stream->dict = comp->dict;
|
1391
|
-
|
1391
|
+
nl_xmlDictReference(stream->dict);
|
1392
1392
|
}
|
1393
1393
|
|
1394
1394
|
i = 0;
|
@@ -1545,16 +1545,16 @@ static xmlStreamCtxtPtr
|
|
1545
1545
|
xmlNewStreamCtxt(xmlStreamCompPtr stream) {
|
1546
1546
|
xmlStreamCtxtPtr cur;
|
1547
1547
|
|
1548
|
-
cur = (xmlStreamCtxtPtr)
|
1548
|
+
cur = (xmlStreamCtxtPtr) nl_xmlMalloc(sizeof(xmlStreamCtxt));
|
1549
1549
|
if (cur == NULL) {
|
1550
1550
|
ERROR(NULL, NULL, NULL,
|
1551
1551
|
"xmlNewStreamCtxt: malloc failed\n");
|
1552
1552
|
return(NULL);
|
1553
1553
|
}
|
1554
1554
|
memset(cur, 0, sizeof(xmlStreamCtxt));
|
1555
|
-
cur->states = (int *)
|
1555
|
+
cur->states = (int *) nl_xmlMalloc(4 * 2 * sizeof(int));
|
1556
1556
|
if (cur->states == NULL) {
|
1557
|
-
|
1557
|
+
nl_xmlFree(cur);
|
1558
1558
|
ERROR(NULL, NULL, NULL,
|
1559
1559
|
"xmlNewStreamCtxt: malloc failed\n");
|
1560
1560
|
return(NULL);
|
@@ -1568,20 +1568,20 @@ xmlNewStreamCtxt(xmlStreamCompPtr stream) {
|
|
1568
1568
|
}
|
1569
1569
|
|
1570
1570
|
/**
|
1571
|
-
*
|
1571
|
+
* nl_xmlFreeStreamCtxt:
|
1572
1572
|
* @stream: the stream context
|
1573
1573
|
*
|
1574
1574
|
* Free the stream context
|
1575
1575
|
*/
|
1576
1576
|
void
|
1577
|
-
|
1577
|
+
nl_xmlFreeStreamCtxt(xmlStreamCtxtPtr stream) {
|
1578
1578
|
xmlStreamCtxtPtr next;
|
1579
1579
|
|
1580
1580
|
while (stream != NULL) {
|
1581
1581
|
next = stream->next;
|
1582
1582
|
if (stream->states != NULL)
|
1583
|
-
|
1584
|
-
|
1583
|
+
nl_xmlFree(stream->states);
|
1584
|
+
nl_xmlFree(stream);
|
1585
1585
|
stream = next;
|
1586
1586
|
}
|
1587
1587
|
}
|
@@ -1608,7 +1608,7 @@ xmlStreamCtxtAddState(xmlStreamCtxtPtr comp, int idx, int level) {
|
|
1608
1608
|
if (comp->nbState >= comp->maxState) {
|
1609
1609
|
int *cur;
|
1610
1610
|
|
1611
|
-
cur = (int *)
|
1611
|
+
cur = (int *) nl_xmlRealloc(comp->states,
|
1612
1612
|
comp->maxState * 4 * sizeof(int));
|
1613
1613
|
if (cur == NULL) {
|
1614
1614
|
ERROR(NULL, NULL, NULL,
|
@@ -1630,7 +1630,7 @@ xmlStreamCtxtAddState(xmlStreamCtxtPtr comp, int idx, int level) {
|
|
1630
1630
|
* @ns: the namespace name
|
1631
1631
|
* @nodeType: the type of the node
|
1632
1632
|
*
|
1633
|
-
* Push new data onto the stream. NOTE: if the call
|
1633
|
+
* Push new data onto the stream. NOTE: if the call nl_xmlPatterncompile()
|
1634
1634
|
* indicated a dictionary, then strings for name and ns will be expected
|
1635
1635
|
* to come from the dictionary.
|
1636
1636
|
* Both @name and @ns being NULL means the / i.e. the root of the document.
|
@@ -1806,12 +1806,12 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
|
|
1806
1806
|
*/
|
1807
1807
|
match = 1;
|
1808
1808
|
} else if (ns != NULL)
|
1809
|
-
match =
|
1809
|
+
match = nl_xmlStrEqual(step.ns, ns);
|
1810
1810
|
} else if (((step.ns != NULL) == (ns != NULL)) &&
|
1811
1811
|
(name != NULL) &&
|
1812
1812
|
(step.name[0] == name[0]) &&
|
1813
|
-
|
1814
|
-
((step.ns == ns) ||
|
1813
|
+
nl_xmlStrEqual(step.name, name) &&
|
1814
|
+
((step.ns == ns) || nl_xmlStrEqual(step.ns, ns)))
|
1815
1815
|
{
|
1816
1816
|
match = 1;
|
1817
1817
|
}
|
@@ -1938,12 +1938,12 @@ compare:
|
|
1938
1938
|
*/
|
1939
1939
|
match = 1;
|
1940
1940
|
} else if (ns != NULL)
|
1941
|
-
match =
|
1941
|
+
match = nl_xmlStrEqual(step.ns, ns);
|
1942
1942
|
} else if (((step.ns != NULL) == (ns != NULL)) &&
|
1943
1943
|
(name != NULL) &&
|
1944
1944
|
(step.name[0] == name[0]) &&
|
1945
|
-
|
1946
|
-
((step.ns == ns) ||
|
1945
|
+
nl_xmlStrEqual(step.name, name) &&
|
1946
|
+
((step.ns == ns) || nl_xmlStrEqual(step.ns, ns)))
|
1947
1947
|
{
|
1948
1948
|
match = 1;
|
1949
1949
|
}
|
@@ -1983,12 +1983,12 @@ stream_next:
|
|
1983
1983
|
}
|
1984
1984
|
|
1985
1985
|
/**
|
1986
|
-
*
|
1986
|
+
* nl_xmlStreamPush:
|
1987
1987
|
* @stream: the stream context
|
1988
1988
|
* @name: the current name
|
1989
1989
|
* @ns: the namespace name
|
1990
1990
|
*
|
1991
|
-
* Push new data onto the stream. NOTE: if the call
|
1991
|
+
* Push new data onto the stream. NOTE: if the call nl_xmlPatterncompile()
|
1992
1992
|
* indicated a dictionary, then strings for name and ns will be expected
|
1993
1993
|
* to come from the dictionary.
|
1994
1994
|
* Both @name and @ns being NULL means the / i.e. the root of the document.
|
@@ -1999,24 +1999,24 @@ stream_next:
|
|
1999
1999
|
* match and 0 otherwise.
|
2000
2000
|
*/
|
2001
2001
|
int
|
2002
|
-
|
2002
|
+
nl_xmlStreamPush(xmlStreamCtxtPtr stream,
|
2003
2003
|
const xmlChar *name, const xmlChar *ns) {
|
2004
2004
|
return (xmlStreamPushInternal(stream, name, ns, XML_ELEMENT_NODE));
|
2005
2005
|
}
|
2006
2006
|
|
2007
2007
|
/**
|
2008
|
-
*
|
2008
|
+
* nl_xmlStreamPushNode:
|
2009
2009
|
* @stream: the stream context
|
2010
2010
|
* @name: the current name
|
2011
2011
|
* @ns: the namespace name
|
2012
2012
|
* @nodeType: the type of the node being pushed
|
2013
2013
|
*
|
2014
|
-
* Push new data onto the stream. NOTE: if the call
|
2014
|
+
* Push new data onto the stream. NOTE: if the call nl_xmlPatterncompile()
|
2015
2015
|
* indicated a dictionary, then strings for name and ns will be expected
|
2016
2016
|
* to come from the dictionary.
|
2017
2017
|
* Both @name and @ns being NULL means the / i.e. the root of the document.
|
2018
2018
|
* This can also act as a reset.
|
2019
|
-
* Different from
|
2019
|
+
* Different from nl_xmlStreamPush() this function can be fed with nodes of type:
|
2020
2020
|
* element-, attribute-, text-, cdata-section-, comment- and
|
2021
2021
|
* processing-instruction-node.
|
2022
2022
|
*
|
@@ -2024,7 +2024,7 @@ xmlStreamPush(xmlStreamCtxtPtr stream,
|
|
2024
2024
|
* match and 0 otherwise.
|
2025
2025
|
*/
|
2026
2026
|
int
|
2027
|
-
|
2027
|
+
nl_xmlStreamPushNode(xmlStreamCtxtPtr stream,
|
2028
2028
|
const xmlChar *name, const xmlChar *ns,
|
2029
2029
|
int nodeType)
|
2030
2030
|
{
|
@@ -2033,12 +2033,12 @@ xmlStreamPushNode(xmlStreamCtxtPtr stream,
|
|
2033
2033
|
}
|
2034
2034
|
|
2035
2035
|
/**
|
2036
|
-
*
|
2036
|
+
* nl_xmlStreamPushAttr:
|
2037
2037
|
* @stream: the stream context
|
2038
2038
|
* @name: the current name
|
2039
2039
|
* @ns: the namespace name
|
2040
2040
|
*
|
2041
|
-
* Push new attribute data onto the stream. NOTE: if the call
|
2041
|
+
* Push new attribute data onto the stream. NOTE: if the call nl_xmlPatterncompile()
|
2042
2042
|
* indicated a dictionary, then strings for name and ns will be expected
|
2043
2043
|
* to come from the dictionary.
|
2044
2044
|
* Both @name and @ns being NULL means the / i.e. the root of the document.
|
@@ -2049,13 +2049,13 @@ xmlStreamPushNode(xmlStreamCtxtPtr stream,
|
|
2049
2049
|
* match and 0 otherwise.
|
2050
2050
|
*/
|
2051
2051
|
int
|
2052
|
-
|
2052
|
+
nl_xmlStreamPushAttr(xmlStreamCtxtPtr stream,
|
2053
2053
|
const xmlChar *name, const xmlChar *ns) {
|
2054
2054
|
return (xmlStreamPushInternal(stream, name, ns, XML_ATTRIBUTE_NODE));
|
2055
2055
|
}
|
2056
2056
|
|
2057
2057
|
/**
|
2058
|
-
*
|
2058
|
+
* nl_xmlStreamPop:
|
2059
2059
|
* @stream: the stream context
|
2060
2060
|
*
|
2061
2061
|
* push one level from the stream.
|
@@ -2063,7 +2063,7 @@ xmlStreamPushAttr(xmlStreamCtxtPtr stream,
|
|
2063
2063
|
* Returns: -1 in case of error, 0 otherwise.
|
2064
2064
|
*/
|
2065
2065
|
int
|
2066
|
-
|
2066
|
+
nl_xmlStreamPop(xmlStreamCtxtPtr stream) {
|
2067
2067
|
int i, lev;
|
2068
2068
|
|
2069
2069
|
if (stream == NULL)
|
@@ -2099,7 +2099,7 @@ xmlStreamPop(xmlStreamCtxtPtr stream) {
|
|
2099
2099
|
}
|
2100
2100
|
|
2101
2101
|
/**
|
2102
|
-
*
|
2102
|
+
* nl_xmlStreamWantsAnyNode:
|
2103
2103
|
* @streamCtxt: the stream context
|
2104
2104
|
*
|
2105
2105
|
* Query if the streaming pattern additionally needs to be fed with
|
@@ -2111,7 +2111,7 @@ xmlStreamPop(xmlStreamCtxtPtr stream) {
|
|
2111
2111
|
* 0 otherwise. -1 on API errors.
|
2112
2112
|
*/
|
2113
2113
|
int
|
2114
|
-
|
2114
|
+
nl_xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt)
|
2115
2115
|
{
|
2116
2116
|
if (streamCtxt == NULL)
|
2117
2117
|
return(-1);
|
@@ -2130,7 +2130,7 @@ xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt)
|
|
2130
2130
|
************************************************************************/
|
2131
2131
|
|
2132
2132
|
/**
|
2133
|
-
*
|
2133
|
+
* nl_xmlPatterncompile:
|
2134
2134
|
* @pattern: the pattern to compile
|
2135
2135
|
* @dict: an optional dictionary for interned strings
|
2136
2136
|
* @flags: compilation flags, see xmlPatternFlags
|
@@ -2141,7 +2141,7 @@ xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt)
|
|
2141
2141
|
* Returns the compiled form of the pattern or NULL in case of error
|
2142
2142
|
*/
|
2143
2143
|
xmlPatternPtr
|
2144
|
-
|
2144
|
+
nl_xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags,
|
2145
2145
|
const xmlChar **namespaces) {
|
2146
2146
|
xmlPatternPtr ret = NULL, cur;
|
2147
2147
|
xmlPatParserContextPtr ctxt = NULL;
|
@@ -2161,7 +2161,7 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags,
|
|
2161
2161
|
if (*or == 0)
|
2162
2162
|
ctxt = xmlNewPatParserContext(start, dict, namespaces);
|
2163
2163
|
else {
|
2164
|
-
tmp =
|
2164
|
+
tmp = nl_xmlStrndup(start, or - start);
|
2165
2165
|
if (tmp != NULL) {
|
2166
2166
|
ctxt = xmlNewPatParserContext(tmp, dict, namespaces);
|
2167
2167
|
}
|
@@ -2175,7 +2175,7 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags,
|
|
2175
2175
|
*/
|
2176
2176
|
if (dict) {
|
2177
2177
|
cur->dict = dict;
|
2178
|
-
|
2178
|
+
nl_xmlDictReference(dict);
|
2179
2179
|
}
|
2180
2180
|
if (ret == NULL)
|
2181
2181
|
ret = cur;
|
@@ -2212,7 +2212,7 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags,
|
|
2212
2212
|
if (xmlReversePattern(cur) < 0)
|
2213
2213
|
goto error;
|
2214
2214
|
if (tmp != NULL) {
|
2215
|
-
|
2215
|
+
nl_xmlFree(tmp);
|
2216
2216
|
tmp = NULL;
|
2217
2217
|
}
|
2218
2218
|
start = or;
|
@@ -2231,22 +2231,22 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags,
|
|
2231
2231
|
return(ret);
|
2232
2232
|
error:
|
2233
2233
|
if (ctxt != NULL) xmlFreePatParserContext(ctxt);
|
2234
|
-
if (ret != NULL)
|
2235
|
-
if (tmp != NULL)
|
2234
|
+
if (ret != NULL) nl_xmlFreePattern(ret);
|
2235
|
+
if (tmp != NULL) nl_xmlFree(tmp);
|
2236
2236
|
return(NULL);
|
2237
2237
|
}
|
2238
2238
|
|
2239
2239
|
/**
|
2240
|
-
*
|
2240
|
+
* nl_xmlPatternGetStreamCtxt:
|
2241
2241
|
* @comp: the precompiled pattern
|
2242
2242
|
*
|
2243
2243
|
* Get a streaming context for that pattern
|
2244
|
-
* Use
|
2244
|
+
* Use nl_xmlFreeStreamCtxt to free the context.
|
2245
2245
|
*
|
2246
2246
|
* Returns a pointer to the context or NULL in case of failure
|
2247
2247
|
*/
|
2248
2248
|
xmlStreamCtxtPtr
|
2249
|
-
|
2249
|
+
nl_xmlPatternGetStreamCtxt(xmlPatternPtr comp)
|
2250
2250
|
{
|
2251
2251
|
xmlStreamCtxtPtr ret = NULL, cur;
|
2252
2252
|
|
@@ -2270,21 +2270,21 @@ xmlPatternGetStreamCtxt(xmlPatternPtr comp)
|
|
2270
2270
|
}
|
2271
2271
|
return(ret);
|
2272
2272
|
failed:
|
2273
|
-
|
2273
|
+
nl_xmlFreeStreamCtxt(ret);
|
2274
2274
|
return(NULL);
|
2275
2275
|
}
|
2276
2276
|
|
2277
2277
|
/**
|
2278
|
-
*
|
2278
|
+
* nl_xmlPatternStreamable:
|
2279
2279
|
* @comp: the precompiled pattern
|
2280
2280
|
*
|
2281
|
-
* Check if the pattern is streamable i.e.
|
2281
|
+
* Check if the pattern is streamable i.e. nl_xmlPatternGetStreamCtxt()
|
2282
2282
|
* should work.
|
2283
2283
|
*
|
2284
2284
|
* Returns 1 if streamable, 0 if not and -1 in case of error.
|
2285
2285
|
*/
|
2286
2286
|
int
|
2287
|
-
|
2287
|
+
nl_xmlPatternStreamable(xmlPatternPtr comp) {
|
2288
2288
|
if (comp == NULL)
|
2289
2289
|
return(-1);
|
2290
2290
|
while (comp != NULL) {
|
@@ -2296,7 +2296,7 @@ xmlPatternStreamable(xmlPatternPtr comp) {
|
|
2296
2296
|
}
|
2297
2297
|
|
2298
2298
|
/**
|
2299
|
-
*
|
2299
|
+
* nl_xmlPatternMaxDepth:
|
2300
2300
|
* @comp: the precompiled pattern
|
2301
2301
|
*
|
2302
2302
|
* Check the maximum depth reachable by a pattern
|
@@ -2305,7 +2305,7 @@ xmlPatternStreamable(xmlPatternPtr comp) {
|
|
2305
2305
|
* and -1 in case of error
|
2306
2306
|
*/
|
2307
2307
|
int
|
2308
|
-
|
2308
|
+
nl_xmlPatternMaxDepth(xmlPatternPtr comp) {
|
2309
2309
|
int ret = 0, i;
|
2310
2310
|
if (comp == NULL)
|
2311
2311
|
return(-1);
|
@@ -2323,7 +2323,7 @@ xmlPatternMaxDepth(xmlPatternPtr comp) {
|
|
2323
2323
|
}
|
2324
2324
|
|
2325
2325
|
/**
|
2326
|
-
*
|
2326
|
+
* nl_xmlPatternMinDepth:
|
2327
2327
|
* @comp: the precompiled pattern
|
2328
2328
|
*
|
2329
2329
|
* Check the minimum depth reachable by a pattern, 0 mean the / or . are
|
@@ -2333,7 +2333,7 @@ xmlPatternMaxDepth(xmlPatternPtr comp) {
|
|
2333
2333
|
*
|
2334
2334
|
*/
|
2335
2335
|
int
|
2336
|
-
|
2336
|
+
nl_xmlPatternMinDepth(xmlPatternPtr comp) {
|
2337
2337
|
int ret = 12345678;
|
2338
2338
|
if (comp == NULL)
|
2339
2339
|
return(-1);
|
@@ -2350,7 +2350,7 @@ xmlPatternMinDepth(xmlPatternPtr comp) {
|
|
2350
2350
|
}
|
2351
2351
|
|
2352
2352
|
/**
|
2353
|
-
*
|
2353
|
+
* nl_xmlPatternFromRoot:
|
2354
2354
|
* @comp: the precompiled pattern
|
2355
2355
|
*
|
2356
2356
|
* Check if the pattern must be looked at from the root.
|
@@ -2358,7 +2358,7 @@ xmlPatternMinDepth(xmlPatternPtr comp) {
|
|
2358
2358
|
* Returns 1 if true, 0 if false and -1 in case of error
|
2359
2359
|
*/
|
2360
2360
|
int
|
2361
|
-
|
2361
|
+
nl_xmlPatternFromRoot(xmlPatternPtr comp) {
|
2362
2362
|
if (comp == NULL)
|
2363
2363
|
return(-1);
|
2364
2364
|
while (comp != NULL) {
|