Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: core dumps with (( #\... ))
- X-seq: zsh-workers 8026
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh workers mailing list <zsh-workers@xxxxxxxxxxxxxx>
- Subject: Re: core dumps with (( #\... ))
- Date: Thu, 23 Sep 1999 14:10:43 +0200
- In-reply-to: "Adam Spiers"'s message of "Thu, 23 Sep 1999 12:18:27 DFT." <19990923121827.A3826@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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 <pws@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author