about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2001-07-06 09:23:55 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2001-07-06 09:23:55 +0000
commit4a8b8bd7522df86d74bbfdb9c1086ae64ad6f861 (patch)
treec50eb9c77a092b5efb8c2739cf0c700d0a389e21
parent40e17d980fd478b91cbfaeedfd3a887ada443cd5 (diff)
downloadzsh-4a8b8bd7522df86d74bbfdb9c1086ae64ad6f861.tar.gz
zsh-4a8b8bd7522df86d74bbfdb9c1086ae64ad6f861.tar.xz
zsh-4a8b8bd7522df86d74bbfdb9c1086ae64ad6f861.zip
15277: Src/glob.c: real backreferencing bug with ${(S)...%%...}
-rw-r--r--ChangeLog3
-rw-r--r--Src/glob.c17
2 files changed, 12 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 7686e3084..e70c20dac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2001-07-06  Peter Stephenson  <pws@csr.com>
 
+	* 15277: Src/glob.c: *real* bug with ${(S)...%%...}: the indices
+	for start and end of backreferences were incorrect.
+
 	* Back out 15266: it was right before, I was looking at it
 	back to front.
 
diff --git a/Src/glob.c b/Src/glob.c
index 5be79329b..2f64434c4 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2236,16 +2236,17 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr)
 	    break;
 
 	case (SUB_END|SUB_SUBSTR):
-	    /* Shortest at end with substrings */
-	    patoffset = ml;
-	    set_pat_start(p, l);
-	    if (pattry(p, s + l) && !--n) {
-		*sp = get_match_ret(*sp, l, l, fl, replstr);
-		patoffset = 0;
-		return 1;
-	    } /* fall through */
 	case (SUB_END|SUB_LONG|SUB_SUBSTR):
 	    /* Longest/shortest at end, matching substrings.       */
+	    patoffset = ml;
+	    if (!(fl & SUB_LONG)) {
+		set_pat_start(p, l);
+		if (pattry(p, s + l) && !--n) {
+		    *sp = get_match_ret(*sp, l, l, fl, replstr);
+		    patoffset = 0;
+		    return 1;
+		}
+	    }
 	    patoffset--;
 	    for (t = s + l - 1; t >= s; t--, patoffset--) {
 		if (t > s && t[-1] == Meta)