Sat Oct 31 09:27:20 2020 UTC ()
make(1): remove redundant null check from s2Boolean


(rillig)
diff -r1.415 -r1.416 src/usr.bin/make/main.c
diff -r1.612 -r1.613 src/usr.bin/make/var.c

cvs diff -r1.415 -r1.416 src/usr.bin/make/main.c (expand / switch to unified diff)

--- src/usr.bin/make/main.c 2020/10/31 09:23:38 1.415
+++ src/usr.bin/make/main.c 2020/10/31 09:27:19 1.416
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.415 2020/10/31 09:23:38 rillig Exp $ */ 1/* $NetBSD: main.c,v 1.416 2020/10/31 09:27:19 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.
@@ -108,27 +108,27 @@ @@ -108,27 +108,27 @@
108 108
109#include <errno.h> 109#include <errno.h>
110#include <signal.h> 110#include <signal.h>
111#include <stdarg.h> 111#include <stdarg.h>
112#include <time.h> 112#include <time.h>
113 113
114#include "make.h" 114#include "make.h"
115#include "dir.h" 115#include "dir.h"
116#include "job.h" 116#include "job.h"
117#include "pathnames.h" 117#include "pathnames.h"
118#include "trace.h" 118#include "trace.h"
119 119
120/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ 120/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
121MAKE_RCSID("$NetBSD: main.c,v 1.415 2020/10/31 09:23:38 rillig Exp $"); 121MAKE_RCSID("$NetBSD: main.c,v 1.416 2020/10/31 09:27:19 rillig Exp $");
122#if defined(MAKE_NATIVE) && !defined(lint) 122#if defined(MAKE_NATIVE) && !defined(lint)
123__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " 123__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
124 "The Regents of the University of California. " 124 "The Regents of the University of California. "
125 "All rights reserved."); 125 "All rights reserved.");
126#endif 126#endif
127 127
128#ifndef DEFMAXLOCAL 128#ifndef DEFMAXLOCAL
129#define DEFMAXLOCAL DEFMAXJOBS 129#define DEFMAXLOCAL DEFMAXJOBS
130#endif 130#endif
131 131
132CmdOpts opts; 132CmdOpts opts;
133time_t now; /* Time at start of make */ 133time_t now; /* Time at start of make */
134GNode *DEFAULT; /* .DEFAULT node */ 134GNode *DEFAULT; /* .DEFAULT node */
@@ -2196,42 +2196,40 @@ mkTempFile(const char *pattern, char **o @@ -2196,42 +2196,40 @@ mkTempFile(const char *pattern, char **o
2196 unlink(tfile); /* we just want the descriptor */ 2196 unlink(tfile); /* we just want the descriptor */
2197 } 2197 }
2198 return fd; 2198 return fd;
2199} 2199}
2200 2200
2201/* 2201/*
2202 * Convert a string representation of a boolean. 2202 * Convert a string representation of a boolean.
2203 * Anything that looks like "No", "False", "Off", "0" etc, 2203 * Anything that looks like "No", "False", "Off", "0" etc,
2204 * is FALSE, otherwise TRUE. 2204 * is FALSE, otherwise TRUE.
2205 */ 2205 */
2206Boolean 2206Boolean
2207s2Boolean(const char *s, Boolean bf) 2207s2Boolean(const char *s, Boolean bf)
2208{ 2208{
2209 if (s) { 2209 switch(s[0]) {
2210 switch(*s) { 2210 case '\0': /* not set - the default wins */
2211 case '\0': /* not set - the default wins */ 2211 break;
2212 break; 2212 case '0':
2213 case '0': 2213 case 'F':
2214 case 'F': 2214 case 'f':
2215 case 'f': 2215 case 'N':
2216 case 'N': 2216 case 'n':
2217 case 'n': 2217 return FALSE;
2218 return FALSE; 2218 case 'O':
2219 case 'O': 2219 case 'o':
2220 case 'o': 2220 return s[1] != 'F' && s[1] != 'f';
2221 return s[1] != 'F' && s[1] != 'f'; 2221 default:
2222 default: 2222 return TRUE;
2223 return TRUE; 
2224 } 
2225 } 2223 }
2226 return bf; 2224 return bf;
2227} 2225}
2228 2226
2229/* 2227/*
2230 * Return a Boolean based on setting of a knob. 2228 * Return a Boolean based on setting of a knob.
2231 * 2229 *
2232 * If the knob is not set, the supplied default is the return value. 2230 * If the knob is not set, the supplied default is the return value.
2233 * If set, anything that looks or smells like "No", "False", "Off", "0" etc, 2231 * If set, anything that looks or smells like "No", "False", "Off", "0" etc,
2234 * is FALSE, otherwise TRUE. 2232 * is FALSE, otherwise TRUE.
2235 */ 2233 */
2236Boolean 2234Boolean
2237getBoolean(const char *name, Boolean fallback) 2235getBoolean(const char *name, Boolean fallback)

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

--- src/usr.bin/make/var.c 2020/10/31 09:03:36 1.612
+++ src/usr.bin/make/var.c 2020/10/31 09:27:19 1.613
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.612 2020/10/31 09:03:36 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.613 2020/10/31 09:27:19 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.612 2020/10/31 09:03:36 rillig Exp $"); 132MAKE_RCSID("$NetBSD: var.c,v 1.613 2020/10/31 09:27:19 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 */
@@ -843,27 +843,27 @@ Var_Set_with_flags(const char *name, con @@ -843,27 +843,27 @@ Var_Set_with_flags(const char *name, con
843 */ 843 */
844 if (ctxt == VAR_CMDLINE && !(flags & VAR_NO_EXPORT) && name[0] != '.') { 844 if (ctxt == VAR_CMDLINE && !(flags & VAR_NO_EXPORT) && name[0] != '.') {
845 if (v == NULL) 845 if (v == NULL)
846 v = VarFind(name, ctxt, 0); /* we just added it */ 846 v = VarFind(name, ctxt, 0); /* we just added it */
847 v->flags |= VAR_FROM_CMD; 847 v->flags |= VAR_FROM_CMD;
848 848
849 /* 849 /*
850 * If requested, don't export these in the environment 850 * If requested, don't export these in the environment
851 * individually. We still put them in MAKEOVERRIDES so 851 * individually. We still put them in MAKEOVERRIDES so
852 * that the command-line settings continue to override 852 * that the command-line settings continue to override
853 * Makefile settings. 853 * Makefile settings.
854 */ 854 */
855 if (!opts.varNoExportEnv) 855 if (!opts.varNoExportEnv)
856 setenv(name, val ? val : "", 1); 856 setenv(name, val, 1);
857 857
858 Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL); 858 Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
859 } 859 }
860 if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0) 860 if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0)
861 save_dollars = s2Boolean(val, save_dollars); 861 save_dollars = s2Boolean(val, save_dollars);
862 862
863out: 863out:
864 free(name_freeIt); 864 free(name_freeIt);
865 if (v != NULL) 865 if (v != NULL)
866 VarFreeEnv(v, TRUE); 866 VarFreeEnv(v, TRUE);
867} 867}
868 868
869/*- 869/*-