From: espie Date: Mon, 4 Sep 2023 11:35:11 +0000 (+0000) Subject: GC old code that was originally implemented to facilitate adoption by X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c9fc29cfc69a20b8ffa3404f847e4bf84cf4130a;p=openbsd GC old code that was originally implemented to facilitate adoption by other BSDs, which never happened, so make things simpler for further development. Ditches config.h entirely since it gets reduced to 2 defines. okay tb@ --- diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index f5ef2dd5eef..7682ba32607 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.64 2020/01/13 15:41:53 espie Exp $ +# $OpenBSD: Makefile,v 1.65 2023/09/04 11:35:11 espie Exp $ PROG= make CFLAGS+= -I${.OBJDIR} -I${.CURDIR} @@ -6,8 +6,7 @@ HOSTCFLAGS+= -I${.OBJDIR} -I${.CURDIR} CDIAGFLAGS=-Wall -W -Wno-char-subscripts -Wstrict-prototypes -pedantic \ -Wmissing-prototypes -Wdeclaration-after-statement -std=c99 -CDEFS+=-DHAS_PATHS_H -CDEFS+=-DHAS_EXTENDED_GETCWD +CDEFS+=-DMAKE_BSIZE=256 -DDEFMAXJOBS=4 #CDEFS+=-DHAS_STATS DPADD += ${LIBUTIL} diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index ef7cdee6234..278574a2d39 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arch.c,v 1.93 2023/02/17 17:59:36 miod Exp $ */ +/* $OpenBSD: arch.c,v 1.94 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */ /* @@ -82,7 +82,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "buf.h" #include "dir.h" diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c index 17365935fa6..92f27d1d614 100644 --- a/usr.bin/make/buf.c +++ b/usr.bin/make/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.29 2020/01/13 13:54:44 espie Exp $ */ +/* $OpenBSD: buf.c,v 1.30 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: buf.c,v 1.9 1996/12/31 17:53:21 christos Exp $ */ /* @@ -75,7 +75,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "buf.h" #include "stats.h" diff --git a/usr.bin/make/cmd_exec.c b/usr.bin/make/cmd_exec.c index 70e28f93f9a..701ad39fbf1 100644 --- a/usr.bin/make/cmd_exec.c +++ b/usr.bin/make/cmd_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_exec.c,v 1.12 2023/08/31 06:53:28 espie Exp $ */ +/* $OpenBSD: cmd_exec.c,v 1.13 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2001 Marc Espie. * @@ -30,7 +30,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "cmd_exec.h" #include "buf.h" diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 97f0524ec13..57a9eb4e591 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat.c,v 1.93 2020/01/26 12:41:21 espie Exp $ */ +/* $OpenBSD: compat.c,v 1.94 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* @@ -40,7 +40,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "dir.h" #include "engine.h" diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index a78e839521f..65a21d5cbf5 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cond.c,v 1.54 2019/12/21 15:29:25 espie Exp $ */ +/* $OpenBSD: cond.c,v 1.55 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */ /* @@ -42,7 +42,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "dir.h" #include "buf.h" diff --git a/usr.bin/make/config.h b/usr.bin/make/config.h deleted file mode 100644 index f077d968124..00000000000 --- a/usr.bin/make/config.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -/* $OpenBSD: config.h,v 1.21 2022/01/05 02:00:55 jsg Exp $ */ -/* $NetBSD: config.h,v 1.7 1996/11/06 17:59:03 christos Exp $ */ - -/* - * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. - * Copyright (c) 1988, 1989 by Adam de Boor - * Copyright (c) 1989 by Berkeley Softworks - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Adam de Boor. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)config.h 8.1 (Berkeley) 6/6/93 - */ - -#define DEFSHELL 1 /* Bourne shell */ - -/* - * DEFMAXJOBS - * This controls the default concurrency. On no occasion will more - * than DEFMAXJOBS targets be created at once. - */ -#define DEFMAXJOBS 4 - -/* - * SYSVINCLUDE - * Recognize system V like include directives [include "filename"] - * SYSVVARSUB - * Recognize system V like ${VAR:x=y} variable substitutions - */ -#define SYSVINCLUDE -#define SYSVVARSUB - -/* - * SUNSHCMD - * Recognize SunOS and Solaris: - * VAR :sh= CMD # Assign VAR to the command substitution of CMD - * ${VAR:sh} # Return the command substitution of the value - * # of ${VAR} - */ -#define SUNSHCMD - -#ifdef HAS_EXTENDED_GETCWD -#define dogetcwd() getcwd(NULL, 0) -#else -#define dogetcwd() getcwd(emalloc(PATH_MAX), PATH_MAX) -#endif - -#ifdef SYSVINCLUDE -#define DOFEATURE_SYSVINCLUDE FEATURE_SYSVINCLUDE -#else -#define DOFEATURE_SYSVINCLUDE 0 -#endif -#ifdef SYSVVARSUB -#define DOFEATURE_SYSVVARSUB FEATURE_SYSVVARSUB -#else -#define DOFEATURE_SYSVVARSUB 0 -#endif -#ifdef SUNSHCMD -#define DOFEATURE_SUNSHCMD FEATURE_SUNSHCMD -#else -#define DOFEATURE_SUNSHCMD 0 -#endif - -#ifndef DEFAULT_FEATURES -#define DEFAULT_FEATURES (FEATURE_UPPERLOWER | DOFEATURE_SYSVVARSUB | DOFEATURE_SYSVINCLUDE | DOFEATURE_SUNSHCMD | FEATURE_RECVARS | FEATURE_CONDINCLUDE) -#endif - -#define FEATURES(x) ((DEFAULT_FEATURES & (x)) != 0) -#define FEATURE_ODE 1 -#define FEATURE_UNIQ 2 -#define FEATURE_SORT 4 -#define FEATURE_UPPERLOWER 8 -#define FEATURE_SYSVVARSUB 16 -#define FEATURE_SYSVINCLUDE 32 -#define FEATURE_SUNSHCMD 64 -#define FEATURE_RECVARS 128 -#define FEATURE_CONDINCLUDE 256 -#define FEATURE_ASSIGN 512 -#define FEATURE_EXECMOD 1024 - -/* - * There are several places where expandable buffers are used (parse.c and - * var.c). This constant is merely the starting point for those buffers. If - * lines tend to be much shorter than this, it would be best to reduce BSIZE. - * If longer, it should be increased. Reducing it will cause more copying to - * be done for longer lines, but will save space for shorter ones. In any - * case, it ought to be a power of two simply because most storage allocation - * schemes allocate in powers of two. - */ -#define MAKE_BSIZE 256 /* starting size for expandable buffers */ - -#endif diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 7e820f8a7fe..d580fb04691 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.68 2016/10/21 16:12:38 espie Exp $ */ +/* $OpenBSD: dir.c,v 1.69 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */ /* @@ -70,7 +70,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "dir.h" #include "lst.h" diff --git a/usr.bin/make/direxpand.c b/usr.bin/make/direxpand.c index 3335e8cfe25..115bb2847cf 100644 --- a/usr.bin/make/direxpand.c +++ b/usr.bin/make/direxpand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: direxpand.c,v 1.8 2016/10/21 16:12:38 espie Exp $ */ +/* $OpenBSD: direxpand.c,v 1.9 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 1999,2007 Marc Espie. * @@ -62,7 +62,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "lst.h" #include "dir.h" diff --git a/usr.bin/make/engine.c b/usr.bin/make/engine.c index 193c038d9ab..a4c518601ac 100644 --- a/usr.bin/make/engine.c +++ b/usr.bin/make/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.72 2023/08/31 06:53:28 espie Exp $ */ +/* $OpenBSD: engine.c,v 1.73 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2012 Marc Espie. * @@ -73,7 +73,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "cmd_exec.h" #include "dir.h" diff --git a/usr.bin/make/enginechoice.c b/usr.bin/make/enginechoice.c index 1b2e62e805a..55d9fd38207 100644 --- a/usr.bin/make/enginechoice.c +++ b/usr.bin/make/enginechoice.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enginechoice.c,v 1.3 2021/03/04 09:34:30 espie Exp $ */ +/* $OpenBSD: enginechoice.c,v 1.4 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2020 Marc Espie. * @@ -23,7 +23,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" #include "defines.h" #include "compat.h" #include "make.h" diff --git a/usr.bin/make/error.c b/usr.bin/make/error.c index 6606f5b6d1c..fd6afa06b40 100644 --- a/usr.bin/make/error.c +++ b/usr.bin/make/error.c @@ -1,4 +1,4 @@ -/* $OpenBSD: error.c,v 1.25 2015/09/27 16:58:16 guenther Exp $ */ +/* $OpenBSD: error.c,v 1.26 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2001 Marc Espie. @@ -31,7 +31,6 @@ #include #include -#include "config.h" #include "defines.h" #include "error.h" #include "job.h" diff --git a/usr.bin/make/expandchildren.c b/usr.bin/make/expandchildren.c index 1e8f2e20916..a259c30c189 100644 --- a/usr.bin/make/expandchildren.c +++ b/usr.bin/make/expandchildren.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expandchildren.c,v 1.2 2020/01/26 12:41:21 espie Exp $ */ +/* $OpenBSD: expandchildren.c,v 1.3 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -44,7 +44,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "direxpand.h" #include "engine.h" diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index e285d2a6a29..5997da2da05 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,4 +1,4 @@ -/* $OpenBSD: for.c,v 1.47 2017/12/05 17:47:09 millert Exp $ */ +/* $OpenBSD: for.c,v 1.48 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */ /* @@ -63,7 +63,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "buf.h" #include "for.h" diff --git a/usr.bin/make/init.c b/usr.bin/make/init.c index ae8d6897117..8c85c61e035 100644 --- a/usr.bin/make/init.c +++ b/usr.bin/make/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.9 2023/08/31 06:53:28 espie Exp $ */ +/* $OpenBSD: init.c,v 1.10 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2001 Marc Espie. @@ -26,7 +26,6 @@ */ #include #include "defines.h" -#include "config.h" #include "init.h" #include "timestamp.h" #include "stats.h" diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index b7dbe32e765..09fce16d0bb 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.164 2023/03/08 04:43:11 guenther Exp $ */ +/* $OpenBSD: job.c,v 1.165 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -93,7 +93,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "job.h" #include "engine.h" diff --git a/usr.bin/make/lowparse.c b/usr.bin/make/lowparse.c index 54f0f95a7d7..ae97609865f 100644 --- a/usr.bin/make/lowparse.c +++ b/usr.bin/make/lowparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lowparse.c,v 1.35 2016/10/21 16:12:38 espie Exp $ */ +/* $OpenBSD: lowparse.c,v 1.36 2023/09/04 11:35:11 espie Exp $ */ /* low-level parsing functions. */ @@ -35,7 +35,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "buf.h" #include "lowparse.h" diff --git a/usr.bin/make/lst.lib/lstInt.h b/usr.bin/make/lst.lib/lstInt.h index f88a8ba8785..4b6d2845735 100644 --- a/usr.bin/make/lst.lib/lstInt.h +++ b/usr.bin/make/lst.lib/lstInt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lstInt.h,v 1.15 2010/07/19 19:46:44 espie Exp $ */ +/* $OpenBSD: lstInt.h,v 1.16 2023/09/04 11:35:12 espie Exp $ */ /* $NetBSD: lstInt.h,v 1.7 1996/11/06 17:59:44 christos Exp $ */ /* @@ -42,7 +42,6 @@ #ifndef _LSTINT_H_ #define _LSTINT_H_ -#include "config.h" #include "defines.h" #include "lst.h" diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 2ffd8456ca8..5f602e4e0d7 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.131 2023/07/08 21:51:45 jmc Exp $ */ +/* $OpenBSD: main.c,v 1.132 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */ /* @@ -45,7 +45,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "var.h" #include "lowparse.h" @@ -517,7 +516,7 @@ figure_out_CURDIR() struct stat sa, sb; /* curdir is cwd... */ - cwd = dogetcwd(); + cwd = getcwd(NULL, 0); if (cwd == NULL) err(2, "getcwd"); diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index bf3443346b3..f3700c7d6ff 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make.c,v 1.83 2023/07/08 18:42:27 espie Exp $ */ +/* $OpenBSD: make.c,v 1.84 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* @@ -64,7 +64,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "dir.h" #include "job.h" diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 19f7c83e46f..ce1e2c0e7cc 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.135 2023/05/30 04:42:21 espie Exp $ */ +/* $OpenBSD: parse.c,v 1.136 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* @@ -68,7 +68,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "dir.h" #include "direxpand.h" @@ -1555,23 +1554,20 @@ parse_as_special_line(Buffer buf, Buffer copy, const char *line) { if (*line == '.' && handle_bsd_command(buf, copy, line+1)) return true; - if (FEATURES(FEATURE_SYSVINCLUDE) && - strncmp(line, "include", 7) == 0 && + if (strncmp(line, "include", 7) == 0 && ISSPACE(line[7]) && strchr(line, ':') == NULL) { /* It's an S3/S5-style "include". */ lookup_sysv_include(line + 7, "include"); return true; } - if (FEATURES(FEATURE_CONDINCLUDE) && - strncmp(line, "sinclude", 8) == 0 && + if (strncmp(line, "sinclude", 8) == 0 && ISSPACE(line[8]) && strchr(line, ':') == NULL) { lookup_conditional_include(line+8, "sinclude"); return true; } - if (FEATURES(FEATURE_CONDINCLUDE) && - strncmp(line, "-include", 8) == 0 && + if (strncmp(line, "-include", 8) == 0 && ISSPACE(line[8]) && strchr(line, ':') == NULL) { lookup_conditional_include(line+8, "-include"); diff --git a/usr.bin/make/parsevar.c b/usr.bin/make/parsevar.c index 80791272767..c90ed89e045 100644 --- a/usr.bin/make/parsevar.c +++ b/usr.bin/make/parsevar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parsevar.c,v 1.16 2016/10/23 14:54:14 espie Exp $ */ +/* $OpenBSD: parsevar.c,v 1.17 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* @@ -30,7 +30,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "var.h" #include "varname.h" @@ -84,8 +83,7 @@ parse_variable_assignment(const char *line, int ctxt) int type; struct Name name; - arg = VarName_Get(line, &name, NULL, true, - FEATURES(FEATURE_SUNSHCMD) ? find_op1 : find_op2); + arg = VarName_Get(line, &name, NULL, true, find_op1); while (ISSPACE(*arg)) arg++; @@ -113,8 +111,7 @@ parse_variable_assignment(const char *line, int ctxt) break; case ':': - if (FEATURES(FEATURE_SUNSHCMD) && - strncmp(arg, "sh", 2) == 0) { + if (strncmp(arg, "sh", 2) == 0) { type = VAR_SUNSHELL; arg += 2; while (*arg != '=' && *arg != '\0') diff --git a/usr.bin/make/stats.c b/usr.bin/make/stats.c index e20cf1fe9e1..b02ed64cdd0 100644 --- a/usr.bin/make/stats.c +++ b/usr.bin/make/stats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stats.c,v 1.11 2014/04/22 12:21:17 espie Exp $ */ +/* $OpenBSD: stats.c,v 1.12 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 1999 Marc Espie. @@ -34,7 +34,6 @@ to allow for concurrent adjustment to variables. */ -#include "config.h" #include "defines.h" #include "stats.h" diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index 8e92350ed38..ce25b172db4 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -1,4 +1,4 @@ -/* $OpenBSD: str.c,v 1.32 2019/05/21 17:21:02 espie Exp $ */ +/* $OpenBSD: str.c,v 1.33 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: str.c,v 1.13 1996/11/06 17:59:23 christos Exp $ */ /*- @@ -37,7 +37,6 @@ #include #include -#include "config.h" #include "defines.h" #include "str.h" #include "memory.h" diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 2a12bbc0200..e9cab43bf73 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: suff.c,v 1.102 2020/01/13 15:41:53 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.103 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -48,7 +48,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "dir.h" #include "engine.h" diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 7ca2cda86d5..9e65e6a3e08 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: targ.c,v 1.85 2020/01/26 12:41:21 espie Exp $ */ +/* $OpenBSD: targ.c,v 1.86 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */ /* @@ -102,7 +102,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "stats.h" #include "suff.h" diff --git a/usr.bin/make/targequiv.c b/usr.bin/make/targequiv.c index b251c775d79..8325e9e159d 100644 --- a/usr.bin/make/targequiv.c +++ b/usr.bin/make/targequiv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: targequiv.c,v 1.9 2019/12/21 15:29:25 espie Exp $ */ +/* $OpenBSD: targequiv.c,v 1.10 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2007-2008 Marc Espie. * @@ -37,7 +37,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "memory.h" #include "gnode.h" diff --git a/usr.bin/make/timestamp.c b/usr.bin/make/timestamp.c index ad1a282880e..2029d6b62ad 100644 --- a/usr.bin/make/timestamp.c +++ b/usr.bin/make/timestamp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timestamp.c,v 1.10 2013/05/22 12:14:08 espie Exp $ */ +/* $OpenBSD: timestamp.c,v 1.11 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2001 Marc Espie. @@ -27,7 +27,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "timestamp.h" diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 5ae52dddb46..65f938180f3 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.105 2023/08/10 10:52:43 espie Exp $ */ +/* $OpenBSD: var.c,v 1.106 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -69,7 +69,6 @@ #include #include -#include "config.h" #include "defines.h" #include "buf.h" #include "cmd_exec.h" diff --git a/usr.bin/make/varmodifiers.c b/usr.bin/make/varmodifiers.c index 1cbcfe8e7d1..8ad0255394d 100644 --- a/usr.bin/make/varmodifiers.c +++ b/usr.bin/make/varmodifiers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: varmodifiers.c,v 1.48 2020/08/30 12:16:04 tb Exp $ */ +/* $OpenBSD: varmodifiers.c,v 1.49 2023/09/04 11:35:11 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -65,6 +65,7 @@ * is also called directly by Var_SubstVar. */ +#include #include #include #include @@ -72,7 +73,6 @@ #include #include #include -#include "config.h" #include "defines.h" #include "buf.h" #include "var.h" @@ -100,7 +100,7 @@ #define VAR_BANG_EQUAL 0x100 typedef struct { - char *lbuffer; /* left string to free */ + char *lbuffer; /* Left string to free */ char *lhs; /* String to match */ size_t leftLen; /* Length of string */ char *rhs; /* Replacement string (w/ &'s removed) */ @@ -108,12 +108,6 @@ typedef struct { int flags; } VarPattern; -struct LoopStuff { - struct LoopVar *var; - char *expand; - bool err; -}; - static bool VarHead(struct Name *, bool, Buffer, void *); static bool VarTail(struct Name *, bool, Buffer, void *); static bool VarSuffix(struct Name *, bool, Buffer, void *); @@ -121,8 +115,6 @@ static bool VarRoot(struct Name *, bool, Buffer, void *); static bool VarMatch(struct Name *, bool, Buffer, void *); static bool VarSYSVMatch(struct Name *, bool, Buffer, void *); static bool VarNoMatch(struct Name *, bool, Buffer, void *); -static bool VarUniq(struct Name *, bool, Buffer, void *); -static bool VarLoop(struct Name *, bool, Buffer, void *); static void VarREError(int, regex_t *, const char *); @@ -149,62 +141,36 @@ static char *do_upper(const char *, const struct Name *, void *); static char *do_lower(const char *, const struct Name *, void *); static void *check_shcmd(const char **, SymTable *, bool, int); static char *do_shcmd(const char *, const struct Name *, void *); -static char *do_sort(const char *, const struct Name *, void *); -static char *finish_loop(const char *, const struct Name *, void *); -static int NameCompare(const void *, const void *); -static char *do_label(const char *, const struct Name *, void *); -static char *do_path(const char *, const struct Name *, void *); -static char *do_def(const char *, const struct Name *, void *); -static char *do_undef(const char *, const struct Name *, void *); -static char *do_assign(const char *, const struct Name *, void *); -static char *do_exec(const char *, const struct Name *, void *); - -static void *assign_get_value(const char **, SymTable *, bool, int); -static void *get_cmd(const char **, SymTable *, bool, int); -static void *get_value(const char **, SymTable *, bool, int); static void *get_stringarg(const char **, SymTable *, bool, int); static void free_stringarg(void *); static void *get_patternarg(const char **, SymTable *, bool, int); static void *get_spatternarg(const char **, SymTable *, bool, int); static void *common_get_patternarg(const char **, SymTable *, bool, int, bool); static void free_patternarg(void *); -static void free_looparg(void *); static void *get_sysvpattern(const char **, SymTable *, bool, int); -static void *get_loop(const char **, SymTable *, bool, int); -static char *LoopGrab(const char **); static struct Name dummy; static struct Name *dummy_arg = &dummy; static struct modifier { - bool atstart; void * (*getarg)(const char **, SymTable *, bool, int); char * (*apply)(const char *, const struct Name *, void *); bool (*word_apply)(struct Name *, bool, Buffer, void *); void (*freearg)(void *); } *choose_mod[256], - match_mod = {false, get_stringarg, NULL, VarMatch, free_stringarg}, - nomatch_mod = {false, get_stringarg, NULL, VarNoMatch, free_stringarg}, - subst_mod = {false, get_spatternarg, NULL, VarSubstitute, free_patternarg}, - resubst_mod = {false, get_patternarg, do_regex, NULL, free_patternarg}, - quote_mod = {false, check_quote, VarQuote, NULL , free}, - tail_mod = {false, check_empty, NULL, VarTail, NULL}, - head_mod = {false, check_empty, NULL, VarHead, NULL}, - suffix_mod = {false, check_empty, NULL, VarSuffix, NULL}, - root_mod = {false, check_empty, NULL, VarRoot, NULL}, - upper_mod = {false, check_empty, do_upper, NULL, NULL}, - lower_mod = {false, check_empty, do_lower, NULL, NULL}, - shcmd_mod = {false, check_shcmd, do_shcmd, NULL, NULL}, - sysv_mod = {false, get_sysvpattern, NULL, VarSYSVMatch, free_patternarg}, - uniq_mod = {false, check_empty, NULL, VarUniq, NULL}, - sort_mod = {false, check_empty, do_sort, NULL, NULL}, - loop_mod = {false, get_loop, finish_loop, VarLoop, free_looparg}, - undef_mod = {true, get_value, do_undef, NULL, NULL}, - def_mod = {true, get_value, do_def, NULL, NULL}, - label_mod = {true, check_empty, do_label, NULL, NULL}, - path_mod = {true, check_empty, do_path, NULL, NULL}, - assign_mod = {true, assign_get_value, do_assign, NULL, free_patternarg}, - exec_mod = {true, get_cmd, do_exec, NULL, free_patternarg} + match_mod = {get_stringarg, NULL, VarMatch, free_stringarg}, + nomatch_mod = {get_stringarg, NULL, VarNoMatch, free_stringarg}, + subst_mod = {get_spatternarg, NULL, VarSubstitute, free_patternarg}, + resubst_mod = {get_patternarg, do_regex, NULL, free_patternarg}, + quote_mod = {check_quote, VarQuote, NULL , free}, + tail_mod = {check_empty, NULL, VarTail, NULL}, + head_mod = {check_empty, NULL, VarHead, NULL}, + suffix_mod = {check_empty, NULL, VarSuffix, NULL}, + root_mod = {check_empty, NULL, VarRoot, NULL}, + upper_mod = {check_empty, do_upper, NULL, NULL}, + lower_mod = {check_empty, do_lower, NULL, NULL}, + shcmd_mod = {check_shcmd, do_shcmd, NULL, NULL}, + sysv_mod = {get_sysvpattern, NULL, VarSYSVMatch, free_patternarg} ; void @@ -219,27 +185,9 @@ VarModifiers_Init() choose_mod['H'] = &head_mod; choose_mod['E'] = &suffix_mod; choose_mod['R'] = &root_mod; - if (FEATURES(FEATURE_UPPERLOWER)) { - choose_mod['U'] = &upper_mod; - choose_mod['L'] = &lower_mod; - } - if (FEATURES(FEATURE_SUNSHCMD)) - choose_mod['s'] = &shcmd_mod; - if (FEATURES(FEATURE_UNIQ)) - choose_mod['u'] = &uniq_mod; - if (FEATURES(FEATURE_SORT)) - choose_mod['O'] = &sort_mod; - if (FEATURES(FEATURE_ODE)) { - choose_mod['@'] = &loop_mod; - choose_mod['D'] = &def_mod; - choose_mod['U'] = &undef_mod; - choose_mod['L'] = &label_mod; - choose_mod['P'] = &path_mod; - } - if (FEATURES(FEATURE_ASSIGN)) - choose_mod[':'] = &assign_mod; - if (FEATURES(FEATURE_EXECMOD)) - choose_mod['!'] = &exec_mod; + choose_mod['U'] = &upper_mod; + choose_mod['L'] = &lower_mod; + choose_mod['s'] = &shcmd_mod; } /* All modifiers handle addSpace (need to add a space before placing the @@ -345,8 +293,7 @@ VarRoot(struct Name *word, bool addSpace, Buffer buf, void *dummy UNUSED) *----------------------------------------------------------------------- */ static bool -VarMatch(struct Name *word, bool addSpace, Buffer buf, - void *pattern) /* Pattern the word must match */ +VarMatch(struct Name *word, bool addSpace, Buffer buf, void *pattern) { const char *pat = pattern; @@ -366,8 +313,7 @@ VarMatch(struct Name *word, bool addSpace, Buffer buf, *----------------------------------------------------------------------- */ static bool -VarNoMatch(struct Name *word, bool addSpace, Buffer buf, - void *pattern) /* Pattern the word must not match */ +VarNoMatch(struct Name *word, bool addSpace, Buffer buf, void *pattern) { const char *pat = pattern; @@ -380,198 +326,6 @@ VarNoMatch(struct Name *word, bool addSpace, Buffer buf, return addSpace; } -static bool -VarUniq(struct Name *word, bool addSpace, Buffer buf, void *lastp) -{ - struct Name *last = lastp; - - /* does not match */ - if (last->s == NULL || last->e - last->s != word->e - word->s || - strncmp(word->s, last->s, word->e - word->s) != 0) { - if (addSpace) - Buf_AddSpace(buf); - Buf_Addi(buf, word->s, word->e); - addSpace = true; - } - last->s = word->s; - last->e = word->e; - return addSpace; -} - -static bool -VarLoop(struct Name *word, bool addSpace, Buffer buf, void *vp) -{ - struct LoopStuff *v = vp; - - if (addSpace) - Buf_AddSpace(buf); - Var_SubstVar(buf, v->expand, v->var, word->s); - return true; -} - -static char * -finish_loop(const char *s, const struct Name *n UNUSED , void *p) -{ - struct LoopStuff *l = p; - - return Var_Subst(s, NULL, l->err); -} - -static int -NameCompare(const void *ap, const void *bp) -{ - const struct Name *a, *b; - size_t n, m; - int c; - - a = ap; - b = bp; - n = a->e - a->s; - m = b->e - b->s; - if (n < m) { - c = strncmp(a->s, b->s, n); - if (c != 0) - return c; - else - return -1; - } else if (m < n) { - c = strncmp(a->s, b->s, m); - if (c != 0) - return c; - else - return 1; - } else - return strncmp(a->s, b->s, n); -} - -static char * -do_sort(const char *s, const struct Name *dummy UNUSED, void *arg UNUSED) -{ - struct Name *t; - unsigned long n, i, j; - const char *start, *end; - - n = 1024; /* start at 1024 words */ - t = ereallocarray(NULL, n, sizeof(struct Name)); - start = s; - end = start; - - for (i = 0;; i++) { - if (i == n) { - n *= 2; - t = ereallocarray(t, n, sizeof(struct Name)); - } - start = iterate_words(&end); - if (start == NULL) - break; - t[i].s = start; - t[i].e = end; - } - if (i > 0) { - BUFFER buf; - - Buf_Init(&buf, end - s); - qsort(t, i, sizeof(struct Name), NameCompare); - Buf_Addi(&buf, t[0].s, t[0].e); - for (j = 1; j < i; j++) { - Buf_AddSpace(&buf); - Buf_Addi(&buf, t[j].s, t[j].e); - } - free(t); - return Buf_Retrieve(&buf); - } else { - free(t); - return ""; - } -} - -static char * -do_label(const char *s UNUSED, const struct Name *n, void *arg UNUSED) -{ - return Str_dupi(n->s, n->e); -} - -static char * -do_path(const char *s UNUSED, const struct Name *n, void *arg UNUSED) -{ - GNode *gn; - - gn = Targ_FindNodei(n->s, n->e, TARG_NOCREATE); - if (gn == NULL) - return Str_dupi(n->s, n->e); - else - return strdup(gn->path); -} - -static char * -do_def(const char *s, const struct Name *n UNUSED, void *arg) -{ - VarPattern *v = arg; - if (s == NULL) { - free_patternarg(v); - return NULL; - } else - return v->lbuffer; -} - -static char * -do_undef(const char *s, const struct Name *n UNUSED, void *arg) -{ - VarPattern *v = arg; - if (s != NULL) { - free_patternarg(v); - return NULL; - } else - return v->lbuffer; -} - -static char * -do_assign(const char *s, const struct Name *n, void *arg) -{ - VarPattern *v = arg; - char *msg; - char *result; - - switch (v->flags) { - case VAR_EQUAL: - Var_Seti(n->s, n->e, v->lbuffer); - break; - case VAR_MAY_EQUAL: - if (s == NULL) - Var_Seti(n->s, n->e, v->lbuffer); - break; - case VAR_ADD_EQUAL: - if (s == NULL) - Var_Seti(n->s, n->e, v->lbuffer); - else - Var_Appendi(n->s, n->e, v->lbuffer); - break; - case VAR_BANG_EQUAL: - result = Cmd_Exec(v->lbuffer, &msg); - if (result != NULL) { - Var_Seti(n->s, n->e, result); - free(result); - } else - Error(msg, v->lbuffer); - break; - - } - return NULL; -} - -static char * -do_exec(const char *s UNUSED, const struct Name *n UNUSED, void *arg) -{ - VarPattern *v = arg; - char *msg; - char *result; - - result = Cmd_Exec(v->lbuffer, &msg); - if (result == NULL) - Error(msg, v->lbuffer); - return result; -} - /*- *----------------------------------------------------------------------- * VarSYSVMatch -- @@ -958,7 +712,7 @@ VarRESubstitute(struct Name *word, bool addSpace, Buffer buf, void *patternp) *----------------------------------------------------------------------- * VarModify -- * Modify each of the words of the passed string using the given - * function. Used to implement all modifiers. + * function. Used to implement most modifiers. * * Results: * A string of all the words modified appropriately. @@ -1218,56 +972,6 @@ get_spatternarg(const char **p, SymTable *ctxt, bool err, int endc) return common_get_patternarg(p, ctxt, err, endc, true); } -static void -free_looparg(void *arg) -{ - struct LoopStuff *l = arg; - - Var_DeleteLoopVar(l->var); - free(l->expand); -} - -static char * -LoopGrab(const char **s) -{ - const char *p, *start; - - start = *s; - for (p = start; *p != '@'; p++) { - if (*p == '\\') - p++; - if (*p == 0) - return NULL; - } - *s = p+1; - return escape_dupi(start, p, "@\\"); -} - -static void * -get_loop(const char **p, SymTable *ctxt UNUSED, bool err, int endc) -{ - static struct LoopStuff loop; - const char *s; - const char *var; - - s = *p +1; - - loop.var = NULL; - loop.expand = NULL; - loop.err = err; - var = LoopGrab(&s); - if (var != NULL) { - loop.expand = LoopGrab(&s); - if (*s == endc || *s == ':') { - *p = s; - loop.var = Var_NewLoopVar(var, NULL); - return &loop; - } - } - free_looparg(&loop); - return NULL; -} - static void * common_get_patternarg(const char **p, SymTable *ctxt, bool err, int endc, bool dosubst) @@ -1328,71 +1032,6 @@ common_get_patternarg(const char **p, SymTable *ctxt, bool err, int endc, return NULL; } -static void * -assign_get_value(const char **p, SymTable *ctxt, bool err, int endc) -{ - const char *s; - int flags; - VarPattern *arg; - - s = *p + 1; - if (s[0] == '=') - flags = VAR_EQUAL; - else if (s[0] == '?' && s[1] == '=') - flags = VAR_MAY_EQUAL; - else if (s[0] == '+' && s[1] == '=') - flags = VAR_ADD_EQUAL; - else if (s[0] == '!' && s[1] == '=') - flags = VAR_BANG_EQUAL; - else - return NULL; - - arg = get_value(&s, ctxt, err, endc); - if (arg != NULL) { - *p = s; - arg->flags = flags; - } - return arg; -} - -static void * -get_value(const char **p, SymTable *ctxt, bool err, int endc) -{ - VarPattern *pattern; - const char *s; - - pattern = emalloc(sizeof(VarPattern)); - s = *p + 1; - pattern->rhs = NULL; - pattern->lbuffer = VarGetPattern(ctxt, err, &s, ':', endc, - &pattern->leftLen, NULL); - if (s[-1] == endc || s[-1] == ':') { - *p = s-1; - return pattern; - } - free_patternarg(pattern); - return NULL; -} - -static void * -get_cmd(const char **p, SymTable *ctxt, bool err, int endc UNUSED) -{ - VarPattern *pattern; - const char *s; - - pattern = emalloc(sizeof(VarPattern)); - s = *p + 1; - pattern->rhs = NULL; - pattern->lbuffer = VarGetPattern(ctxt, err, &s, '!', '!', - &pattern->leftLen, NULL); - if (s[-1] == '!') { - *p = s-1; - return pattern; - } - free_patternarg(pattern); - return NULL; -} - static void free_patternarg(void *p) { @@ -1435,7 +1074,6 @@ VarModifiers_Apply(char *str, const struct Name *name, SymTable *ctxt, bool err, bool *freePtr, const char **pscan, int paren) { const char *tstr; - bool atstart; /* Some ODE modifiers only make sense at start */ char endc = paren == '(' ? ')' : '}'; const char *start = *pscan; @@ -1462,7 +1100,6 @@ VarModifiers_Apply(char *str, const struct Name *name, SymTable *ctxt, * the invocation. */ - atstart = true; while (*tstr != endc && *tstr != '\0') { struct modifier *mod; void *arg; @@ -1479,26 +1116,18 @@ VarModifiers_Apply(char *str, const struct Name *name, SymTable *ctxt, mod = choose_mod[(unsigned char)*tstr]; arg = NULL; - if (mod != NULL && (!mod->atstart || atstart)) + if (mod != NULL) arg = mod->getarg(&tstr, ctxt, err, endc); - if (FEATURES(FEATURE_SYSVVARSUB) && arg == NULL) { + if (arg == NULL) { mod = &sysv_mod; arg = mod->getarg(&tstr, ctxt, err, endc); } - atstart = false; if (arg != NULL) { - if (str != NULL || (mod->atstart && name != NULL)) { + if (str != NULL) { if (mod->word_apply != NULL) { newStr = VarModify(str, mod->word_apply, arg); - if (mod->apply != NULL) { - char *newStr2; - - newStr2 = mod->apply(newStr, - name, arg); - free(newStr); - newStr = newStr2; - } + assert(mod->apply == NULL); } else newStr = mod->apply(str, name, arg); if (*freePtr) diff --git a/usr.bin/make/varname.c b/usr.bin/make/varname.c index b54802f480d..66ea464c027 100644 --- a/usr.bin/make/varname.c +++ b/usr.bin/make/varname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: varname.c,v 1.6 2012/08/25 08:12:56 espie Exp $ */ +/* $OpenBSD: varname.c,v 1.7 2023/09/04 11:35:11 espie Exp $ */ /* * Copyright (c) 2001 Marc Espie. * @@ -25,7 +25,6 @@ */ #include -#include "config.h" #include "defines.h" #include "var.h" #include "buf.h" @@ -39,11 +38,6 @@ VarName_Get(const char *start, struct Name *name, SymTable *ctxt, bool err, size_t len; p = cont(start); - /* If we don't want recursive variables, we skip over '$' */ - if (!FEATURES(FEATURE_RECVARS)) { - while (*p == '$') - p = cont(p+1); - } if (*p != '$') { name->s = start; name->e = p;