Tag
Hash :
260a68fd
Author :
Date :
1998-08-13T03:39:55
Release 0.2, 80% rewrite, nothing left intact ... Daniel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
/*
* error.c: module displaying errors
*/
#include <stdio.h>
#include <stdarg.h>
#include "parser.h"
/*
* Display and format error messages.
*/
void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...) {
const CHAR *cur, *base;
va_list args;
int n;
va_start(args, msg);
if (ctxt->input->filename)
fprintf(stderr, "%s:%d: ", ctxt->input->filename,
ctxt->input->line);
else
fprintf(stderr, "line %d: ", ctxt->input->line);
fprintf(stderr, "error: ");
vfprintf(stderr, msg, args);
va_end(ap);
cur = ctxt->input->cur;
base = ctxt->input->base;
while ((*cur == '\n') || (*cur == '\r')) {
cur--;
base--;
}
n = 0;
while ((n++ < 60) && (cur >= base) && (*cur != '\n') && (*cur != '\r'))
cur--;
if ((*cur == '\n') || (*cur == '\r')) cur++;
base = cur;
n = 0;
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
fprintf(stderr, "%c", (unsigned char) *cur++);
n++;
}
fprintf(stderr, "\n");
cur = ctxt->input->cur;
while ((*cur == '\n') || (*cur == '\r'))
cur--;
n = 0;
while ((cur != base) && (n++ < 60)) {
fprintf(stderr, " ");
base++;
}
fprintf(stderr,"^\n");
}
/*
* Display and format error messages.
*/
void xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...) {
const CHAR *cur, *base;
va_list args;
int n;
va_start(args, msg);
if (ctxt->input->filename)
fprintf(stderr, "%s:%d: ", ctxt->input->filename,
ctxt->input->line);
else
fprintf(stderr, "line %d: ", ctxt->input->line);
fprintf(stderr, "warning: ");
vfprintf(stderr, msg, args);
va_end(ap);
cur = ctxt->input->cur;
base = ctxt->input->base;
n = 0;
while ((n++ < 60) && (cur >= base) && (*cur != '\n') && (*cur != '\r'))
cur--;
if ((*cur != '\n') || (*cur != '\r')) cur++;
base = cur;
n = 0;
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
fprintf(stderr, "%c", (unsigned char) *cur++);
n++;
}
fprintf(stderr, "\n");
cur = ctxt->input->cur;
n = 0;
while ((cur != base) && (n++ < 60)) {
fprintf(stderr, " ");
base++;
}
fprintf(stderr,"^\n");
}