Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 3.1.5 and 3.0.5: ${(l<e><s1><s2>)param} (was Re: Arithmetic expression (bug?))



On Nov 15,  2:46pm, Bart Schaefer wrote:
} Subject: Re: Arithmetic expression (bug?)
}
} Having just said I wasn't sure how to fix this, here's a patch that takes
} care of it.

That patch didn't go far enough; it misses the case where two strings are
passed to (l...) or (r...).  Use this one instead (and this time I did
remember to put the word PATCH in the subject).

Index: Src/subst.c
===================================================================
--- subst.c	1998/11/12 09:21:35	1.2
+++ subst.c	1998/11/15 22:27:52
@@ -743,6 +743,7 @@
 	    long num;
 	    int escapes = 0;
 	    int klen;
+#define UNTOK(C)  (itok(C) ? ztokens[(C) - Pound] : (C))
 #define UNTOK_AND_ESCAPE(X) {\
 		untokenize(X = dupstring(s + 1));\
 		if (escapes) {\
@@ -856,7 +857,7 @@
 			prenum = num;
 		    else
 			postnum = num;
-		    if (s[1] != sav)
+		    if (UNTOK(s[1]) != UNTOK(sav))
 			break;
 		    t = get_strarg(++s);
 		    if (!*t)
@@ -871,7 +871,7 @@
 		    *t = sav;
 		    sav = *s;
 		    s = t + 1;
-		    if (*s != sav) {
+		    if (UNTOK(*s) != UNTOK(sav)) {
 			s--;
 			break;
 		    }

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author