diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2000-06-02 01:54:16 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2000-06-02 01:54:16 +0000 |
commit | 91d5f734349b7188a9a5ae54ecd99974e228bd2b (patch) | |
tree | 1fb8a4a7c864843debaf0e8a163bdb0824ae646b /Src/glob.c | |
parent | f77bd804ee098a999bb29769b3e55d6f32fc1279 (diff) | |
download | zsh-91d5f734349b7188a9a5ae54ecd99974e228bd2b.tar.gz zsh-91d5f734349b7188a9a5ae54ecd99974e228bd2b.tar.xz zsh-91d5f734349b7188a9a5ae54ecd99974e228bd2b.zip |
Changed the array "len" to be "end" -- a 1-relative index of the last
item (or you can think of it as pointing one past the last item).
Diffstat (limited to 'Src/glob.c')
-rw-r--r-- | Src/glob.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/Src/glob.c b/Src/glob.c index e8e6e4fdf..46fef88ea 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -921,8 +921,8 @@ glob(LinkList list, LinkNode np, int nountok) Complist q; /* pattern after parsing */ char *ostr = (char *)getdata(np); /* the pattern before the parser */ /* chops it up */ - int first = 0, count = -1; /* index of first match to return */ - /* plus number of items */ + int first = 0, end = -1; /* index of first match to return */ + /* and index+1 of the last match */ struct globdata saved; /* saved glob state */ if (unset(GLOBOPT) || !haswilds(ostr)) { @@ -1334,7 +1334,7 @@ glob(LinkList list, LinkNode np, int nountok) v.isarr = SCANPM_WANTVALS; v.pm = NULL; - v.len = -1; + v.end = -1; v.inv = 0; if (getindex(&s, &v) || s == os) { zerr("invalid subscript", NULL, 0); @@ -1342,7 +1342,7 @@ glob(LinkList list, LinkNode np, int nountok) return; } first = v.start; - count = v.len; + end = v.end; break; } default: @@ -1426,17 +1426,18 @@ glob(LinkList list, LinkNode np, int nountok) qsort((void *) & matchbuf[0], matchct, sizeof(struct gmatch), (int (*) _((const void *, const void *)))gmatchcmp); - if (first < 0) + if (first < 0) { first += matchct; - if (count < 0) - count += matchct + 1; - if (first < 0) - first = 0; - if (count > matchct - first) - count = matchct - first; - if (count > 0) { - matchptr = matchbuf + matchct - first - count; - while (count-- > 0) { /* insert matches in the arg list */ + if (first < 0) + first = 0; + } + if (end < 0) + end += matchct + 1; + else if (end > matchct) + end = matchct; + if (end -= first > 0) { + matchptr = matchbuf + matchct - first - end; + while (end-- > 0) { /* insert matches in the arg list */ insertlinknode(list, node, matchptr->name); matchptr++; } |