From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11783 invoked from network); 1 Jun 2000 20:51:33 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 1 Jun 2000 20:51:33 -0000 Received: (qmail 27826 invoked by alias); 1 Jun 2000 20:51:21 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11716 Received: (qmail 27817 invoked from network); 1 Jun 2000 20:51:20 -0000 Date: Thu, 1 Jun 2000 13:51:16 -0700 (PDT) From: Wayne Davison X-Sender: wayne@phong.blorf.net To: Zsh Workers Subject: Re: Array slices (PWS's unposted Etc/NEWS change) In-Reply-To: <1000601155002.ZM3182@candle.brasslantern.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 1 Jun 2000, Bart Schaefer wrote: > Unfortunately (?) that means $array[0,0] != $array[0]. This is quite easy to fix, so I think it should be. I've appended a patch (which I will check into cvs momentarily). > That patch has also caused the failure in the last example here: > --------------------------- > zagzig% foo=(a b c d e f g) > zagzig% echo $foo[-4,1] > d e f g > --------------------------- > > Yowtch. Ick. Negative start values combined with positive end values are currently broken. This makes me think that I should have gone with my alternative internal representation which was to change the end position to be a 1-relative index (rather than the old 0-relative index or the new length). I'll look into this to see what might be the cleanest solution. ..wayne.. ---8<------8<------8<------8<---cut here--->8------>8------>8------>8--- Index: Src/params.c @@ -941,7 +941,7 @@ r = isset(KSHARRAYS) ? 1 : 0; } else { r = mathevalarg(s, &s); - if ((!r && !a2) || (isset(KSHARRAYS) && r >= 0)) + if (isset(KSHARRAYS) && r >= 0) r++; } if (word && !v->isarr) { @@ -1185,19 +1185,19 @@ } else { int com; - if (start > 0) - start--; if ((com = (*s == ','))) { s++; len = getarg(&s, &inv, v, 1, &dummy); if (len > 0) { - len -= start; + len -= start - 1; if (len < 0) len = 0; } } else { len = wlen ? wlen : 1; } + if (start > 0) + start--; if (*s == ']' || *s == Outbrack) { s++; if (v->isarr && len == 1 && !com && ---8<------8<------8<------8<---cut here--->8------>8------>8------>8---