From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25758 invoked from network); 10 Apr 2000 08:20:49 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 Apr 2000 08:20:49 -0000 Received: (qmail 16219 invoked by alias); 10 Apr 2000 08:20:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10614 Received: (qmail 16189 invoked from network); 10 Apr 2000 08:20:33 -0000 Date: Mon, 10 Apr 2000 10:20:26 +0200 (MET DST) Message-Id: <200004100820.KAA31955@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Sat, 8 Apr 2000 20:55:14 +0000 Subject: Re: PATCH: $history index in prompt_bart_precmd 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