Module Name: src
Committed By: rillig
Date: Tue Jul 21 21:32:55 UTC 2020
Modified Files:
src/usr.bin/make: var.c
Log Message:
make(1): only ask for newline if :Q actually needs it
This simple change reduces the binary size of var.o by 96 bytes (Clang,
x86_64). Given that the code is still the same, just in a different
order, this is a bit surprising.
To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 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.292 src/usr.bin/make/var.c:1.293
--- src/usr.bin/make/var.c:1.292 Tue Jul 21 21:13:24 2020
+++ src/usr.bin/make/var.c Tue Jul 21 21:32:55 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.292 2020/07/21 21:13:24 rillig Exp $ */
+/* $NetBSD: var.c,v 1.293 2020/07/21 21:32:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.292 2020/07/21 21:13:24 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.293 2020/07/21 21:32:55 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.292 2020/07/21 21:13:24 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.293 2020/07/21 21:32:55 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1971,19 +1971,15 @@ ParseModifierPart(GNode *ctxt, const cha
static char *
VarQuote(char *str, Boolean quoteDollar)
{
- Buffer buf;
- const char *newline;
- size_t nlen;
-
- if ((newline = Shell_GetNewline()) == NULL)
- newline = "\\\n";
- nlen = strlen(newline);
-
+ Buffer buf;
Buf_Init(&buf, 0);
for (; *str != '\0'; str++) {
if (*str == '\n') {
- Buf_AddBytes(&buf, nlen, newline);
+ const char *newline = Shell_GetNewline();
+ if (newline == NULL)
+ newline = "\\\n";
+ Buf_AddBytes(&buf, strlen(newline), newline);
continue;
}
if (isspace((unsigned char)*str) || ismeta((unsigned char)*str))