Sat Oct 31 18:17:08 2020 UTC ()
make(1): rename ismeta to is_shell_metachar

The old name was too broad.


(rillig)
diff -r1.9 -r1.10 src/usr.bin/make/metachar.h
diff -r1.628 -r1.629 src/usr.bin/make/var.c

cvs diff -r1.9 -r1.10 src/usr.bin/make/metachar.h (expand / switch to unified diff)

--- src/usr.bin/make/metachar.h 2020/09/13 15:27:25 1.9
+++ src/usr.bin/make/metachar.h 2020/10/31 18:17:08 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: metachar.h,v 1.9 2020/09/13 15:27:25 rillig Exp $ */ 1/* $NetBSD: metachar.h,v 1.10 2020/10/31 18:17:08 rillig Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 The NetBSD Foundation, Inc. 4 * Copyright (c) 2015 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,28 +25,28 @@ @@ -25,28 +25,28 @@
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31#ifndef MAKE_METACHAR_H 31#ifndef MAKE_METACHAR_H
32#define MAKE_METACHAR_H 32#define MAKE_METACHAR_H
33 33
34#include "make.h" 34#include "make.h"
35 35
36extern unsigned char _metachar[]; 36extern unsigned char _metachar[];
37 37
38#define ismeta(c) _metachar[(c) & 0x7f] 38#define is_shell_metachar(c) _metachar[(c) & 0x7f]
39 39
40static inline MAKE_ATTR_UNUSED int 40static inline MAKE_ATTR_UNUSED int
41needshell(const char *cmd, int white) 41needshell(const char *cmd, int white)
42{ 42{
43 while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=') { 43 while (!is_shell_metachar(*cmd) && *cmd != ':' && *cmd != '=') {
44 if (white && ch_isspace(*cmd)) 44 if (white && ch_isspace(*cmd))
45 break; 45 break;
46 cmd++; 46 cmd++;
47 } 47 }
48 48
49 return *cmd != '\0'; 49 return *cmd != '\0';
50} 50}
51 51
52#endif /* MAKE_METACHAR_H */ 52#endif /* MAKE_METACHAR_H */

cvs diff -r1.628 -r1.629 src/usr.bin/make/var.c (expand / switch to unified diff)

--- src/usr.bin/make/var.c 2020/10/31 18:14:59 1.628
+++ src/usr.bin/make/var.c 2020/10/31 18:17:08 1.629
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.629 2020/10/31 18:17:08 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -119,27 +119,27 @@ @@ -119,27 +119,27 @@
119#include <sys/types.h> 119#include <sys/types.h>
120#include <regex.h> 120#include <regex.h>
121#endif 121#endif
122#include <inttypes.h> 122#include <inttypes.h>
123#include <limits.h> 123#include <limits.h>
124#include <time.h> 124#include <time.h>
125 125
126#include "make.h" 126#include "make.h"
127#include "dir.h" 127#include "dir.h"
128#include "job.h" 128#include "job.h"
129#include "metachar.h" 129#include "metachar.h"
130 130
131/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ 131/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
132MAKE_RCSID("$NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $"); 132MAKE_RCSID("$NetBSD: var.c,v 1.629 2020/10/31 18:17:08 rillig Exp $");
133 133
134#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) 134#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
135#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) 135#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
136#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3) 136#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3)
137#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4) 137#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4)
138 138
139ENUM_FLAGS_RTTI_3(VarEvalFlags, 139ENUM_FLAGS_RTTI_3(VarEvalFlags,
140 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN); 140 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN);
141 141
142/* 142/*
143 * This lets us tell if we have replaced the original environ 143 * This lets us tell if we have replaced the original environ
144 * (which we cannot free). 144 * (which we cannot free).
145 */ 145 */
@@ -1637,27 +1637,27 @@ static char * @@ -1637,27 +1637,27 @@ static char *
1637VarQuote(const char *str, Boolean quoteDollar) 1637VarQuote(const char *str, Boolean quoteDollar)
1638{ 1638{
1639 Buffer buf; 1639 Buffer buf;
1640 Buf_Init(&buf, 0); 1640 Buf_Init(&buf, 0);
1641 1641
1642 for (; *str != '\0'; str++) { 1642 for (; *str != '\0'; str++) {
1643 if (*str == '\n') { 1643 if (*str == '\n') {
1644 const char *newline = Shell_GetNewline(); 1644 const char *newline = Shell_GetNewline();
1645 if (newline == NULL) 1645 if (newline == NULL)
1646 newline = "\\\n"; 1646 newline = "\\\n";
1647 Buf_AddStr(&buf, newline); 1647 Buf_AddStr(&buf, newline);
1648 continue; 1648 continue;
1649 } 1649 }
1650 if (ch_isspace(*str) || ismeta((unsigned char)*str)) 1650 if (ch_isspace(*str) || is_shell_metachar((unsigned char)*str))
1651 Buf_AddByte(&buf, '\\'); 1651 Buf_AddByte(&buf, '\\');
1652 Buf_AddByte(&buf, *str); 1652 Buf_AddByte(&buf, *str);
1653 if (quoteDollar && *str == '$') 1653 if (quoteDollar && *str == '$')
1654 Buf_AddStr(&buf, "\\$"); 1654 Buf_AddStr(&buf, "\\$");
1655 } 1655 }
1656 1656
1657 return Buf_Destroy(&buf, FALSE); 1657 return Buf_Destroy(&buf, FALSE);
1658} 1658}
1659 1659
1660/* Compute the 32-bit hash of the given string, using the MurmurHash3 1660/* Compute the 32-bit hash of the given string, using the MurmurHash3
1661 * algorithm. Output is encoded as 8 hex digits, in Little Endian order. */ 1661 * algorithm. Output is encoded as 8 hex digits, in Little Endian order. */
1662static char * 1662static char *
1663VarHash(const char *str) 1663VarHash(const char *str)