From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: [bug-report] brace_ccl and $'\0' in ranges
Date: Mon, 06 Oct 2003 23:08:23 +0100 [thread overview]
Message-ID: <20031006220824.379BA84E0@pwstephenson.fsnet.co.uk> (raw)
In-Reply-To: "Stephane Chazelas"'s message of "Sat, 04 Oct 2003 15:06:45 +0200." <20031004130645.GB3640@pcchazelas.free.fr>
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 <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk
parent reply other threads:[~2003-10-06 22:07 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20031004130645.GB3640@pcchazelas.free.fr>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031006220824.379BA84E0@pwstephenson.fsnet.co.uk \
--to=pws@pwstephenson.fsnet.co.uk \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).