Author: pfg
Date: Sun Nov 27 20:38:14 2016
New Revision: 309220
URL: https://svnweb.freebsd.org/changeset/base/309220

Log:
  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

Modified:
  head/usr.bin/indent/indent.c
  head/usr.bin/indent/indent_codes.h
  head/usr.bin/indent/lexi.c

Modified: head/usr.bin/indent/indent.c
==============================================================================
--- head/usr.bin/indent/indent.c        Sun Nov 27 20:30:09 2016        
(r309219)
+++ head/usr.bin/indent/indent.c        Sun Nov 27 20:38:14 2016        
(r309220)
@@ -1004,6 +1004,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 */

Modified: head/usr.bin/indent/indent_codes.h
==============================================================================
--- head/usr.bin/indent/indent_codes.h  Sun Nov 27 20:30:09 2016        
(r309219)
+++ head/usr.bin/indent/indent_codes.h  Sun Nov 27 20:38:14 2016        
(r309220)
@@ -68,3 +68,4 @@
 #define ifhead         30
 #define elsehead       31
 #define period         32
+#define strpfx         33

Modified: head/usr.bin/indent/lexi.c
==============================================================================
--- head/usr.bin/indent/lexi.c  Sun Nov 27 20:30:09 2016        (r309219)
+++ head/usr.bin/indent/lexi.c  Sun Nov 27 20:38:14 2016        (r309220)
@@ -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();
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to