diff options
Diffstat (limited to 'src/preproc.c')
-rw-r--r-- | src/preproc.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/preproc.c b/src/preproc.c index 1eeddd0..a5dda52 100644 --- a/src/preproc.c +++ b/src/preproc.c @@ -52,12 +52,13 @@ extern int grecs_grecs__flex_debug; static struct buffer_ctx *context_stack; static char *linebufbase = NULL; static size_t linebufsize = 0; #define INFILE context_stack->infile #define LOCUS context_stack->locus +#define POINT context_stack->locus.beg static char *linebuf; static size_t bufsize; static char *putback_buffer; static size_t putback_size; static size_t putback_max; @@ -120,14 +121,14 @@ pp_line_stmt() { size_t ls_size; size_t pb_size; if (grecs_asprintf(&linebufbase, &linebufsize, "#line %lu \"%s\" %lu\n", - (unsigned long) LOCUS.line, - LOCUS.file, (unsigned long) context_stack->xlines)) + (unsigned long) POINT.line, + POINT.file, (unsigned long) context_stack->xlines)) grecs_alloc_die(); ls_size = strlen(linebufbase); pb_size = putback_size + ls_size + 1; if (pb_size > putback_max) { @@ -208,13 +209,13 @@ grecs_preproc_fill_buffer(char *buf, size_t size) if (size == 0) { putback(linebuf + len); break; } if (!is_line && len > 0 && linebuf[len - 1] == '\n') - LOCUS.line++; + POINT.line++; } return bufsize - size; } #define STAT_ID_EQ(st,id) ((id).i_node == (st).st_ino \ && (id).device == (st).st_dev) @@ -394,13 +395,13 @@ push_source(const char *name, int once) if (rc) { grecs_error(&LOCUS, errno, _("Cannot stat `%s'"), name); return 1; } - if (LOCUS.file && STAT_ID_EQ(st, context_stack->id)) { + if (POINT.file && STAT_ID_EQ(st, context_stack->id)) { grecs_error(&LOCUS, 0, _("Recursive inclusion")); return 1; } if ((ctx = ctx_lookup(&st))) { grecs_error(&LOCUS, 0, _("Recursive inclusion")); @@ -428,16 +429,19 @@ push_source(const char *name, int once) _("Cannot open `%s'"), name); return 1; } /* Push current context */ ctx = grecs_malloc(sizeof(*ctx)); - ctx->locus.file = grecs_install_text(name); - ctx->locus.line = 1; + ctx->locus.beg.file = grecs_install_text(name); + ctx->locus.beg.line = 1; + ctx->locus.beg.col = 0; + ctx->locus.end.file = NULL; + ctx->locus.end.line = ctx->locus.end.col = 0; ctx->xlines = 0; - ctx->namelen = strlen(ctx->locus.file); + ctx->namelen = strlen(ctx->locus.beg.file); ctx->id.i_node = st.st_ino; ctx->id.device = st.st_dev; ctx->infile = fp; ctx->prev = context_stack; context_stack = ctx; @@ -467,17 +471,17 @@ pop_source() if (!context_stack) { if (grecs_grecs__flex_debug) fprintf(stderr, "End of input\n"); return 1; } - LOCUS.line++; + POINT.line++; if (grecs_grecs__flex_debug) fprintf(stderr, "Resuming file `%s' at line %lu\n", - LOCUS.file, (unsigned long) LOCUS.line); + POINT.file, (unsigned long) POINT.line); pp_line_stmt(); return 0; } |