[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] CDATA sections do not count line numbers via SAX2 API
- From: Dave Beckett <dave beckett bristol ac uk>
- Cc: veillard redhat com, xml gnome org
- Subject: Re: [xml] CDATA sections do not count line numbers via SAX2 API
- Date: Mon, 22 Dec 2003 17:08:57 +0000
On Mon, 22 Dec 2003 16:48:57 +0000, Dave Beckett <dave beckett bristol ac uk> wrote:
> ... after dealing with the cdata, the following is at parser.c line 9719:
> SKIP(base + 3);.
>
> where base is returned from xmlParseLookupSequence
> looking for the closing ]]>
>
> Earlier on it says
> * SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined
> * strings without newlines within the parser.
>
> However, that SKIP does (may) contain newlines. There's
> another nearby one at 9705 that might also be suspicious.
Well, I tried fixing that by making a SKIPL(x) that checks for
newlines in the skipped chars. This is only needed for SKIP(x)
when x is not a constant, both places I see here are near
the CDATA counting.
So the attached patch adds a SKIPL macro and uses it;
with that, the answer I get is consistent.
Dave
--- parser.c.orig Mon Dec 22 14:35:49 2003
+++ parser.c Mon Dec 22 17:04:08 2003
@@ -1260,6 +1260,21 @@
xmlPopInput(ctxt); \
} while (0)
+#define SKIPL(val) do { \
+ int skipl; \
+ for(skipl=0; skipl<val; skipl++) { \
+ if (*(ctxt->input->cur) == '\n') { \
+ ctxt->input->line++; ctxt->input->col = 1; \
+ } else ctxt->input->col++; \
+ ctxt->nbChars++; \
+ ctxt->input->cur++; \
+ } \
+ if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt); \
+ if ((*ctxt->input->cur == 0) && \
+ (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) \
+ xmlPopInput(ctxt); \
+ } while (0)
+
#define SHRINK if ((ctxt->progressive == 0) && \
(ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
@@ -9702,7 +9717,7 @@
ctxt->input->cur,
XML_PARSER_BIG_BUFFER_SIZE);
}
- SKIP(XML_PARSER_BIG_BUFFER_SIZE);
+ SKIPL(XML_PARSER_BIG_BUFFER_SIZE);
ctxt->checkIndex = 0;
}
goto done;
@@ -9716,7 +9731,7 @@
ctxt->sax->characters(ctxt->userData,
ctxt->input->cur, base);
}
- SKIP(base + 3);
+ SKIPL(base + 3);
ctxt->checkIndex = 0;
ctxt->instate = XML_PARSER_CONTENT;
#ifdef DEBUG_PUSH
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]