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.
This commit is contained in:
parent
25ff14505c
commit
011db151f6
@ -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 char **tstr, int delim,
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user