CVS commit: src/usr.bin/lam
Module Name:src Committed By: dholland Date: Mon Oct 26 04:09:32 UTC 2020 Modified Files: src/usr.bin/lam: lam.1 Log Message: Clarify the behavior of -S further in lam(1). Seems that "lam file1 -S sep file2" does not carry the -S over past file2, even though you can also write "lam file1 file2 -[sS] sep" to give a separator string after the last file. Ride previous date bump. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/lam/lam.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/lam/lam.1 diff -u src/usr.bin/lam/lam.1:1.13 src/usr.bin/lam/lam.1:1.14 --- src/usr.bin/lam/lam.1:1.13 Mon Oct 26 03:51:54 2020 +++ src/usr.bin/lam/lam.1 Mon Oct 26 04:09:32 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: lam.1,v 1.13 2020/10/26 03:51:54 dholland Exp $ +.\" $NetBSD: lam.1,v 1.14 2020/10/26 04:09:32 dholland Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -89,6 +89,8 @@ Print .Ar sepstring before printing line fragments from the next file. This option may appear after the last file. +(A capitalized version appearing before the last file is not carried +over past the last file.) .It Fl t Ar c The input line terminator is .Ar c
CVS commit: src/usr.bin/lam
Module Name:src Committed By: dholland Date: Mon Oct 26 03:51:54 UTC 2020 Modified Files: src/usr.bin/lam: lam.1 Log Message: Improve previous lam(1) change. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/lam/lam.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/lam/lam.1 diff -u src/usr.bin/lam/lam.1:1.12 src/usr.bin/lam/lam.1:1.13 --- src/usr.bin/lam/lam.1:1.12 Mon Oct 26 03:46:57 2020 +++ src/usr.bin/lam/lam.1 Mon Oct 26 03:51:54 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: lam.1,v 1.12 2020/10/26 03:46:57 dholland Exp $ +.\" $NetBSD: lam.1,v 1.13 2020/10/26 03:51:54 dholland Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -111,6 +111,9 @@ lam file1 \-S " " file2 file3 file4 .Ed .Pp +(with a literal newline; the means for inserting one may depend on +your shell.) +.Pp Every 2 lines of a file may be joined on one line with .Bd -literal -offset indent lam \- \- < file
CVS commit: src/usr.bin/lam
Module Name:src Committed By: dholland Date: Mon Oct 26 03:46:57 UTC 2020 Modified Files: src/usr.bin/lam: lam.1 Log Message: Fix the second example in lam(1). (a) revert -r1.8 (changing -s back to -S) as it was wrong; (b) get rid of the backslash since it doesn't belong. (c) bump date. Noted by Robert Elz. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/lam/lam.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/lam/lam.1 diff -u src/usr.bin/lam/lam.1:1.11 src/usr.bin/lam/lam.1:1.12 --- src/usr.bin/lam/lam.1:1.11 Mon Jul 3 21:34:19 2017 +++ src/usr.bin/lam/lam.1 Mon Oct 26 03:46:57 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: lam.1,v 1.11 2017/07/03 21:34:19 wiz Exp $ +.\" $NetBSD: lam.1,v 1.12 2020/10/26 03:46:57 dholland Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)lam.1 8.1 (Berkeley) 6/6/93 .\" -.Dd January 5, 2016 +.Dd October 25, 2020 .Dt LAM 1 .Os .Sh NAME @@ -107,7 +107,7 @@ lam file1 file2 file3 file4 joins 4 files together along each line. To merge the lines from four different files use .Bd -literal -offset indent -lam file1 \-s "\e +lam file1 \-S " " file2 file3 file4 .Ed .Pp
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 22:13:53 UTC 2020 Modified Files: src/usr.bin/make: suff.c src/usr.bin/make/unit-tests: suff-lookup.exp Log Message: make(1): properly terminate debug output with newline Without this, NetBSD's sed adds the missing newline at the end of the file, while other sed implementations don't do that. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/usr.bin/make/suff.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/suff-lookup.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.225 src/usr.bin/make/suff.c:1.226 --- src/usr.bin/make/suff.c:1.225 Sun Oct 25 21:51:49 2020 +++ src/usr.bin/make/suff.c Sun Oct 25 22:13:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.225 2020/10/25 21:51:49 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.226 2020/10/25 22:13:53 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -129,7 +129,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.225 2020/10/25 21:51:49 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.226 2020/10/25 22:13:53 rillig Exp $"); #define SUFF_DEBUG0(text) DEBUG0(SUFF, text) #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1) @@ -1348,13 +1348,11 @@ Suff_FindPath(GNode* gn) } if (suff != NULL) { - SUFF_DEBUG1("suffix is \"%s\"...", suff->name); + SUFF_DEBUG1("suffix is \"%s\"...\n", suff->name); return suff->searchPath; } else { - /* - * Use default search path - */ - return dirSearchPath; +SUFF_DEBUG0("\n"); + return dirSearchPath; /* Use default search path */ } } Index: src/usr.bin/make/unit-tests/suff-lookup.exp diff -u src/usr.bin/make/unit-tests/suff-lookup.exp:1.2 src/usr.bin/make/unit-tests/suff-lookup.exp:1.3 --- src/usr.bin/make/unit-tests/suff-lookup.exp:1.2 Sat Oct 24 03:18:22 2020 +++ src/usr.bin/make/unit-tests/suff-lookup.exp Sun Oct 25 22:13:53 2020 @@ -28,10 +28,12 @@ inserting ".sho" (5) at end of list inserting ".c" (1) at end of list inserting ".dead-end" (6) at end of list inserting ".short" (4) at end of list -Wildcard expanding "all"...SuffFindDeps (all) +Wildcard expanding "all"... +SuffFindDeps (all) No known suffix on all. Using .NULL suffix adding suffix rules -Wildcard expanding "suff-lookup.cc"...suffix is ".cc"...SuffFindDeps (suff-lookup.cc) +Wildcard expanding "suff-lookup.cc"...suffix is ".cc"... +SuffFindDeps (suff-lookup.cc) trying suff-lookup.ccc...not there trying suff-lookup.c...not there trying suff-lookup.short...not there @@ -39,12 +41,17 @@ Wildcard expanding "suff-lookup.cc"...su applying .sho -> .c to "suff-lookup.c" applying .c -> .ccc to "suff-lookup.ccc" applying .ccc -> .cc to "suff-lookup.cc" -suffix is ".ccc"...suffix is ".c"...suffix is ".sho"...SuffFindDeps (suff-lookup.sho) -suffix is ".sho"...: 'Making suff-lookup.sho out of nothing.' +suffix is ".ccc"... +suffix is ".c"... +suffix is ".sho"... +SuffFindDeps (suff-lookup.sho) +suffix is ".sho"... +: 'Making suff-lookup.sho out of nothing.' : 'Making suff-lookup.c from suff-lookup.sho.' : 'Making suff-lookup.ccc from suff-lookup.c.' : 'Making suff-lookup.cc from suff-lookup.ccc.' -Wildcard expanding "all"...SuffFindDeps (.END) +Wildcard expanding "all"... +SuffFindDeps (.END) No known suffix on .END. Using .NULL suffix adding suffix rules Wildcard expanding ".END"...
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 22:05:00 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): fix typos in job.c comments To generate a diff of this commit: cvs rdiff -u -r1.287 -r1.288 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.287 src/usr.bin/make/job.c:1.288 --- src/usr.bin/make/job.c:1.287 Sun Oct 25 21:51:48 2020 +++ src/usr.bin/make/job.c Sun Oct 25 22:05:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $ */ +/* $NetBSD: job.c,v 1.288 2020/10/25 22:05:00 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.288 2020/10/25 22:05:00 rillig Exp $"); /* A shell defines how the commands are run. All commands for a target are * written into a single file, which is then given to the shell to execute @@ -552,7 +552,7 @@ static void JobContinueSig(int signo MAKE_ATTR_UNUSED) { /* - * Defer sending to SIGCONT to our stopped children until we return + * Defer sending SIGCONT to our stopped children until we return * from the signal handler. */ while (write(childExitJob.outPipe, DO_JOB_RESUME, 1) == -1 && @@ -623,7 +623,7 @@ JobPassSig_suspend(int signo) * events will have happened by then - and that the waitpid() will * collect the child 'suspended' events. * For correct sequencing we just need to ensure we process the - * waitpid() before passign on the SIGCONT. + * waitpid() before passing on the SIGCONT. * * In any case nothing else is needed here. */
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Oct 25 22:04:24 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: sh-dots.exp sh-dots.mk Log Message: make(1): add tests for generating the ... command indirectly To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/sh-dots.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/sh-dots.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/sh-dots.exp diff -u src/usr.bin/make/unit-tests/sh-dots.exp:1.3 src/usr.bin/make/unit-tests/sh-dots.exp:1.4 --- src/usr.bin/make/unit-tests/sh-dots.exp:1.3 Sun Oct 18 18:12:42 2020 +++ src/usr.bin/make/unit-tests/sh-dots.exp Sun Oct 25 22:04:24 2020 @@ -9,7 +9,14 @@ commented commented *** Error code 127 (ignored) commented delayed commented +indirect regular +indirect-space regular +... +make: exec(...) failed (No such file or directory) +*** Error code 1 (ignored) +indirect-space deferred first delayed first repeated delayed repeated repeated delayed twice repeated +indirect deferred exit status 0 Index: src/usr.bin/make/unit-tests/sh-dots.mk diff -u src/usr.bin/make/unit-tests/sh-dots.mk:1.2 src/usr.bin/make/unit-tests/sh-dots.mk:1.3 --- src/usr.bin/make/unit-tests/sh-dots.mk:1.2 Sun Oct 18 18:12:42 2020 +++ src/usr.bin/make/unit-tests/sh-dots.mk Sun Oct 25 22:04:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: sh-dots.mk,v 1.2 2020/10/18 18:12:42 rillig Exp $ +# $NetBSD: sh-dots.mk,v 1.3 2020/10/25 22:04:24 rillig Exp $ # # Tests for the special shell command line "...", which does not run the # commands below it but appends them to the list of commands that are run @@ -6,7 +6,7 @@ .MAKEFLAGS: -d0 # switch stdout to being line-buffered -all: first hidden repeated commented +all: first hidden repeated commented indirect indirect-space # The ${.TARGET} correctly expands to the target name, even though the # commands are run separately from the main commands. @@ -29,6 +29,21 @@ commented: .IGNORE ... # Run the below commands later @echo commented delayed ${.TARGET} +# The dots don't have to be written literally, they can also come from a +# variable expression. +indirect: + @echo indirect regular + ${:U...} + @echo indirect deferred + +# If the dots are followed by a space, that space is part of the command and +# thus does not defer the command below it. +indirect-space: .IGNORE + @echo indirect-space regular + ${:U... } + @echo indirect-space deferred + + # The "..." can appear more than once, even though that doesn't make sense. # The second "..." is a no-op. repeated: .IGNORE
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 21:51:49 UTC 2020 Modified Files: src/usr.bin/make: dir.c job.c make.c make.h meta.c suff.c targ.c var.c Log Message: make(1): add GNode_Path to access the path of a GNode To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/usr.bin/make/dir.c cvs rdiff -u -r1.286 -r1.287 src/usr.bin/make/job.c cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/make.c cvs rdiff -u -r1.171 -r1.172 src/usr.bin/make/make.h cvs rdiff -u -r1.130 -r1.131 src/usr.bin/make/meta.c cvs rdiff -u -r1.224 -r1.225 src/usr.bin/make/suff.c cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/targ.c cvs rdiff -u -r1.588 -r1.589 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.188 src/usr.bin/make/dir.c:1.189 --- src/usr.bin/make/dir.c:1.188 Sun Oct 25 19:19:07 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 21:51:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.189 2020/10/25 21:51:48 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.189 2020/10/25 21:51:48 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -1367,9 +1367,8 @@ Dir_MTime(GNode *gn, Boolean recheck) } } -if (fullName && gn->path == NULL) { +if (fullName != NULL && gn->path == NULL) gn->path = fullName; -} gn->mtime = mst.mst_mtime; return gn->mtime; Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.286 src/usr.bin/make/job.c:1.287 --- src/usr.bin/make/job.c:1.286 Sun Oct 25 21:34:52 2020 +++ src/usr.bin/make/job.c Sun Oct 25 21:51:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $ */ +/* $NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $"); /* A shell defines how the commands are run. All commands for a target are * written into a single file, which is then given to the shell to execute @@ -443,6 +443,8 @@ job_table_dump(const char *where) static void JobDeleteTarget(GNode *gn) { +const char *file; + if (gn->type & OP_JOIN) return; if (gn->type & OP_PHONY) @@ -452,11 +454,9 @@ JobDeleteTarget(GNode *gn) if (noExecute) return; -{ - char *file = (gn->path == NULL ? gn->name : gn->path); - if (eunlink(file) != -1) - Error("*** %s removed", file); -} +file = GNode_Path(gn); +if (eunlink(file) != -1) + Error("*** %s removed", file); } /* @@ -1138,7 +1138,7 @@ Job_Touch(GNode *gn, Boolean silent) } else if (gn->type & OP_LIB) { Arch_TouchLib(gn); } else { - char *file = gn->path ? gn->path : gn->name; + const char *file = GNode_Path(gn); times.actime = times.modtime = now; if (utime(file, ) < 0){ Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.179 src/usr.bin/make/make.c:1.180 --- src/usr.bin/make/make.c:1.179 Sun Oct 25 10:07:23 2020 +++ src/usr.bin/make/make.c Sun Oct 25 21:51:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $ */ +/* $NetBSD: make.c,v 1.180 2020/10/25 21:51:48 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -107,7 +107,7 @@ #include"job.h" /* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: make.c,v 1.180 2020/10/25 21:51:48 rillig Exp $"); /* Sequence # to detect recursion. */ static unsigned int checked = 1; @@ -294,8 +294,7 @@ Make_OODate(GNode *gn) if (gn->youngestChild != NULL && gn->mtime < gn->youngestChild->mtime) { debug_printf("modified before source %s...", - gn->youngestChild->path ? gn->youngestChild->path - : gn->youngestChild->name); + GNode_Path(gn->youngestChild)); } else if (gn->mtime == 0) { debug_printf("non-existent and no sources..."); } else { @@ -785,7 +784,7 @@ MakeAddAllSrc(GNode *cgn, GNode *pgn) if (cgn->type & OP_ARCHV) child = Var_Value(MEMBER, cgn, ); else - child = cgn->path ? cgn->path : cgn->name; + child = GNode_Path(cgn); if (cgn->type & OP_JOIN) { allsrc = Var_Value(ALLSRC, cgn, ); } else { @@ -1178,7 +1177,7 @@ Make_ExpandUse(GNodeList *targs) } (void)Dir_MTime(gn, 0); - Var_Set(TARGET, gn->path ? gn->path :
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 21:34:52 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): refactor JobDeleteTarget Splitting the many conditions into separate pieces makes the code more understandable. To generate a diff of this commit: cvs rdiff -u -r1.285 -r1.286 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.285 src/usr.bin/make/job.c:1.286 --- src/usr.bin/make/job.c:1.285 Sun Oct 25 20:34:05 2020 +++ src/usr.bin/make/job.c Sun Oct 25 21:34:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.285 2020/10/25 20:34:05 rillig Exp $ */ +/* $NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.285 2020/10/25 20:34:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $"); /* A shell defines how the commands are run. All commands for a target are * written into a single file, which is then given to the shell to execute @@ -443,12 +443,20 @@ job_table_dump(const char *where) static void JobDeleteTarget(GNode *gn) { - if ((gn->type & (OP_JOIN|OP_PHONY)) == 0 && !Targ_Precious(gn)) { - char *file = (gn->path == NULL ? gn->name : gn->path); - if (!noExecute && eunlink(file) != -1) { - Error("*** %s removed", file); - } - } +if (gn->type & OP_JOIN) + return; +if (gn->type & OP_PHONY) + return; +if (Targ_Precious(gn)) + return; +if (noExecute) + return; + +{ + char *file = (gn->path == NULL ? gn->name : gn->path); + if (eunlink(file) != -1) + Error("*** %s removed", file); +} } /*
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Oct 25 21:31:00 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: deptgt-delete_on_error.exp deptgt-delete_on_error.mk Log Message: make(1): add test for deleting targets using .DELETE_ON_ERROR To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/deptgt-delete_on_error.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp diff -u src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.1 src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.2 --- src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp Sun Oct 25 21:31:00 2020 @@ -1 +1,51 @@ +Compatibility mode +> deptgt-delete_on_error-regular; false +*** Error code 1 (continuing) +make: *** deptgt-delete_on_error-regular removed +> deptgt-delete_on_error-regular-delete; false +*** Error code 1 (continuing) +make: *** deptgt-delete_on_error-regular-delete removed +> deptgt-delete_on_error-phony; false +*** Error code 1 (continuing) +make: *** deptgt-delete_on_error-phony removed +> deptgt-delete_on_error-phony-delete; false +*** Error code 1 (continuing) +make: *** deptgt-delete_on_error-phony-delete removed +> deptgt-delete_on_error-precious; false +*** Error code 1 (continuing) +> deptgt-delete_on_error-precious-delete; false +*** Error code 1 (continuing) + +Stop. +make: stopped in unit-tests + +Parallel mode +> deptgt-delete_on_error-regular; false +*** [deptgt-delete_on_error-regular] Error code 1 +make: *** deptgt-delete_on_error-regular removed + +make: stopped in unit-tests +> deptgt-delete_on_error-regular-delete; false +*** [deptgt-delete_on_error-regular-delete] Error code 1 +make: *** deptgt-delete_on_error-regular-delete removed + +make: stopped in unit-tests +> deptgt-delete_on_error-phony; false +*** [deptgt-delete_on_error-phony] Error code 1 + +make: stopped in unit-tests +> deptgt-delete_on_error-phony-delete; false +*** [deptgt-delete_on_error-phony-delete] Error code 1 + +make: stopped in unit-tests +> deptgt-delete_on_error-precious; false +*** [deptgt-delete_on_error-precious] Error code 1 + +make: stopped in unit-tests +> deptgt-delete_on_error-precious-delete; false +*** [deptgt-delete_on_error-precious-delete] Error code 1 + +make: stopped in unit-tests +*** Error code 1 (ignored) +*** Error code 1 (ignored) exit status 0 Index: src/usr.bin/make/unit-tests/deptgt-delete_on_error.mk diff -u src/usr.bin/make/unit-tests/deptgt-delete_on_error.mk:1.2 src/usr.bin/make/unit-tests/deptgt-delete_on_error.mk:1.3 --- src/usr.bin/make/unit-tests/deptgt-delete_on_error.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/deptgt-delete_on_error.mk Sun Oct 25 21:31:00 2020 @@ -1,8 +1,45 @@ -# $NetBSD: deptgt-delete_on_error.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ + # $NetBSD: deptgt-delete_on_error.mk,v 1.3 2020/10/25 21:31:00 rillig Exp $ # -# Tests for the special target .DELETE_ON_ERROR in dependency declarations. +# Tests for the special target .DELETE_ON_ERROR in dependency declarations, +# which controls whether the target is deleted if a shell command fails or +# is interrupted. +# +# In compatibility mode, regular and phony targets are deleted, but precious +# targets are preserved. +# +# In parallel mode, regular targets are deleted, while phony and precious +# targets are preserved. +# +# See also: +# CompatDeleteTarget +# JobDeleteTarget -# TODO: Implementation +THIS= deptgt-delete_on_error +TARGETS= ${THIS}-regular ${THIS}-regular-delete +TARGETS+= ${THIS}-phony ${THIS}-phony-delete +TARGETS+= ${THIS}-precious ${THIS}-precious-delete all: - @:; + @rm -f ${TARGETS} + @echo 'Compatibility mode' + @-${.MAKE} -f ${MAKEFILE} -k ${TARGETS} + @rm -f ${TARGETS} + @echo + @echo 'Parallel mode' + @-${.MAKE} -f ${MAKEFILE} -k -j1 ${TARGETS} + @rm -f ${TARGETS} + +${THIS}-regular{,-delete}: + > ${.TARGET}; false + +${THIS}-phony{,-delete}: .PHONY + > ${.TARGET}; false + +${THIS}-precious{,-delete}: .PRECIOUS + > ${.TARGET}; false + +# The special target .DELETE_ON_ERROR is a global setting. +# It does not apply to single targets. +# The following line is therefore misleading but does not generate any +# warning or even an error message. +.DELETE_ON_ERROR: ${TARGETS:M*-delete}
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 20:34:05 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): inline macro STATIC It was a leftover from the remote code, which was removed on 2006-03-11. To generate a diff of this commit: cvs rdiff -u -r1.284 -r1.285 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.284 src/usr.bin/make/job.c:1.285 --- src/usr.bin/make/job.c:1.284 Sun Oct 25 20:29:51 2020 +++ src/usr.bin/make/job.c Sun Oct 25 20:34:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.284 2020/10/25 20:29:51 rillig Exp $ */ +/* $NetBSD: job.c,v 1.285 2020/10/25 20:34:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,9 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.284 2020/10/25 20:29:51 rillig Exp $"); - -# define STATIC static +MAKE_RCSID("$NetBSD: job.c,v 1.285 2020/10/25 20:34:05 rillig Exp $"); /* A shell defines how the commands are run. All commands for a target are * written into a single file, which is then given to the shell to execute @@ -376,8 +374,8 @@ char *shellErrFlag = NULL; static char *shellArgv = NULL; /* Custom shell args */ -STATIC Job *job_table; /* The structures that describe them */ -STATIC Job *job_table_end; /* job_table + maxJobs */ +static Job *job_table; /* The structures that describe them */ +static Job *job_table_end; /* job_table + maxJobs */ static unsigned int wantToken; /* we want a token */ static int lurking_children = 0; static int make_suspended = 0; /* non-zero if we've seen a SIGTSTP (etc) */ @@ -393,7 +391,7 @@ static void watchfd(Job *); static void clearfd(Job *); static int readyfd(Job *); -STATIC GNode *lastNode; /* The node for which output was most recently +static GNode *lastNode; /* The node for which output was most recently * produced. */ static char *targPrefix = NULL; /* What we print at the start of TARG_FMT */ static Job tokenWaitJob; /* token wait pseudo-job */ @@ -1724,7 +1722,7 @@ JobOutput(Job *job, char *cp, char *endp * curPos may be shifted as may the contents of outBuf. *--- */ -STATIC void +static void JobDoOutput(Job *job, Boolean finish) { Boolean gotNL = FALSE; /* true if got a newline */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 20:29:51 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): convert result of JobStart from macros to enum Right now the result is not used by any code. To generate a diff of this commit: cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.283 src/usr.bin/make/job.c:1.284 --- src/usr.bin/make/job.c:1.283 Sun Oct 25 20:24:25 2020 +++ src/usr.bin/make/job.c Sun Oct 25 20:29:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.283 2020/10/25 20:24:25 rillig Exp $ */ +/* $NetBSD: job.c,v 1.284 2020/10/25 20:29:51 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.283 2020/10/25 20:24:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.284 2020/10/25 20:29:51 rillig Exp $"); # define STATIC static @@ -238,12 +238,11 @@ int jobTokensRunning = 0; * Should this number be 0, no shell will be executed. */ static int numCommands; -/* - * Return values from JobStart. - */ -#define JOB_RUNNING 0 /* Job is running */ -#define JOB_ERROR 1 /* Error in starting the job */ -#define JOB_FINISHED 2 /* The job is already finished */ +typedef enum JobStartResult { +JOB_RUNNING, /* Job is running */ +JOB_ERROR, /* Error in starting the job */ +JOB_FINISHED /* The job is already finished */ +} JobStartResult; /* * Descriptions for various shells. @@ -657,11 +656,6 @@ JobFindPid(int pid, JobState status, Boo * made and return non-zero to signal that the end of the commands * was reached. These commands are later attached to the postCommands * node and executed by Job_End when all things are done. - * This function is called from JobStart via Lst_ForEachUntil. - * - * Input: - * cmdp command string to print - * jobp job for which to print it * * Side Effects: * If the command begins with a '-' and the shell has no error control, @@ -1248,7 +1242,7 @@ Job_CheckCommands(GNode *gn, void (*abor return FALSE; } -/* Execute the shell for the given job. Called from JobStart +/* Execute the shell for the given job. * * A shell is executed, its output is altered and the Job structure added * to the job table. @@ -1475,7 +1469,7 @@ JobMakeArgv(Job *job, char **argv) * Also the return value is ignored by everyone. *--- */ -static int +static JobStartResult JobStart(GNode *gn, int flags) { Job *job; /* new job descriptor */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 20:24:25 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): convert abort reason macros to enum To generate a diff of this commit: cvs rdiff -u -r1.282 -r1.283 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.282 src/usr.bin/make/job.c:1.283 --- src/usr.bin/make/job.c:1.282 Sun Oct 25 20:19:06 2020 +++ src/usr.bin/make/job.c Sun Oct 25 20:24:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.282 2020/10/25 20:19:06 rillig Exp $ */ +/* $NetBSD: job.c,v 1.283 2020/10/25 20:24:25 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.282 2020/10/25 20:19:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.283 2020/10/25 20:24:25 rillig Exp $"); # define STATIC static @@ -218,10 +218,13 @@ typedef struct Shell { * error handling variables */ static int errors = 0; /* number of errors reported */ -static int aborting = 0; /* why is the make aborting? */ -#define ABORT_ERROR 1 /* Because of an error */ -#define ABORT_INTERRUPT 2 /* Because it was interrupted */ -#define ABORT_WAIT 3 /* Waiting for jobs to finish */ +typedef enum AbortReason { /* why is the make aborting? */ +ABORT_NONE, +ABORT_ERROR, /* Because of an error */ +ABORT_INTERRUPT, /* Because it was interrupted */ +ABORT_WAIT /* Waiting for jobs to finish */ +} AbortReason; +static AbortReason aborting = ABORT_NONE; #define JOB_TOKENS "+EI+" /* Token to requeue for each abort state */ /*
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 20:19:06 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): invert condition in Job_CheckCommands, reduce indentation To generate a diff of this commit: cvs rdiff -u -r1.281 -r1.282 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.281 src/usr.bin/make/job.c:1.282 --- src/usr.bin/make/job.c:1.281 Sun Oct 25 20:15:56 2020 +++ src/usr.bin/make/job.c Sun Oct 25 20:19:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.281 2020/10/25 20:15:56 rillig Exp $ */ +/* $NetBSD: job.c,v 1.282 2020/10/25 20:19:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.281 2020/10/25 20:15:56 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.282 2020/10/25 20:19:06 rillig Exp $"); # define STATIC static @@ -1208,39 +1208,41 @@ Job_CheckCommands(GNode *gn, void (*abor return TRUE; } -if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) { - /* - * The node wasn't the target of an operator. We have no .DEFAULT - * rule to go on and the target doesn't already exist. There's - * nothing more we can do for this branch. If the -k flag wasn't - * given, we stop in our tracks, otherwise we just don't update - * this node's parents so they never get examined. - */ - - if (gn->flags & FROM_DEPEND) { - if (!Job_RunTarget(".STALE", gn->fname)) - fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n", - progname, gn->fname, gn->lineno, makeDependfile, - gn->name); - return TRUE; - } - - if (gn->type & OP_OPTIONAL) { - (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", - progname, gn->name, "ignored"); - (void)fflush(stdout); - } else if (keepgoing) { - (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", - progname, gn->name, "continuing"); - (void)fflush(stdout); - return FALSE; - } else { - abortProc("%s: don't know how to make %s. Stop", - progname, gn->name); - return FALSE; - } +if (Dir_MTime(gn, 0) != 0 || (gn->type & OP_SPECIAL)) + return TRUE; + +/* + * The node wasn't the target of an operator. We have no .DEFAULT + * rule to go on and the target doesn't already exist. There's + * nothing more we can do for this branch. If the -k flag wasn't + * given, we stop in our tracks, otherwise we just don't update + * this node's parents so they never get examined. + */ + +if (gn->flags & FROM_DEPEND) { + if (!Job_RunTarget(".STALE", gn->fname)) + fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n", + progname, gn->fname, gn->lineno, makeDependfile, + gn->name); + return TRUE; } -return TRUE; + +if (gn->type & OP_OPTIONAL) { + (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", + progname, gn->name, "ignored"); + (void)fflush(stdout); + return TRUE; +} + +if (keepgoing) { + (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", + progname, gn->name, "continuing"); + (void)fflush(stdout); + return FALSE; +} + +abortProc("%s: don't know how to make %s. Stop", progname, gn->name); +return FALSE; } /* Execute the shell for the given job. Called from JobStart
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 20:15:56 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): reduce indentation in Job_CheckCommands To generate a diff of this commit: cvs rdiff -u -r1.280 -r1.281 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.280 src/usr.bin/make/job.c:1.281 --- src/usr.bin/make/job.c:1.280 Sun Oct 25 20:14:08 2020 +++ src/usr.bin/make/job.c Sun Oct 25 20:15:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.280 2020/10/25 20:14:08 rillig Exp $ */ +/* $NetBSD: job.c,v 1.281 2020/10/25 20:15:56 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.280 2020/10/25 20:14:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.281 2020/10/25 20:15:56 rillig Exp $"); # define STATIC static @@ -1180,63 +1180,64 @@ Boolean Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) { if (GNode_IsTarget(gn)) -return TRUE; + return TRUE; if (!Lst_IsEmpty(gn->commands)) -return TRUE; + return TRUE; if ((gn->type & OP_LIB) && !Lst_IsEmpty(gn->children)) -return TRUE; + return TRUE; -{ +/* + * No commands. Look for .DEFAULT rule from which we might infer + * commands + */ +if ((DEFAULT != NULL) && !Lst_IsEmpty(DEFAULT->commands) && + (gn->type & OP_SPECIAL) == 0) { + char *p1; /* - * No commands. Look for .DEFAULT rule from which we might infer - * commands + * Make only looks for a .DEFAULT if the node was never the + * target of an operator, so that's what we do too. If + * a .DEFAULT was given, we substitute its commands for gn's + * commands and set the IMPSRC variable to be the target's name + * The DEFAULT node acts like a transformation rule, in that + * gn also inherits any attributes or sources attached to + * .DEFAULT itself. + */ + Make_HandleUse(DEFAULT, gn); + Var_Set(IMPSRC, Var_Value(TARGET, gn, ), gn); + bmake_free(p1); + return TRUE; +} + +if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) { + /* + * The node wasn't the target of an operator. We have no .DEFAULT + * rule to go on and the target doesn't already exist. There's + * nothing more we can do for this branch. If the -k flag wasn't + * given, we stop in our tracks, otherwise we just don't update + * this node's parents so they never get examined. */ - if ((DEFAULT != NULL) && !Lst_IsEmpty(DEFAULT->commands) && - (gn->type & OP_SPECIAL) == 0) { - char *p1; - /* - * Make only looks for a .DEFAULT if the node was never the - * target of an operator, so that's what we do too. If - * a .DEFAULT was given, we substitute its commands for gn's - * commands and set the IMPSRC variable to be the target's name - * The DEFAULT node acts like a transformation rule, in that - * gn also inherits any attributes or sources attached to - * .DEFAULT itself. - */ - Make_HandleUse(DEFAULT, gn); - Var_Set(IMPSRC, Var_Value(TARGET, gn, ), gn); - bmake_free(p1); - } else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) { - /* - * The node wasn't the target of an operator. We have no .DEFAULT - * rule to go on and the target doesn't already exist. There's - * nothing more we can do for this branch. If the -k flag wasn't - * given, we stop in our tracks, otherwise we just don't update - * this node's parents so they never get examined. - */ - if (gn->flags & FROM_DEPEND) { - if (!Job_RunTarget(".STALE", gn->fname)) - fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n", + if (gn->flags & FROM_DEPEND) { + if (!Job_RunTarget(".STALE", gn->fname)) + fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n", progname, gn->fname, gn->lineno, makeDependfile, gn->name); - return TRUE; - } + return TRUE; + } - if (gn->type & OP_OPTIONAL) { - (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", - progname, gn->name, "ignored"); - (void)fflush(stdout); - } else if (keepgoing) { - (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", - progname, gn->name, "continuing"); - (void)fflush(stdout); - return FALSE; - } else { - abortProc("%s: don't know how to make %s. Stop", - progname, gn->name); - return FALSE; - } + if (gn->type & OP_OPTIONAL) { + (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", + progname, gn->name, "ignored"); + (void)fflush(stdout); + } else if (keepgoing) { + (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", + progname, gn->name, "continuing"); + (void)fflush(stdout); + return FALSE; + }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 20:14:09 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): split and invert complex condition in Job_CheckCommands To generate a diff of this commit: cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.279 src/usr.bin/make/job.c:1.280 --- src/usr.bin/make/job.c:1.279 Sun Oct 25 20:09:28 2020 +++ src/usr.bin/make/job.c Sun Oct 25 20:14:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.279 2020/10/25 20:09:28 rillig Exp $ */ +/* $NetBSD: job.c,v 1.280 2020/10/25 20:14:08 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.279 2020/10/25 20:09:28 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.280 2020/10/25 20:14:08 rillig Exp $"); # define STATIC static @@ -1179,8 +1179,14 @@ Job_Touch(GNode *gn, Boolean silent) Boolean Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) { -if (!GNode_IsTarget(gn) && Lst_IsEmpty(gn->commands) && - ((gn->type & OP_LIB) == 0 || Lst_IsEmpty(gn->children))) { +if (GNode_IsTarget(gn)) +return TRUE; +if (!Lst_IsEmpty(gn->commands)) +return TRUE; +if ((gn->type & OP_LIB) && !Lst_IsEmpty(gn->children)) +return TRUE; + +{ /* * No commands. Look for .DEFAULT rule from which we might infer * commands
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 20:09:28 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): inline error message This saves a variable, and since bmake needs to adhere to C90, this variable declaration prevents refactoring the code. To generate a diff of this commit: cvs rdiff -u -r1.278 -r1.279 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.278 src/usr.bin/make/job.c:1.279 --- src/usr.bin/make/job.c:1.278 Sun Oct 25 19:57:43 2020 +++ src/usr.bin/make/job.c Sun Oct 25 20:09:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.278 2020/10/25 19:57:43 rillig Exp $ */ +/* $NetBSD: job.c,v 1.279 2020/10/25 20:09:28 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.278 2020/10/25 19:57:43 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.279 2020/10/25 20:09:28 rillig Exp $"); # define STATIC static @@ -1208,7 +1208,6 @@ Job_CheckCommands(GNode *gn, void (*abor * given, we stop in our tracks, otherwise we just don't update * this node's parents so they never get examined. */ - static const char msg[] = ": don't know how to make"; if (gn->flags & FROM_DEPEND) { if (!Job_RunTarget(".STALE", gn->fname)) @@ -1219,16 +1218,17 @@ Job_CheckCommands(GNode *gn, void (*abor } if (gn->type & OP_OPTIONAL) { - (void)fprintf(stdout, "%s%s %s (ignored)\n", progname, - msg, gn->name); + (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", + progname, gn->name, "ignored"); (void)fflush(stdout); } else if (keepgoing) { - (void)fprintf(stdout, "%s%s %s (continuing)\n", progname, - msg, gn->name); + (void)fprintf(stdout, "%s: don't know how to make %s (%s)\n", + progname, gn->name, "continuing"); (void)fflush(stdout); return FALSE; } else { - (*abortProc)("%s%s %s. Stop", progname, msg, gn->name); + abortProc("%s: don't know how to make %s. Stop", + progname, gn->name); return FALSE; } }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 19:57:43 UTC 2020 Modified Files: src/usr.bin/make: job.c Log Message: make(1): clean up API comment in job.c To generate a diff of this commit: cvs rdiff -u -r1.277 -r1.278 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.277 src/usr.bin/make/job.c:1.278 --- src/usr.bin/make/job.c:1.277 Fri Oct 23 18:36:09 2020 +++ src/usr.bin/make/job.c Sun Oct 25 19:57:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.277 2020/10/23 18:36:09 rillig Exp $ */ +/* $NetBSD: job.c,v 1.278 2020/10/25 19:57:43 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -74,6 +74,14 @@ * handle the creation etc. of our child processes. * * Interface: + * Job_Init Called to initialize this module. In addition, + * any commands attached to the .BEGIN target + * are executed before this function returns. + * Hence, the makefiles must have been parsed + * before this function is called. + * + * Job_End Clean up any memory used. + * * Job_Make Start the creation of the given target. * * Job_CatchChildren @@ -91,14 +99,6 @@ * a time given by the SEL_* constants, below, * or until output is ready. * - * Job_Init Called to initialize this module. in addition, - * any commands attached to the .BEGIN target - * are executed before this function returns. - * Hence, the makefile must have been parsed - * before this function is called. - * - * Job_End Clean up any memory used. - * * Job_ParseShell Given the line following a .SHELL target, parse * the line as a shell specification. Returns * FALSE if the spec was incorrect. @@ -112,7 +112,7 @@ * Job_AbortAll Abort all currently running jobs. It doesn't * handle output or do anything for the jobs, * just kills them. It should only be called in - * an emergency, as it were. + * an emergency. * * Job_CheckCommands * Verify that the commands for a target are @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.277 2020/10/23 18:36:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.278 2020/10/25 19:57:43 rillig Exp $"); # define STATIC static
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 19:28:44 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): print hash in debug log with fixed width This way all the keys are nicely aligned in the debug log. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/usr.bin/make/hash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.54 src/usr.bin/make/hash.c:1.55 --- src/usr.bin/make/hash.c:1.54 Sun Oct 25 19:19:07 2020 +++ src/usr.bin/make/hash.c Sun Oct 25 19:28:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.54 2020/10/25 19:19:07 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.55 2020/10/25 19:28:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -74,7 +74,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.54 2020/10/25 19:19:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.55 2020/10/25 19:28:44 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -86,7 +86,7 @@ MAKE_RCSID("$NetBSD: hash.c,v 1.54 2020/ static unsigned int hash(const char *key, size_t *out_keylen) { - unsigned h = 0; + unsigned int h = 0; const char *p = key; while (*p != '\0') h = (h << 5) - h + (unsigned char)*p++; @@ -108,7 +108,7 @@ HashTable_Find(HashTable *t, unsigned in unsigned int chainlen = 0; #ifdef DEBUG_HASH_LOOKUP - DEBUG4(HASH, "%s: %p h=%x key=%s\n", __func__, t, h, key); + DEBUG4(HASH, "%s: %p h=%08x key=%s\n", __func__, t, h, key); #endif for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) { @@ -156,11 +156,9 @@ HashTable_Done(HashTable *t) } free(t->buckets); - /* - * Set up the hash table to cause memory faults on any future access - * attempts until re-initialization. - */ +#ifdef CLEANUP t->buckets = NULL; +#endif } /* Find the entry corresponding to the key, or return NULL. */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 19:19:07 UTC 2020 Modified Files: src/usr.bin/make: arch.c dir.c hash.c hash.h main.c targ.c var.c Log Message: make(1): rename hash functions to identify the type name This makes it easier to spot mismatches between the function name and its first parameter, although the compiler should already catch most of them. Except for void pointers. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/usr.bin/make/arch.c cvs rdiff -u -r1.187 -r1.188 src/usr.bin/make/dir.c cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/hash.c cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/hash.h cvs rdiff -u -r1.389 -r1.390 src/usr.bin/make/main.c cvs rdiff -u -r1.122 -r1.123 src/usr.bin/make/targ.c cvs rdiff -u -r1.587 -r1.588 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.146 src/usr.bin/make/arch.c:1.147 --- src/usr.bin/make/arch.c:1.146 Sun Oct 25 07:57:01 2020 +++ src/usr.bin/make/arch.c Sun Oct 25 19:19:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.146 2020/10/25 07:57:01 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.147 2020/10/25 19:19:07 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -130,7 +130,7 @@ #include"config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.146 2020/10/25 07:57:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.147 2020/10/25 19:19:07 rillig Exp $"); #ifdef TARGET_MACHINE #undef MAKE_MACHINE @@ -172,11 +172,11 @@ ArchFree(void *ap) /* Free memory from hash entries */ HashIter_Init(, >members); while ((he = HashIter_Next()) != NULL) - free(Hash_GetValue(he)); + free(HashEntry_Get(he)); free(a->name); free(a->fnametab); -Hash_DeleteTable(>members); +HashTable_Done(>members); free(a); } #endif @@ -445,7 +445,7 @@ ArchStatMember(const char *archive, cons struct ar_hdr *hdr; ar = ln->datum; - hdr = Hash_FindValue(>members, member); + hdr = HashTable_FindValue(>members, member); if (hdr != NULL) return hdr; @@ -458,7 +458,7 @@ ArchStatMember(const char *archive, cons len = AR_MAX_NAME_LEN; snprintf(copy, sizeof copy, "%s", member); } - hdr = Hash_FindValue(>members, copy); + hdr = HashTable_FindValue(>members, copy); return hdr; } } @@ -503,7 +503,7 @@ ArchStatMember(const char *archive, cons ar->name = bmake_strdup(archive); ar->fnametab = NULL; ar->fnamesize = 0; -Hash_InitTable(>members); +HashTable_Init(>members); memName[AR_MAX_NAME_LEN] = '\0'; while (fread((char *), sizeof(struct ar_hdr), 1, arch) == 1) { @@ -580,9 +580,9 @@ ArchStatMember(const char *archive, cons { HashEntry *he; - he = Hash_CreateEntry(>members, memName, NULL); - Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr))); - memcpy(Hash_GetValue(he), , sizeof(struct ar_hdr)); + he = HashTable_CreateEntry(>members, memName, NULL); + HashEntry_Set(he, bmake_malloc(sizeof(struct ar_hdr))); + memcpy(HashEntry_Get(he), , sizeof(struct ar_hdr)); } } if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0) @@ -597,11 +597,11 @@ ArchStatMember(const char *archive, cons * Now that the archive has been read and cached, we can look into * the hash table to find the desired member's header. */ -return Hash_FindValue(>members, member); +return HashTable_FindValue(>members, member); badarch: fclose(arch); -Hash_DeleteTable(>members); +HashTable_Done(>members); free(ar->fnametab); free(ar); return NULL; Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.187 src/usr.bin/make/dir.c:1.188 --- src/usr.bin/make/dir.c:1.187 Sun Oct 25 10:00:20 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 19:19:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -228,7 +228,7 @@ static void OpenDirs_Init(OpenDirs *odirs) { odirs->list = Lst_New(); -Hash_InitTable(>table); +HashTable_Init(>table); } #ifdef CLEANUP @@ -243,37 +243,37 @@ OpenDirs_Done(OpenDirs *odirs) ln = next; } Lst_Free(odirs->list); -Hash_DeleteTable(>table); +HashTable_Done(>table); } #endif static CachedDir * OpenDirs_Find(OpenDirs *odirs, const char *name) { -CachedDirListNode *ln = Hash_FindValue(>table, name); +
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 19:11:31 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): reduce duplicate code in VarFind To generate a diff of this commit: cvs rdiff -u -r1.586 -r1.587 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.586 src/usr.bin/make/var.c:1.587 --- src/usr.bin/make/var.c:1.586 Sun Oct 25 17:01:05 2020 +++ src/usr.bin/make/var.c Sun Oct 25 19:11:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.586 2020/10/25 17:01:05 rillig Exp $ */ +/* $NetBSD: var.c,v 1.587 2020/10/25 19:11:30 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.586 2020/10/25 17:01:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.587 2020/10/25 19:11:30 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -331,6 +331,12 @@ CanonicalVarname(const char *name) return name; } +static Var * +GNode_FindVar(GNode *ctxt, const char *varname, unsigned int hash) +{ +return Hash_FindValueHash(>context, varname, hash); +} + /*- *--- * VarFind -- @@ -369,18 +375,18 @@ VarFind(const char *name, GNode *ctxt, V * look for it in VAR_CMD, VAR_GLOBAL and the environment, in that order, * depending on the FIND_* flags in 'flags' */ -var = Hash_FindValueHash(>context, name, nameHash); +var = GNode_FindVar(ctxt, name, nameHash); if (var == NULL && (flags & FIND_CMD) && ctxt != VAR_CMD) - var = Hash_FindValueHash(_CMD->context, name, nameHash); + var = GNode_FindVar(VAR_CMD, name, nameHash); if (!checkEnvFirst && var == NULL && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) { - var = Hash_FindValueHash(_GLOBAL->context, name, nameHash); + var = GNode_FindVar(VAR_GLOBAL, name, nameHash); if (var == NULL && ctxt != VAR_INTERNAL) { /* VAR_INTERNAL is subordinate to VAR_GLOBAL */ - var = Hash_FindValueHash(_INTERNAL->context, name, nameHash); + var = GNode_FindVar(VAR_INTERNAL, name, nameHash); } } @@ -393,9 +399,9 @@ VarFind(const char *name, GNode *ctxt, V } if (checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) { - var = Hash_FindValueHash(_GLOBAL->context, name, nameHash); + var = GNode_FindVar(VAR_GLOBAL, name, nameHash); if (var == NULL && ctxt != VAR_INTERNAL) - var = Hash_FindValueHash(_INTERNAL->context, name, nameHash); + var = GNode_FindVar(VAR_INTERNAL, name, nameHash); return var; }
CVS commit: src/sys/arch/sparc64/conf
Module Name:src Committed By: martin Date: Sun Oct 25 18:53:12 UTC 2020 Modified Files: src/sys/arch/sparc64/conf: GENERIC Log Message: Temporarily disable NTFS for an internal test. To generate a diff of this commit: cvs rdiff -u -r1.230 -r1.231 src/sys/arch/sparc64/conf/GENERIC Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/conf/GENERIC diff -u src/sys/arch/sparc64/conf/GENERIC:1.230 src/sys/arch/sparc64/conf/GENERIC:1.231 --- src/sys/arch/sparc64/conf/GENERIC:1.230 Sun Sep 27 13:48:54 2020 +++ src/sys/arch/sparc64/conf/GENERIC Sun Oct 25 18:53:11 2020 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.230 2020/09/27 13:48:54 roy Exp $ +# $NetBSD: GENERIC,v 1.231 2020/10/25 18:53:11 martin Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.230 $" +#ident "GENERIC-$Revision: 1.231 $" maxusers 64 @@ -861,3 +861,6 @@ options PAX_SEGVGUARD=0 # PaX Segmenta # options PAX_MPROTECT=0 # PaX mprotect(2) restrictions # options PAX_MPROTECT_DEBUG=1 # PaX mprotect debug options PAX_ASLR=1 # PaX Address Space Layout Randomization + +# Temporary workaround while analyzing memory corruption when booting from CD +no file-system NTFS
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 18:40:00 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): clean up comments in hash.c To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.bin/make/hash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.52 src/usr.bin/make/hash.c:1.53 --- src/usr.bin/make/hash.c:1.52 Sun Oct 25 18:37:08 2020 +++ src/usr.bin/make/hash.c Sun Oct 25 18:40:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.52 2020/10/25 18:37:08 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.53 2020/10/25 18:40:00 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -69,17 +69,12 @@ * SUCH DAMAGE. */ -/* - * This module contains routines to manipulate a hash table. - * See hash.h for a definition of the structure of the hash - * table. Hash tables grow automatically as the amount of - * information increases. - */ +/* Hash tables with string keys. */ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.52 2020/10/25 18:37:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.53 2020/10/25 18:40:00 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -87,7 +82,7 @@ MAKE_RCSID("$NetBSD: hash.c,v 1.52 2020/ */ #define rebuildLimit 3 -/* This hash function matches Gosling's emacs. */ +/* This hash function matches Gosling's emacs and java.lang.String. */ static unsigned int hash(const char *key, size_t *out_keylen) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 18:37:08 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): clean up hash table functions To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/usr.bin/make/hash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.51 src/usr.bin/make/hash.c:1.52 --- src/usr.bin/make/hash.c:1.51 Sun Oct 25 18:12:35 2020 +++ src/usr.bin/make/hash.c Sun Oct 25 18:37:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.51 2020/10/25 18:12:35 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.52 2020/10/25 18:37:08 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.51 2020/10/25 18:12:35 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.52 2020/10/25 18:37:08 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -241,23 +241,19 @@ RebuildTable(HashTable *t) * Input: * t Hash table to search. * key A hash key. - * newPtr Filled with TRUE if new entry created, - * FALSE otherwise. + * out_isNew Filled with TRUE if new entry created, FALSE otherwise. */ HashEntry * -Hash_CreateEntry(HashTable *t, const char *key, Boolean *newPtr) +Hash_CreateEntry(HashTable *t, const char *key, Boolean *out_isNew) { - HashEntry *e; - unsigned h; size_t keylen; - HashEntry **hp; + unsigned int h = hash(key, ); + HashEntry *he = HashTable_Find(t, h, key); - h = hash(key, ); - e = HashTable_Find(t, h, key); - if (e) { - if (newPtr != NULL) - *newPtr = FALSE; - return e; + if (he != NULL) { + if (out_isNew != NULL) + *out_isNew = FALSE; + return he; } /* @@ -268,30 +264,30 @@ Hash_CreateEntry(HashTable *t, const cha if (t->numEntries >= rebuildLimit * t->bucketsSize) RebuildTable(t); - e = bmake_malloc(sizeof(*e) + keylen); - hp = >buckets[h & t->bucketsMask]; - e->next = *hp; - *hp = e; - Hash_SetValue(e, NULL); - e->key_hash = h; - memcpy(e->key, key, keylen + 1); + he = bmake_malloc(sizeof(*he) + keylen); + he->value = NULL; + he->key_hash = h; + memcpy(he->key, key, keylen + 1); + + he->next = t->buckets[h & t->bucketsMask]; + t->buckets[h & t->bucketsMask] = he; t->numEntries++; - if (newPtr != NULL) - *newPtr = TRUE; - return e; + if (out_isNew != NULL) + *out_isNew = TRUE; + return he; } /* Delete the given hash table entry and free memory associated with it. */ void -Hash_DeleteEntry(HashTable *t, HashEntry *e) +Hash_DeleteEntry(HashTable *t, HashEntry *he) { - HashEntry **hp, *p; + HashEntry **ref = >buckets[he->key_hash & t->bucketsMask]; + HashEntry *p; - for (hp = >buckets[e->key_hash & t->bucketsMask]; - (p = *hp) != NULL; hp = >next) { - if (p == e) { - *hp = p->next; + for (; (p = *ref) != NULL; ref = >next) { + if (p == he) { + *ref = p->next; free(p); t->numEntries--; return; @@ -314,28 +310,21 @@ HashIter_Init(HashIter *hi, HashTable *t HashEntry * HashIter_Next(HashIter *hi) { - HashEntry *e; HashTable *t = hi->table; + HashEntry *he = hi->entry; + HashEntry **buckets = t->buckets; + unsigned int bucketsSize = t->bucketsSize; - /* - * The entry field points to the most recently returned - * entry, or is NULL if we are starting up. If not NULL, we have - * to start at the next one in the chain. - */ - e = hi->entry; - if (e != NULL) - e = e->next; - /* - * If the chain ran out, or if we are starting up, we need to - * find the next nonempty chain. - */ - while (e == NULL) { - if (hi->nextBucket >= t->bucketsSize) + if (he != NULL) + he = he->next; /* skip the most recently returned entry */ + + while (he == NULL) { /* find the next nonempty chain */ + if (hi->nextBucket >= bucketsSize) return NULL; - e = t->buckets[hi->nextBucket++]; + he = buckets[hi->nextBucket++]; } - hi->entry = e; - return e; + hi->entry = he; + return he; } void
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 18:12:35 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): refactor Hash_DeleteTable To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/usr.bin/make/hash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.50 src/usr.bin/make/hash.c:1.51 --- src/usr.bin/make/hash.c:1.50 Sun Oct 25 18:03:59 2020 +++ src/usr.bin/make/hash.c Sun Oct 25 18:12:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.51 2020/10/25 18:12:35 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.51 2020/10/25 18:12:35 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -149,13 +149,15 @@ Hash_InitTable(HashTable *t) void Hash_DeleteTable(HashTable *t) { - HashEntry **hp, *h, *nexth = NULL; - int i; + HashEntry **buckets = t->buckets; + size_t i, n = t->bucketsSize; - for (hp = t->buckets, i = (int)t->bucketsSize; --i >= 0;) { - for (h = *hp++; h != NULL; h = nexth) { - nexth = h->next; - free(h); + for (i = 0; i < n; i++) { + HashEntry *he = buckets[i]; + while (he != NULL) { + HashEntry *next = he->next; + free(he); + he = next; } } free(t->buckets);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 18:03:59 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): refactor Hash_InitTable First prepare all the data, then initialize the fields in declaration order. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/usr.bin/make/hash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.49 src/usr.bin/make/hash.c:1.50 --- src/usr.bin/make/hash.c:1.49 Sun Oct 25 17:58:53 2020 +++ src/usr.bin/make/hash.c Sun Oct 25 18:03:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.49 2020/10/25 17:58:53 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.49 2020/10/25 17:58:53 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.50 2020/10/25 18:03:59 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -133,15 +133,15 @@ void Hash_InitTable(HashTable *t) { unsigned int n = 16, i; - HashEntry **hp; + HashEntry **buckets = bmake_malloc(sizeof(*buckets) * n); + for (i = 0; i < n; i++) + buckets[i] = NULL; - t->numEntries = 0; - t->maxchain = 0; + t->buckets = buckets; t->bucketsSize = n; + t->numEntries = 0; t->bucketsMask = n - 1; - t->buckets = hp = bmake_malloc(sizeof(*hp) * n); - for (i = 0; i < n; i++) - hp[i] = NULL; + t->maxchain = 0; } /* Removes everything from the hash table and frees up the memory space it
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 17:58:53 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): clean up RebuildTable for hash tables The previous code used ++ and -- a lot, it also reused variables a lot for different purposes. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/make/hash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.48 src/usr.bin/make/hash.c:1.49 --- src/usr.bin/make/hash.c:1.48 Sun Oct 25 17:01:05 2020 +++ src/usr.bin/make/hash.c Sun Oct 25 17:58:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.48 2020/10/25 17:01:05 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.49 2020/10/25 17:58:53 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.48 2020/10/25 17:01:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.49 2020/10/25 17:58:53 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -203,29 +203,31 @@ Hash_FindValueHash(HashTable *t, const c static void RebuildTable(HashTable *t) { - HashEntry *e, *next = NULL, **hp, **xp; - int i; - unsigned int mask, oldsize, newsize; - HashEntry **oldhp; - - oldhp = t->buckets; - oldsize = t->bucketsSize; - newsize = oldsize << 1; - t->bucketsSize = (unsigned int)newsize; - t->bucketsMask = mask = newsize - 1; - t->buckets = hp = bmake_malloc(sizeof(*hp) * newsize); - i = (int)newsize; - while (--i >= 0) - *hp++ = NULL; - for (hp = oldhp, i = (int)oldsize; --i >= 0;) { - for (e = *hp++; e != NULL; e = next) { - next = e->next; - xp = >buckets[e->key_hash & mask]; - e->next = *xp; - *xp = e; + unsigned int oldSize = t->bucketsSize; + HashEntry **oldBuckets = t->buckets; + unsigned int newSize = 2 * oldSize; + unsigned int newMask = newSize - 1; + HashEntry **newBuckets = bmake_malloc(sizeof(*newBuckets) * newSize); + size_t i; + + for (i = 0; i < newSize; i++) + newBuckets[i] = NULL; + + for (i = 0; i < oldSize; i++) { + HashEntry *he = oldBuckets[i]; + while (he != NULL) { + HashEntry *next = he->next; + he->next = newBuckets[he->key_hash & newMask]; + newBuckets[he->key_hash & newMask] = he; + he = next; } } - free(oldhp); + + free(oldBuckets); + + t->bucketsSize = newSize; + t->bucketsMask = newMask; + t->buckets = newBuckets; DEBUG5(HASH, "%s: %p size=%d entries=%d maxchain=%d\n", __func__, t, t->bucketsSize, t->numEntries, t->maxchain); t->maxchain = 0;
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Oct 25 17:37:36 UTC 2020 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: varmod-match-escape.exp Log Message: Skip reading .MAKE.DEPENDFILE if set to "/dev/null" or anything starting with "no". Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223564 To generate a diff of this commit: cvs rdiff -u -r1.388 -r1.389 src/usr.bin/make/main.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-match-escape.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.388 src/usr.bin/make/main.c:1.389 --- src/usr.bin/make/main.c:1.388 Sat Oct 24 20:29:40 2020 +++ src/usr.bin/make/main.c Sun Oct 25 17:37:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.388 2020/10/24 20:29:40 rillig Exp $ */ +/* $NetBSD: main.c,v 1.389 2020/10/25 17:37:36 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -118,7 +118,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.388 2020/10/24 20:29:40 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.389 2020/10/25 17:37:36 sjg Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1408,12 +1408,15 @@ main(int argc, char **argv) /* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */ if (!noBuiltins || !printVars) { - (void)Var_Subst("${.MAKE.DEPENDFILE:T}", + /* ignore /dev/null and anything starting with "no" */ + (void)Var_Subst("${.MAKE.DEPENDFILE:N/dev/null:Nno*:T}", VAR_CMD, VARE_WANTRES, ); - /* TODO: handle errors */ - doing_depend = TRUE; - (void)ReadMakefile(makeDependfile); - doing_depend = FALSE; + if (makeDependfile[0] != '\0') { + /* TODO: handle errors */ + doing_depend = TRUE; + (void)ReadMakefile(makeDependfile); + doing_depend = FALSE; + } } if (enterFlagObj) Index: src/usr.bin/make/unit-tests/varmod-match-escape.exp diff -u src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.1 src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.2 --- src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.1 Sun Aug 16 20:03:53 2020 +++ src/usr.bin/make/unit-tests/varmod-match-escape.exp Sun Oct 25 17:37:36 2020 @@ -1,3 +1,5 @@ Pattern[SPECIALS] for [\: : \\ * \*] is [\:] Pattern[SPECIALS] for [\: : \\ * \*] is [:] +Pattern[.MAKE.DEPENDFILE] for [.depend] is [/dev/null] +Pattern[.MAKE.DEPENDFILE] for [.depend] is [no*] exit status 0
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 17:12:51 UTC 2020 Modified Files: src/usr.bin/make: suff.c Log Message: make(1): add more details to DEBUG_SRC log To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.223 src/usr.bin/make/suff.c:1.224 --- src/usr.bin/make/suff.c:1.223 Sun Oct 25 10:00:20 2020 +++ src/usr.bin/make/suff.c Sun Oct 25 17:12:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.223 2020/10/25 10:00:20 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.224 2020/10/25 17:12:51 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -129,7 +129,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.223 2020/10/25 10:00:20 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.224 2020/10/25 17:12:51 rillig Exp $"); #define SUFF_DEBUG0(text) DEBUG0(SUFF, text) #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1) @@ -875,7 +875,8 @@ SuffAddSrc(Suff *suff, SrcList *srcList, Lst_Append(srcList, s2); #ifdef DEBUG_SRC Lst_Append(targ->childrenList, s2); -debug_printf("%s add %p %p to %p:", debug_tag, targ, s2, srcList); +debug_printf("%s add suff %p src %p to list %p:", + debug_tag, targ, s2, srcList); SrcList_PrintAddrs(srcList); #endif } @@ -927,7 +928,7 @@ SuffRemoveSrc(SrcList *l) SrcListNode *ln; #ifdef DEBUG_SRC -debug_printf("cleaning %p:", l); +debug_printf("cleaning list %p:", l); SrcList_PrintAddrs(l); #endif @@ -947,7 +948,8 @@ SuffRemoveSrc(SrcList *l) s->parent->children--; } #ifdef DEBUG_SRC - debug_printf("free: [l=%p] p=%p %d\n", l, s, s->children); + debug_printf("free: list %p src %p children %d\n", + l, s, s->children); Lst_Free(s->childrenList); #endif Lst_Remove(l, ln); @@ -956,7 +958,8 @@ SuffRemoveSrc(SrcList *l) } #ifdef DEBUG_SRC else { - debug_printf("keep: [l=%p] p=%p %d:", l, s, s->children); + debug_printf("keep: list %p src %p children %d:", + l, s, s->children); SrcList_PrintAddrs(s->childrenList); } #endif @@ -989,7 +992,7 @@ SuffFindThem(SrcList *srcs, SrcList *sls */ if (Targ_FindNode(src->file) != NULL) { #ifdef DEBUG_SRC - debug_printf("remove %p from %p\n", src, srcs); + debug_printf("remove from list %p src %p\n", srcs, src); #endif retsrc = src; break; @@ -1000,7 +1003,7 @@ SuffFindThem(SrcList *srcs, SrcList *sls if (file != NULL) { retsrc = src; #ifdef DEBUG_SRC - debug_printf("remove %p from %p\n", src, srcs); + debug_printf("remove from list %p src %p\n", srcs, src); #endif free(file); break; @@ -1099,7 +1102,7 @@ SuffFindCmds(Src *targ, SrcList *slst) suff->refCount++; targ->children++; #ifdef DEBUG_SRC -debug_printf("3 add %p %p\n", targ, ret); +debug_printf("3 add targ %p ret %p\n", targ, ret); Lst_Append(targ->childrenList, ret); #endif Lst_Append(slst, ret);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 17:01:05 UTC 2020 Modified Files: src/usr.bin/make: hash.c hash.h var.c Log Message: make(1): reduce amount of string hashing In pkgsrc, running "bmake show-all" in pkgtools/pkglint called the hash function 249130 times before, and only 115502 times after. Still, a single call to Var_Set hashes the same string 3 times. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/make/hash.c cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/hash.h cvs rdiff -u -r1.585 -r1.586 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.47 src/usr.bin/make/hash.c:1.48 --- src/usr.bin/make/hash.c:1.47 Sun Oct 18 12:47:43 2020 +++ src/usr.bin/make/hash.c Sun Oct 25 17:01:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.47 2020/10/18 12:47:43 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.48 2020/10/25 17:01:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.47 2020/10/18 12:47:43 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.48 2020/10/25 17:01:05 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -100,6 +100,12 @@ hash(const char *key, size_t *out_keylen return h; } +unsigned int +Hash_Hash(const char *key) +{ +return hash(key, NULL); +} + static HashEntry * HashTable_Find(HashTable *t, unsigned int h, const char *key) { @@ -185,6 +191,13 @@ Hash_FindValue(HashTable *t, const char return he != NULL ? he->value : NULL; } +void * +Hash_FindValueHash(HashTable *t, const char *key, unsigned int h) +{ + HashEntry *he = HashTable_Find(t, h, key); + return he != NULL ? he->value : NULL; +} + /* Makes a new hash table that is larger than the old one. The entire hash * table is moved, so any bucket numbers from the old table become invalid. */ static void Index: src/usr.bin/make/hash.h diff -u src/usr.bin/make/hash.h:1.29 src/usr.bin/make/hash.h:1.30 --- src/usr.bin/make/hash.h:1.29 Sun Oct 18 12:47:43 2020 +++ src/usr.bin/make/hash.h Sun Oct 25 17:01:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.h,v 1.29 2020/10/18 12:47:43 rillig Exp $ */ +/* $NetBSD: hash.h,v 1.30 2020/10/25 17:01:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -81,9 +81,9 @@ typedef struct HashEntry { struct HashEntry *next; /* Used to link together all the entries * associated with the same bucket. */ -void *value; -unsigned key_hash; /* hash value of the key */ -char key[1]; /* key string, variable length */ +void *value; +unsigned int key_hash; /* hash value of the key */ +char key[1]; /* key string, variable length */ } HashEntry; /* The hash table containing the entries. */ @@ -119,6 +119,8 @@ void Hash_InitTable(HashTable *); void Hash_DeleteTable(HashTable *); HashEntry *Hash_FindEntry(HashTable *, const char *); void *Hash_FindValue(HashTable *, const char *); +unsigned int Hash_Hash(const char *); +void *Hash_FindValueHash(HashTable *, const char *, unsigned int); HashEntry *Hash_CreateEntry(HashTable *, const char *, Boolean *); void Hash_DeleteEntry(HashTable *, HashEntry *); Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.585 src/usr.bin/make/var.c:1.586 --- src/usr.bin/make/var.c:1.585 Sun Oct 25 13:06:12 2020 +++ src/usr.bin/make/var.c Sun Oct 25 17:01:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.585 2020/10/25 13:06:12 rillig Exp $ */ +/* $NetBSD: var.c,v 1.586 2020/10/25 17:01:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.585 2020/10/25 13:06:12 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.586 2020/10/25 17:01:05 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -353,6 +353,7 @@ static Var * VarFind(const char *name, GNode *ctxt, VarFindFlags flags) { Var *var; +unsigned int nameHash; /* * If the variable name begins with a '.', it could very well be one of @@ -361,24 +362,25 @@ VarFind(const char *name, GNode *ctxt, V * them. */ name = CanonicalVarname(name); +nameHash = Hash_Hash(name); /* * First look for the variable in the given context. If it's not there, * look for it in VAR_CMD, VAR_GLOBAL and the environment, in that order, * depending on the FIND_* flags in 'flags' */ -var = Hash_FindValue(>context, name); +var = Hash_FindValueHash(>context, name, nameHash); if (var == NULL && (flags &
CVS commit: src
Module Name:src Committed By: nia Date: Sun Oct 25 16:59:28 UTC 2020 Modified Files: src/distrib/sets/lists/xbase: shl.mi src/distrib/sets/lists/xcomp: mi shl.mi src/distrib/sets/lists/xdebug: mi shl.mi src/external/mit/xorg/lib: Makefile Removed Files: src/external/mit/xorg/lib/libglut: Makefile shlib_version Log Message: Unhook libglut (MesaGLUT) from the build. The GL Utility Library was formerly a core part of most OpenGL distributions. Originally, this version of libglut was developed as part of Mesa (the primary OpenGL implementation used in NetBSD) before it was mostly abandoned and work moved to the freeglut fork. It provides a platform-neutral way of creating OpenGL contexts, something that many other libraries can also do today (e.g. SDL, glfw). All users in pkgsrc have been switched to the freeglut fork and there are no remaining users of this library in src. If having a GLUT implementation in base turns out to be particularly useful outside of compatibility with previous NetBSD versions, we can import freeglut (which, AFAIK, is also ABI compatible with MesaGLUT). To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/distrib/sets/lists/xbase/shl.mi cvs rdiff -u -r1.218 -r1.219 src/distrib/sets/lists/xcomp/mi cvs rdiff -u -r1.53 -r1.54 src/distrib/sets/lists/xcomp/shl.mi cvs rdiff -u -r1.36 -r1.37 src/distrib/sets/lists/xdebug/mi cvs rdiff -u -r1.55 -r1.56 src/distrib/sets/lists/xdebug/shl.mi cvs rdiff -u -r1.51 -r1.52 src/external/mit/xorg/lib/Makefile cvs rdiff -u -r1.9 -r0 src/external/mit/xorg/lib/libglut/Makefile cvs rdiff -u -r1.2 -r0 src/external/mit/xorg/lib/libglut/shlib_version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/xbase/shl.mi diff -u src/distrib/sets/lists/xbase/shl.mi:1.89 src/distrib/sets/lists/xbase/shl.mi:1.90 --- src/distrib/sets/lists/xbase/shl.mi:1.89 Thu Aug 27 15:32:00 2020 +++ src/distrib/sets/lists/xbase/shl.mi Sun Oct 25 16:59:27 2020 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.89 2020/08/27 15:32:00 riastradh Exp $ +# $NetBSD: shl.mi,v 1.90 2020/10/25 16:59:27 nia Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -191,9 +191,9 @@ ./usr/X11R7/lib/libglapi.so xbase-libglapi-lib xorg,compatx11file ./usr/X11R7/lib/libglapi.so.1 xbase-libglapi-lib xorg,compatx11file ./usr/X11R7/lib/libglapi.so.1.0 xbase-libglapi-lib xorg,compatx11file -./usr/X11R7/lib/libglut.so xbase-libglut-lib xorg,compatx11file -./usr/X11R7/lib/libglut.so.4 xbase-libglut-lib xorg,compatx11file -./usr/X11R7/lib/libglut.so.4.0 xbase-libglut-lib xorg,compatx11file +./usr/X11R7/lib/libglut.so xbase-obsolete obsolete +./usr/X11R7/lib/libglut.so.4 xbase-obsolete obsolete +./usr/X11R7/lib/libglut.so.4.0 xbase-obsolete obsolete ./usr/X11R7/lib/liblbxutil.so xbase-obsolete obsolete ./usr/X11R7/lib/liblbxutil.so.2 xbase-obsolete obsolete ./usr/X11R7/lib/liblbxutil.so.2.0 xbase-obsolete obsolete Index: src/distrib/sets/lists/xcomp/mi diff -u src/distrib/sets/lists/xcomp/mi:1.218 src/distrib/sets/lists/xcomp/mi:1.219 --- src/distrib/sets/lists/xcomp/mi:1.218 Wed Oct 21 15:12:15 2020 +++ src/distrib/sets/lists/xcomp/mi Sun Oct 25 16:59:27 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.218 2020/10/21 15:12:15 maya Exp $ +# $NetBSD: mi,v 1.219 2020/10/25 16:59:27 nia Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -20,8 +20,8 @@ ./usr/X11R7/include/GL/glext.hxcomp-xorgproto-include xorg ./usr/X11R7/include/GL/glu.hxcomp-xorgproto-include xorg ./usr/X11R7/include/GL/glu_mangle.h xcomp-xorgproto-include xorg -./usr/X11R7/include/GL/glut.hxcomp-xorgproto-include xorg -./usr/X11R7/include/GL/glutf90.h xcomp-xorgproto-include xorg +./usr/X11R7/include/GL/glut.hxcomp-obsolete obsolete +./usr/X11R7/include/GL/glutf90.h xcomp-obsolete obsolete ./usr/X11R7/include/GL/glx.hxcomp-xorgproto-include xorg ./usr/X11R7/include/GL/glx_mangle.h xcomp-xorgproto-include xorg ./usr/X11R7/include/GL/glxext.hxcomp-xorgproto-include xorg @@ -1229,8 +1229,8 @@ ./usr/X11R7/lib/libgbm_p.axcomp-libgbm-lib profile,xorg,compatx11file ./usr/X11R7/lib/libglapi.axcomp-libglapi-lib xorg,compatx11file ./usr/X11R7/lib/libglapi_p.axcomp-libglapi-lib profile,xorg,compatx11file -./usr/X11R7/lib/libglut.axcomp-libglut-lib xorg,compatx11file -./usr/X11R7/lib/libglut_p.axcomp-libglut-lib profile,xorg,compatx11file +./usr/X11R7/lib/libglut.axcomp-obsolete obsolete +./usr/X11R7/lib/libglut_p.axcomp-obsolete obsolete ./usr/X11R7/lib/liblbxutil.axcomp-obsolete obsolete,compatx11file ./usr/X11R7/lib/liblbxutil_p.axcomp-obsolete obsolete,compatx11file ./usr/X11R7/lib/liblisp.axcomp-obsolete obsolete @@ -1340,7 +1340,7 @@ ./usr/X11R7/lib/pkgconfig/gl.pcxcomp-libGL-lib xorg
CVS commit: src
Module Name:src Committed By: nia Date: Sun Oct 25 16:39:00 UTC 2020 Modified Files: src/share/man/man4: acpicpu.4 src/share/man/man4/man4.x86: est.4 powernow.4 src/sys/arch/evbmips/loongson: loongson_clock.c src/sys/arch/macppc/dev: obio.c src/sys/arch/x86/acpi: acpi_cpu_md.c src/sys/arch/x86/x86: est.c powernow.c Log Message: Normalize some machine dependent CPU frequenct sysctl variables. This moves machdep.*.frequency.* to machdep.cpu.frequency.*. This was proposed on tech-kern some time ago. The intention is to allow third-party tools such as estd and conky to more easily and reliably fetch or modify the current CPU frequency without iterating through various machine-dependent variables to check their presence. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/share/man/man4/acpicpu.4 cvs rdiff -u -r1.5 -r1.6 src/share/man/man4/man4.x86/est.4 cvs rdiff -u -r1.3 -r1.4 src/share/man/man4/man4.x86/powernow.4 cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/loongson/loongson_clock.c cvs rdiff -u -r1.46 -r1.47 src/sys/arch/macppc/dev/obio.c cvs rdiff -u -r1.83 -r1.84 src/sys/arch/x86/acpi/acpi_cpu_md.c cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x86/x86/est.c cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/x86/powernow.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/acpicpu.4 diff -u src/share/man/man4/acpicpu.4:1.35 src/share/man/man4/acpicpu.4:1.36 --- src/share/man/man4/acpicpu.4:1.35 Fri Aug 31 19:34:44 2018 +++ src/share/man/man4/acpicpu.4 Sun Oct 25 16:39:00 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: acpicpu.4,v 1.35 2018/08/31 19:34:44 sevan Exp $ +.\" $NetBSD: acpicpu.4,v 1.36 2020/10/25 16:39:00 nia Exp $ .\" .\" Copyright (c) 2010 Jukka Ruohonen .\" All rights reserved. @@ -257,10 +257,6 @@ controls for P-states as the ones provid .Xr est 4 and .Xr powernow 4 . -Depending on the processor, the second-level node is either -.Ic machdep.est -or -.Ic machdep.powernow . Please note that future versions of .Nm may however remove these system control variables without further notice. Index: src/share/man/man4/man4.x86/est.4 diff -u src/share/man/man4/man4.x86/est.4:1.5 src/share/man/man4/man4.x86/est.4:1.6 --- src/share/man/man4/man4.x86/est.4:1.5 Fri Feb 17 22:10:47 2017 +++ src/share/man/man4/man4.x86/est.4 Sun Oct 25 16:39:00 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: est.4,v 1.5 2017/02/17 22:10:47 christos Exp $ +.\" $NetBSD: est.4,v 1.6 2020/10/25 16:39:00 nia Exp $ .\" .\" Copyright (c) 2011 Jukka Ruohonen .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 17, 2017 +.Dd September 7, 2020 .Dt EST 4 .Os .Sh NAME @@ -41,13 +41,13 @@ The following .Xr sysctl 8 variables are available with .Nm : -.Bl -tag -width "machdep.est.frequency.available" -offset indent -.It Ic machdep.est.frequency.target +.Bl -tag -width "machdep.cpu.frequency.available" -offset indent +.It Ic machdep.cpu.frequency.target The target frequency of the .Tn CPUs . -.It Ic machdep.est.frequency.current +.It Ic machdep.cpu.frequency.current The current frequency. -.It Ic machdep.est.frequency.available +.It Ic machdep.cpu.frequency.available The frequencies recognized by .Nm . .El Index: src/share/man/man4/man4.x86/powernow.4 diff -u src/share/man/man4/man4.x86/powernow.4:1.3 src/share/man/man4/man4.x86/powernow.4:1.4 --- src/share/man/man4/man4.x86/powernow.4:1.3 Fri Feb 17 22:10:47 2017 +++ src/share/man/man4/man4.x86/powernow.4 Sun Oct 25 16:39:00 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: powernow.4,v 1.3 2017/02/17 22:10:47 christos Exp $ +.\" $NetBSD: powernow.4,v 1.4 2020/10/25 16:39:00 nia Exp $ .\" .\" Copyright (c) 2011 Jukka Ruohonen .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 17, 2017 +.Dd September 7, 2020 .Dt POWERNOW 4 .Os .Sh NAME @@ -46,13 +46,13 @@ The following .Xr sysctl 8 variables are available with .Nm : -.Bl -tag -width "machdep.powernow.frequency.available" -offset 2n -.It Ic machdep.powernow.frequency.target +.Bl -tag -width "machdep.cpu.frequency.available" -offset 2n +.It Ic machdep.cpu.frequency.target The target frequency of the .Tn CPUs . -.It Ic machdep.powernow.frequency.current +.It Ic machdep.cpu.frequency.current The current frequency. -.It Ic machdep.powernow.frequency.available +.It Ic machdep.cpu.frequency.available The available frequencies. .El .Pp Index: src/sys/arch/evbmips/loongson/loongson_clock.c diff -u src/sys/arch/evbmips/loongson/loongson_clock.c:1.2 src/sys/arch/evbmips/loongson/loongson_clock.c:1.3 --- src/sys/arch/evbmips/loongson/loongson_clock.c:1.2 Fri May 29 12:30:40 2020 +++ src/sys/arch/evbmips/loongson/loongson_clock.c
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 16:18:02 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): clean up comments in .for handling To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.107 src/usr.bin/make/for.c:1.108 --- src/usr.bin/make/for.c:1.107 Sun Oct 25 16:15:48 2020 +++ src/usr.bin/make/for.c Sun Oct 25 16:18:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.107 2020/10/25 16:15:48 rillig Exp $ */ +/* $NetBSD: for.c,v 1.108 2020/10/25 16:18:02 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.107 2020/10/25 16:15:48 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.108 2020/10/25 16:18:02 rillig Exp $"); /* The .for loop substitutes the items as ${:U...}, which means * that characters that break this syntax must be backslash-escaped. */ @@ -178,14 +178,9 @@ For_Eval(const char *line) For *new_for; const char *p; -/* Skip the '.' and any following whitespace */ -p = line + 1; +p = line + 1; /* skip the '.' */ cpp_skip_whitespace(); -/* - * If we are not in a for loop quickly determine if the statement is - * a for. - */ if (!IsFor(p)) { if (IsEndfor(p)) { Parse_Error(PARSE_FATAL, "for-less endfor");
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 16:15:48 UTC 2020 Modified Files: src/usr.bin/make: for.c src/usr.bin/make/unit-tests: forloop.exp Log Message: make(1): use complete words in error message for .for loop To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/for.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/forloop.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.106 src/usr.bin/make/for.c:1.107 --- src/usr.bin/make/for.c:1.106 Sun Oct 25 16:14:08 2020 +++ src/usr.bin/make/for.c Sun Oct 25 16:15:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.106 2020/10/25 16:14:08 rillig Exp $ */ +/* $NetBSD: for.c,v 1.107 2020/10/25 16:15:48 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.106 2020/10/25 16:14:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.107 2020/10/25 16:15:48 rillig Exp $"); /* The .for loop substitutes the items as ${:U...}, which means * that characters that break this syntax must be backslash-escaped. */ @@ -260,7 +260,7 @@ For_Eval(const char *line) nitems % (nvars = new_for->vars.len)) { Parse_Error(PARSE_FATAL, "Wrong number of words (%zu) in .for substitution list" - " with %zu vars", nitems, nvars); + " with %zu variables", nitems, nvars); /* * Return 'success' so that the body of the .for loop is * accumulated. Index: src/usr.bin/make/unit-tests/forloop.exp diff -u src/usr.bin/make/unit-tests/forloop.exp:1.2 src/usr.bin/make/unit-tests/forloop.exp:1.3 --- src/usr.bin/make/unit-tests/forloop.exp:1.2 Fri May 1 16:29:34 2020 +++ src/usr.bin/make/unit-tests/forloop.exp Sun Oct 25 16:15:48 2020 @@ -13,7 +13,7 @@ a=four b="five" a=ONE b="TWO AND THREE" a=FOUR b="FIVE" We expect an error next: -make: "forloop.mk" line 46: Wrong number of words (9) in .for substitution list with 2 vars +make: "forloop.mk" line 46: Wrong number of words (9) in .for substitution list with 2 variables make: Fatal errors encountered -- cannot continue make: stopped in unit-tests OK
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 16:14:08 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): extract code to see if a directive is a .for or .endfor To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.105 src/usr.bin/make/for.c:1.106 --- src/usr.bin/make/for.c:1.105 Sun Oct 25 15:58:04 2020 +++ src/usr.bin/make/for.c Sun Oct 25 16:14:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.105 2020/10/25 15:58:04 rillig Exp $ */ +/* $NetBSD: for.c,v 1.106 2020/10/25 16:14:08 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,8 +60,10 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.105 2020/10/25 15:58:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.106 2020/10/25 16:14:08 rillig Exp $"); +/* The .for loop substitutes the items as ${:U...}, which means + * that characters that break this syntax must be backslash-escaped. */ typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, FOR_SUB_ESCAPE_BRACE = 0x0002, @@ -146,6 +148,19 @@ GetEscapes(const char *word) return escapes; } +static Boolean +IsFor(const char *p) +{ +return p[0] == 'f' && p[1] == 'o' && p[2] == 'r' && ch_isspace(p[3]); +} + +static Boolean +IsEndfor(const char *p) +{ +return p[0] == 'e' && strncmp(p, "endfor", 6) == 0 && + (p[6] == '\0' || ch_isspace(p[6])); +} + /* Evaluate the for loop in the passed line. The line looks like this: * .for in * @@ -171,8 +186,8 @@ For_Eval(const char *line) * If we are not in a for loop quickly determine if the statement is * a for. */ -if (p[0] != 'f' || p[1] != 'o' || p[2] != 'r' || !ch_isspace(p[3])) { - if (p[0] == 'e' && strncmp(p + 1, "ndfor", 5) == 0) { +if (!IsFor(p)) { + if (IsEndfor(p)) { Parse_Error(PARSE_FATAL, "for-less endfor"); return -1; } @@ -205,7 +220,7 @@ For_Eval(const char *line) } /* XXX: This allows arbitrary variable names; see directive-for.mk. */ - for (len = 1; p[len] && !ch_isspace(p[len]); len++) + for (len = 1; p[len] != '\0' && !ch_isspace(p[len]); len++) continue; if (len == 2 && p[0] == 'i' && p[1] == 'n') { @@ -227,14 +242,6 @@ For_Eval(const char *line) cpp_skip_whitespace(); -/* - * Make a list with the remaining words. - * The values are later substituted as ${:U...} so we must - * backslash-escape characters that break that syntax. - * Variables are fully expanded - so it is safe for escape $. - * We can't do the escapes here - because we don't know whether - * we will be substituting into ${...} or $(...). - */ { char *items; (void)Var_Subst(p, VAR_GLOBAL, VARE_WANTRES, ); @@ -281,11 +288,11 @@ For_Accum(const char *line) ptr++; cpp_skip_whitespace(); - if (strncmp(ptr, "endfor", 6) == 0 && (ch_isspace(ptr[6]) || !ptr[6])) { + if (IsEndfor(ptr)) { DEBUG1(FOR, "For: end for %d\n", forLevel); if (--forLevel <= 0) return FALSE; - } else if (strncmp(ptr, "for", 3) == 0 && ch_isspace(ptr[3])) { + } else if (IsFor(ptr)) { forLevel++; DEBUG1(FOR, "For: new loop %d\n", forLevel); }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 15:58:04 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): rename local variable in For_Eval To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.104 src/usr.bin/make/for.c:1.105 --- src/usr.bin/make/for.c:1.104 Sun Oct 25 15:49:03 2020 +++ src/usr.bin/make/for.c Sun Oct 25 15:58:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.104 2020/10/25 15:49:03 rillig Exp $ */ +/* $NetBSD: for.c,v 1.105 2020/10/25 15:58:04 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.104 2020/10/25 15:49:03 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.105 2020/10/25 15:58:04 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -161,25 +161,24 @@ int For_Eval(const char *line) { For *new_for; -const char *ptr; +const char *p; /* Skip the '.' and any following whitespace */ -ptr = line + 1; -cpp_skip_whitespace(); +p = line + 1; +cpp_skip_whitespace(); /* * If we are not in a for loop quickly determine if the statement is * a for. */ -if (ptr[0] != 'f' || ptr[1] != 'o' || ptr[2] != 'r' || - !ch_isspace(ptr[3])) { - if (ptr[0] == 'e' && strncmp(ptr + 1, "ndfor", 5) == 0) { +if (p[0] != 'f' || p[1] != 'o' || p[2] != 'r' || !ch_isspace(p[3])) { + if (p[0] == 'e' && strncmp(p + 1, "ndfor", 5) == 0) { Parse_Error(PARSE_FATAL, "for-less endfor"); return -1; } return 0; } -ptr += 3; +p += 3; /* * we found a for loop, and now we are going to parse it. @@ -198,26 +197,26 @@ For_Eval(const char *line) for (;;) { size_t len; - cpp_skip_whitespace(); - if (*ptr == '\0') { + cpp_skip_whitespace(); + if (*p == '\0') { Parse_Error(PARSE_FATAL, "missing `in' in for"); For_Free(new_for); return -1; } /* XXX: This allows arbitrary variable names; see directive-for.mk. */ - for (len = 1; ptr[len] && !ch_isspace(ptr[len]); len++) + for (len = 1; p[len] && !ch_isspace(p[len]); len++) continue; - if (len == 2 && ptr[0] == 'i' && ptr[1] == 'n') { - ptr += 2; + if (len == 2 && p[0] == 'i' && p[1] == 'n') { + p += 2; break; } if (len == 1) new_for->short_var = TRUE; - ForAddVar(new_for, ptr, len); - ptr += len; + ForAddVar(new_for, p, len); + p += len; } if (new_for->vars.len == 0) { @@ -226,7 +225,7 @@ For_Eval(const char *line) return -1; } -cpp_skip_whitespace(); +cpp_skip_whitespace(); /* * Make a list with the remaining words. @@ -238,7 +237,7 @@ For_Eval(const char *line) */ { char *items; - (void)Var_Subst(ptr, VAR_GLOBAL, VARE_WANTRES, ); + (void)Var_Subst(p, VAR_GLOBAL, VARE_WANTRES, ); /* TODO: handle errors */ new_for->items = Str_Words(items, FALSE); free(items);
CVS commit: src/sys/kern
Module Name:src Committed By: pgoyette Date: Sun Oct 25 15:55:37 UTC 2020 Modified Files: src/sys/kern: sys_ptrace_common.c Log Message: ptrace_Common is a module unto itself. Don't use the ptrace module's init/fini routines. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/kern/sys_ptrace_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_ptrace_common.c diff -u src/sys/kern/sys_ptrace_common.c:1.87 src/sys/kern/sys_ptrace_common.c:1.88 --- src/sys/kern/sys_ptrace_common.c:1.87 Tue Oct 20 20:28:55 2020 +++ src/sys/kern/sys_ptrace_common.c Sun Oct 25 15:55:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_ptrace_common.c,v 1.87 2020/10/20 20:28:55 christos Exp $ */ +/* $NetBSD: sys_ptrace_common.c,v 1.88 2020/10/25 15:55:36 pgoyette Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -107,7 +107,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.87 2020/10/20 20:28:55 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.88 2020/10/25 15:55:36 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ptrace.h" @@ -1577,16 +1577,30 @@ process_auxv_offset(struct proc *p, stru MODULE(MODULE_CLASS_EXEC, ptrace_common, NULL); static int +ptrace_common_init(void) +{ + + return 0; +} + +static int +ptrace_common_fini(void) +{ + + return 0; +} + +static int ptrace_common_modcmd(modcmd_t cmd, void *arg) { int error; switch (cmd) { case MODULE_CMD_INIT: -error = ptrace_init(); +error = ptrace_common_init(); break; case MODULE_CMD_FINI: -error = ptrace_fini(); +error = ptrace_common_fini(); break; default: ptrace_hooks();
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 15:49:03 UTC 2020 Modified Files: src/usr.bin/make: for.c src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk Log Message: make(1): test funny character in .for variable names To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/for.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-for.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.103 src/usr.bin/make/for.c:1.104 --- src/usr.bin/make/for.c:1.103 Sun Oct 25 15:41:31 2020 +++ src/usr.bin/make/for.c Sun Oct 25 15:49:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.103 2020/10/25 15:41:31 rillig Exp $ */ +/* $NetBSD: for.c,v 1.104 2020/10/25 15:49:03 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.103 2020/10/25 15:41:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.104 2020/10/25 15:49:03 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -205,8 +205,10 @@ For_Eval(const char *line) return -1; } + /* XXX: This allows arbitrary variable names; see directive-for.mk. */ for (len = 1; ptr[len] && !ch_isspace(ptr[len]); len++) continue; + if (len == 2 && ptr[0] == 'i' && ptr[1] == 'n') { ptr += 2; break; Index: src/usr.bin/make/unit-tests/directive-for.exp diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.5 src/usr.bin/make/unit-tests/directive-for.exp:1.6 --- src/usr.bin/make/unit-tests/directive-for.exp:1.5 Sun Oct 25 14:55:23 2020 +++ src/usr.bin/make/unit-tests/directive-for.exp Sun Oct 25 15:49:03 2020 @@ -14,4 +14,6 @@ make: "directive-for.mk" line 132: {{}} make: "directive-for.mk" line 132: )( )( )( make: "directive-for.mk" line 132: ][ ][ ][ make: "directive-for.mk" line 132: }{ }{ }{ +make: "directive-for.mk" line 140: outer value value +make: "directive-for.mk" line 140: outer "quoted" \"quoted\" exit status 0 Index: src/usr.bin/make/unit-tests/directive-for.mk diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.7 src/usr.bin/make/unit-tests/directive-for.mk:1.8 --- src/usr.bin/make/unit-tests/directive-for.mk:1.7 Sun Oct 25 14:55:23 2020 +++ src/usr.bin/make/unit-tests/directive-for.mk Sun Oct 25 15:49:03 2020 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for.mk,v 1.7 2020/10/25 14:55:23 rillig Exp $ +# $NetBSD: directive-for.mk,v 1.8 2020/10/25 15:49:03 rillig Exp $ # # Tests for the .for directive. @@ -132,5 +132,13 @@ EXPANSION${plus}= value . info $v ${v} $(v) .endfor +# As of 2020-10-25, the variable names may contain arbitrary characters, +# except for whitespace. This allows for creative side effects. Hopefully +# nobody is misusing this "feature". +var= outer +.for var:Q in value "quoted" +. info ${var} ${var:Q} ${var:Q:Q} +.endfor + all: @:;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 15:41:31 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): reduce memory allocation in .for loops It was not necessary to allocate a new buffer for each iteration of the .for loop. To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.102 src/usr.bin/make/for.c:1.103 --- src/usr.bin/make/for.c:1.102 Sun Oct 25 15:26:18 2020 +++ src/usr.bin/make/for.c Sun Oct 25 15:41:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.102 2020/10/25 15:26:18 rillig Exp $ */ +/* $NetBSD: for.c,v 1.103 2020/10/25 15:41:31 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.102 2020/10/25 15:26:18 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.103 2020/10/25 15:41:31 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -80,15 +80,15 @@ typedef struct ForVar { * State of a for loop. */ typedef struct For { -Buffer buf; /* Body of loop */ -Vector /* of ForVar */ vars; /* Iteration variables */ +Buffer body; /* Unexpanded body of the loop */ +Vector /* of ForVar */ vars; /* Iteration variables */ Words items; /* Substitution items */ -char *parse_buf; +Buffer curBody; /* Expanded body of the current iteration */ /* Is any of the names 1 character long? If so, when the variable values * are substituted, the parser must handle $V expressions as well, not * only ${V} and $(V). */ Boolean short_var; -unsigned int sub_next; +unsigned int sub_next; /* Where to continue iterating */ } For; static For *accumFor; /* Loop being accumulated */ @@ -110,14 +110,14 @@ ForVarDone(ForVar *var) static void For_Free(For *arg) { -Buf_Destroy(>buf, TRUE); +Buf_Destroy(>body, TRUE); while (arg->vars.len > 0) ForVarDone(Vector_Pop(>vars)); Vector_Done(>vars); Words_Free(arg->items); -free(arg->parse_buf); +Buf_Destroy(>curBody, TRUE); free(arg); } @@ -186,11 +186,11 @@ For_Eval(const char *line) */ new_for = bmake_malloc(sizeof *new_for); -Buf_Init(_for->buf, 0); +Buf_Init(_for->body, 0); Vector_Init(_for->vars, sizeof(ForVar)); new_for->items.words = NULL; new_for->items.freeIt = NULL; -new_for->parse_buf = NULL; +Buf_Init(_for->curBody, 0); new_for->short_var = FALSE; new_for->sub_next = 0; @@ -290,8 +290,8 @@ For_Accum(const char *line) } } -Buf_AddStr(>buf, line); -Buf_AddByte(>buf, '\n'); +Buf_AddStr(>body, line); +Buf_AddByte(>body, '\n'); return TRUE; } @@ -361,7 +361,7 @@ for_substitute(Buffer *cmds, const char static void SubstVarLong(For *arg, const char **inout_cp, const char **inout_cmd_cp, - Buffer *cmds, char ech) + char ech) { size_t i; const char *cp = *inout_cp; @@ -380,11 +380,11 @@ SubstVarLong(For *arg, const char **inou continue; /* Found a variable match. Replace with :U */ - Buf_AddBytesBetween(cmds, cmd_cp, cp); - Buf_AddStr(cmds, ":U"); + Buf_AddBytesBetween(>curBody, cmd_cp, cp); + Buf_AddStr(>curBody, ":U"); cp += vlen; cmd_cp = cp; - for_substitute(cmds, arg->items.words[arg->sub_next + i], ech); + for_substitute(>curBody, arg->items.words[arg->sub_next + i], ech); break; } @@ -394,7 +394,7 @@ SubstVarLong(For *arg, const char **inou static void SubstVarShort(For *arg, char const ch, - const char **inout_cp, const char **input_cmd_cp, Buffer *cmds) + const char **inout_cp, const char **input_cmd_cp) { const char *cp = *inout_cp; const char *cmd_cp = *input_cmd_cp; @@ -414,11 +414,11 @@ SubstVarShort(For *arg, char const ch, continue; /* Found a variable match. Replace with ${:U} */ - Buf_AddBytesBetween(cmds, cmd_cp, cp); - Buf_AddStr(cmds, "{:U"); + Buf_AddBytesBetween(>curBody, cmd_cp, cp); + Buf_AddStr(>curBody, "{:U"); cmd_cp = ++cp; - for_substitute(cmds, arg->items.words[arg->sub_next + i], '}'); - Buf_AddByte(cmds, '}'); + for_substitute(>curBody, arg->items.words[arg->sub_next + i], '}'); + Buf_AddByte(>curBody, '}'); break; } @@ -445,7 +445,6 @@ ForIterate(void *v_arg, size_t *ret_len) const char *cp; const char *cmd_cp; const char *body_end; -Buffer cmds; char *cmds_str; size_t cmd_len; @@ -455,35 +454,32 @@ ForIterate(void *v_arg, size_t *ret_len) return NULL; } -free(arg->parse_buf); -arg->parse_buf = NULL; +Buf_Empty(>curBody); -cmd_cp = Buf_GetAll(>buf, _len); +cmd_cp = Buf_GetAll(>body, _len); body_end = cmd_cp + cmd_len; -
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 15:26:19 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): use Words instead of Vector for the .for items This makes memory management a bit simpler and also more efficient. To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.101 src/usr.bin/make/for.c:1.102 --- src/usr.bin/make/for.c:1.101 Sun Oct 25 15:15:45 2020 +++ src/usr.bin/make/for.c Sun Oct 25 15:26:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.101 2020/10/25 15:15:45 rillig Exp $ */ +/* $NetBSD: for.c,v 1.102 2020/10/25 15:26:18 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.101 2020/10/25 15:15:45 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.102 2020/10/25 15:26:18 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -82,7 +82,7 @@ typedef struct ForVar { typedef struct For { Buffer buf; /* Body of loop */ Vector /* of ForVar */ vars; /* Iteration variables */ -Vector /* of char * */ items; /* Substitution items */ +Words items; /* Substitution items */ char *parse_buf; /* Is any of the names 1 character long? If so, when the variable values * are substituted, the parser must handle $V expressions as well, not @@ -107,26 +107,6 @@ ForVarDone(ForVar *var) free(var->name); } -static const char * -ForItem(For *f, size_t i) -{ -const char **item = Vector_Get(>items, i); -return *item; -} - -static void -ForAddItem(For *f, const char *value) -{ -char **item = Vector_Push(>items); -*item = bmake_strdup(value); -} - -static void -ForItemDone(char **item) -{ -free(*item); -} - static void For_Free(For *arg) { @@ -136,10 +116,7 @@ For_Free(For *arg) ForVarDone(Vector_Pop(>vars)); Vector_Done(>vars); -while (arg->items.len > 0) - ForItemDone(Vector_Pop(>items)); -Vector_Done(>items); - +Words_Free(arg->items); free(arg->parse_buf); free(arg); @@ -185,7 +162,6 @@ For_Eval(const char *line) { For *new_for; const char *ptr; -Words words; /* Skip the '.' and any following whitespace */ ptr = line + 1; @@ -212,7 +188,8 @@ For_Eval(const char *line) new_for = bmake_malloc(sizeof *new_for); Buf_Init(_for->buf, 0); Vector_Init(_for->vars, sizeof(ForVar)); -Vector_Init(_for->items, sizeof(char *)); +new_for->items.words = NULL; +new_for->items.freeIt = NULL; new_for->parse_buf = NULL; new_for->short_var = FALSE; new_for->sub_next = 0; @@ -261,25 +238,13 @@ For_Eval(const char *line) char *items; (void)Var_Subst(ptr, VAR_GLOBAL, VARE_WANTRES, ); /* TODO: handle errors */ - words = Str_Words(items, FALSE); + new_for->items = Str_Words(items, FALSE); free(items); -} - -{ - size_t i; - for (i = 0; i < words.len; i++) { - const char *word = words.words[i]; - - if (word[0] == '\0') - continue; /* .for var in ${:U} */ - - ForAddItem(new_for, word); - } + if (new_for->items.len == 1 && new_for->items.words[0][0] == '\0') + new_for->items.len = 0; /* .for var in ${:U} */ } -Words_Free(words); - { size_t nitems, nvars; @@ -293,8 +258,7 @@ For_Eval(const char *line) * accumulated. * Remove all items so that the loop doesn't iterate. */ - while (new_for->items.len > 0) - ForItemDone(Vector_Pop(_for->items)); + new_for->items.len = 0; } } @@ -420,7 +384,7 @@ SubstVarLong(For *arg, const char **inou Buf_AddStr(cmds, ":U"); cp += vlen; cmd_cp = cp; - for_substitute(cmds, ForItem(arg, arg->sub_next + i), ech); + for_substitute(cmds, arg->items.words[arg->sub_next + i], ech); break; } @@ -453,7 +417,7 @@ SubstVarShort(For *arg, char const ch, Buf_AddBytesBetween(cmds, cmd_cp, cp); Buf_AddStr(cmds, "{:U"); cmd_cp = ++cp; - for_substitute(cmds, ForItem(arg, arg->sub_next + i), '}'); + for_substitute(cmds, arg->items.words[arg->sub_next + i], '}'); Buf_AddByte(cmds, '}'); break; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 15:15:45 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): remove unnecessary type ForVar Now that the escaping information is computed just-in-time, the item of a .for loops is a simple string with no additional information. Therefore, unwrap the struct. To generate a diff of this commit: cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.100 src/usr.bin/make/for.c:1.101 --- src/usr.bin/make/for.c:1.100 Sun Oct 25 14:58:23 2020 +++ src/usr.bin/make/for.c Sun Oct 25 15:15:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.100 2020/10/25 14:58:23 rillig Exp $ */ +/* $NetBSD: for.c,v 1.101 2020/10/25 15:15:45 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.100 2020/10/25 14:58:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.101 2020/10/25 15:15:45 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -76,18 +76,13 @@ typedef struct ForVar { size_t len; } ForVar; -/* One of the items to the right of the "in" in a .for loop. */ -typedef struct ForItem { -char *value; -} ForItem; - /* * State of a for loop. */ typedef struct For { Buffer buf; /* Body of loop */ -Vector /* of ForVar */ vars; -Vector /* of ForItem */ items; /* Substitution items */ +Vector /* of ForVar */ vars; /* Iteration variables */ +Vector /* of char * */ items; /* Substitution items */ char *parse_buf; /* Is any of the names 1 character long? If so, when the variable values * are substituted, the parser must handle $V expressions as well, not @@ -112,17 +107,24 @@ ForVarDone(ForVar *var) free(var->name); } +static const char * +ForItem(For *f, size_t i) +{ +const char **item = Vector_Get(>items, i); +return *item; +} + static void ForAddItem(For *f, const char *value) { -ForItem *item = Vector_Push(>items); -item->value = bmake_strdup(value); +char **item = Vector_Push(>items); +*item = bmake_strdup(value); } static void -ForItemDone(ForItem *item) +ForItemDone(char **item) { -free(item->value); +free(*item); } static void @@ -210,7 +212,7 @@ For_Eval(const char *line) new_for = bmake_malloc(sizeof *new_for); Buf_Init(_for->buf, 0); Vector_Init(_for->vars, sizeof(ForVar)); -Vector_Init(_for->items, sizeof(ForItem)); +Vector_Init(_for->items, sizeof(char *)); new_for->parse_buf = NULL; new_for->short_var = FALSE; new_for->sub_next = 0; @@ -363,9 +365,8 @@ for_var_len(const char *var) } static void -for_substitute(Buffer *cmds, ForItem *forItem, char ech) +for_substitute(Buffer *cmds, const char *item, char ech) { -const char *item = forItem->value; ForEscapes escapes = GetEscapes(item); char ch; @@ -419,7 +420,7 @@ SubstVarLong(For *arg, const char **inou Buf_AddStr(cmds, ":U"); cp += vlen; cmd_cp = cp; - for_substitute(cmds, Vector_Get(>items, arg->sub_next + i), ech); + for_substitute(cmds, ForItem(arg, arg->sub_next + i), ech); break; } @@ -452,7 +453,7 @@ SubstVarShort(For *arg, char const ch, Buf_AddBytesBetween(cmds, cmd_cp, cp); Buf_AddStr(cmds, "{:U"); cmd_cp = ++cp; - for_substitute(cmds, Vector_Get(>items, arg->sub_next + i), '}'); + for_substitute(cmds, ForItem(arg, arg->sub_next + i), '}'); Buf_AddByte(cmds, '}'); break; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 14:58:23 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): compute escaping flags for .for values when needed Before, they were computed when parsing the .for line, which was unnecessarily early. To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.99 src/usr.bin/make/for.c:1.100 --- src/usr.bin/make/for.c:1.99 Sun Oct 25 14:29:13 2020 +++ src/usr.bin/make/for.c Sun Oct 25 14:58:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.99 2020/10/25 14:29:13 rillig Exp $ */ +/* $NetBSD: for.c,v 1.100 2020/10/25 14:58:23 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.99 2020/10/25 14:29:13 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.100 2020/10/25 14:58:23 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -78,8 +78,7 @@ typedef struct ForVar { /* One of the items to the right of the "in" in a .for loop. */ typedef struct ForItem { -char *value; /* unexpanded */ -ForEscapes escapes; +char *value; } ForItem; /* @@ -114,11 +113,10 @@ ForVarDone(ForVar *var) } static void -ForAddItem(For *f, const char *value, ForEscapes escapes) +ForAddItem(For *f, const char *value) { ForItem *item = Vector_Push(>items); item->value = bmake_strdup(value); -item->escapes = escapes; } static void @@ -270,13 +268,11 @@ For_Eval(const char *line) for (i = 0; i < words.len; i++) { const char *word = words.words[i]; - ForEscapes escapes; if (word[0] == '\0') continue; /* .for var in ${:U} */ - escapes = GetEscapes(word); - ForAddItem(new_for, word, escapes); + ForAddItem(new_for, word); } } @@ -370,7 +366,7 @@ static void for_substitute(Buffer *cmds, ForItem *forItem, char ech) { const char *item = forItem->value; -ForEscapes escapes = forItem->escapes; +ForEscapes escapes = GetEscapes(item); char ch; /* If there were no escapes, or the only escape is the other variable
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Oct 25 14:55:23 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk Log Message: make(1): add test for escaping parentheses and braces in .for loops To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-for.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-for.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/directive-for.exp diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.4 src/usr.bin/make/unit-tests/directive-for.exp:1.5 --- src/usr.bin/make/unit-tests/directive-for.exp:1.4 Tue Sep 22 19:08:48 2020 +++ src/usr.bin/make/unit-tests/directive-for.exp Sun Oct 25 14:55:23 2020 @@ -2,4 +2,16 @@ make: "directive-for.mk" line 100: outer make: "directive-for.mk" line 125: a:\ a:\file.txt make: "directive-for.mk" line 125: d:\\ make: "directive-for.mk" line 125: d:\\file.txt +make: "directive-for.mk" line 132: ( ( ( +make: "directive-for.mk" line 132: [ [ [ +make: "directive-for.mk" line 132: { { { +make: "directive-for.mk" line 132: ) ) ) +make: "directive-for.mk" line 132: ] ] ] +make: "directive-for.mk" line 132: } } } +make: "directive-for.mk" line 132: (()) (()) (()) +make: "directive-for.mk" line 132: [[]] [[]] [[]] +make: "directive-for.mk" line 132: {{}} {{}} {{}} +make: "directive-for.mk" line 132: )( )( )( +make: "directive-for.mk" line 132: ][ ][ ][ +make: "directive-for.mk" line 132: }{ }{ }{ exit status 0 Index: src/usr.bin/make/unit-tests/directive-for.mk diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.6 src/usr.bin/make/unit-tests/directive-for.mk:1.7 --- src/usr.bin/make/unit-tests/directive-for.mk:1.6 Sat Oct 24 08:50:17 2020 +++ src/usr.bin/make/unit-tests/directive-for.mk Sun Oct 25 14:55:23 2020 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for.mk,v 1.6 2020/10/24 08:50:17 rillig Exp $ +# $NetBSD: directive-for.mk,v 1.7 2020/10/25 14:55:23 rillig Exp $ # # Tests for the .for directive. @@ -125,5 +125,12 @@ EXPANSION${plus}= value . info ${path} .endfor +# Ensure that braces and parentheses are properly escaped by the .for loop. +# Each line must print the same word 3 times. +# See GetEscapes. +.for v in ( [ { ) ] } (()) [[]] {{}} )( ][ }{ +. info $v ${v} $(v) +.endfor + all: @:;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 14:29:13 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): extract GetEscapes from For_Eval To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.98 src/usr.bin/make/for.c:1.99 --- src/usr.bin/make/for.c:1.98 Sun Oct 25 13:51:56 2020 +++ src/usr.bin/make/for.c Sun Oct 25 14:29:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.98 2020/10/25 13:51:56 rillig Exp $ */ +/* $NetBSD: for.c,v 1.99 2020/10/25 14:29:13 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.98 2020/10/25 13:51:56 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.99 2020/10/25 14:29:13 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -145,6 +145,30 @@ For_Free(For *arg) free(arg); } +static ForEscapes +GetEscapes(const char *word) +{ +const char *p; +ForEscapes escapes = 0; + +for (p = word; *p != '\0'; p++) { + switch (*p) { + case ':': + case '$': + case '\\': + escapes |= FOR_SUB_ESCAPE_CHAR; + break; + case ')': + escapes |= FOR_SUB_ESCAPE_PAREN; + break; + case '}': + escapes |= FOR_SUB_ESCAPE_BRACE; + break; + } +} +return escapes; +} + /* Evaluate the for loop in the passed line. The line looks like this: * .for in * @@ -242,32 +266,17 @@ For_Eval(const char *line) } { - size_t n; + size_t i; - for (n = 0; n < words.len; n++) { + for (i = 0; i < words.len; i++) { + const char *word = words.words[i]; ForEscapes escapes; - char ch; - ptr = words.words[n]; - if (ptr[0] == '\0') - continue; - escapes = 0; - while ((ch = *ptr++)) { - switch (ch) { - case ':': - case '$': - case '\\': - escapes |= FOR_SUB_ESCAPE_CHAR; - break; - case ')': - escapes |= FOR_SUB_ESCAPE_PAREN; - break; - case '}': - escapes |= FOR_SUB_ESCAPE_BRACE; - break; - } - } - ForAddItem(new_for, words.words[n], escapes); + if (word[0] == '\0') + continue; /* .for var in ${:U} */ + + escapes = GetEscapes(word); + ForAddItem(new_for, word, escapes); } }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 13:51:56 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): extract SubstVarShort from ForIterate To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.97 src/usr.bin/make/for.c:1.98 --- src/usr.bin/make/for.c:1.97 Sun Oct 25 13:45:33 2020 +++ src/usr.bin/make/for.c Sun Oct 25 13:51:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.97 2020/10/25 13:45:33 rillig Exp $ */ +/* $NetBSD: for.c,v 1.98 2020/10/25 13:51:56 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.97 2020/10/25 13:45:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.98 2020/10/25 13:51:56 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -422,6 +422,40 @@ SubstVarLong(For *arg, const char **inou *inout_cmd_cp = cmd_cp; } +static void +SubstVarShort(For *arg, char const ch, + const char **inout_cp, const char **input_cmd_cp, Buffer *cmds) +{ +const char *cp = *inout_cp; +const char *cmd_cp = *input_cmd_cp; +size_t i; + +/* Probably a single character name, ignore $$ and stupid ones. {*/ +if (!arg->short_var || strchr("}):$", ch) != NULL) { + cp++; + *inout_cp = cp; + return; +} + +for (i = 0; i < arg->vars.len; i++) { + ForVar *forVar = Vector_Get(>vars, i); + char *var = forVar->name; + if (var[0] != ch || var[1] != 0) + continue; + + /* Found a variable match. Replace with ${:U} */ + Buf_AddBytesBetween(cmds, cmd_cp, cp); + Buf_AddStr(cmds, "{:U"); + cmd_cp = ++cp; + for_substitute(cmds, Vector_Get(>items, arg->sub_next + i), '}'); + Buf_AddByte(cmds, '}'); + break; +} + +*inout_cp = cp; +*input_cmd_cp = cmd_cp; +} + /* * Scan the for loop body and replace references to the loop variables * with variable references that expand to the required text. @@ -459,7 +493,6 @@ ForIterate(void *v_arg, size_t *ret_len) Buf_Init(, cmd_len + 256); for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) { char ch, ech; - unsigned int i; ch = *++cp; if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) { cp++; @@ -470,24 +503,7 @@ ForIterate(void *v_arg, size_t *ret_len) if (ch == '\0') break; - /* Probably a single character name, ignore $$ and stupid ones. {*/ - if (!arg->short_var || strchr("}):$", ch) != NULL) { - cp++; - continue; - } - for (i = 0; i < arg->vars.len; i++) { - ForVar *forVar = Vector_Get(>vars, i); - char *var = forVar->name; - if (var[0] != ch || var[1] != 0) - continue; - /* Found a variable match. Replace with ${:U} */ - Buf_AddBytesBetween(, cmd_cp, cp); - Buf_AddStr(, "{:U"); - cmd_cp = ++cp; - for_substitute(, Vector_Get(>items, arg->sub_next + i), '}'); - Buf_AddByte(, '}'); - break; - } + SubstVarShort(arg, ch, , _cp, ); } Buf_AddBytesBetween(, cmd_cp, body_end);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 13:45:33 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): extract SubstVarLong from ForIterate To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.96 src/usr.bin/make/for.c:1.97 --- src/usr.bin/make/for.c:1.96 Sun Oct 25 13:20:11 2020 +++ src/usr.bin/make/for.c Sun Oct 25 13:45:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.96 2020/10/25 13:20:11 rillig Exp $ */ +/* $NetBSD: for.c,v 1.97 2020/10/25 13:45:33 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -60,7 +60,7 @@ #include"make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.96 2020/10/25 13:20:11 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.97 2020/10/25 13:45:33 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -389,6 +389,39 @@ for_substitute(Buffer *cmds, ForItem *fo } } +static void +SubstVarLong(For *arg, const char **inout_cp, const char **inout_cmd_cp, + Buffer *cmds, char ech) +{ +size_t i; +const char *cp = *inout_cp; +const char *cmd_cp = *inout_cmd_cp; + +for (i = 0; i < arg->vars.len; i++) { + ForVar *forVar = Vector_Get(>vars, i); + char *var = forVar->name; + size_t vlen = forVar->len; + + /* XXX: undefined behavior for cp if vlen is longer than cp? */ + if (memcmp(cp, var, vlen) != 0) + continue; + /* XXX: why test for backslash here? */ + if (cp[vlen] != ':' && cp[vlen] != ech && cp[vlen] != '\\') + continue; + + /* Found a variable match. Replace with :U */ + Buf_AddBytesBetween(cmds, cmd_cp, cp); + Buf_AddStr(cmds, ":U"); + cp += vlen; + cmd_cp = cp; + for_substitute(cmds, Vector_Get(>items, arg->sub_next + i), ech); + break; +} + +*inout_cp = cp; +*inout_cmd_cp = cmd_cp; +} + /* * Scan the for loop body and replace references to the loop variables * with variable references that expand to the required text. @@ -431,26 +464,12 @@ ForIterate(void *v_arg, size_t *ret_len) if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) { cp++; /* Check variable name against the .for loop variables */ - for (i = 0; i < arg->vars.len; i++) { - ForVar *forVar = Vector_Get(>vars, i); - char *var = forVar->name; - size_t vlen = forVar->len; - if (memcmp(cp, var, vlen) != 0) - continue; - if (cp[vlen] != ':' && cp[vlen] != ech && cp[vlen] != '\\') - continue; - /* Found a variable match. Replace with :U */ - Buf_AddBytesBetween(, cmd_cp, cp); - Buf_AddStr(, ":U"); - cp += vlen; - cmd_cp = cp; - for_substitute(, Vector_Get(>items, arg->sub_next + i), ech); - break; - } + SubstVarLong(arg, , _cp, , ech); continue; } if (ch == '\0') break; + /* Probably a single character name, ignore $$ and stupid ones. {*/ if (!arg->short_var || strchr("}):$", ch) != NULL) { cp++;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 13:31:16 UTC 2020 Modified Files: src/usr.bin/make: lst.h Log Message: make(1): remove obsolete comment from lst.h To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/usr.bin/make/lst.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.82 src/usr.bin/make/lst.h:1.83 --- src/usr.bin/make/lst.h:1.82 Sun Oct 25 13:06:12 2020 +++ src/usr.bin/make/lst.h Sun Oct 25 13:31:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.82 2020/10/25 13:06:12 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.83 2020/10/25 13:31:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -153,9 +153,6 @@ void LstNode_SetNull(ListNode *); * During this iteration, the list must not be modified structurally. */ int Lst_ForEachUntil(List *, LstActionUntilProc, void *); -/* Iterating over a list while keeping track of the current node and possible - * concurrent modifications */ - /* Using the list as a queue */ /* Add a datum at the tail of the queue. */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 13:25:19 UTC 2020 Modified Files: src/usr.bin/make: Makefile Makefile.boot Removed Files: src/usr.bin/make: strlist.c strlist.h Log Message: make(1): remove unused strlist_t To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/Makefile cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/Makefile.boot cvs rdiff -u -r1.8 -r0 src/usr.bin/make/strlist.c cvs rdiff -u -r1.4 -r0 src/usr.bin/make/strlist.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/Makefile diff -u src/usr.bin/make/Makefile:1.105 src/usr.bin/make/Makefile:1.106 --- src/usr.bin/make/Makefile:1.105 Fri Oct 23 15:44:38 2020 +++ src/usr.bin/make/Makefile Sun Oct 25 13:25:19 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.105 2020/10/23 15:44:38 rillig Exp $ +# $NetBSD: Makefile,v 1.106 2020/10/25 13:25:19 rillig Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 PROG= make @@ -18,7 +18,6 @@ SRCS+= make_malloc.c SRCS+= metachar.c SRCS+= parse.c SRCS+= str.c -SRCS+= strlist.c SRCS+= suff.c SRCS+= targ.c SRCS+= trace.c @@ -37,7 +36,6 @@ HDRS+= meta.h HDRS+= metachar.h HDRS+= nonints.h HDRS+= pathnames.h -HDRS+= strlist.h HDRS+= trace.h # Whether to generate a coverage report after running the tests. Index: src/usr.bin/make/Makefile.boot diff -u src/usr.bin/make/Makefile.boot:1.22 src/usr.bin/make/Makefile.boot:1.23 --- src/usr.bin/make/Makefile.boot:1.22 Sun Aug 9 15:54:13 2020 +++ src/usr.bin/make/Makefile.boot Sun Oct 25 13:25:19 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.boot,v 1.22 2020/08/09 15:54:13 rillig Exp $ +# $NetBSD: Makefile.boot,v 1.23 2020/10/25 13:25:19 rillig Exp $ # # A very simple makefile... # @@ -18,7 +18,7 @@ EXTRA_LIBS= OBJS= arch.o buf.o compat.o cond.o dir.o enum.o for.o hash.o \ job.o lst.o main.o make.o make_malloc.o metachar.o parse.o \ - str.o strlist.o suff.o targ.o trace.o var.o util.o + str.o suff.o targ.o trace.o var.o util.o .c.o: ${CC} ${CPPFLAGS} ${CFLAGS} ${EXTRA_CFLAGS} -c $< -o $@
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 13:20:11 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): use Vector instead of strlist_t for expanding .for loops strlist_t combines a string with an unsigned int. This unsigned int had been the string length for variables and the escaping flags for values. This is another case of using generic types where specific types would give more guidance to the reader. Defining the types ForVar and ForItem expresses the involved concepts more directly. This is the last use of strlist_t, which will be removed in a follow-up commit. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.95 src/usr.bin/make/for.c:1.96 --- src/usr.bin/make/for.c:1.95 Sun Oct 25 12:01:33 2020 +++ src/usr.bin/make/for.c Sun Oct 25 13:20:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.95 2020/10/25 12:01:33 rillig Exp $ */ +/* $NetBSD: for.c,v 1.96 2020/10/25 13:20:11 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -58,10 +58,9 @@ */ #include"make.h" -#include"strlist.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.95 2020/10/25 12:01:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.96 2020/10/25 13:20:11 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -71,13 +70,25 @@ typedef enum ForEscapes { static int forLevel = 0; /* Nesting level */ +/* One of the variables to the left of the "in" in a .for loop. */ +typedef struct ForVar { +char *name; +size_t len; +} ForVar; + +/* One of the items to the right of the "in" in a .for loop. */ +typedef struct ForItem { +char *value; /* unexpanded */ +ForEscapes escapes; +} ForItem; + /* * State of a for loop. */ typedef struct For { Buffer buf; /* Body of loop */ -strlist_t vars; /* Iteration variables */ -strlist_t items; /* Substitution items */ +Vector /* of ForVar */ vars; +Vector /* of ForItem */ items; /* Substitution items */ char *parse_buf; /* Is any of the names 1 character long? If so, when the variable values * are substituted, the parser must handle $V expressions as well, not @@ -88,13 +99,47 @@ typedef struct For { static For *accumFor; /* Loop being accumulated */ +static void +ForAddVar(For *f, const char *name, size_t len) +{ +ForVar *var = Vector_Push(>vars); +var->name = bmake_strldup(name, len); +var->len = len; +} + +static void +ForVarDone(ForVar *var) +{ +free(var->name); +} + +static void +ForAddItem(For *f, const char *value, ForEscapes escapes) +{ +ForItem *item = Vector_Push(>items); +item->value = bmake_strdup(value); +item->escapes = escapes; +} + +static void +ForItemDone(ForItem *item) +{ +free(item->value); +} static void For_Free(For *arg) { Buf_Destroy(>buf, TRUE); -strlist_clean(>vars); -strlist_clean(>items); + +while (arg->vars.len > 0) +ForVarDone(Vector_Pop(>vars)); +Vector_Done(>vars); + +while (arg->items.len > 0) + ForItemDone(Vector_Pop(>items)); +Vector_Done(>items); + free(arg->parse_buf); free(arg); @@ -142,8 +187,8 @@ For_Eval(const char *line) new_for = bmake_malloc(sizeof *new_for); Buf_Init(_for->buf, 0); -strlist_init(_for->vars); -strlist_init(_for->items); +Vector_Init(_for->vars, sizeof(ForVar)); +Vector_Init(_for->items, sizeof(ForItem)); new_for->parse_buf = NULL; new_for->short_var = FALSE; new_for->sub_next = 0; @@ -168,12 +213,11 @@ For_Eval(const char *line) if (len == 1) new_for->short_var = TRUE; - strlist_add_str(_for->vars, bmake_strldup(ptr, len), - (unsigned int)len); + ForAddVar(new_for, ptr, len); ptr += len; } -if (strlist_num(_for->vars) == 0) { +if (new_for->vars.len == 0) { Parse_Error(PARSE_FATAL, "no iteration variables in for"); For_Free(new_for); return -1; @@ -223,12 +267,7 @@ For_Eval(const char *line) break; } } - /* - * We have to dup words[n] to maintain the semantics of - * strlist. - */ - strlist_add_str(_for->items, bmake_strdup(words.words[n]), - escapes); + ForAddItem(new_for, words.words[n], escapes); } } @@ -237,8 +276,8 @@ For_Eval(const char *line) { size_t nitems, nvars; - if ((nitems = strlist_num(_for->items)) > 0 && - nitems% (nvars = strlist_num(_for->vars))) { + if ((nitems = new_for->items.len) > 0 && + nitems % (nvars = new_for->vars.len)) { Parse_Error(PARSE_FATAL, "Wrong number of words (%zu) in .for substitution list" " with %zu vars", nitems, nvars); @@ -247,7 +286,8 @@ For_Eval(const char *line) * accumulated. *
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 13:06:12 UTC 2020 Modified Files: src/usr.bin/make: lst.c lst.h parse.c var.c Log Message: make(1): replace PtrVector with Vector, which can contain any type To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/usr.bin/make/lst.c cvs rdiff -u -r1.81 -r1.82 src/usr.bin/make/lst.h cvs rdiff -u -r1.399 -r1.400 src/usr.bin/make/parse.c cvs rdiff -u -r1.584 -r1.585 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.89 src/usr.bin/make/lst.c:1.90 --- src/usr.bin/make/lst.c:1.89 Sun Oct 25 12:08:53 2020 +++ src/usr.bin/make/lst.c Sun Oct 25 13:06:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.89 2020/10/25 12:08:53 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.90 2020/10/25 13:06:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -34,7 +34,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: lst.c,v 1.89 2020/10/25 12:08:53 rillig Exp $"); +MAKE_RCSID("$NetBSD: lst.c,v 1.90 2020/10/25 13:06:12 rillig Exp $"); static ListNode * LstNodeNew(ListNode *prev, ListNode *next, void *datum) @@ -275,43 +275,48 @@ Lst_Dequeue(List *list) } void -PtrVector_Init(PtrVector *v) +Vector_Init(Vector *v, size_t itemSize) { v->len = 0; -v->cap = 10; -v->items = bmake_malloc(v->cap * sizeof v->items[0]); +v->priv_cap = 10; +v->itemSize = itemSize; +v->items = bmake_malloc(v->priv_cap * v->itemSize); } -Boolean PtrVector_IsEmpty(PtrVector *v) +/* Return the pointer to the given item in the vector. + * The returned data is valid until the next modifying operation. */ +void * +Vector_Get(Vector *v, size_t i) { -return v->len == 0; +unsigned char *items = v->items; +return items + i * v->itemSize; } -void PtrVector_Push(PtrVector *v, void *datum) +/* Add space for a new item to the vector and return a pointer to that space. + * The returned data is valid until the next modifying operation. */ +void * +Vector_Push(Vector *v) { -if (v->len >= v->cap) { - v->cap *= 2; - v->items = bmake_realloc(v->items, - v->cap * sizeof v->items[0]); +if (v->len >= v->priv_cap) { + v->priv_cap *= 2; + v->items = bmake_realloc(v->items, v->priv_cap * v->itemSize); } -v->items[v->len] = datum; v->len++; +return Vector_Get(v, v->len - 1); } -void *PtrVector_Pop(PtrVector *v) +/* Return the pointer to the last item in the vector. + * The returned data is valid until the next modifying operation. */ +void * +Vector_Pop(Vector *v) { -void *datum; - assert(v->len > 0); v->len--; -datum = v->items[v->len]; -#ifdef CLEANUP -v->items[v->len] = NULL; -#endif -return datum; +return Vector_Get(v, v->len); } -void PtrVector_Done(PtrVector *v) +void +Vector_Done(Vector *v) { free(v->items); } Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.81 src/usr.bin/make/lst.h:1.82 --- src/usr.bin/make/lst.h:1.81 Sun Oct 25 12:08:53 2020 +++ src/usr.bin/make/lst.h Sun Oct 25 13:06:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.81 2020/10/25 12:08:53 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.82 2020/10/25 13:06:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -163,18 +163,19 @@ void Lst_Enqueue(List *, void *); /* Remove the head node of the queue and return its datum. */ void *Lst_Dequeue(List *); -/* A pointer vector is an ordered collection of pointers, allowing for fast - * indexed access. */ -typedef struct PtrVector { -void **items; -size_t len; -size_t cap; -} PtrVector; - -void PtrVector_Init(PtrVector *); -Boolean PtrVector_IsEmpty(PtrVector *); -void PtrVector_Push(PtrVector *, void *); -void *PtrVector_Pop(PtrVector *); -void PtrVector_Done(PtrVector *); +/* A vector is an ordered collection of items, allowing for fast indexed + * access. */ +typedef struct Vector { +void *items; /* memory holding the items */ +size_t itemSize; /* size of a single item in bytes */ +size_t len; /* number of actually usable elements */ +size_t priv_cap; /* capacity */ +} Vector; + +void Vector_Init(Vector *, size_t); +void *Vector_Get(Vector *, size_t); +void *Vector_Push(Vector *); +void *Vector_Pop(Vector *); +void Vector_Done(Vector *); #endif /* MAKE_LST_H */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.399 src/usr.bin/make/parse.c:1.400 --- src/usr.bin/make/parse.c:1.399 Sun Oct 25 12:08:53 2020 +++ src/usr.bin/make/parse.c Sun Oct 25 13:06:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.399 2020/10/25 12:08:53 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.400 2020/10/25 13:06:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.399
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 12:08:53 UTC 2020 Modified Files: src/usr.bin/make: lst.c lst.h parse.c var.c src/usr.bin/make/unit-tests: include-sub.mk Log Message: make(1): rename type Vector to PtrVector This allows the name Vector to be used for a more generic vector type, which will be added soon. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/lst.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/make/lst.h cvs rdiff -u -r1.398 -r1.399 src/usr.bin/make/parse.c cvs rdiff -u -r1.583 -r1.584 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/include-sub.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.88 src/usr.bin/make/lst.c:1.89 --- src/usr.bin/make/lst.c:1.88 Sun Oct 25 10:07:23 2020 +++ src/usr.bin/make/lst.c Sun Oct 25 12:08:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.89 2020/10/25 12:08:53 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -34,7 +34,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: lst.c,v 1.89 2020/10/25 12:08:53 rillig Exp $"); static ListNode * LstNodeNew(ListNode *prev, ListNode *next, void *datum) @@ -275,19 +275,19 @@ Lst_Dequeue(List *list) } void -Vector_Init(Vector *v) +PtrVector_Init(PtrVector *v) { v->len = 0; v->cap = 10; v->items = bmake_malloc(v->cap * sizeof v->items[0]); } -Boolean Vector_IsEmpty(Vector *v) +Boolean PtrVector_IsEmpty(PtrVector *v) { return v->len == 0; } -void Vector_Push(Vector *v, void *datum) +void PtrVector_Push(PtrVector *v, void *datum) { if (v->len >= v->cap) { v->cap *= 2; @@ -298,7 +298,7 @@ void Vector_Push(Vector *v, void *datum) v->len++; } -void *Vector_Pop(Vector *v) +void *PtrVector_Pop(PtrVector *v) { void *datum; @@ -311,7 +311,7 @@ void *Vector_Pop(Vector *v) return datum; } -void Vector_Done(Vector *v) +void PtrVector_Done(PtrVector *v) { free(v->items); } Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.80 src/usr.bin/make/lst.h:1.81 --- src/usr.bin/make/lst.h:1.80 Sun Oct 25 10:07:23 2020 +++ src/usr.bin/make/lst.h Sun Oct 25 12:08:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.80 2020/10/25 10:07:23 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.81 2020/10/25 12:08:53 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -163,17 +163,18 @@ void Lst_Enqueue(List *, void *); /* Remove the head node of the queue and return its datum. */ void *Lst_Dequeue(List *); -/* A vector is an ordered collection of items, allowing fast indexed access. */ -typedef struct Vector { +/* A pointer vector is an ordered collection of pointers, allowing for fast + * indexed access. */ +typedef struct PtrVector { void **items; size_t len; size_t cap; -} Vector; +} PtrVector; -void Vector_Init(Vector *); -Boolean Vector_IsEmpty(Vector *); -void Vector_Push(Vector *, void *); -void *Vector_Pop(Vector *); -void Vector_Done(Vector *); +void PtrVector_Init(PtrVector *); +Boolean PtrVector_IsEmpty(PtrVector *); +void PtrVector_Push(PtrVector *, void *); +void *PtrVector_Pop(PtrVector *); +void PtrVector_Done(PtrVector *); #endif /* MAKE_LST_H */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.398 src/usr.bin/make/parse.c:1.399 --- src/usr.bin/make/parse.c:1.398 Fri Oct 23 20:04:56 2020 +++ src/usr.bin/make/parse.c Sun Oct 25 12:08:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.398 2020/10/23 20:04:56 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.399 2020/10/25 12:08:53 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.398 2020/10/23 20:04:56 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.399 2020/10/25 12:08:53 rillig Exp $"); /* types and constants */ @@ -281,7 +281,7 @@ static IFile *curFile; * (not printed since it is below a .for loop) * includes[0]: include-main.mk:27 */ -static Vector /* of IFile pointer */ includes; +static PtrVector /* of IFile pointer */ includes; /* include paths (lists of directories) */ SearchPath *parseIncPath; /* dirs for "..." includes */ @@ -2404,7 +2404,7 @@ Parse_SetInput(const char *name, int lin if (curFile != NULL) /* Save existing file info */ - Vector_Push(, curFile); + PtrVector_Push(, curFile); /* Allocate and fill in new structure */ curFile = bmake_malloc(sizeof *curFile); @@ -2599,7 +2599,7 @@ ParseEOF(void) free(curFile->P_str); free(curFile); -if (Vector_IsEmpty()) { +if (PtrVector_IsEmpty()) { curFile = NULL; /* We've run out of input */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 12:01:33 UTC 2020 Modified Files: src/usr.bin/make: for.c Log Message: make(1): clean up code for handling .for loops To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/usr.bin/make/for.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.94 src/usr.bin/make/for.c:1.95 --- src/usr.bin/make/for.c:1.94 Sun Oct 18 17:19:54 2020 +++ src/usr.bin/make/for.c Sun Oct 25 12:01:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.94 2020/10/18 17:19:54 rillig Exp $ */ +/* $NetBSD: for.c,v 1.95 2020/10/25 12:01:33 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -61,7 +61,7 @@ #include"strlist.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.94 2020/10/18 17:19:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.95 2020/10/25 12:01:33 rillig Exp $"); typedef enum ForEscapes { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -235,13 +235,13 @@ For_Eval(const char *line) Words_Free(words); { - size_t len, n; + size_t nitems, nvars; - if ((len = strlist_num(_for->items)) > 0 && - len % (n = strlist_num(_for->vars))) { + if ((nitems = strlist_num(_for->items)) > 0 && + nitems% (nvars = strlist_num(_for->vars))) { Parse_Error(PARSE_FATAL, "Wrong number of words (%zu) in .for substitution list" - " with %zu vars", len, n); + " with %zu vars", nitems, nvars); /* * Return 'success' so that the body of the .for loop is * accumulated. @@ -334,7 +334,7 @@ for_substitute(Buffer *cmds, strlist_t * /* Escape ':', '$', '\\' and 'ech' - these will be removed later by * :U processing, see ApplyModifier_Defined. */ -while ((ch = *item++) != 0) { +while ((ch = *item++) != '\0') { if (ch == '$') { size_t len = for_var_len(item); if (len != 0) { @@ -349,16 +349,25 @@ for_substitute(Buffer *cmds, strlist_t * } } +/* + * Scan the for loop body and replace references to the loop variables + * with variable references that expand to the required text. + * + * Using variable expansions ensures that the .for loop can't generate + * syntax, and that the later parsing will still see a variable. + * We assume that the null variable will never be defined. + * + * The detection of substitutions of the loop control variable is naive. + * Many of the modifiers use \ to escape $ (not $) so it is possible + * to contrive a makefile where an unwanted substitution happens. + */ static char * ForIterate(void *v_arg, size_t *ret_len) { For *arg = v_arg; -unsigned int i; -char *var; const char *cp; const char *cmd_cp; const char *body_end; -char ch; Buffer cmds; char *cmds_str; size_t cmd_len; @@ -372,23 +381,13 @@ ForIterate(void *v_arg, size_t *ret_len) free(arg->parse_buf); arg->parse_buf = NULL; -/* - * Scan the for loop body and replace references to the loop variables - * with variable references that expand to the required text. - * Using variable expansions ensures that the .for loop can't generate - * syntax, and that the later parsing will still see a variable. - * We assume that the null variable will never be defined. - * - * The detection of substitutions of the loop control variable is naive. - * Many of the modifiers use \ to escape $ (not $) so it is possible - * to contrive a makefile where an unwanted substitution happens. - */ - cmd_cp = Buf_GetAll(>buf, _len); body_end = cmd_cp + cmd_len; Buf_Init(, cmd_len + 256); for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) { - char ech; + char *var; + char ch, ech; + unsigned int i; ch = *++cp; if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) { cp++; @@ -409,7 +408,7 @@ ForIterate(void *v_arg, size_t *ret_len) } continue; } - if (ch == 0) + if (ch == '\0') break; /* Probably a single character name, ignore $$ and stupid ones. {*/ if (!arg->short_var || strchr("}):$", ch) != NULL) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 10:07:23 UTC 2020 Modified Files: src/usr.bin/make: lst.c lst.h make.c Log Message: make(1): inline Lst_Copy in Make_ExpandUse To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/usr.bin/make/lst.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/lst.h cvs rdiff -u -r1.178 -r1.179 src/usr.bin/make/make.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.87 src/usr.bin/make/lst.c:1.88 --- src/usr.bin/make/lst.c:1.87 Sat Oct 24 10:36:23 2020 +++ src/usr.bin/make/lst.c Sun Oct 25 10:07:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.87 2020/10/24 10:36:23 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -34,7 +34,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: lst.c,v 1.87 2020/10/24 10:36:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $"); static ListNode * LstNodeNew(ListNode *prev, ListNode *next, void *datum) @@ -58,25 +58,6 @@ Lst_New(void) return list; } -/* Duplicate an entire list, usually by copying the datum pointers. - * If copyProc is given, that function is used to create the new datum from the - * old datum, usually by creating a copy of it. */ -List * -Lst_Copy(List *list, LstCopyProc copyProc) -{ -List *newList; -ListNode *node; - -newList = Lst_New(); - -for (node = list->first; node != NULL; node = node->next) { - void *datum = copyProc != NULL ? copyProc(node->datum) : node->datum; - Lst_Append(newList, datum); -} - -return newList; -} - /* Free a list and all its nodes. The node data are not freed though. */ void Lst_Free(List *list) Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.79 src/usr.bin/make/lst.h:1.80 --- src/usr.bin/make/lst.h:1.79 Sat Oct 24 10:36:23 2020 +++ src/usr.bin/make/lst.h Sun Oct 25 10:07:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.79 2020/10/24 10:36:23 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.80 2020/10/25 10:07:23 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -102,10 +102,6 @@ struct List { ListNode *last; /* last node in list */ }; -/* Copy a node, usually by allocating a copy of the given object. - * For reference-counted objects, the original object may need to be - * modified, therefore the parameter is not const. */ -typedef void *LstCopyProc(void *); /* Free the datum of a node, called before freeing the node itself. */ typedef void LstFreeProc(void *); /* An action for Lst_ForEachUntil and Lst_ForEachUntilConcurrent. */ @@ -115,8 +111,6 @@ typedef int LstActionUntilProc(void *dat /* Create a new list. */ List *Lst_New(void); -/* Duplicate an existing list. */ -List *Lst_Copy(List *, LstCopyProc); /* Free the list, leaving the node data unmodified. */ void Lst_Free(List *); /* Free the list, freeing the node data using the given function. */ Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.178 src/usr.bin/make/make.c:1.179 --- src/usr.bin/make/make.c:1.178 Fri Oct 23 19:48:17 2020 +++ src/usr.bin/make/make.c Sun Oct 25 10:07:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.178 2020/10/23 19:48:17 rillig Exp $ */ +/* $NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -107,7 +107,7 @@ #include"job.h" /* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: make.c,v 1.178 2020/10/23 19:48:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $"); /* Sequence # to detect recursion. */ static unsigned int checked = 1; @@ -1126,7 +1126,15 @@ Make_ExpandUse(GNodeList *targs) { GNodeList *examine; /* List of targets to examine */ -examine = Lst_Copy(targs, NULL); +{ +/* XXX: Why is it necessary to copy the list? There shouldn't be + * any modifications to the list, at least the function name + * ExpandUse doesn't suggest that. */ + GNodeListNode *ln; + examine = Lst_New(); + for (ln = targs->first; ln != NULL; ln = ln->next) + Lst_Append(examine, ln->datum); +} /* * Make an initial downward pass over the graph, marking nodes to be made
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 10:00:20 UTC 2020 Modified Files: src/usr.bin/make: dir.c dir.h suff.c Log Message: make(1): replace Dir_CopyDir with Dir_CopyDirSearchPath Callback functions for the Lst functions do not belong in the public API of a module. To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/usr.bin/make/dir.c cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/dir.h cvs rdiff -u -r1.222 -r1.223 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.186 src/usr.bin/make/dir.c:1.187 --- src/usr.bin/make/dir.c:1.186 Sun Oct 25 09:51:52 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 10:00:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.186 2020/10/25 09:51:52 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.186 2020/10/25 09:51:52 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.187 2020/10/25 10:00:20 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -1447,22 +1447,19 @@ Dir_AddDir(SearchPath *path, const char return dir; } -/*- - *--- - * Dir_CopyDir -- - * Callback function for duplicating a search path via Lst_Copy. - * Ups the reference count for the directory. - * - * Results: - * Returns the Path it was given. - *--- - */ -void * -Dir_CopyDir(void *p) +/* Return a copy of dirSearchPath, incrementing the reference counts for + * the contained directories. */ +SearchPath * +Dir_CopyDirSearchPath(void) { -CachedDir *dir = p; -dir->refCount++; -return dir; +SearchPath *path = Lst_New(); +SearchPathNode *ln; +for (ln = dirSearchPath->first; ln != NULL; ln = ln->next) { + CachedDir *dir = ln->datum; + dir->refCount++; +Lst_Append(path, dir); +} +return path; } /*- Index: src/usr.bin/make/dir.h diff -u src/usr.bin/make/dir.h:1.31 src/usr.bin/make/dir.h:1.32 --- src/usr.bin/make/dir.h:1.31 Mon Oct 19 23:43:55 2020 +++ src/usr.bin/make/dir.h Sun Oct 25 10:00:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.31 2020/10/19 23:43:55 rillig Exp $ */ +/* $NetBSD: dir.h,v 1.32 2020/10/25 10:00:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -109,7 +109,7 @@ void Dir_Concat(SearchPath *, SearchPath void Dir_PrintDirectories(void); void Dir_PrintPath(SearchPath *); void Dir_Destroy(void *); -void *Dir_CopyDir(void *); +SearchPath *Dir_CopyDirSearchPath(void); /* Stripped-down variant of struct stat. */ struct make_stat { Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.222 src/usr.bin/make/suff.c:1.223 --- src/usr.bin/make/suff.c:1.222 Sat Oct 24 10:36:23 2020 +++ src/usr.bin/make/suff.c Sun Oct 25 10:00:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.222 2020/10/24 10:36:23 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.223 2020/10/25 10:00:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -129,7 +129,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.222 2020/10/24 10:36:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.223 2020/10/25 10:00:20 rillig Exp $"); #define SUFF_DEBUG0(text) DEBUG0(SUFF, text) #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1) @@ -789,7 +789,7 @@ Suff_DoPaths(void) Dir_Concat(s->searchPath, dirSearchPath); } else { Lst_Destroy(s->searchPath, Dir_Destroy); - s->searchPath = Lst_Copy(dirSearchPath, Dir_CopyDir); + s->searchPath = Dir_CopyDirSearchPath(); } }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 09:51:52 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): clean up Dir_HasWildcards To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.185 src/usr.bin/make/dir.c:1.186 --- src/usr.bin/make/dir.c:1.185 Sun Oct 25 09:30:45 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 09:51:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.185 2020/10/25 09:30:45 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.186 2020/10/25 09:51:52 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.185 2020/10/25 09:30:45 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.186 2020/10/25 09:51:52 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -529,28 +529,24 @@ Dir_SetPATH(void) } } -/* See if the given name has any wildcard characters in it. Be careful not to - * expand unmatching brackets or braces. +/* See if the given name has any wildcard characters in it and all braces and + * brackets are properly balanced. * * XXX: This code is not 100% correct ([^]] fails etc.). I really don't think * that make(1) should be expanding patterns, because then you have to set a * mechanism for escaping the expansion! * - * Input: - * name name to check - * - * Results: - * returns TRUE if the word should be expanded, FALSE otherwise + * Return TRUE if the word should be expanded, FALSE otherwise. */ Boolean Dir_HasWildcards(const char *name) { -const char *cp; +const char *p; Boolean wild = FALSE; int braces = 0, brackets = 0; -for (cp = name; *cp; cp++) { - switch (*cp) { +for (p = name; *p != '\0'; p++) { + switch (*p) { case '{': braces++; wild = TRUE;
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Oct 25 09:46:25 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: var-class-local.exp var-class-local.mk Log Message: make(1): add test for setting a variable in a GNode context This edge case is probably not used widely. The local variables of a GNode should only ever be the predefined variables. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-class-local.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-class-local.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/var-class-local.exp diff -u src/usr.bin/make/unit-tests/var-class-local.exp:1.1 src/usr.bin/make/unit-tests/var-class-local.exp:1.2 --- src/usr.bin/make/unit-tests/var-class-local.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/var-class-local.exp Sun Oct 25 09:46:25 2020 @@ -1 +1,2 @@ +: all overwritten exit status 0 Index: src/usr.bin/make/unit-tests/var-class-local.mk diff -u src/usr.bin/make/unit-tests/var-class-local.mk:1.3 src/usr.bin/make/unit-tests/var-class-local.mk:1.4 --- src/usr.bin/make/unit-tests/var-class-local.mk:1.3 Fri Oct 23 17:21:22 2020 +++ src/usr.bin/make/unit-tests/var-class-local.mk Sun Oct 25 09:46:25 2020 @@ -1,4 +1,4 @@ -# $NetBSD: var-class-local.mk,v 1.3 2020/10/23 17:21:22 rillig Exp $ +# $NetBSD: var-class-local.mk,v 1.4 2020/10/25 09:46:25 rillig Exp $ # # Tests for target-local variables, such as ${.TARGET} or $@. @@ -25,4 +25,7 @@ .endif all: - @:; + # The ::= modifier overwrites the .TARGET variable in the node + # 'all', not in the global scope. This can be seen with the -dv + # option, looking for "all:@ = overwritten". + : ${.TARGET} ${.TARGET::=overwritten}${.TARGET}
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 09:30:46 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): clean up DirLookupSubdir and DirLookupAbs As with cp2, the variable names p1 and p2 are not expressive. To generate a diff of this commit: cvs rdiff -u -r1.184 -r1.185 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.184 src/usr.bin/make/dir.c:1.185 --- src/usr.bin/make/dir.c:1.184 Sun Oct 25 09:19:10 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 09:30:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.184 2020/10/25 09:19:10 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.185 2020/10/25 09:30:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.184 2020/10/25 09:19:10 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.185 2020/10/25 09:30:45 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -887,34 +887,14 @@ DirLookup(CachedDir *dir, const char *ba } -/*- - *--- - * DirLookupSubdir -- - * Find if the file with the given name exists in the given path. - * - * Results: - * The path to the file or NULL. This path is guaranteed to be in a - * different part of memory than name and so may be safely free'd. - * - * Side Effects: - * If the file is found, it is added in the modification times hash - * table. - *--- - */ +/* Find if the file with the given name exists in the given directory. + * Return the freshly allocated path to the file, or NULL. */ static char * DirLookupSubdir(CachedDir *dir, const char *name) { struct make_stat mst; -char *file; /* the current filename to check */ - -if (dir != dot) { - file = str_concat3(dir->name, "/", name); -} else { - /* - * Checking in dot -- DON'T put a leading ./ on the thing. - */ - file = bmake_strdup(name); -} +char *file = dir == dot ? bmake_strdup(name) + : str_concat3(dir->name, "/", name); DIR_DEBUG1("checking %s ...\n", file); @@ -926,26 +906,15 @@ DirLookupSubdir(CachedDir *dir, const ch return NULL; } -/*- - *--- - * DirLookupAbs -- - * Find if the file with the given name exists in the given path. - * - * Results: - * The path to the file, the empty string or NULL. If the file is - * the empty string, the search should be terminated. - * This path is guaranteed to be in a different part of memory - * than name and so may be safely free'd. - * - * Side Effects: - * None. - *--- +/* Find if the file with the given name exists in the given path. + * Return the freshly allocated path to the file, the empty string, or NULL. + * Returning the empty string means that the search should be terminated. */ static char * DirLookupAbs(CachedDir *dir, const char *name, const char *cp) { -char *p1; /* pointer into dir->name */ -const char *p2; /* pointer into name */ +const char *dnp; /* pointer into dir->name */ +const char *np; /* pointer into name */ DIR_DEBUG1(" %s ...\n", dir->name); @@ -955,17 +924,14 @@ DirLookupAbs(CachedDir *dir, const char * directory, we can attempt another cache lookup. And if we don't * have a hit, we can safely assume the file does not exist at all. */ -for (p1 = dir->name, p2 = name; *p1 && *p1 == *p2; p1++, p2++) { +for (dnp = dir->name, np = name; *dnp != '\0' && *dnp == *np; dnp++, np++) continue; -} -if (*p1 != '\0' || p2 != cp - 1) { +if (*dnp != '\0' || np != cp - 1) return NULL; -} if (Hash_FindEntry(>files, cp) == NULL) { DIR_DEBUG0(" must be here but isn't -- returning\n"); - /* Return empty string: terminates search */ - return bmake_strdup(""); + return bmake_strdup(""); /* to terminate the search */ } dir->hits++;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 09:19:10 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): omit trailing space in debug output for expanding file patterns To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.183 src/usr.bin/make/dir.c:1.184 --- src/usr.bin/make/dir.c:1.183 Sun Oct 25 09:10:46 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 09:19:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.183 2020/10/25 09:10:46 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.184 2020/10/25 09:19:10 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.183 2020/10/25 09:10:46 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.184 2020/10/25 09:19:10 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -757,12 +757,14 @@ DirExpandPath(const char *word, SearchPa } static void -DirPrintExpansions(StringList *words) +PrintExpansions(StringList *expansions) { +const char *sep = ""; StringListNode *ln; -for (ln = words->first; ln != NULL; ln = ln->next) { +for (ln = expansions->first; ln != NULL; ln = ln->next) { const char *word = ln->datum; - debug_printf("%s ", word); + debug_printf("%s%s", sep, word); + sep = " "; } debug_printf("\n"); } @@ -862,7 +864,7 @@ Dir_Expand(const char *word, SearchPath } } if (DEBUG(DIR)) - DirPrintExpansions(expansions); + PrintExpansions(expansions); } /* Find if the file with the given name exists in the given path.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 09:10:46 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): clean up documentation of DirExpandInt, rename it The code in that function is so trivial that there is no point in writing this much redundant documentation. To generate a diff of this commit: cvs rdiff -u -r1.182 -r1.183 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.182 src/usr.bin/make/dir.c:1.183 --- src/usr.bin/make/dir.c:1.182 Sun Oct 25 09:03:05 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 09:10:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.182 2020/10/25 09:03:05 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.183 2020/10/25 09:10:46 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.182 2020/10/25 09:03:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.183 2020/10/25 09:10:46 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -745,28 +745,9 @@ DirExpandCurly(const char *word, const c } -/*- - *--- - * DirExpandInt -- - * Internal expand routine. Passes through the directories in the - * path one by one, calling DirMatchFiles for each. NOTE: This still - * doesn't handle patterns in directories... - * - * Input: - * word Word to expand - * path Directory in which to look - * expansions Place to store the result - * - * Results: - * None. - * - * Side Effects: - * Things are added to the expansions list. - * - *--- - */ +/* Expand the word in each of the directories from the path. */ static void -DirExpandInt(const char *word, SearchPath *path, StringList *expansions) +DirExpandPath(const char *word, SearchPath *path, StringList *expansions) { SearchPathNode *ln; for (ln = path->first; ln != NULL; ln = ln->next) { @@ -853,20 +834,20 @@ Dir_Expand(const char *word, SearchPath *dp = '\0'; path = Lst_New(); (void)Dir_AddDir(path, dirpath); - DirExpandInt(cp + 1, path, expansions); + DirExpandPath(cp + 1, path, expansions); Lst_Free(path); } } else { /* * Start the search from the local directory */ - DirExpandInt(word, path, expansions); + DirExpandPath(word, path, expansions); } } else { /* * Return the file -- this should never happen. */ - DirExpandInt(word, path, expansions); + DirExpandPath(word, path, expansions); } } else { /* @@ -877,7 +858,7 @@ Dir_Expand(const char *word, SearchPath /* * Then the files in every other directory on the path. */ - DirExpandInt(word, path, expansions); + DirExpandPath(word, path, expansions); } } if (DEBUG(DIR))
CVS commit: src/share/mk
Module Name:src Committed By: tsutsui Date: Sun Oct 25 09:06:24 UTC 2020 Modified Files: src/share/mk: bsd.own.mk Log Message: Switch alpha to USE_XZ_SETS=no, i.e. using gzip for installation sets. Ok'ed by martin@ in PR/55751. Maybe worth to pullup to netbsd-9. To generate a diff of this commit: cvs rdiff -u -r1.1228 -r1.1229 src/share/mk/bsd.own.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.own.mk diff -u src/share/mk/bsd.own.mk:1.1228 src/share/mk/bsd.own.mk:1.1229 --- src/share/mk/bsd.own.mk:1.1228 Sun Oct 18 19:58:02 2020 +++ src/share/mk/bsd.own.mk Sun Oct 25 09:06:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.own.mk,v 1.1228 2020/10/18 19:58:02 christos Exp $ +# $NetBSD: bsd.own.mk,v 1.1229 2020/10/25 09:06:24 tsutsui Exp $ # This needs to be before bsd.init.mk .if defined(BSD_MK_COMPAT_FILE) @@ -1494,7 +1494,6 @@ ${var}?= no .if ${USE_PIGZGZIP} == "no" && \ (${MACHINE} == "amd64" || \ ${MACHINE} == "sparc64" || \ - ${MACHINE} == "alpha" || \ ${MACHINE_ARCH} == "aarch64") USE_XZ_SETS?= yes .else
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 09:03:05 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): document pattern matching edge case in DirMatchFiles To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.181 src/usr.bin/make/dir.c:1.182 --- src/usr.bin/make/dir.c:1.181 Sun Oct 25 08:59:26 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 09:03:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.181 2020/10/25 08:59:26 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.182 2020/10/25 09:03:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.181 2020/10/25 08:59:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.182 2020/10/25 09:03:05 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -608,7 +608,8 @@ DirMatchFiles(const char *pattern, Cache * pattern begins with a dot. The pattern '.*' does not match '.' or * '..' since these are not included in the directory cache. * - * XXX: This means that the pattern '[a-z.]*' does not find '.file'. + * This means that the pattern '[a-z.]*' does not find '.file', which + * is consistent with bash, NetBSD sh and csh. */ if (base[0] == '.' && pattern[0] != '.') continue;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 08:59:26 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): refactor DirMatchFiles Split the conditions since the comment only applies to one of them. Use local variables for common subexpressions. To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.180 src/usr.bin/make/dir.c:1.181 --- src/usr.bin/make/dir.c:1.180 Sun Oct 25 08:10:03 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 08:59:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.180 2020/10/25 08:10:03 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.181 2020/10/25 08:59:26 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.180 2020/10/25 08:10:03 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.181 2020/10/25 08:59:26 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -576,48 +576,48 @@ Dir_HasWildcards(const char *name) return wild && brackets == 0 && braces == 0; } -/*- - *--- - * DirMatchFiles -- - * Given a pattern and a CachedDir structure, see if any files - * match the pattern and add their names to the 'expansions' list if - * any do. This is incomplete -- it doesn't take care of patterns like - * src / *src / *.c properly (just *.c on any of the directories), but it - * will do for now. +/* See if any files match the pattern and add their names to the 'expansions' + * list if they do. + * + * This is incomplete -- wildcards are only expanded in the final path + * component, but not in directories like src/lib*c/file*.c, but it + * will do for now (now being 1993 until at least 2020). To expand these, + * use the ':sh' variable modifier such as in ${:!echo src/lib*c/file*.c!}. * * Input: * pattern Pattern to look for * dir Directory to search * expansion Place to store the results - * - * Side Effects: - * File names are added to the expansions lst. The directory will be - * fully hashed when this is done. - *--- */ static void DirMatchFiles(const char *pattern, CachedDir *dir, StringList *expansions) { +const char *dirName = dir->name; +Boolean isDot = dirName[0] == '.' && dirName[1] == '\0'; HashIter hi; -HashEntry *entry; /* Current entry in the table */ -Boolean isDot; /* TRUE if the directory being searched is . */ - -isDot = (dir->name[0] == '.' && dir->name[1] == '\0'); HashIter_Init(, >files); -while ((entry = HashIter_Next()) != NULL) { +while (HashIter_Next() != NULL) { + const char *base = hi.entry->key; + + if (!Str_Match(base, pattern)) + continue; + /* - * See if the file matches the given pattern. Note we follow the UNIX - * convention that dot files will only be found if the pattern - * begins with a dot (note also that as a side effect of the hashing - * scheme, .* won't match . or .. since they aren't hashed). + * Follow the UNIX convention that dot files are only found if the + * pattern begins with a dot. The pattern '.*' does not match '.' or + * '..' since these are not included in the directory cache. + * + * XXX: This means that the pattern '[a-z.]*' does not find '.file'. */ - if (Str_Match(entry->key, pattern) && - (entry->key[0] != '.' || pattern[0] == '.')) + if (base[0] == '.' && pattern[0] != '.') + continue; + { - Lst_Append(expansions, - (isDot ? bmake_strdup(entry->key) : - str_concat3(dir->name, "/", entry->key))); + char *fullName = isDot + ? bmake_strdup(base) + : str_concat3(dirName, "/", base); + Lst_Append(expansions, fullName); } } } @@ -686,10 +686,14 @@ concat3(const char *a, size_t a_len, con return s; } -/* Expand curly braces like the C shell. Does this recursively. - * Note the special case: if after the piece of the curly brace is - * done, there are no wildcard characters in the result, the result is - * placed on the list WITHOUT CHECKING FOR ITS EXISTENCE. +/* Expand curly braces like the C shell. Brace expansion by itself is purely + * textual, the expansions are not looked up in the file system. But if an + * expanded word contains wildcard characters, it is expanded further, + * matching only the actually existing files. + * + * Example: "{a{b,c}}" expands to "ab" and "ac". + * Example: "{a}" expands to "a". + * Example: "{a,*.c}" expands to "a" and all "*.c" files that exist. * * Input: * word Entire word to expand
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Sun Oct 25 08:50:32 UTC 2020 Modified Files: src/usr.sbin/sysinst: util.c Log Message: Mark a variable only used in an assert as __diagused. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/sysinst/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/sysinst/util.c diff -u src/usr.sbin/sysinst/util.c:1.49 src/usr.sbin/sysinst/util.c:1.50 --- src/usr.sbin/sysinst/util.c:1.49 Sat Oct 24 16:13:15 2020 +++ src/usr.sbin/sysinst/util.c Sun Oct 25 08:50:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.49 2020/10/24 16:13:15 martin Exp $ */ +/* $NetBSD: util.c,v 1.50 2020/10/25 08:50:32 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -515,7 +515,7 @@ static int get_available_cds(void) { struct get_available_cds_state data; - int n, e; + int n, __diagused e; memset(, 0, sizeof data); data.info = cds;
CVS commit: src/sys/arch/arm/pic
Module Name:src Committed By: skrll Date: Sun Oct 25 08:29:30 UTC 2020 Modified Files: src/sys/arch/arm/pic: pic.c Log Message: KASSERT -> KASSERTMSG To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/arch/arm/pic/pic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/pic/pic.c diff -u src/sys/arch/arm/pic/pic.c:1.57 src/sys/arch/arm/pic/pic.c:1.58 --- src/sys/arch/arm/pic/pic.c:1.57 Mon Jul 27 16:26:51 2020 +++ src/sys/arch/arm/pic/pic.c Sun Oct 25 08:29:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $ */ +/* $NetBSD: pic.c,v 1.58 2020/10/25 08:29:30 skrll Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -33,7 +33,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.58 2020/10/25 08:29:30 skrll Exp $"); #include #include @@ -215,7 +215,8 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo sent_p = true; } } - KASSERT(cold || sent_p || ncpu <= 1); + KASSERTMSG(cold || sent_p || ncpu <= 1, "cold %d sent_p %d ncpu %d", + cold, sent_p, ncpu); } #endif /* MULTIPROCESSOR */
CVS commit: src/sys/net
Module Name:src Committed By: roy Date: Sun Oct 25 08:18:39 UTC 2020 Modified Files: src/sys/net: if_l2tp.c Log Message: l2tp: call if_link_state_change rather then directly setting it. This allows protocols to do their thing. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/net/if_l2tp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_l2tp.c diff -u src/sys/net/if_l2tp.c:1.45 src/sys/net/if_l2tp.c:1.46 --- src/sys/net/if_l2tp.c:1.45 Sun Oct 25 08:15:54 2020 +++ src/sys/net/if_l2tp.c Sun Oct 25 08:18:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_l2tp.c,v 1.45 2020/10/25 08:15:54 roy Exp $ */ +/* $NetBSD: if_l2tp.c,v 1.46 2020/10/25 08:18:39 roy Exp $ */ /* * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.45 2020/10/25 08:15:54 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.46 2020/10/25 08:18:39 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -324,6 +324,7 @@ l2tpattach0(struct l2tp_softc *sc) rv = if_attach(>l2tp_ec.ec_if); if (rv != 0) return rv; + if_link_state_change(>l2tp_ec.ec_if, LINK_STATE_DOWN); if_alloc_sadl(>l2tp_ec.ec_if); bpf_attach(>l2tp_ec.ec_if, DLT_EN10MB, sizeof(struct ether_header)); @@ -1354,6 +1355,7 @@ l2tp_set_state(struct l2tp_softc *sc, in { struct ifnet *ifp = >l2tp_ec.ec_if; struct l2tp_variant *nvar; + int ostate; nvar = kmem_alloc(sizeof(*nvar), KM_SLEEP); @@ -1361,16 +1363,21 @@ l2tp_set_state(struct l2tp_softc *sc, in *nvar = *sc->l2tp_var; psref_target_init(>lv_psref, lv_psref_class); + ostate = nvar->lv_state; nvar->lv_state = state; l2tp_variant_update(sc, nvar); + mutex_exit(>l2tp_lock); - if (nvar->lv_state == L2TP_STATE_UP) { - ifp->if_link_state = LINK_STATE_UP; - } else { - ifp->if_link_state = LINK_STATE_DOWN; - } + if (ostate != state) { + int lstate; - mutex_exit(>l2tp_lock); + if (state == L2TP_STATE_UP) + lstate = LINK_STATE_UP; + else + lstate = LINK_STATE_DOWN; + + if_link_state_change(ifp, lstate); + } #ifdef NOTYET vlan_linkstate_notify(ifp, ifp->if_link_state);
CVS commit: src/sys/net
Module Name:src Committed By: roy Date: Sun Oct 25 08:15:54 UTC 2020 Modified Files: src/sys/net: if_l2tp.c Log Message: l2tp: Revert prior It proves I can't read comments and that if_initialize should not be used. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/net/if_l2tp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_l2tp.c diff -u src/sys/net/if_l2tp.c:1.44 src/sys/net/if_l2tp.c:1.45 --- src/sys/net/if_l2tp.c:1.44 Thu Oct 15 02:54:10 2020 +++ src/sys/net/if_l2tp.c Sun Oct 25 08:15:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_l2tp.c,v 1.44 2020/10/15 02:54:10 roy Exp $ */ +/* $NetBSD: if_l2tp.c,v 1.45 2020/10/25 08:15:54 roy Exp $ */ /* * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.44 2020/10/15 02:54:10 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.45 2020/10/25 08:15:54 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -321,13 +321,11 @@ l2tpattach0(struct l2tp_softc *sc) * if_percpuq_enqueue(). However, that causes recursive softnet_lock * when NET_MPSAFE is not set. */ - rv = if_initialize(>l2tp_ec.ec_if); + rv = if_attach(>l2tp_ec.ec_if); if (rv != 0) return rv; - sc->l2tp_ec.ec_if.if_link_state = LINK_STATE_DOWN; if_alloc_sadl(>l2tp_ec.ec_if); bpf_attach(>l2tp_ec.ec_if, DLT_EN10MB, sizeof(struct ether_header)); - if_register(>l2tp_ec.ec_if); return 0; } @@ -811,7 +809,6 @@ l2tp_ioctl(struct ifnet *ifp, u_long cmd case SIOCDIFPHYADDR: l2tp_delete_tunnel(>l2tp_ec.ec_if); - if_link_state_change(>l2tp_ec.ec_if, LINK_STATE_DOWN); break; case SIOCGIFPSRCADDR: @@ -1074,8 +1071,6 @@ l2tp_set_tunnel(struct ifnet *ifp, struc if (odst) sockaddr_free(odst); kmem_free(ovar, sizeof(*ovar)); - - if_link_state_change(ifp, LINK_STATE_UP); return 0; error:
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 08:10:03 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): clean up documentation of DirExpandCurly and Dir_Expand To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.179 src/usr.bin/make/dir.c:1.180 --- src/usr.bin/make/dir.c:1.179 Sun Oct 25 07:59:09 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 08:10:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.179 2020/10/25 07:59:09 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.180 2020/10/25 08:10:03 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.179 2020/10/25 07:59:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.180 2020/10/25 08:10:03 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -686,27 +686,16 @@ concat3(const char *a, size_t a_len, con return s; } -/*- - *--- - * DirExpandCurly -- - * Expand curly braces like the C shell. Does this recursively. - * Note the special case: if after the piece of the curly brace is - * done there are no wildcard characters in the result, the result is - * placed on the list WITHOUT CHECKING FOR ITS EXISTENCE. +/* Expand curly braces like the C shell. Does this recursively. + * Note the special case: if after the piece of the curly brace is + * done, there are no wildcard characters in the result, the result is + * placed on the list WITHOUT CHECKING FOR ITS EXISTENCE. * * Input: * word Entire word to expand * brace First curly brace in it * path Search path to use * expansions Place to store the expansions - * - * Results: - * None. - * - * Side Effects: - * The given list is filled with the expansions... - * - *--- */ static void DirExpandCurly(const char *word, const char *brace, SearchPath *path, @@ -792,25 +781,13 @@ DirPrintExpansions(StringList *words) debug_printf("\n"); } -/*- - *--- - * Dir_Expand -- - * Expand the given word into a list of words by globbing it looking - * in the directories on the given search path. +/* Expand the given word into a list of words by globbing it, looking in the + * directories on the given search path. * * Input: * word the word to expand - * path the list of directories in which to find the - * resulting files + * path the directories in which to find the files * expansions the list on which to place the results - * - * Results: - * A list of words consisting of the files which exist along the search - * path matching the given pattern. - * - * Side Effects: - * Directories may be opened. Who knows? - *--- */ void Dir_Expand(const char *word, SearchPath *path, StringList *expansions)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 07:59:09 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): document that the SearchPath of Dir_FindFile may be NULL To generate a diff of this commit: cvs rdiff -u -r1.178 -r1.179 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.178 src/usr.bin/make/dir.c:1.179 --- src/usr.bin/make/dir.c:1.178 Sun Oct 25 07:46:05 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 07:59:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.178 2020/10/25 07:46:05 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.179 2020/10/25 07:59:09 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.178 2020/10/25 07:46:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.179 2020/10/25 07:59:09 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -1031,27 +1031,21 @@ DirFindDot(const char *name, const char return NULL; } -/*- - *--- - * Dir_FindFile -- - * Find the file with the given name along the given search path. +/* Find the file with the given name along the given search path. + * + * If the file is found in a directory that is not on the path + * already (either 'name' is absolute or it is a relative path + * [ dir1/.../dirn/file ] which exists below one of the directories + * already on the search path), its directory is added to the end + * of the path, on the assumption that there will be more files in + * that directory later on. Sometimes this is true. Sometimes not. * * Input: * name the file to find - * path the Lst of directories to search + * path the directories to search, or NULL * * Results: - * The path to the file or NULL. This path is guaranteed to be in a - * different part of memory than name and so may be safely free'd. - * - * Side Effects: - * If the file is found in a directory which is not on the path - * already (either 'name' is absolute or it is a relative path - * [ dir1/.../dirn/file ] which exists below one of the directories - * already on the search path), its directory is added to the end - * of the path on the assumption that there will be more files in - * that directory later on. Sometimes this is true. Sometimes not. - *--- + * The freshly allocated path to the file, or NULL. */ char * Dir_FindFile(const char *name, SearchPath *path)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 07:57:01 UTC 2020 Modified Files: src/usr.bin/make: arch.c Log Message: make(1): make Arch_FindLib simpler To generate a diff of this commit: cvs rdiff -u -r1.145 -r1.146 src/usr.bin/make/arch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.145 src/usr.bin/make/arch.c:1.146 --- src/usr.bin/make/arch.c:1.145 Sat Oct 24 04:20:50 2020 +++ src/usr.bin/make/arch.c Sun Oct 25 07:57:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.145 2020/10/24 04:20:50 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.146 2020/10/25 07:57:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -130,7 +130,7 @@ #include"config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.145 2020/10/24 04:20:50 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.146 2020/10/25 07:57:01 rillig Exp $"); #ifdef TARGET_MACHINE #undef MAKE_MACHINE @@ -993,19 +993,12 @@ Arch_MemMTime(GNode *gn) * * Input: * gn Node of library to find - * path Search path */ void Arch_FindLib(GNode *gn, SearchPath *path) { -char *libName; /* file name for archive */ -size_t sz = strlen(gn->name) + 6 - 2; - -libName = bmake_malloc(sz); -snprintf(libName, sz, "lib%s.a", >name[2]); - +char *libName = str_concat3("lib", gn->name + 2, ".a"); gn->path = Dir_FindFile(libName, path); - free(libName); #ifdef LIBRARIES
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: jdc Date: Sun Oct 25 07:46:54 UTC 2020 Modified Files: src/sys/arch/sparc64/sparc64: ofw_patch.c Log Message: Don't release the last reference to the "i2c-child-devices" dictionary in the v210/v240 patches. Fixes missing i2c devices there (pointed out by macallan@). While here, add debug to show when we create the dictionary. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/sparc64/ofw_patch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/sparc64/ofw_patch.c diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5 --- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4 Sat Oct 24 13:47:53 2020 +++ src/sys/arch/sparc64/sparc64/ofw_patch.c Sun Oct 25 07:46:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $ */ +/* $NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $"); #include @@ -63,6 +63,7 @@ create_i2c_dict(device_t busdev) cfg = prop_dictionary_get(props, "i2c-child-devices"); if (!cfg) { + DPRINTF(ACDB_PROBE, ("\nCreating new i2c-child-devices\n")); cfg = prop_array_create(); prop_dictionary_set(props, "i2c-child-devices", cfg); prop_dictionary_set_bool(props, "i2c-indirect-config", false); @@ -171,8 +172,6 @@ add_env_sensors_v210(device_t busdev) add_i2c_device(cfg, "hardware-monitor", "i2c-adm1026", 0x2e, 0); /* LM75 at 0x4e */ add_i2c_device(cfg, "temperature-sensor", "i2c-lm75", 0x4e, 0); - - prop_object_release(cfg); } /* Sensors and GPIO's for E450 and E250 */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 07:46:05 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): remove unused parameter from DirFindDot To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.177 src/usr.bin/make/dir.c:1.178 --- src/usr.bin/make/dir.c:1.177 Sun Oct 25 07:44:16 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 07:46:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.177 2020/10/25 07:44:16 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.178 2020/10/25 07:46:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.177 2020/10/25 07:44:16 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.178 2020/10/25 07:46:05 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -1009,34 +1009,23 @@ DirLookupAbs(CachedDir *dir, const char return bmake_strdup(name); } -/*- - *--- - * DirFindDot -- - * Find the file given on "." or curdir - * - * Results: - * The path to the file or NULL. This path is guaranteed to be in a - * different part of memory than name and so may be safely free'd. - * - * Side Effects: - * Hit counts change - *--- - */ +/* Find the file given on "." or curdir. + * Return the freshly allocated path to the file, or NULL. */ static char * -DirFindDot(Boolean hasSlash MAKE_ATTR_UNUSED, const char *name, const char *cp) +DirFindDot(const char *name, const char *base) { -if (Hash_FindEntry(>files, cp) != NULL) { +if (Hash_FindEntry(>files, base) != NULL) { DIR_DEBUG0(" in '.'\n"); hits++; dot->hits++; return bmake_strdup(name); } -if (cur && Hash_FindEntry(>files, cp) != NULL) { +if (cur != NULL && Hash_FindEntry(>files, base) != NULL) { DIR_DEBUG1(" in ${.CURDIR} = %s\n", cur->name); hits++; cur->hits++; - return str_concat3(cur->name, "/", cp); + return str_concat3(cur->name, "/", base); } return NULL; @@ -1125,7 +1114,7 @@ Dir_FindFile(const char *name, SearchPat * This is so there are no conflicts between what the user * specifies (fish.c) and what pmake finds (./fish.c). */ - if (!hasLastDot && (file = DirFindDot(hasSlash, name, base)) != NULL) + if (!hasLastDot && (file = DirFindDot(name, base)) != NULL) return file; for (; ln != NULL; ln = ln->next) { @@ -1136,7 +1125,7 @@ Dir_FindFile(const char *name, SearchPat return file; } - if (hasLastDot && (file = DirFindDot(hasSlash, name, base)) != NULL) + if (hasLastDot && (file = DirFindDot(name, base)) != NULL) return file; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 07:44:16 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): rename parameter of DirLookup The DirLookup functions work on "name", which may be a complete path, and on "base" or "cp", which is the basename of the file. Don't use "name" for the basename, since that would be confusing. To generate a diff of this commit: cvs rdiff -u -r1.176 -r1.177 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.176 src/usr.bin/make/dir.c:1.177 --- src/usr.bin/make/dir.c:1.176 Sun Oct 25 07:32:07 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 07:44:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.176 2020/10/25 07:32:07 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.177 2020/10/25 07:44:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.176 2020/10/25 07:32:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.177 2020/10/25 07:44:16 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -905,16 +905,16 @@ Dir_Expand(const char *word, SearchPath /* Find if the file with the given name exists in the given path. * Return the freshly allocated path to the file, or NULL. */ static char * -DirLookup(CachedDir *dir, const char *name) +DirLookup(CachedDir *dir, const char *base) { char *file; /* the current filename to check */ DIR_DEBUG1(" %s ...\n", dir->name); -if (Hash_FindEntry(>files, name) == NULL) +if (Hash_FindEntry(>files, base) == NULL) return NULL; -file = str_concat3(dir->name, "/", name); +file = str_concat3(dir->name, "/", base); DIR_DEBUG1(" returning %s\n", file); dir->hits++; hits++;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 07:32:07 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): remove unused parameters from DirLookup To generate a diff of this commit: cvs rdiff -u -r1.175 -r1.176 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.175 src/usr.bin/make/dir.c:1.176 --- src/usr.bin/make/dir.c:1.175 Sun Oct 25 07:27:06 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 07:32:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.175 2020/10/25 07:27:06 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.176 2020/10/25 07:32:07 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.175 2020/10/25 07:27:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.176 2020/10/25 07:32:07 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -902,31 +902,19 @@ Dir_Expand(const char *word, SearchPath DirPrintExpansions(expansions); } -/*- - *--- - * DirLookup -- - * Find if the file with the given name exists in the given path. - * - * Results: - * The path to the file or NULL. This path is guaranteed to be in a - * different part of memory than name and so may be safely free'd. - * - * Side Effects: - * None. - *--- - */ +/* Find if the file with the given name exists in the given path. + * Return the freshly allocated path to the file, or NULL. */ static char * -DirLookup(CachedDir *dir, const char *name MAKE_ATTR_UNUSED, const char *cp, - Boolean hasSlash MAKE_ATTR_UNUSED) +DirLookup(CachedDir *dir, const char *name) { char *file; /* the current filename to check */ DIR_DEBUG1(" %s ...\n", dir->name); -if (Hash_FindEntry(>files, cp) == NULL) +if (Hash_FindEntry(>files, name) == NULL) return NULL; -file = str_concat3(dir->name, "/", cp); +file = str_concat3(dir->name, "/", name); DIR_DEBUG1(" returning %s\n", file); dir->hits++; hits++; @@ -1144,7 +1132,7 @@ Dir_FindFile(const char *name, SearchPat CachedDir *dir = ln->datum; if (dir == dotLast) continue; - if ((file = DirLookup(dir, name, base, hasSlash)) != NULL) + if ((file = DirLookup(dir, base)) != NULL) return file; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Oct 25 07:27:06 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): only define OpenDirs_Done if necessary To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/usr.bin/make/dir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.174 src/usr.bin/make/dir.c:1.175 --- src/usr.bin/make/dir.c:1.174 Sat Oct 24 23:27:33 2020 +++ src/usr.bin/make/dir.c Sun Oct 25 07:27:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.174 2020/10/24 23:27:33 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.175 2020/10/25 07:27:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -135,7 +135,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.174 2020/10/24 23:27:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.175 2020/10/25 07:27:06 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -231,7 +231,8 @@ OpenDirs_Init(OpenDirs *odirs) Hash_InitTable(>table); } -static void MAKE_ATTR_UNUSED +#ifdef CLEANUP +static void OpenDirs_Done(OpenDirs *odirs) { CachedDirListNode *ln = odirs->list->first; @@ -244,6 +245,7 @@ OpenDirs_Done(OpenDirs *odirs) Lst_Free(odirs->list); Hash_DeleteTable(>table); } +#endif static CachedDir * OpenDirs_Find(OpenDirs *odirs, const char *name)