From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 22 18:40:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9BBA106566C for ; Fri, 22 Jan 2010 18:40:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A42288FC18 for ; Fri, 22 Jan 2010 18:40:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o0MIe22A049682 for ; Fri, 22 Jan 2010 18:40:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o0MIe2si049681; Fri, 22 Jan 2010 18:40:02 GMT (envelope-from gnats) Resent-Date: Fri, 22 Jan 2010 18:40:02 GMT Resent-Message-Id: <201001221840.o0MIe2si049681@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Tobias Rehbein Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D628610656A4 for ; Fri, 22 Jan 2010 18:35:40 +0000 (UTC) (envelope-from tobias.rehbein@web.de) Received: from fmmailgate02.web.de (fmmailgate02.web.de [217.72.192.227]) by mx1.freebsd.org (Postfix) with ESMTP id 638298FC2F for ; Fri, 22 Jan 2010 18:35:40 +0000 (UTC) Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate02.web.de (Postfix) with ESMTP id D050314C5AC86 for ; Fri, 22 Jan 2010 19:35:38 +0100 (CET) Received: from [95.88.224.31] (helo=sushi.pseudo.local) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NYOM6-0004jP-00 for FreeBSD-gnats-submit@freebsd.org; Fri, 22 Jan 2010 19:35:38 +0100 Received: from sushi.pseudo.local (localhost [127.0.0.1]) by sushi.pseudo.local (8.14.3/8.14.3) with ESMTP id o0MIZbVP011433 for ; Fri, 22 Jan 2010 19:35:37 +0100 (CET) (envelope-from tobi@sushi.pseudo.local) Received: (from tobi@localhost) by sushi.pseudo.local (8.14.3/8.14.3/Submit) id o0MIZbLZ011432; Fri, 22 Jan 2010 19:35:37 +0100 (CET) (envelope-from tobi) Message-Id: <201001221835.o0MIZbLZ011432@sushi.pseudo.local> Date: Fri, 22 Jan 2010 19:35:37 +0100 (CET) From: Tobias Rehbein Sender: tobias.rehbein@web.de To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/143090: [PATCH] Let indent(1) handle widecharacter literals correctly X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Tobias Rehbein List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2010 18:40:03 -0000 >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@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@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 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: