diff options
author | Manoj Srivastava <srivasta@debian.org> | 2016-02-24 14:54:26 -0800 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2016-02-24 14:54:26 -0800 |
commit | 7b308a5f1652444a812ba39bce631cd895449c3a (patch) | |
tree | 33453eb329336bb57d0f826a0267874f3fc680f4 /src | |
parent | 36e2e59881e6c5ac981242d2e28ee5ad43600a6a (diff) | |
parent | 58213fd78e208381815502c0574d8d0c1c467f85 (diff) |
Merge branch 'fix-line-directives'
Diffstat (limited to 'src')
-rw-r--r-- | src/buf.c | 16 | ||||
-rw-r--r-- | src/main.c | 3 |
2 files changed, 12 insertions, 7 deletions
@@ -36,13 +36,13 @@ /* Take note: The buffer object is sometimes used as a String buffer (one * continuous string), and sometimes used as a list of strings, usually line by * line. - * + * * The type is specified in buf_init by the elt_size. If the elt_size is * sizeof(char), then the buffer should be treated as string buffer. If the * elt_size is sizeof(char*), then the buffer should be treated as a list of * strings. * - * Certain functions are only appropriate for one type or the other. + * Certain functions are only appropriate for one type or the other. */ /* global buffers. */ @@ -93,10 +93,14 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno) char *dst, *t; const char *src; - t = flex_alloc (strlen ("#line \"\"\n") + /* constant parts */ - 2 * strlen (filename) + /* filename with possibly all backslashes escaped */ - (int) (1 + log10 (abs (lineno))) + /* line number */ - 1); /* NUL */ + 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 */ + 1; /* NUL */ + t = malloc(tsz); if (!t) flexfatal (_("Allocation of buffer for line directive failed")); for (dst = t + sprintf (t, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++) @@ -474,7 +474,8 @@ void check_options () 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) |