diff options
-rw-r--r-- | util/cairo-script/cairo-script-interpreter.c | 6 | ||||
-rw-r--r-- | util/cairo-script/cairo-script-interpreter.h | 3 | ||||
-rw-r--r-- | util/cairo-script/cairo-script-private.h | 2 | ||||
-rw-r--r-- | util/cairo-script/cairo-script-scanner.c | 12 |
4 files changed, 20 insertions, 3 deletions
diff --git a/util/cairo-script/cairo-script-interpreter.c b/util/cairo-script/cairo-script-interpreter.c index ad4a1a7a..db26b003 100644 --- a/util/cairo-script/cairo-script-interpreter.c +++ b/util/cairo-script/cairo-script-interpreter.c @@ -567,6 +567,12 @@ cairo_script_interpreter_feed_string (csi_t *ctx, const char *line, int len) return ctx->status; } +unsigned int +cairo_script_interpreter_get_line_number (csi_t *ctx) +{ + return ctx->scanner.line_number + 1; /* 1 index based */ +} + csi_t * cairo_script_interpreter_reference (csi_t *ctx) { diff --git a/util/cairo-script/cairo-script-interpreter.h b/util/cairo-script/cairo-script-interpreter.h index a9318b03..a5004671 100644 --- a/util/cairo-script/cairo-script-interpreter.h +++ b/util/cairo-script/cairo-script-interpreter.h @@ -88,6 +88,9 @@ cairo_script_interpreter_feed_string (cairo_script_interpreter_t *ctx, const char *line, int len); +cairo_public unsigned int +cairo_script_interpreter_get_line_number (cairo_script_interpreter_t *ctx); + cairo_public cairo_script_interpreter_t * cairo_script_interpreter_reference (cairo_script_interpreter_t *ctx); diff --git a/util/cairo-script/cairo-script-private.h b/util/cairo-script/cairo-script-private.h index d19737af..96c20443 100644 --- a/util/cairo-script/cairo-script-private.h +++ b/util/cairo-script/cairo-script-private.h @@ -441,6 +441,8 @@ struct _csi_scanner { int string_p; unsigned int accumulator; unsigned int accumulator_count; + + unsigned int line_number; }; typedef cairo_script_interpreter_hooks_t csi_hooks_t; diff --git a/util/cairo-script/cairo-script-scanner.c b/util/cairo-script/cairo-script-scanner.c index 538aad42..6ade97f5 100644 --- a/util/cairo-script/cairo-script-scanner.c +++ b/util/cairo-script/cairo-script-scanner.c @@ -678,9 +678,10 @@ scan_none (csi_t *ctx, csi_object_t obj = { CSI_OBJECT_TYPE_NULL }; switch (c) { + case 0xa: + scan->line_number++; case 0x0: case 0x9: - case 0xa: case 0xc: case 0xd: case 0x20: /* ignore whitespace */ @@ -829,9 +830,10 @@ scan_token (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src) while ((c = scan_getc (scan, src)) != EOF) { switch (c) { + case 0xa: + scan->line_number++; case 0x0: case 0x9: - case 0xa: case 0xc: case 0xd: case 0x20: @@ -901,9 +903,10 @@ scan_hex (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src) while ((c = scan_getc (scan, src)) != EOF) { switch (c) { + case 0xa: + scan->line_number++; case 0x0: case 0x9: - case 0xa: case 0xc: case 0xd: case 0x20: /* ignore whitespace */ @@ -1056,6 +1059,7 @@ scan_string (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src) scan_putc (scan, src, next); break; } + scan->line_number++; break; case 0xc: break; @@ -1098,6 +1102,7 @@ scan_comment (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src) while ((c = scan_getc (scan, src)) != EOF) { switch (c) { case 0xa: + scan->line_number++; case 0xc: comment_end (scan); return 1; @@ -1119,6 +1124,7 @@ _csi_scan_file (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src) scan_base85, }; + scan->line_number = 0; while (func[scan->state] (ctx, scan, src)) ; |