bin/143090: [PATCH] Let indent(1) handle widecharacter literals correctly

Tobias Rehbein tobias.rehbein at web.de
Fri Jan 22 18:40:03 UTC 2010


>Number:         143090
>Category:       bin
>Synopsis:       [PATCH] Let indent(1) handle widecharacter literals correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 22 18:40:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Tobias Rehbein
>Release:        FreeBSD 8.0-RELEASE-p2 i386
>Organization:
>Environment:
System: FreeBSD sushi.pseudo.local 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #5: Fri Jan 15 19:16:49 CET 2010 tobi at sushi.pseudo.local:/usr/obj/usr/src/sys/SUSHI i386


	
>Description:
        I noticed that indent(1) handles widecharacter literals (e.g. L'c' or
        L"string") incorrectly. indent(1)s parser treats the L-prefix and the
        quoted part as seperate tokens. The result is:

                L'c'            ->      L 'c'
                L"string"       ->      L "string"

        Of course this breaks any code using widecharacters. As I use indent(1)
        quite extensively I decided to fix this issue. 
        
        As this is my first patch against the FreeBSD user land feel free to
        comment!

        The first version of this patch including examples was posted to
        freebsd-current at freebsd.org:

        http://archive.netbsd.se/?ml=freebsd-current&a=2010-01&m=12274166
>How-To-Repeat:
        indent /usr/src/lib/libc/string/wcsxfrm.c
>Fix:

	

--- indent.diff begins here ---
diff -u /usr/src/usr.bin/indent/Makefile usr.bin/indent/Makefile
--- /usr/src/usr.bin/indent/Makefile	2010-01-22 19:18:41.000000000 +0100
+++ usr.bin/indent/Makefile	2010-01-21 19:01:13.000000000 +0100
@@ -3,4 +3,6 @@
 PROG=	indent
 SRCS=	indent.c io.c lexi.c parse.c pr_comment.c args.c
 
+WARNS?=		6
+
 .include <bsd.prog.mk>
diff -u /usr/src/usr.bin/indent/lexi.c usr.bin/indent/lexi.c
--- /usr/src/usr.bin/indent/lexi.c	2010-01-22 19:18:41.000000000 +0100
+++ usr.bin/indent/lexi.c	2010-01-22 19:14:00.000000000 +0100
@@ -222,6 +222,14 @@
 			    break;
 		}
 		CHECK_SIZE_TOKEN;
+		if ((s_token == e_token) && *buf_ptr == 'L' &&
+			(*(buf_ptr + 1) == '\'' || *(buf_ptr + 1) == '"' )) {
+		    /* widecharacter literal */
+		    *e_token++ = *buf_ptr++;        /* copy L */
+		    *e_token++ = *buf_ptr;          /* copy ' or " */
+		    qchar = *buf_ptr++;             /* set string delimeter */
+		    goto found_string;
+		}
 		/* copy it over */
 		*e_token++ = *buf_ptr++;
 		if (buf_ptr >= buf_end)
@@ -361,6 +369,7 @@
     case '\'':			/* start of quoted character */
     case '"':			/* start of string */
 	qchar = *token;
+found_string:
 	if (troff) {
 	    e_token[-1] = '`';
 	    if (qchar == '"')
--- indent.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list