From: Wayne Davison <wayned@users.sourceforge.net>
To: Zsh Workers <zsh-workers@sunsite.auc.dk>
Subject: Re: Array slices (PWS's unposted Etc/NEWS change)
Date: Thu, 1 Jun 2000 13:51:16 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.21.0006011343390.27045-100000@phong.blorf.net> (raw)
In-Reply-To: <1000601155002.ZM3182@candle.brasslantern.com>
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---
next prev parent reply other threads:[~2000-06-01 20:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-01 15:50 Bart Schaefer
2000-06-01 20:51 ` Wayne Davison [this message]
2000-06-02 2:08 ` Wayne Davison
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=Pine.LNX.4.21.0006011343390.27045-100000@phong.blorf.net \
--to=wayned@users.sourceforge.net \
--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).