Skip to content

Commit

Permalink
Emit no #line directives if gen_line_dirs is false, resolves igh#55.
Browse files Browse the repository at this point in the history
There are two instances in the code which will print a #line directive
to the resulting lexer, regardless of the value of gen_line_dirs. Fix
them, so they also respect gen_line_dirs.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser authored and westes committed Feb 24, 2016
1 parent 64f2774 commit 647a92b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
const char *src;
size_t tsz;

if (gen_line_dirs)
return buf;

tsz = strlen("#line \"\"\n") + /* constant parts */
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
(int) (1 + log10 (abs (lineno))) + /* line number */
Expand Down
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ void check_options (void)
m4defs_buf.nelts = 0; /* memory leak here. */

/* Place a bogus line directive, it will be fixed in the filter. */
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
if (gen_line_dirs)
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");

/* Dump the user defined preproc directives. */
if (userdef_buf.elts)
Expand Down

0 comments on commit 647a92b

Please sign in to comment.