From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14090 invoked from network); 6 Oct 2003 22:07:07 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 6 Oct 2003 22:07:07 -0000 Received: (qmail 5507 invoked by alias); 6 Oct 2003 22:06:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19167 Received: (qmail 5494 invoked from network); 6 Oct 2003 22:06:58 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 6 Oct 2003 22:06:58 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [195.92.193.19] by sunsite.dk (MessageWall 1.0.8) with SMTP; 6 Oct 2003 22:6:56 -0000 Received: from modem-245.dusty-damsel.dialup.pol.co.uk ([62.137.3.245] helo=pwstephenson.fsnet.co.uk) by cmailm3.svr.pol.co.uk with esmtp (Exim 4.14) id 1A6dVG-0005w8-EH for zsh-workers@sunsite.dk; Mon, 06 Oct 2003 23:06:54 +0100 Received: by pwstephenson.fsnet.co.uk (Postfix, from userid 501) id 379BA84E0; Mon, 6 Oct 2003 18:08:24 -0400 (EDT) Received: from pwstephenson.fsnet.co.uk (localhost [127.0.0.1]) by pwstephenson.fsnet.co.uk (Postfix) with ESMTP id C4DDB84C7 for ; Mon, 6 Oct 2003 23:08:24 +0100 (BST) To: Zsh hackers list Subject: Re: [bug-report] brace_ccl and $'\0' in ranges In-reply-to: "Stephane Chazelas"'s message of "Sat, 04 Oct 2003 15:06:45 +0200." <20031004130645.GB3640@pcchazelas.free.fr> Date: Mon, 06 Oct 2003 23:08:23 +0100 From: Peter Stephenson Message-Id: <20031006220824.379BA84E0@pwstephenson.fsnet.co.uk> Stephane Chazelas wrote: > [message sent to Peter Stephenson and zsh-workers ML, even if > it will probably never show up on the ML for a reason I don't > know of] Possibly @free.fr is not a very felicitous domain from the point of view of the spam checker at Sunsite. (I'm assuming you're reading the list so haven't copied it.) > ~$ setopt brace_ccl > ~$ print -rn {$'\1'-$'\37'} | od -c # works OK > 0000000 001 002 003 004 005 006 \a \b > 0000020 \t \n \v \f \r 016 017 020 > 0000040 021 022 023 024 025 026 027 030 > 0000060 031 032 033 034 035 036 037 > 0000075 > ~$ print -rn {$'\0'-$'\37'} | od -c > 0000000 \0 037 - > 0000005 > > tested with 4.1.1-dev-1, CVS tree from 2003/09/22. Yes, the test for termination is pre-eight-bit and uses zero as the termination condition instead of a number out of the range of an unsigned char. Hope I've got the signed/unsigned stuff right; gcc isn't complaining, anyway. There's a new test for this. I got a bit worried there was somewhere that a $'\000' assigned to a scalar parameter wasn't being expaned properly, but maybe I got confused. Index: Src/glob.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/glob.c,v retrieving revision 1.30 diff -u -r1.30 glob.c --- Src/glob.c 1 Aug 2003 14:14:20 -0000 1.30 +++ Src/glob.c 6 Oct 2003 22:02:49 -0000 @@ -1867,12 +1867,13 @@ * set of flags saying whether each character is present; * * the final list is in lexical order. */ char ccl[256], *p; - unsigned char c1, c2, lastch; + unsigned char c1, c2; unsigned int len, pl; + int lastch = -1; uremnode(list, node); memset(ccl, 0, sizeof(ccl) / sizeof(ccl[0])); - for (p = str + 1, lastch = 0; p < str2;) { + for (p = str + 1; p < str2;) { if (itok(c1 = *p++)) c1 = ztokens[c1 - STOUC(Pound)]; if ((char) c1 == Meta) @@ -1881,22 +1882,21 @@ c2 = ztokens[c2 - STOUC(Pound)]; if ((char) c2 == Meta) c2 = 32 ^ p[1]; - if (c1 == '-' && lastch && p < str2 && (int)lastch <= (int)c2) { - while ((int)lastch < (int)c2) + if (c1 == '-' && lastch >= 0 && p < str2 && lastch <= (int)c2) { + while (lastch < (int)c2) ccl[lastch++] = 1; - lastch = 0; + lastch = -1; } else ccl[lastch = c1] = 1; } Index: Test/E01options.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/E01options.ztst,v retrieving revision 1.11 diff -u -r1.11 E01options.ztst --- Test/E01options.ztst 16 Mar 2002 19:43:36 -0000 1.11 +++ Test/E01options.ztst 6 Oct 2003 22:03:15 -0000 @@ -154,6 +154,19 @@ >a b c d >{abcd} +# Don't use NUL as a field separator in the following. + setopt braceccl + print {$'\0'-$'\5'} | IFS=' ' read -A chars + for c in $chars; do print $(( #c )); done + unsetopt braceccl +0:BRACE_CCL option starting from NUL +>0 +>1 +>2 +>3 +>4 +>5 + setopt bsdecho echo "histon\nimpington" echo -e "girton\ncottenham" -- Peter Stephenson Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk