Module Name:    src
Committed By:   rillig
Date:           Sun Jul 26 12:19:37 UTC 2020

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: modmisc.mk

Log Message:
make(1): fix bug in :S modifier from 2020-07-19


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/var.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/modmisc.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.309 src/usr.bin/make/var.c:1.310
--- src/usr.bin/make/var.c:1.309	Sun Jul 26 10:11:04 2020
+++ src/usr.bin/make/var.c	Sun Jul 26 12:19:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.309 2020/07/26 10:11:04 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.310 2020/07/26 12:19:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.309 2020/07/26 10:11:04 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.310 2020/07/26 12:19:37 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.309 2020/07/26 10:11:04 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.310 2020/07/26 12:19:37 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1339,11 +1339,11 @@ ModifyWord_Subst(const char *word, SepBu
     while ((cp = Str_FindSubstring(word, args->lhs)) != NULL) {
 	SepBuf_AddBytes(buf, word, cp - word);
 	SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
+	args->pflags |= VARP_SUB_MATCHED;
 	wordLen -= (cp - word) + args->lhsLen;
 	word = cp + args->lhsLen;
 	if (wordLen == 0 || !(args->pflags & VARP_SUB_GLOBAL))
 	    break;
-	args->pflags |= VARP_SUB_MATCHED;
     }
 nosub:
     SepBuf_AddBytes(buf, word, wordLen);

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.24 src/usr.bin/make/unit-tests/modmisc.mk:1.25
--- src/usr.bin/make/unit-tests/modmisc.mk:1.24	Sun Jul 26 12:18:11 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sun Jul 26 12:19:37 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.24 2020/07/26 12:18:11 rillig Exp $
+# $Id: modmisc.mk,v 1.25 2020/07/26 12:19:37 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -73,8 +73,7 @@ undefvar:
 	@echo @:${:U:@var@empty@}
 
 WORDS=		sequences of letters
-# FIXME: The "*" in "letters" must not be substituted because of the 1.
-.if ${WORDS:S,e,*,1} != "s*quences of l*tters"
+.if ${WORDS:S,e,*,1} != "s*quences of letters"
 .warning ${WORDS:S,e,*,1}
 .endif
 .if ${WORDS:S,e,*,} != "s*quences of l*tters"

Reply via email to