mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-21 22:50:08 +03:00
parser: Make CRLF increment line number
Partial revert of cb927e85 fixing CRLFs not incrementing the line number. This requires to rework xmlParseQNameHashed. The original implementation prompted the change to xmlCurrentChar which really shouldn't modify the 'cur' pointer as side effect. But the NEXTL macro relies on this behavior. Ultimately, we should reintroduce the change to xmlCurrentChar and fix the NEXTL macro. This will lead to single CRs incrementing the line number as well which seems more consistent. Fixes #628.
This commit is contained in:
parent
455c61d635
commit
43b511fa71
15
parser.c
15
parser.c
@ -8949,7 +8949,7 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
|
||||
static xmlHashedString
|
||||
xmlParseQNameHashed(xmlParserCtxtPtr ctxt, xmlHashedString *prefix) {
|
||||
xmlHashedString l, p;
|
||||
int start;
|
||||
int start, isNCName = 0;
|
||||
|
||||
l.name = NULL;
|
||||
p.name = NULL;
|
||||
@ -8960,10 +8960,13 @@ xmlParseQNameHashed(xmlParserCtxtPtr ctxt, xmlHashedString *prefix) {
|
||||
start = CUR_PTR - BASE_PTR;
|
||||
|
||||
l = xmlParseNCName(ctxt);
|
||||
if ((l.name != NULL) && (CUR == ':')) {
|
||||
NEXT;
|
||||
p = l;
|
||||
l = xmlParseNCName(ctxt);
|
||||
if (l.name != NULL) {
|
||||
isNCName = 1;
|
||||
if (CUR == ':') {
|
||||
NEXT;
|
||||
p = l;
|
||||
l = xmlParseNCName(ctxt);
|
||||
}
|
||||
}
|
||||
if ((l.name == NULL) || (CUR == ':')) {
|
||||
xmlChar *tmp;
|
||||
@ -8972,7 +8975,7 @@ xmlParseQNameHashed(xmlParserCtxtPtr ctxt, xmlHashedString *prefix) {
|
||||
p.name = NULL;
|
||||
if (ctxt->instate == XML_PARSER_EOF)
|
||||
return(l);
|
||||
if ((CUR != ':') && (CUR_PTR <= BASE_PTR + start))
|
||||
if ((isNCName == 0) && (CUR != ':'))
|
||||
return(l);
|
||||
tmp = xmlParseNmtoken(ctxt);
|
||||
if (tmp != NULL)
|
||||
|
@ -849,7 +849,14 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
|
||||
* the single character #xA.
|
||||
*/
|
||||
if (c == '\r') {
|
||||
*len = ((cur[1] == '\n') ? 2 : 1);
|
||||
/*
|
||||
* TODO: This function shouldn't change the 'cur' pointer
|
||||
* as side effect, but the NEXTL macro in parser.c relies
|
||||
* on this behavior when incrementing line numbers.
|
||||
*/
|
||||
if (cur[1] == '\n')
|
||||
ctxt->input->cur++;
|
||||
*len = 1;
|
||||
c = '\n';
|
||||
} else if (c == 0) {
|
||||
if (ctxt->input->cur >= ctxt->input->end) {
|
||||
|
3
result/errors/name3.xml.ent
Normal file
3
result/errors/name3.xml.ent
Normal file
@ -0,0 +1,3 @@
|
||||
./test/errors/name3.xml:1: parser error : StartTag: invalid element name
|
||||
<.name/>
|
||||
^
|
3
result/errors/name3.xml.err
Normal file
3
result/errors/name3.xml.err
Normal file
@ -0,0 +1,3 @@
|
||||
./test/errors/name3.xml:1: parser error : StartTag: invalid element name
|
||||
<.name/>
|
||||
^
|
4
result/errors/name3.xml.str
Normal file
4
result/errors/name3.xml.str
Normal file
@ -0,0 +1,4 @@
|
||||
./test/errors/name3.xml:1: parser error : StartTag: invalid element name
|
||||
<.name/>
|
||||
^
|
||||
./test/errors/name3.xml : failed to parse
|
1
test/errors/name3.xml
Normal file
1
test/errors/name3.xml
Normal file
@ -0,0 +1 @@
|
||||
<.name/>
|
Loading…
x
Reference in New Issue
Block a user