about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Src/glob.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Src/glob.c b/Src/glob.c
index b8c535a6f..2df5270c2 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1971,8 +1971,11 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr)
 				*ptr = sav;
 			    }
 			}
-			if (!--n || (n <= 0 && (fl & SUB_GLOBAL)))
+			if (!--n || (n <= 0 && (fl & SUB_GLOBAL))) {
 			    *sp = get_match_ret(*sp, t-s, mpos-s, fl, replstr);
+			    if (mpos == start)
+				mpos++;
+			}
 			if (!(fl & SUB_GLOBAL)) {
 			    if (n) {
 				/*