Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Nov 2016 20:38:14 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r309220 - head/usr.bin/indent
Message-ID:  <201611272038.uARKcESW077476@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611272038.uARKcESW077476>