Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: reverse string subscripting
- X-seq: zsh-workers 13907
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: reverse string subscripting
- Date: Thu, 5 Apr 2001 13:22:12 +0200 (MET DST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This is from the debian bug list:
% a=abcd
% echo $a[1,(r)d]
didn't work, because it stopped one character too early trying to find
the matching substring for `d'.
Bye
Sven
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.32
diff -u -r1.32 params.c
--- Src/params.c 2001/02/14 23:37:39 1.32
+++ Src/params.c 2001/04/05 11:21:51
@@ -1113,6 +1113,8 @@
if (beg < 0)
beg += len;
if (beg >= 0 && beg < len) {
+ char *de = d + len;
+
if (a2) {
if (down) {
if (!hasbeg)
@@ -1128,7 +1130,7 @@
*t = sav;
}
} else
- for (r = beg, t = d + beg; *t; r++, t++) {
+ for (r = beg, t = d + beg; t <= de; r++, t++) {
sav = *t;
*t = '\0';
if (pattry(pprog, d) &&
@@ -1148,7 +1150,7 @@
return r;
}
} else
- for (r = beg + 1, t = d + beg; *t; r++, t++)
+ for (r = beg + 1, t = d + beg; t <= de; r++, t++)
if (pattry(pprog, t) &&
!--num)
return r;
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author