Module Name: src
Committed By: rillig
Date: Tue Jul 21 23:22:45 UTC 2020
Modified Files:
src/usr.bin/make: var.c
Log Message:
make(1): make implementation of the :C modifier simpler
To generate a diff of this commit:
cvs rdiff -u -r1.293 -r1.294 src/usr.bin/make/var.c
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.293 src/usr.bin/make/var.c:1.294
--- src/usr.bin/make/var.c:1.293 Tue Jul 21 21:32:55 2020
+++ src/usr.bin/make/var.c Tue Jul 21 23:22:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.293 2020/07/21 21:32:55 rillig Exp $ */
+/* $NetBSD: var.c,v 1.294 2020/07/21 23:22:45 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.293 2020/07/21 21:32:55 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.294 2020/07/21 23:22:45 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.293 2020/07/21 21:32:55 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.294 2020/07/21 23:22:45 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1435,8 +1435,6 @@ ModifyWord_SubstRegex(GNode *ctx MAKE_AT
} else if (*rp == '&' ||
(*rp == '\\' && isdigit((unsigned char)rp[1]))) {
int n;
- const char *subbuf;
- int sublen;
char errstr[3];
if (*rp == '&') {
@@ -1452,20 +1450,16 @@ ModifyWord_SubstRegex(GNode *ctx MAKE_AT
}
if (n >= pat->nsub) {
- Error("No subexpression %s", &errstr[0]);
- subbuf = "";
- sublen = 0;
+ Error("No subexpression %s", errstr);
} else if ((pat->matches[n].rm_so == -1) &&
(pat->matches[n].rm_eo == -1)) {
- Error("No match for subexpression %s", &errstr[0]);
- subbuf = "";
- sublen = 0;
+ Error("No match for subexpression %s", errstr);
} else {
- subbuf = wp + pat->matches[n].rm_so;
- sublen = pat->matches[n].rm_eo - pat->matches[n].rm_so;
+ const char *subbuf = wp + pat->matches[n].rm_so;
+ int sublen = pat->matches[n].rm_eo - pat->matches[n].rm_so;
+ SepBuf_AddBytes(buf, subbuf, sublen);
}
- SepBuf_AddBytes(buf, subbuf, sublen);
} else {
SepBuf_AddBytes(buf, rp, 1);
}