1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

Stop counting nbChars in parser context

The value was inaccurate and never used.
This commit is contained in:
Nick Wellnhofer
2020-08-09 14:43:53 +02:00
parent f6a9541fb8
commit 438e595a8c
4 changed files with 4 additions and 21 deletions

View File

@ -296,7 +296,7 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
#define UPPER (toupper(*ctxt->input->cur)) #define UPPER (toupper(*ctxt->input->cur))
#define SKIP(val) ctxt->nbChars += (val),ctxt->input->cur += (val),ctxt->input->col+=(val) #define SKIP(val) ctxt->input->cur += (val),ctxt->input->col+=(val)
#define NXT(val) ctxt->input->cur[(val)] #define NXT(val) ctxt->input->cur[(val)]
@ -330,7 +330,7 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
if (*(ctxt->input->cur) == '\n') { \ if (*(ctxt->input->cur) == '\n') { \
ctxt->input->line++; ctxt->input->col = 1; \ ctxt->input->line++; ctxt->input->col = 1; \
} else ctxt->input->col++; \ } else ctxt->input->col++; \
ctxt->token = 0; ctxt->input->cur += l; ctxt->nbChars++; \ ctxt->token = 0; ctxt->input->cur += l; \
} while (0) } while (0)
/************ /************
@ -597,7 +597,6 @@ htmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
ctxt->input->line++; ctxt->input->col = 1; ctxt->input->line++; ctxt->input->col = 1;
} else ctxt->input->col++; } else ctxt->input->col++;
ctxt->input->cur++; ctxt->input->cur++;
ctxt->nbChars++;
if (*ctxt->input->cur == 0) if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
} }
@ -2495,7 +2494,6 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
count = in - ctxt->input->cur; count = in - ctxt->input->cur;
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
ctxt->input->cur = in; ctxt->input->cur = in;
ctxt->nbChars += count;
ctxt->input->col += count; ctxt->input->col += count;
return(ret); return(ret);
} }
@ -4938,7 +4936,6 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
ctxt->vctxt.warning = xmlParserValidityWarning; ctxt->vctxt.warning = xmlParserValidityWarning;
ctxt->record_info = 0; ctxt->record_info = 0;
ctxt->validate = 0; ctxt->validate = 0;
ctxt->nbChars = 0;
ctxt->checkIndex = 0; ctxt->checkIndex = 0;
ctxt->catalogs = NULL; ctxt->catalogs = NULL;
xmlInitNodeInfoSeq(&ctxt->node_seq); xmlInitNodeInfoSeq(&ctxt->node_seq);
@ -6581,7 +6578,6 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
ctxt->vctxt.error = xmlParserValidityError; ctxt->vctxt.error = xmlParserValidityError;
ctxt->vctxt.warning = xmlParserValidityWarning; ctxt->vctxt.warning = xmlParserValidityWarning;
ctxt->record_info = 0; ctxt->record_info = 0;
ctxt->nbChars = 0;
ctxt->checkIndex = 0; ctxt->checkIndex = 0;
ctxt->inSubset = 0; ctxt->inSubset = 0;
ctxt->errNo = XML_ERR_OK; ctxt->errNo = XML_ERR_OK;

View File

@ -231,7 +231,7 @@ struct _xmlParserCtxt {
int nameMax; /* Max depth of the parsing stack */ int nameMax; /* Max depth of the parsing stack */
const xmlChar * *nameTab; /* array of nodes */ const xmlChar * *nameTab; /* array of nodes */
long nbChars; /* number of xmlChar processed */ long nbChars; /* unused */
long checkIndex; /* used by progressive parsing lookup */ long checkIndex; /* used by progressive parsing lookup */
int keepBlanks; /* ugly but ... */ int keepBlanks; /* ugly but ... */
int disableSAX; /* SAX callbacks are disabled */ int disableSAX; /* SAX callbacks are disabled */

View File

@ -2055,7 +2055,7 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
((unsigned char *) s)[ 9 ] == c10 ) ((unsigned char *) s)[ 9 ] == c10 )
#define SKIP(val) do { \ #define SKIP(val) do { \
ctxt->nbChars += (val),ctxt->input->cur += (val),ctxt->input->col+=(val); \ ctxt->input->cur += (val),ctxt->input->col+=(val); \
if (*ctxt->input->cur == 0) \ if (*ctxt->input->cur == 0) \
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \ xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
} while (0) } while (0)
@ -2066,7 +2066,6 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
if (*(ctxt->input->cur) == '\n') { \ if (*(ctxt->input->cur) == '\n') { \
ctxt->input->line++; ctxt->input->col = 1; \ ctxt->input->line++; ctxt->input->col = 1; \
} else ctxt->input->col++; \ } else ctxt->input->col++; \
ctxt->nbChars++; \
ctxt->input->cur++; \ ctxt->input->cur++; \
} \ } \
if (*ctxt->input->cur == 0) \ if (*ctxt->input->cur == 0) \
@ -2119,7 +2118,6 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
#define NEXT1 { \ #define NEXT1 { \
ctxt->input->col++; \ ctxt->input->col++; \
ctxt->input->cur++; \ ctxt->input->cur++; \
ctxt->nbChars++; \
if (*ctxt->input->cur == 0) \ if (*ctxt->input->cur == 0) \
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \ xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
} }
@ -2332,7 +2330,6 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
if (RAW == ';') { if (RAW == ';') {
/* on purpose to avoid reentrancy problems with NEXT and SKIP */ /* on purpose to avoid reentrancy problems with NEXT and SKIP */
ctxt->input->col++; ctxt->input->col++;
ctxt->nbChars ++;
ctxt->input->cur++; ctxt->input->cur++;
} }
} else if ((RAW == '&') && (NXT(1) == '#')) { } else if ((RAW == '&') && (NXT(1) == '#')) {
@ -2361,7 +2358,6 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
if (RAW == ';') { if (RAW == ';') {
/* on purpose to avoid reentrancy problems with NEXT and SKIP */ /* on purpose to avoid reentrancy problems with NEXT and SKIP */
ctxt->input->col++; ctxt->input->col++;
ctxt->nbChars ++;
ctxt->input->cur++; ctxt->input->cur++;
} }
} else { } else {
@ -3333,7 +3329,6 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
} }
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
ctxt->input->cur = in; ctxt->input->cur = in;
ctxt->nbChars += count;
ctxt->input->col += count; ctxt->input->col += count;
if (ret == NULL) if (ret == NULL)
xmlErrMemory(ctxt, NULL); xmlErrMemory(ctxt, NULL);
@ -3456,7 +3451,6 @@ xmlParseNCName(xmlParserCtxtPtr ctxt) {
} }
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
ctxt->input->cur = in; ctxt->input->cur = in;
ctxt->nbChars += count;
ctxt->input->col += count; ctxt->input->col += count;
if (ret == NULL) { if (ret == NULL) {
xmlErrMemory(ctxt, NULL); xmlErrMemory(ctxt, NULL);
@ -14793,7 +14787,6 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->vctxt.warning = xmlParserValidityWarning; ctxt->vctxt.warning = xmlParserValidityWarning;
#endif #endif
ctxt->record_info = 0; ctxt->record_info = 0;
ctxt->nbChars = 0;
ctxt->checkIndex = 0; ctxt->checkIndex = 0;
ctxt->inSubset = 0; ctxt->inSubset = 0;
ctxt->errNo = XML_ERR_OK; ctxt->errNo = XML_ERR_OK;

View File

@ -519,8 +519,6 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
} else } else
/* 1-byte code */ /* 1-byte code */
ctxt->input->cur++; ctxt->input->cur++;
ctxt->nbChars++;
} else { } else {
/* /*
* Assume it's a fixed length encoding (1) with * Assume it's a fixed length encoding (1) with
@ -533,7 +531,6 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
} else } else
ctxt->input->col++; ctxt->input->col++;
ctxt->input->cur++; ctxt->input->cur++;
ctxt->nbChars++;
} }
if (*ctxt->input->cur == 0) if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
@ -677,7 +674,6 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
} }
if (*ctxt->input->cur == 0xD) { if (*ctxt->input->cur == 0xD) {
if (ctxt->input->cur[1] == 0xA) { if (ctxt->input->cur[1] == 0xA) {
ctxt->nbChars++;
ctxt->input->cur++; ctxt->input->cur++;
} }
return(0xA); return(0xA);
@ -693,7 +689,6 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
*len = 1; *len = 1;
if (*ctxt->input->cur == 0xD) { if (*ctxt->input->cur == 0xD) {
if (ctxt->input->cur[1] == 0xA) { if (ctxt->input->cur[1] == 0xA) {
ctxt->nbChars++;
ctxt->input->cur++; ctxt->input->cur++;
} }
return(0xA); return(0xA);
@ -1748,7 +1743,6 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
ctxt->options |= XML_PARSE_NOENT; ctxt->options |= XML_PARSE_NOENT;
} }
ctxt->record_info = 0; ctxt->record_info = 0;
ctxt->nbChars = 0;
ctxt->checkIndex = 0; ctxt->checkIndex = 0;
ctxt->inSubset = 0; ctxt->inSubset = 0;
ctxt->errNo = XML_ERR_OK; ctxt->errNo = XML_ERR_OK;