Sat Oct 31 09:23:38 2020 UTC ()
make(1): write s2Boolean in a more compact form


(rillig)
diff -r1.414 -r1.415 src/usr.bin/make/main.c

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

--- src/usr.bin/make/main.c 2020/10/31 09:20:07 1.414
+++ src/usr.bin/make/main.c 2020/10/31 09:23:38 1.415
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.414 2020/10/31 09:20:07 rillig Exp $ */ 1/* $NetBSD: main.c,v 1.415 2020/10/31 09:23:38 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.414 2020/10/31 09:20:07 rillig Exp $"); 121MAKE_RCSID("$NetBSD: main.c,v 1.415 2020/10/31 09:23:38 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 */
@@ -2205,43 +2205,32 @@ mkTempFile(const char *pattern, char **o @@ -2205,43 +2205,32 @@ mkTempFile(const char *pattern, char **o
2205 */ 2205 */
2206Boolean 2206Boolean
2207s2Boolean(const char *s, Boolean bf) 2207s2Boolean(const char *s, Boolean bf)
2208{ 2208{
2209 if (s) { 2209 if (s) {
2210 switch(*s) { 2210 switch(*s) {
2211 case '\0': /* not set - the default wins */ 2211 case '\0': /* not set - the default wins */
2212 break; 2212 break;
2213 case '0': 2213 case '0':
2214 case 'F': 2214 case 'F':
2215 case 'f': 2215 case 'f':
2216 case 'N': 2216 case 'N':
2217 case 'n': 2217 case 'n':
2218 bf = FALSE; 2218 return FALSE;
2219 break; 
2220 case 'O': 2219 case 'O':
2221 case 'o': 2220 case 'o':
2222 switch (s[1]) { 2221 return s[1] != 'F' && s[1] != 'f';
2223 case 'F': 
2224 case 'f': 
2225 bf = FALSE; 
2226 break; 
2227 default: 
2228 bf = TRUE; 
2229 break; 
2230 } 
2231 break; 
2232 default: 2222 default:
2233 bf = TRUE; 2223 return TRUE;
2234 break; 
2235 } 2224 }
2236 } 2225 }
2237 return bf; 2226 return bf;
2238} 2227}
2239 2228
2240/* 2229/*
2241 * Return a Boolean based on setting of a knob. 2230 * Return a Boolean based on setting of a knob.
2242 * 2231 *
2243 * If the knob is not set, the supplied default is the return value. 2232 * If the knob is not set, the supplied default is the return value.
2244 * If set, anything that looks or smells like "No", "False", "Off", "0" etc, 2233 * If set, anything that looks or smells like "No", "False", "Off", "0" etc,
2245 * is FALSE, otherwise TRUE. 2234 * is FALSE, otherwise TRUE.
2246 */ 2235 */
2247Boolean 2236Boolean