diff options
author | Demi Obenour <demiobenour@gmail.com> | 2016-09-27 10:54:16 -0400 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2016-10-05 19:25:56 -0400 |
commit | 9d3ddf572e3744e4cf5e9788b676f423fe69aee8 (patch) | |
tree | 1a9ae51e2be904714c0afdae5dbad00c81ccf300 /src/misc.c | |
parent | 735ffb6a653552831321acaa0e7d0a834a210a84 (diff) |
Fix M4 quoting of section 3.
This fixes M4 quoting of section 3 of the input file, including escape
sequences and character constants.
Tests were added to verify the behavior in section 3 with respect to
quoting. Both escaping of quotes and quoting of potential macro-start
characters are tested. Existing tests were also fixed to account for the new -- and now correct -- behavior. Many tests relied on the old behavior of expanding M4 macros
in section 3. They needed to be updated for the new behavior.
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -362,8 +362,8 @@ void line_directive_out (FILE *output_file, int do_infile) s3 = &filename[sizeof (filename) - 2]; while (s2 < s3 && *s1) { - if (*s1 == '\\') - /* Escape the '\' */ + if (*s1 == '\\' || *s1 == '"') + /* Escape the '\' or '"' */ *s2++ = '\\'; *s2++ = *s1++; @@ -512,7 +512,8 @@ unsigned char myesc (unsigned char array[]) { /* \<octal> */ int sptr = 1; - while (isascii (array[sptr]) && + while (sptr <= 3 && + isascii (array[sptr]) && isdigit (array[sptr])) /* Don't increment inside loop control * because if isdigit() is a macro it might |