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
MFC after:	2 weeks
This commit is contained in:
Pedro F. Giffuni 2016-11-27 20:38:14 +00:00
parent 6daffe6ebf
commit 350fcdd5df
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=309220
3 changed files with 16 additions and 0 deletions

View File

@ -1004,6 +1004,16 @@ main(int argc, char **argv)
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 */

View File

@ -68,3 +68,4 @@
#define ifhead 30
#define elsehead 31
#define period 32
#define strpfx 33

View File

@ -237,6 +237,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();