Module Name: src
Committed By: rillig
Date: Sat Aug 1 15:03:43 UTC 2020
Modified Files:
src/usr.bin/make: var.c
Log Message:
make(1): inline literal dollar characters
This reduces the code size when compiling with GCC 5. Apparently GCC
wasn't sure enough that str[0] and str[1] stay the same around the call
to Buf_AddByte.
To generate a diff of this commit:
cvs rdiff -u -r1.380 -r1.381 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.380 src/usr.bin/make/var.c:1.381
--- src/usr.bin/make/var.c:1.380 Sat Aug 1 14:47:49 2020
+++ src/usr.bin/make/var.c Sat Aug 1 15:03:43 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.380 2020/08/01 14:47:49 rillig Exp $ */
+/* $NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.380 2020/08/01 14:47:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 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.380 2020/08/01 14:47:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.381 2020/08/01 15:03:43 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -3420,7 +3420,7 @@ Var_Parse(const char * const str, GNode
if (v == NULL) {
*lengthPtr = 2;
- if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) {
+ if (ctxt == VAR_CMD || ctxt == VAR_GLOBAL) {
/*
* If substituting a local variable in a non-local context,
* assume it's for dynamic source stuff. We have to handle
@@ -3689,17 +3689,16 @@ Var_Subst(const char *str, GNode *ctxt,
while (*str) {
if (*str == '\n' && trailingBslash)
Buf_AddByte(&buf, ' ');
- if ((*str == '$') && (str[1] == '$')) {
+ if (*str == '$' && str[1] == '$') {
/*
- * A dollar sign may be escaped either with another dollar sign.
+ * A dollar sign may be escaped with another dollar sign.
* In such a case, we skip over the escape character and store the
* dollar sign into the buffer directly.
*/
if (save_dollars && (eflags & VARE_ASSIGN))
- Buf_AddByte(&buf, *str);
- str++;
- Buf_AddByte(&buf, *str);
- str++;
+ Buf_AddByte(&buf, '$');
+ Buf_AddByte(&buf, '$');
+ str += 2;
} else if (*str != '$') {
/*
* Skip as many characters as possible -- either to the end of