From owner-freebsd-current@FreeBSD.ORG Thu Jan 21 21:23:51 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 001F41065672 for ; Thu, 21 Jan 2010 21:23:50 +0000 (UTC) (envelope-from tobias.rehbein@web.de) Received: from fmmailgate03.web.de (fmmailgate03.web.de [217.72.192.234]) by mx1.freebsd.org (Postfix) with ESMTP id 492F68FC1B for ; Thu, 21 Jan 2010 21:23:50 +0000 (UTC) Received: from smtp08.web.de (fmsmtp08.dlan.cinetic.de [172.20.5.216]) by fmmailgate03.web.de (Postfix) with ESMTP id 7C1BB13C6BB2B for ; Thu, 21 Jan 2010 22:05:27 +0100 (CET) Received: from [95.88.224.31] (helo=sushi.pseudo.local) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NY4DW-0007zs-00 for freebsd-current@freebsd.org; Thu, 21 Jan 2010 22:05:27 +0100 Received: from sushi.pseudo.local (localhost [127.0.0.1]) by sushi.pseudo.local (8.14.3/8.14.3) with ESMTP id o0LL5O0e002035; Thu, 21 Jan 2010 22:05:24 +0100 (CET) (envelope-from tobi@sushi.pseudo.local) Received: (from tobi@localhost) by sushi.pseudo.local (8.14.3/8.14.3/Submit) id o0LL5NAs002034; Thu, 21 Jan 2010 22:05:24 +0100 (CET) (envelope-from tobi) Date: Thu, 21 Jan 2010 22:05:23 +0100 From: Tobias Rehbein To: freebsd-current@freebsd.org Message-ID: <20100121210523.GA1442@sushi.pseudo.local> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="nmemrqcdn5VTmUEE" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Sender: tobias.rehbein@web.de X-Sender: tobias.rehbein@web.de X-Provags-ID: V01U2FsdGVkX19WWoAmnsiKvD6MDji3iKT6JA2pn8jrFiMuT5Zv L4osc6oxAU4Y/D7hNj8TkInXvxVC3RxTL/vkV2mecdObAYUVml kkoesnQ5VDzwnDgqHUGw== X-Mailman-Approved-At: Thu, 21 Jan 2010 22:18:54 +0000 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: [patch] Let indent(1) handle widecharacter literals correctly X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jan 2010 21:23:51 -0000 --nmemrqcdn5VTmUEE Content-Type: multipart/mixed; boundary="PmA2V3Z32TCmWXqI" Content-Disposition: inline --PmA2V3Z32TCmWXqI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi. I am not subscribed to this list, so please answer me off-list or cc me. I noticed that indent(1) handles widecharacter literals (e.g. L'c' or L"str= ing") 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) qui= te extensively I decided to fix this issue. As this is my first patch against = the FreeBSD user land feel free to comment! Find attached: indent.diff: the patch wcsxfrm.old.c: the result of `indent wcsxfrm.c`; using the indent(1) version from the base system =20 wcsxfrm.new.c: the result of `indent wcsxfrm.c`; using the patched indent(1) Please note the diff between wcsxfrm.old.c and wcsxfrm.new.c: =20 =3D=3D=3D=3D=3D=3D=3D=3D diff -u wcsxfrm.old.c wcsxfrm.new.c =3D=3D=3D=3D= =3D=3D=3D=3D --- wcsxfrm.old.c 2010-01-21 18:49:04.000000000 +0100 +++ wcsxfrm.new.c 2010-01-21 18:49:48.000000000 +0100 @@ -49,9 +49,9 @@ size_t slen; char *mbsrc, *s, *ss; =20 - if (*src =3D=3D L '\0') { + if (*src =3D=3D L'\0') { if (len !=3D 0) - *dest =3D L '\0'; + *dest =3D L'\0'; return (0); } if (__collate_load_error || MB_CUR_MAX > 1) { @@ -61,7 +61,7 @@ wcscpy(dest, src); else { wcsncpy(dest, src, len - 1); - dest[len - 1] =3D L '\0'; + dest[len - 1] =3D L'\0'; } } return (slen); @@ -87,7 +87,7 @@ free(ss); free(mbsrc); if (len !=3D 0) - *dest =3D L '\0'; + *dest =3D L'\0'; =20 return (slen); } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D Regards --=20 Tobias Rehbein PGP key: 4F2AE314 server: keys.gnupg.net fingerprint: ECDA F300 1B6E 9B87 8524 8663 E8B6 3138 4F2A E314 --PmA2V3Z32TCmWXqI Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="indent.diff" Content-Transfer-Encoding: quoted-printable diff -u /usr/src/usr.bin/indent/Makefile usr.bin/indent/Makefile --- /usr/src/usr.bin/indent/Makefile 2010-01-20 23:59:33.000000000 +0100 +++ usr.bin/indent/Makefile 2010-01-21 19:01:13.000000000 +0100 @@ -3,4 +3,6 @@ PROG=3D indent SRCS=3D indent.c io.c lexi.c parse.c pr_comment.c args.c =20 +WARNS?=3D 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-20 23:59:33.000000000 +0100 +++ usr.bin/indent/lexi.c 2010-01-21 18:52:49.000000000 +0100 @@ -221,6 +221,13 @@ } else break; } + if (*buf_ptr =3D=3D 'L' && (*(buf_ptr + 1) =3D=3D '\'' || = *(buf_ptr + 1) =3D=3D '"' ) && (s_token =3D=3D e_token)) { + /* widecharacter literal */ + *e_token++ =3D *buf_ptr++; /* copy L */ + *e_token++ =3D *buf_ptr; /* copy ' or " */ + qchar =3D *buf_ptr++; /* set string de= limeter */ + goto found_string; + } CHECK_SIZE_TOKEN; /* copy it over */ *e_token++ =3D *buf_ptr++; @@ -361,6 +368,7 @@ case '\'': /* start of quoted character */ case '"': /* start of string */ qchar =3D *token; +found_string: if (troff) { e_token[-1] =3D '`'; if (qchar =3D=3D '"') --PmA2V3Z32TCmWXqI-- --nmemrqcdn5VTmUEE Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAktYwZEACgkQ6LYxOE8q4xSYWgCeJKty9Ypk6BCr1V+54q+R0xo8 jNgAoIcvAger3Oc9rsna5A0RXdnKeFrc =0vBN -----END PGP SIGNATURE----- --nmemrqcdn5VTmUEE--