Sat Oct 31 18:20:01 2020 UTC ()
make(1): remove unused code from needshell

Since usr.bin/xinstall no longer uses this code, there is no need to
keep the second parameter.


(rillig)
diff -r1.171 -r1.172 src/usr.bin/make/compat.c
diff -r1.10 -r1.11 src/usr.bin/make/metachar.h

cvs diff -r1.171 -r1.172 src/usr.bin/make/compat.c (expand / switch to unified diff)

--- src/usr.bin/make/compat.c 2020/10/31 11:54:33 1.171
+++ src/usr.bin/make/compat.c 2020/10/31 18:20:00 1.172
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: compat.c,v 1.171 2020/10/31 11:54:33 rillig Exp $ */ 1/* $NetBSD: compat.c,v 1.172 2020/10/31 18:20:00 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * 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.
@@ -86,27 +86,27 @@ @@ -86,27 +86,27 @@
86#include <sys/stat.h> 86#include <sys/stat.h>
87#include <sys/wait.h> 87#include <sys/wait.h>
88 88
89#include <errno.h> 89#include <errno.h>
90#include <signal.h> 90#include <signal.h>
91 91
92#include "make.h" 92#include "make.h"
93#include "dir.h" 93#include "dir.h"
94#include "job.h" 94#include "job.h"
95#include "metachar.h" 95#include "metachar.h"
96#include "pathnames.h" 96#include "pathnames.h"
97 97
98/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ 98/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
99MAKE_RCSID("$NetBSD: compat.c,v 1.171 2020/10/31 11:54:33 rillig Exp $"); 99MAKE_RCSID("$NetBSD: compat.c,v 1.172 2020/10/31 18:20:00 rillig Exp $");
100 100
101static GNode *curTarg = NULL; 101static GNode *curTarg = NULL;
102static pid_t compatChild; 102static pid_t compatChild;
103static int compatSigno; 103static int compatSigno;
104 104
105/* 105/*
106 * CompatDeleteTarget -- delete a failed, interrupted, or otherwise 106 * CompatDeleteTarget -- delete a failed, interrupted, or otherwise
107 * duffed target if not inhibited by .PRECIOUS. 107 * duffed target if not inhibited by .PRECIOUS.
108 */ 108 */
109static void 109static void
110CompatDeleteTarget(GNode *gn) 110CompatDeleteTarget(GNode *gn)
111{ 111{
112 if (gn != NULL && !Targ_Precious(gn)) { 112 if (gn != NULL && !Targ_Precious(gn)) {
@@ -257,27 +257,27 @@ Compat_RunCommand(const char *cmdp, GNod @@ -257,27 +257,27 @@ Compat_RunCommand(const char *cmdp, GNod
257 */ 257 */
258 useShell = TRUE; 258 useShell = TRUE;
259#else 259#else
260 /* 260 /*
261 * Search for meta characters in the command. If there are no meta 261 * Search for meta characters in the command. If there are no meta
262 * characters, there's no need to execute a shell to execute the 262 * characters, there's no need to execute a shell to execute the
263 * command. 263 * command.
264 * 264 *
265 * Additionally variable assignments and empty commands 265 * Additionally variable assignments and empty commands
266 * go to the shell. Therefore treat '=' and ':' like shell 266 * go to the shell. Therefore treat '=' and ':' like shell
267 * meta characters as documented in make(1). 267 * meta characters as documented in make(1).
268 */ 268 */
269 269
270 useShell = needshell(cmd, FALSE); 270 useShell = needshell(cmd);
271#endif 271#endif
272 272
273 /* 273 /*
274 * Print the command before echoing if we're not supposed to be quiet for 274 * Print the command before echoing if we're not supposed to be quiet for
275 * this one. We also print the command if -n given. 275 * this one. We also print the command if -n given.
276 */ 276 */
277 if (!silent || NoExecute(gn)) { 277 if (!silent || NoExecute(gn)) {
278 printf("%s\n", cmd); 278 printf("%s\n", cmd);
279 fflush(stdout); 279 fflush(stdout);
280 } 280 }
281 281
282 /* 282 /*
283 * If we're not supposed to execute any commands, this is as far as 283 * If we're not supposed to execute any commands, this is as far as

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

--- src/usr.bin/make/metachar.h 2020/10/31 18:17:08 1.10
+++ src/usr.bin/make/metachar.h 2020/10/31 18:20:00 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: metachar.h,v 1.10 2020/10/31 18:17:08 rillig Exp $ */ 1/* $NetBSD: metachar.h,v 1.11 2020/10/31 18:20:00 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.
@@ -28,25 +28,21 @@ @@ -28,25 +28,21 @@
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 is_shell_metachar(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)
42{ 42{
43 while (!is_shell_metachar(*cmd) && *cmd != ':' && *cmd != '=') { 43 while (!is_shell_metachar(*cmd) && *cmd != ':' && *cmd != '=')
44 if (white && ch_isspace(*cmd)) 
45 break; 
46 cmd++; 44 cmd++;
47 } 
48 
49 return *cmd != '\0'; 45 return *cmd != '\0';
50} 46}
51 47
52#endif /* MAKE_METACHAR_H */ 48#endif /* MAKE_METACHAR_H */