diff options
author | eadler <eadler@FreeBSD.org> | 2018-03-08 06:54:33 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2018-03-08 06:54:33 +0000 |
commit | 126864de7120b99391210ae581dc5e61ee5dd88c (patch) | |
tree | c6fda35af445ef5f00b54f590b6f967bf8646415 /usr.bin | |
parent | dff9ee209bf42c314bc2e3d8238715b24f962fb4 (diff) | |
download | FreeBSD-src-126864de7120b99391210ae581dc5e61ee5dd88c.zip FreeBSD-src-126864de7120b99391210ae581dc5e61ee5dd88c.tar.gz |
MFC r309220:
indent(1): Properly handle the wide string literal and wide char constant L.
indent(1) treated the "L" in "L'a'" as if it were an identifier and forced
a space character after it, breaking valid code.
PR: 143090
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/indent/indent.c | 10 | ||||
-rw-r--r-- | usr.bin/indent/indent_codes.h | 1 | ||||
-rw-r--r-- | usr.bin/indent/lexi.c | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index bc28079..b463579 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -1017,6 +1017,16 @@ check_type: ps.want_blank = true; break; + case strpfx: + if (ps.want_blank) + *e_code++ = ' '; + for (t_ptr = token; *t_ptr; ++t_ptr) { + CHECK_SIZE_CODE; + *e_code++ = *t_ptr; + } + ps.want_blank = false; + break; + case period: /* treat a period kind of like a binary * operation */ *e_code++ = '.'; /* move the period into line */ diff --git a/usr.bin/indent/indent_codes.h b/usr.bin/indent/indent_codes.h index e1ff294..a58b90a 100644 --- a/usr.bin/indent/indent_codes.h +++ b/usr.bin/indent/indent_codes.h @@ -68,3 +68,4 @@ #define ifhead 30 #define elsehead 31 #define period 32 +#define strpfx 33 diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index 1200a39..3425f9a 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -228,6 +228,11 @@ lexi(void) fill_buffer(); } *e_token++ = '\0'; + + if (s_token[0] == 'L' && s_token[1] == '\0' && + (*buf_ptr == '"' || *buf_ptr == '\'')) + return (strpfx); + while (*buf_ptr == ' ' || *buf_ptr == '\t') { /* get rid of blanks */ if (++buf_ptr >= buf_end) fill_buffer(); |