From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 839 invoked from network); 10 Feb 2007 22:09:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Feb 2007 22:09:24 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 31957 invoked from network); 10 Feb 2007 22:09:18 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Feb 2007 22:09:18 -0000 Received: (qmail 26518 invoked by alias); 10 Feb 2007 22:09:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23162 Received: (qmail 26508 invoked from network); 10 Feb 2007 22:09:15 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Feb 2007 22:09:15 -0000 Received: (qmail 31658 invoked from network); 10 Feb 2007 22:09:15 -0000 Received: from mtaout03-winn.ispmail.ntl.com (81.103.221.49) by a.mx.sunsite.dk with SMTP; 10 Feb 2007 22:09:08 -0000 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com with ESMTP id <20070210220907.KUNW1468.mtaout03-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Sat, 10 Feb 2007 22:09:07 +0000 Received: from pwslaptop.csr.com ([81.107.44.96]) by aamtaout01-winn.ispmail.ntl.com with ESMTP id <20070210220907.ZOQT219.aamtaout01-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Sat, 10 Feb 2007 22:09:07 +0000 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.8/8.13.7) with ESMTP id l1AM8ner009906; Sat, 10 Feb 2007 22:08:49 GMT Message-Id: <200702102208.l1AM8ner009906@pwslaptop.csr.com> From: Peter Stephenson To: zsh-workers@sunsite.dk, pws@pwslaptop.csr.com Subject: Re: Quoting problem and crashes with ${(#)var} In-Reply-To: Message from Bart Schaefer of "Sat, 10 Feb 2007 11:07:05 PST." <070210110706.ZM6627@torch.brasslantern.com> Date: Sat, 10 Feb 2007 22:08:49 +0000 Bart Schaefer wrote: > With zsh -f from the latest CVS as of 2007-02-10 10:28 AM PST: > > torch% for x in {1..255}; echo -n ${(#)x}; echo '' I think this is it, but shout if you can see any problems left... This was always a bit broken, since the character was never metafied properly, but UTF-8 gave exciting new was for bogus tokens to get into the input. I also forgot the MULTIBYTE_SUPPORT test. Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.74 diff -u -r1.74 subst.c --- Src/subst.c 2 Feb 2007 21:42:15 -0000 1.74 +++ Src/subst.c 10 Feb 2007 22:07:29 -0000 @@ -1193,21 +1193,25 @@ substevalchar(char *ptr) { zlong ires = mathevali(ptr); + int len; if (errflag) return NULL; +#ifdef MULTIBYTE_SUPPORT if (isset(MULTIBYTE) && ires > 127) { char buf[10]; - int dummy; /* inefficient: should separate out \U handling from getkeystring */ sprintf(buf, "\\U%.8x", (unsigned int)ires); - return getkeystring(buf, &dummy, GETKEYS_BINDKEY, NULL); - } else { + ptr = getkeystring(buf, &len, GETKEYS_BINDKEY, NULL); + } else +#endif + { ptr = zhalloc(2); + len = 1; sprintf(ptr, "%c", (int)ires); - return ptr; } + return metafy(ptr, len, META_USEHEAP); } /* parameter substitution */ Index: Test/D07multibyte.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D07multibyte.ztst,v retrieving revision 1.14 diff -u -r1.14 D07multibyte.ztst --- Test/D07multibyte.ztst 22 Jan 2007 14:35:14 -0000 1.14 +++ Test/D07multibyte.ztst 10 Feb 2007 22:07:29 -0000 @@ -326,3 +326,35 @@ 0:Multibyte characters in print sorting >HAH HEH HÉH HÈH HUH >HAH HEH HUH HÈH HÉH + +# These are control characters in Unicode, so don't show up. +# We just want to check they're not being treated as tokens. + for x in {128..150}; do + print ${(#)x} + done | while read line; do + print ${#line} $(( #line )) + done +0:evaluated character number with multibyte characters +>1 128 +>1 129 +>1 130 +>1 131 +>1 132 +>1 133 +>1 134 +>1 135 +>1 136 +>1 137 +>1 138 +>1 139 +>1 140 +>1 141 +>1 142 +>1 143 +>1 144 +>1 145 +>1 146 +>1 147 +>1 148 +>1 149 +>1 150 -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/