From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.4/8.7.3) with ESMTP id GAA22069 for ; Thu, 7 Mar 1996 06:55:08 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id OAA08261; Wed, 6 Mar 1996 14:43:09 -0500 (EST) Resent-Date: Wed, 6 Mar 1996 14:43:09 -0500 (EST) From: Zoltan Hidvegi Message-Id: <199603061942.UAA16559@bolyai.cs.elte.hu> Subject: Re: Bug: subscripting error To: schuh@meteo.uni-koeln.de (Markus Schuh) Date: Wed, 6 Mar 1996 20:42:45 +0100 (MET) Cc: zsh-workers@math.gatech.edu In-Reply-To: <199603061337.AA03725@taifun.meteo.Uni-Koeln.DE> from "Markus Schuh" at Mar 6, 96 02:37:17 pm Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4 PL24 PGP3 *ALPHA*] Mime-Version: 1.0 Content-Type: application/pgp Content-Transfer-Encoding: 7bit Resent-Message-ID: <"J0vIQ.0.-02.ChUFn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/800 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- Markus Schuh wrote: > taifun% PATH=/usr/ucb:/usr/bin:/bin > taifun% echo $PATH[1,(ws.:.)-2] > /usr/ucb:/usr/bi > > I would expect the answer > /usr/ucb:/usr/bin The patch below should fix this. It ilustrates how much more complicated can be a buggy code than a working one (hoping that I didn't overlooked it). Zoltan *** Src/params.c 1996/03/05 01:44:31 1.15 --- Src/params.c 1996/03/06 19:31:54 *************** *** 259,265 **** { int num = 1, word = 0, rev = 0, ind = 0, down = 0, exp = 0, l, i; char *s = *str, *sep = NULL, *t, sav, *d, **ta, **p, *tt; ! long r = 0, rr, rrr; Comp c; if (*s == '(' || *s == Inpar) { --- 259,265 ---- { int num = 1, word = 0, rev = 0, ind = 0, down = 0, exp = 0, l, i; char *s = *str, *sep = NULL, *t, sav, *d, **ta, **p, *tt; ! long r = 0; Comp c; if (*s == '(' || *s == Inpar) { *************** *** 365,389 **** r = i; if (!s || !*s) return 0; - rrr = r; while ((d = findword(&s, sep)) && --r); if (!d) return 0; - if (a2) { - if ((d = findword(&s, sep))) { - r = (long)(d - t) - (sep ? strlen(sep) + (rrr == i ? 0 : 1) : 1); - } else - r = -1; - } else { - rr = (long)(d - t); - if (rrr > 1) - rr++; - r = rr; - } - if (!a2 && *tt != ',') *w = (long)(s - t) - 1; } else if (!v->isarr && !word) { s = getstrvalue(v); if (r > 0) { --- 365,378 ---- r = i; if (!s || !*s) return 0; while ((d = findword(&s, sep)) && --r); if (!d) return 0; if (!a2 && *tt != ',') *w = (long)(s - t) - 1; + + return (a2 ? s : d + 1) - t; } else if (!v->isarr && !word) { s = getstrvalue(v); if (r > 0) { -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv iQCVAwUBMT3qpwupSCiLN749AQEFEQP5Ad4/WILoOFjc6V2up8f0PGJt7FuPQOdd LC8+2HPx9TOqxt3LvcXz8Z46r6Qg7Ogcf6KmS69b5Lp1cjW1QxytSJ7s3Mqq6nBk WWjxCyG5Q/4EMp2o7vX2j2RAgJCZEl5PaDNPue7d7K22ABU0UrFnOf0wOkWt03L4 XRmyLs4MoxQ= =UNf2 -----END PGP SIGNATURE-----