From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7513 invoked from network); 23 Sep 1999 12:46:22 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 23 Sep 1999 12:46:22 -0000 Received: (qmail 28700 invoked by alias); 23 Sep 1999 12:46:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8026 Received: (qmail 28691 invoked from network); 23 Sep 1999 12:46:12 -0000 Message-Id: <9909231210.AA30983@ibmth.df.unipi.it> To: zsh workers mailing list Subject: Re: core dumps with (( #\... )) In-Reply-To: "Adam Spiers"'s message of "Thu, 23 Sep 1999 12:18:27 DFT." <19990923121827.A3826@thelonious.new.ox.ac.uk> Date: Thu, 23 Sep 1999 14:10:43 +0200 From: Peter Stephenson Adam Spiers wrote: > Found this through mistyping #\a syntax :-) > > % print $(( \#a )) > zsh: bad math expression: operand expected at `\#a ' > zsh: 16508 segmentation fault (core dumped) /bin/zsh This time, it was simple innumeracy. I fixed some irrelevant details while I was looking at it (ptr hid a file static, and the error code wants the unmetafied length of the string to be shown). > Here's another, maybe the same bug? > > % (( 1 == #\M-/ )) && print yep > zsh: bad math expression: operand expected at `/ ' > zsh: 17042 segmentation fault (core dumped) /bin/zsh Yes, except that the supposed syntax, which is #\ followed by some key string such as \M-/, doesn't work because the \\ is turned into a single \ by double quoting rules, so actually you need #\\\M-/, which is rather unfortunate. Maybe the syntax should have been ## for a key string, then both the errors which led to uncovering the bug would be less likely. Should I change it but keep \ for backward compatibility? --- Src/math.c.agen Thu Sep 23 09:55:50 1999 +++ Src/math.c Thu Sep 23 13:56:53 1999 @@ -947,7 +947,7 @@ /**/ static void -checkunary(int mtokc, char *ptr) +checkunary(int mtokc, char *mptr) { int errmsg = 0; int tp = type[mtokc]; @@ -959,11 +959,11 @@ errmsg = 2; } if (errmsg) { - char errbuf[40]; + char errbuf[80]; int len, over = 0; - while (inblank(*ptr)) - ptr++; - len = strlen(ptr); + while (inblank(*mptr)) + mptr++; + len = ztrlen(mptr); if (len > 10) { len = 10; over = 1; @@ -971,7 +971,7 @@ sprintf(errbuf, "bad math expression: %s expected at `%%l%s'", errmsg == 2 ? "operator" : "operand", over ? "..." : ""); - zerr(errbuf, ptr, len); + zerr(errbuf, mptr, len); } unary = !(tp & OP_OPF); } -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy