From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh workers mailing list <zsh-workers@sunsite.auc.dk>
Subject: Re: core dumps with (( #\... ))
Date: Thu, 23 Sep 1999 14:10:43 +0200 [thread overview]
Message-ID: <9909231210.AA30983@ibmth.df.unipi.it> (raw)
In-Reply-To: "Adam Spiers"'s message of "Thu, 23 Sep 1999 12:18:27 DFT." <19990923121827.A3826@thelonious.new.ox.ac.uk>
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@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
next prev parent reply other threads:[~1999-09-23 12:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-23 11:18 Adam Spiers
1999-09-23 12:10 ` Peter Stephenson [this message]
1999-09-23 13:04 Sven Wischnowsky
1999-09-23 13:48 ` Peter Stephenson
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=9909231210.AA30983@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@sunsite.auc.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).