Annotation of XML/error.c, revision 1.3

1.1       daniel      1: /*
                      2:  * error.c: module displaying errors
                      3:  */
                      4: 
                      5: #include <stdio.h>
                      6: #include <stdarg.h>
                      7: #include "parser.h"
                      8: 
                      9: /*
                     10:  * Display and format error messages.
                     11:  */
                     12: void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...) {
                     13:     const CHAR *cur, *base;
                     14:     va_list args;
                     15:     int n;
                     16: 
                     17:     va_start(args, msg);
                     18:     fprintf(stderr, "error: ");
                     19:     vfprintf(stderr, msg, args);
                     20:     va_end(ap);
1.3     ! daniel     21:     cur = ctxt->input->cur;
        !            22:     base = ctxt->input->base;
1.2       daniel     23:     n = 0;
                     24:     while ((n++ < 60) && (cur >= base) && (*cur != '\n') && (*cur != '\r'))
                     25:         cur--;
1.1       daniel     26:     if ((*cur != '\n') || (*cur != '\r')) cur++;
                     27:     base = cur;
1.2       daniel     28:     n = 0;
1.1       daniel     29:     while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
                     30:         fprintf(stderr, "%c", (unsigned char) *cur++);
                     31:        n++;
                     32:     }
                     33:     fprintf(stderr, "\n");
1.3     ! daniel     34:     cur = ctxt->input->cur;
1.1       daniel     35:     while (cur != base) {
                     36:         fprintf(stderr, " ");
                     37:         base++;
                     38:     }
                     39:     fprintf(stderr,"^\n");
                     40: }

Webmaster