Commit 3dd57f79 authored by William M. Brack's avatar William M. Brack

Fixed bug 109942

parent d72c7e33
Mon May 12 21:58:00 EDT 2003 William Brack <wbrack@mmm.com.hk>
* minor cleanup of configure '--help' display
* error.c: enhanced xmlParserPrintFileContext to fix bug #109942
Mon May 12 17:53:30 EDT 2003 Daniel Veillard <daniel@veillard.com>
* tree.c: PI nodes in external subset were not freed :-\
......
......@@ -149,8 +149,8 @@ xmlParserPrintFileInfo(xmlParserInputPtr input) {
void
xmlParserPrintFileContext(xmlParserInputPtr input) {
const xmlChar *cur, *base;
int n;
xmlChar content[81];
int n, col;
xmlChar content[81]; /* space for 80 chars + line terminator */
xmlChar *ctnt;
if (input == NULL) return;
......@@ -161,37 +161,34 @@ xmlParserPrintFileContext(xmlParserInputPtr input) {
cur--;
}
n = 0;
/* search backwards for beginning-of-line maximum 80 characters */
while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
/* search backwards for beginning-of-line (to max buff size) */
while ((n++ < sizeof(content)-1) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
cur--;
if ((*cur == '\n') || (*cur == '\r')) cur++;
/* search forward for end-of-line maximum 80 characters */
/* calculate the error position in terms of the current position */
col = input->cur - cur;
/* search forward for end-of-line (to max buff size) */
n = 0;
ctnt = content;
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
/* copy selected text to our buffer */
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < sizeof(content)-1)) {
*ctnt++ = *cur++;
n++;
}
*ctnt = 0;
/* print out the selected text */
xmlGenericError(xmlGenericErrorContext,"%s\n", content);
/* create blank line with problem pointer */
cur = input->cur;
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
cur--;
}
n = 0;
ctnt = content;
while ((n++ < 79) && (cur > base) && (*cur != '\n') && (*cur != '\r')) {
*ctnt++ = ' ';
cur--;
}
if (ctnt > content) {
*(--ctnt) = '^';
*(++ctnt) = 0;
} else {
*ctnt = '^';
*(++ctnt) = 0;
/* (leave buffer space for pointer + line terminator) */
while ((n<col) && (n++ < sizeof(content)-2) && (*ctnt != 0)) {
if (*ctnt!='\t')
*ctnt = ' ';
*ctnt++;
}
*ctnt++ = '^';
*ctnt = 0;
xmlGenericError(xmlGenericErrorContext,"%s\n", content);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment