about summary refs log tree commit diff
diff options
context:
space:
mode:
-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)