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

- error.c: applied the context output patch of the error

handling submitted by Chuck Griffith
- error/VC/*: this slightly change some error logs
Daniel
This commit is contained in:
Daniel Veillard
2001-03-27 00:32:28 +00:00
parent 505821145f
commit 2be30641d1
6 changed files with 33 additions and 17 deletions

30
error.c
View File

@ -107,34 +107,44 @@ void
xmlParserPrintFileContext(xmlParserInputPtr input) {
const xmlChar *cur, *base;
int n;
xmlChar content[81];
xmlChar *ctnt;
if (input == NULL) return;
cur = input->cur;
base = input->base;
/* skip backwards over any end-of-lines */
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
cur--;
}
n = 0;
/* search backwards for beginning-of-line maximum 80 characters */
while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
cur--;
if ((*cur == '\n') || (*cur == '\r')) cur++;
base = cur;
/* search forward for end-of-line maximum 80 characters */
n = 0;
ctnt = content;
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
xmlGenericError(xmlGenericErrorContext,
"%c", (unsigned char) *cur++);
*ctnt++ = *cur++;
n++;
}
xmlGenericError(xmlGenericErrorContext, "\n");
*ctnt = 0;
xmlGenericError(xmlGenericErrorContext,"%s\n", content);
/* create blank line with problem pointer */
cur = input->cur;
while ((*cur == '\n') || (*cur == '\r'))
cur--;
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
cur--;
}
n = 0;
while ((cur != base) && (n++ < 80)) {
xmlGenericError(xmlGenericErrorContext, " ");
base++;
ctnt = content;
while ((n++ < 79) && (cur > base) && (*cur != '\n') && (*cur != '\r')) {
*ctnt++ = ' ';
cur--;
}
xmlGenericError(xmlGenericErrorContext,"^\n");
*(--ctnt) = '^';
*(++ctnt) = 0;
xmlGenericError(xmlGenericErrorContext,"%s\n", content);
}
/**