Re: [xml] column information in the error structure (patch)
- From: Aleksey Sanin <aleksey aleksey com>
- To: xml <xml gnome org>
- Subject: Re: [xml] column information in the error structure (patch)
- Date: Tue, 04 Jan 2005 17:14:40 -0800
The attached patch fixes column number calculation in _xmlParserInput
(thanks, Rob!) and propagates error column number in the xmlError as
we discussed. Please let me know if it is OK to check it in.
Thanks!
Aleksey
Rob Richards wrote:
Here's the patch I have for the line numbers and columns. Not sure if I
caught all the spots, but my line/columns have been more accurate with
this at least using SAX.
Rob
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-xml/ChangeLog,v
retrieving revision 1.2286
diff -u -r1.2286 ChangeLog
--- ChangeLog 4 Jan 2005 21:50:02 -0000 1.2286
+++ ChangeLog 5 Jan 2005 01:12:29 -0000
@@ -1,3 +1,10 @@
+Tue Jan 4 17:08:45 PST 2005 Aleksey Sanin <aleksey aleksey com>
+
+ * parser.c, parserInternal.c: fixed "col" calculation for
+ struct _xmlParserInput (based on patch from Rob Richards)
+ * include/libxml/xmlerror.h, error.c: propagated error column
+ number in the xmlError structure
+
Tue Jan 4 22:47:22 CET 2005 Daniel Veillard <daniel veillard com>
* parser.c: fixed namespace bug in push mode reported by
@@ -40,7 +47,7 @@
Mon Jan 3 13:57:21 PST 2005 Aleksey Sanin <aleksey aleksey com>
- * Added GetLineNumber and GetColumnNumber functions for xmlReader
+ * parser.c: added GetLineNumber and GetColumnNumber functions for xmlReader
Sun Jan 2 17:51:18 HKT 2005 William Brack <wbrack mmm com hk>
Index: error.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/error.c,v
retrieving revision 1.75
diff -u -r1.75 error.c
--- error.c 4 Jan 2005 15:10:21 -0000 1.75
+++ error.c 5 Jan 2005 01:12:29 -0000
@@ -429,7 +429,7 @@
* @str2: extra string info
* @str3: extra string info
* @int1: extra int info
- * @int2: extra int info
+ * @col: column number of the error or 0 if N/A
* @msg: the message to display/transmit
* @...: extra parameters for the message display
*
@@ -442,7 +442,7 @@
xmlGenericErrorFunc channel, void *data, void *ctx,
void *nod, int domain, int code, xmlErrorLevel level,
const char *file, int line, const char *str1,
- const char *str2, const char *str3, int int1, int int2,
+ const char *str2, const char *str3, int int1, int col,
const char *msg, ...)
{
xmlParserCtxtPtr ctxt = NULL;
@@ -505,6 +505,7 @@
if (input != NULL) {
file = input->filename;
line = input->line;
+ col = input->col;
}
}
to = &ctxt->lastError;
@@ -571,7 +572,7 @@
if (str3 != NULL)
to->str3 = (char *) xmlStrdup((const xmlChar *) str3);
to->int1 = int1;
- to->int2 = int2;
+ to->int2 = col;
to->node = node;
to->ctxt = ctx;
Index: parser.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/parser.c,v
retrieving revision 1.407
diff -u -r1.407 parser.c
--- parser.c 4 Jan 2005 21:50:02 -0000 1.407
+++ parser.c 5 Jan 2005 01:12:30 -0000
@@ -2421,6 +2421,7 @@
while (*in != 0 && *in == *cmp) {
++in;
++cmp;
+ ctxt->input->col++;
}
if (*cmp == 0 && (*in == '>' || IS_BLANK_CH (*in))) {
/* success */
@@ -3201,10 +3202,10 @@
get_more_space:
while (*in == 0x20) in++;
if (*in == 0xA) {
- ctxt->input->line++;
+ ctxt->input->line++; ctxt->input->col = 1;
in++;
while (*in == 0xA) {
- ctxt->input->line++;
+ ctxt->input->line++; ctxt->input->col = 1;
in++;
}
goto get_more_space;
@@ -3237,13 +3238,15 @@
((*in > '&') && (*in < '<')) ||
((*in > '<') && (*in < ']')) ||
((*in >= 0x20) && (*in < '&')) ||
- (*in == 0x09))
- in++;
+ (*in == 0x09)) {
+ in++;
+ ctxt->input->col++;
+ }
if (*in == 0xA) {
- ctxt->input->line++;
+ ctxt->input->line++; ctxt->input->col = 1;
in++;
while (*in == 0xA) {
- ctxt->input->line++;
+ ctxt->input->line++; ctxt->input->col = 1;
in++;
}
goto get_more;
@@ -3255,6 +3258,7 @@
return;
}
in++;
+ ctxt->input->col++;
goto get_more;
}
nbchar = in - ctxt->input->cur;
@@ -3288,7 +3292,7 @@
if (*in == 0xA) {
ctxt->input->cur = in;
in++;
- ctxt->input->line++;
+ ctxt->input->line++; ctxt->input->col = 1;
continue; /* while */
}
in--;
Index: parserInternals.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/parserInternals.c,v
retrieving revision 1.112
diff -u -r1.112 parserInternals.c
--- parserInternals.c 25 Dec 2004 10:14:57 -0000 1.112
+++ parserInternals.c 5 Jan 2005 01:12:40 -0000
@@ -473,8 +473,7 @@
* the single character #xA.
*/
if (*(ctxt->input->cur) == '\n') {
- ctxt->input->line++;
- ctxt->input->col = 1;
+ ctxt->input->line++; ctxt->input->col = 1;
} else
ctxt->input->col++;
@@ -551,8 +550,7 @@
*/
if (*(ctxt->input->cur) == '\n') {
- ctxt->input->line++;
- ctxt->input->col = 1;
+ ctxt->input->line++; ctxt->input->col = 1;
} else
ctxt->input->col++;
ctxt->input->cur++;
Index: include/libxml/xmlerror.h
===================================================================
RCS file: /cvs/gnome/gnome-xml/include/libxml/xmlerror.h,v
retrieving revision 1.65
diff -u -r1.65 xmlerror.h
--- include/libxml/xmlerror.h 4 Jan 2005 15:10:21 -0000 1.65
+++ include/libxml/xmlerror.h 5 Jan 2005 01:12:41 -0000
@@ -82,7 +82,7 @@
char *str2; /* extra string information */
char *str3; /* extra string information */
int int1; /* extra number information */
- int int2; /* extra number information */
+ int int2; /* column number of the error or 0 if N/A (todo: rename this field when we
would break ABI) */
void *ctxt; /* the parser context if available */
void *node; /* the node in the tree */
};
@@ -889,7 +889,7 @@
const char *str2,
const char *str3,
int int1,
- int int2,
+ int col,
const char *msg,
...);
XMLPUBFUN void XMLCALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]