Module Name:    src
Committed By:   rillig
Date:           Fri Jul  3 18:41:50 UTC 2020

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

Log Message:
make(1): fix bug in :E modifier, introduced in r1.239 today

That case was not covered by the tests before.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/modmisc.exp \
    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.242 src/usr.bin/make/var.c:1.243
--- src/usr.bin/make/var.c:1.242	Fri Jul  3 17:48:47 2020
+++ src/usr.bin/make/var.c	Fri Jul  3 18:41:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.242 2020/07/03 17:48:47 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.243 2020/07/03 18:41:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.242 2020/07/03 17:48:47 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.243 2020/07/03 18:41:50 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.242 2020/07/03 17:48:47 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.243 2020/07/03 18:41:50 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1202,7 +1202,7 @@ VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var
     return TRUE;
 }
 
-/* Add the filename suffix of the given word to the buffer. */
+/* Add the filename suffix of the given word to the buffer, if it exists. */
 static Boolean
 VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
 	  char *word, Boolean addSpace, Buffer *buf,
@@ -1210,7 +1210,7 @@ VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, V
 {
     const char *dot = strrchr(word, '.');
     if (dot == NULL)
-	return FALSE;
+	return addSpace;
 
     if (addSpace && vpstate->varSpace)
 	Buf_AddByte(buf, vpstate->varSpace);

Index: src/usr.bin/make/unit-tests/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.5 src/usr.bin/make/unit-tests/modmisc.exp:1.6
--- src/usr.bin/make/unit-tests/modmisc.exp:1.5	Fri Jul  3 15:41:37 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Fri Jul  3 18:41:50 2020
@@ -7,8 +7,8 @@ path_/usr/xbin=/opt/xbin/
 paths=/bin /tmp / /no/such/dir /opt/xbin
 PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
 The answer is 42
-head of 'a/b/c def archive.tar.gz conf.d/file' is 'a/b . . conf.d
-tail of 'a/b/c def archive.tar.gz conf.d/file' is 'c def archive.tar.gz file
-suffix of 'a/b/c def archive.tar.gz conf.d/file' is 'gz d/file
-root of 'a/b/c def archive.tar.gz conf.d/file' is 'a/b/c def archive.tar conf
+head of 'a/b/c def archive.tar.gz conf.d/file' is 'a/b . . conf.d'
+tail of 'a/b/c def archive.tar.gz conf.d/file' is 'c def archive.tar.gz file'
+suffix of 'a/b/c def archive.tar.gz conf.d/file' is 'gz d/file'
+root of 'a/b/c def archive.tar.gz conf.d/file' is 'a/b/c def archive.tar conf'
 exit status 0
Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.5 src/usr.bin/make/unit-tests/modmisc.mk:1.6
--- src/usr.bin/make/unit-tests/modmisc.mk:1.5	Fri Jul  3 15:41:37 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Fri Jul  3 18:41:50 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.5 2020/07/03 15:41:37 rillig Exp $
+# $Id: modmisc.mk,v 1.6 2020/07/03 18:41:50 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -37,9 +37,9 @@ modvarloop:
 	@echo "paths=${paths}"
 	@echo "PATHS=${paths:tu}"
 
-PATHNAMES=	a/b/c def archive.tar.gz conf.d/file
+PATHNAMES=	a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
 mod-HTE:
-	@echo "head of '"${PATHNAMES:Q}"' is '"${PATHNAMES:H:Q}
-	@echo "tail of '"${PATHNAMES:Q}"' is '"${PATHNAMES:T:Q}
-	@echo "suffix of '"${PATHNAMES:Q}"' is '"${PATHNAMES:E:Q}
-	@echo "root of '"${PATHNAMES:Q}"' is '"${PATHNAMES:R:Q}
+	@echo "dirname of '"${PATHNAMES:Q}"' is '"${PATHNAMES:H:Q}"'"
+	@echo "basename of '"${PATHNAMES:Q}"' is '"${PATHNAMES:T:Q}"'"
+	@echo "suffix of '"${PATHNAMES:Q}"' is '"${PATHNAMES:E:Q}"'"
+	@echo "root of '"${PATHNAMES:Q}"' is '"${PATHNAMES:R:Q}"'"

Reply via email to