From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: $history index in prompt_bart_precmd
Date: Mon, 10 Apr 2000 10:20:26 +0200 (MET DST) [thread overview]
Message-ID: <200004100820.KAA31955@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Sat, 8 Apr 2000 20:55:14 +0000
Bart Schaefer wrote:
> ...
>
> There is, however, some kind of bug with interpretation of the keys for
> $history, because e.g. $history[3-1] == $history[3]. (It should yield
> the empty string, as there isn't any hash table value for key "3-1".)
It was using atoi(). Yes, since this is supposed to be an assoc, we
should probably be more careful to check the index used.
Bye
Sven
Index: Src/Modules/parameter.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/parameter.c,v
retrieving revision 1.2
diff -u -r1.2 parameter.c
--- Src/Modules/parameter.c 2000/04/01 20:49:48 1.2
+++ Src/Modules/parameter.c 2000/04/10 08:20:17
@@ -1020,6 +1020,8 @@
{
Param pm = NULL;
Histent he;
+ char *p;
+ int ok = 1;
pm = (Param) zhalloc(sizeof(struct param));
pm->nam = dupstring(name);
@@ -1032,7 +1034,17 @@
pm->ename = NULL;
pm->old = NULL;
pm->level = 0;
- if ((he = quietgethist(atoi(name))))
+
+ if (*name != '0' || name[1]) {
+ if (*name == '0')
+ ok = 0;
+ else {
+ for (p = name; *p && idigit(*p); p++);
+ if (*p)
+ ok = 0;
+ }
+ }
+ if (ok && (he = quietgethist(atoi(name))))
pm->u.str = dupstring(he->text);
else {
pm->u.str = dupstring("");
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-04-10 8:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-10 8:20 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-04-08 20:55 Bart Schaefer
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=200004100820.KAA31955@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).