Module Name: src Committed By: rillig Date: Sun Jul 26 22:19:12 UTC 2020
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varparse-dynamic.exp Log Message: make(1): fix off-by-one error in Var_Parse for dynamic variables To generate a diff of this commit: cvs rdiff -u -r1.333 -r1.334 src/usr.bin/make/var.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varparse-dynamic.exp 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.333 src/usr.bin/make/var.c:1.334 --- src/usr.bin/make/var.c:1.333 Sun Jul 26 21:31:11 2020 +++ src/usr.bin/make/var.c Sun Jul 26 22:19:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.333 2020/07/26 21:31:11 rillig Exp $ */ +/* $NetBSD: var.c,v 1.334 2020/07/26 22:19:11 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.333 2020/07/26 21:31:11 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.334 2020/07/26 22:19:11 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.333 2020/07/26 21:31:11 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.334 2020/07/26 22:19:11 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -136,6 +136,12 @@ __RCSID("$NetBSD: var.c,v 1.333 2020/07/ #include "job.h" #include "metachar.h" +#define VAR_DEBUG(fmt, ...) \ + if (!DEBUG(VAR)) \ + (void) 0; \ + else \ + fprintf(debug_file, fmt, __VA_ARGS__) + /* * This lets us tell if we have replaced the original environ * (which we cannot free). @@ -3561,11 +3567,10 @@ Var_Parse(const char * const str, GNode isupper((unsigned char) varname[1]) && (ctxt == VAR_CMD || ctxt == VAR_GLOBAL)) { - int len = namelen - 1; - if ((strncmp(varname, ".TARGET", len) == 0) || - (strncmp(varname, ".ARCHIVE", len) == 0) || - (strncmp(varname, ".PREFIX", len) == 0) || - (strncmp(varname, ".MEMBER", len) == 0)) + if ((strcmp(varname, ".TARGET") == 0) || + (strcmp(varname, ".ARCHIVE") == 0) || + (strcmp(varname, ".PREFIX") == 0) || + (strcmp(varname, ".MEMBER") == 0)) { dynamic = TRUE; } Index: src/usr.bin/make/unit-tests/varparse-dynamic.exp diff -u src/usr.bin/make/unit-tests/varparse-dynamic.exp:1.1 src/usr.bin/make/unit-tests/varparse-dynamic.exp:1.2 --- src/usr.bin/make/unit-tests/varparse-dynamic.exp:1.1 Sun Jul 26 22:15:36 2020 +++ src/usr.bin/make/unit-tests/varparse-dynamic.exp Sun Jul 26 22:19:12 2020 @@ -1,3 +1,4 @@ +make: "varparse-dynamic.mk" line 8: Malformed conditional (${.TARGEX}) make: "varparse-dynamic.mk" line 10: Malformed conditional (${.TARGXX}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests