Thu Aug 27 06:31:46 2020 UTC ()
make(1): migrate Lst_ForEachFrom to Lst_ForEachFromS


(rillig)
diff -r1.215 -r1.216 src/usr.bin/make/job.c
diff -r1.124 -r1.125 src/usr.bin/make/make.c

cvs diff -r1.215 -r1.216 src/usr.bin/make/job.c (expand / switch to unified diff)

--- src/usr.bin/make/job.c 2020/08/23 18:26:35 1.215
+++ src/usr.bin/make/job.c 2020/08/27 06:31:46 1.216
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: job.c,v 1.215 2020/08/23 18:26:35 rillig Exp $ */ 1/* $NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -60,34 +60,34 @@ @@ -60,34 +60,34 @@
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE. 69 * SUCH DAMAGE.
70 */ 70 */
71 71
72#ifndef MAKE_NATIVE 72#ifndef MAKE_NATIVE
73static char rcsid[] = "$NetBSD: job.c,v 1.215 2020/08/23 18:26:35 rillig Exp $"; 73static char rcsid[] = "$NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig Exp $";
74#else 74#else
75#include <sys/cdefs.h> 75#include <sys/cdefs.h>
76#ifndef lint 76#ifndef lint
77#if 0 77#if 0
78static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; 78static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
79#else 79#else
80__RCSID("$NetBSD: job.c,v 1.215 2020/08/23 18:26:35 rillig Exp $"); 80__RCSID("$NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig Exp $");
81#endif 81#endif
82#endif /* not lint */ 82#endif /* not lint */
83#endif 83#endif
84 84
85/*- 85/*-
86 * job.c -- 86 * job.c --
87 * handle the creation etc. of our child processes. 87 * handle the creation etc. of our child processes.
88 * 88 *
89 * Interface: 89 * Interface:
90 * Job_Make Start the creation of the given target. 90 * Job_Make Start the creation of the given target.
91 * 91 *
92 * Job_CatchChildren Check for and handle the termination of any 92 * Job_CatchChildren Check for and handle the termination of any
93 * children. This must be called reasonably 93 * children. This must be called reasonably
@@ -1091,29 +1091,29 @@ JobFinish(Job *job, int status) @@ -1091,29 +1091,29 @@ JobFinish(Job *job, int status)
1091 (aborting == ABORT_ERROR) || 1091 (aborting == ABORT_ERROR) ||
1092 (aborting == ABORT_INTERRUPT)) 1092 (aborting == ABORT_INTERRUPT))
1093 return_job_token = TRUE; 1093 return_job_token = TRUE;
1094 } 1094 }
1095 1095
1096 if ((aborting != ABORT_ERROR) && (aborting != ABORT_INTERRUPT) && (status == 0)) { 1096 if ((aborting != ABORT_ERROR) && (aborting != ABORT_INTERRUPT) && (status == 0)) {
1097 /* 1097 /*
1098 * As long as we aren't aborting and the job didn't return a non-zero 1098 * As long as we aren't aborting and the job didn't return a non-zero
1099 * status that we shouldn't ignore, we call Make_Update to update 1099 * status that we shouldn't ignore, we call Make_Update to update
1100 * the parents. In addition, any saved commands for the node are placed 1100 * the parents. In addition, any saved commands for the node are placed
1101 * on the .END target. 1101 * on the .END target.
1102 */ 1102 */
1103 if (job->tailCmds != NULL) { 1103 if (job->tailCmds != NULL) {
1104 Lst_ForEachFrom(job->node->commands, job->tailCmds, 1104 Lst_ForEachFromS(job->node->commands, job->tailCmds,
1105 JobSaveCommand, 1105 JobSaveCommand,
1106 job->node); 1106 job->node);
1107 } 1107 }
1108 job->node->made = MADE; 1108 job->node->made = MADE;
1109 if (!(job->flags & JOB_SPECIAL)) 1109 if (!(job->flags & JOB_SPECIAL))
1110 return_job_token = TRUE; 1110 return_job_token = TRUE;
1111 Make_Update(job->node); 1111 Make_Update(job->node);
1112 job->job_state = JOB_ST_FREE; 1112 job->job_state = JOB_ST_FREE;
1113 } else if (status != 0) { 1113 } else if (status != 0) {
1114 errors += 1; 1114 errors += 1;
1115 job->job_state = JOB_ST_FREE; 1115 job->job_state = JOB_ST_FREE;
1116 } 1116 }
1117 1117
1118 /* 1118 /*
1119 * Set aborting if any error. 1119 * Set aborting if any error.
@@ -1714,29 +1714,29 @@ JobStart(GNode *gn, int flags) @@ -1714,29 +1714,29 @@ JobStart(GNode *gn, int flags)
1714 if (job->cmdFILE != stdout) { 1714 if (job->cmdFILE != stdout) {
1715 if (job->cmdFILE != NULL) { 1715 if (job->cmdFILE != NULL) {
1716 (void)fclose(job->cmdFILE); 1716 (void)fclose(job->cmdFILE);
1717 job->cmdFILE = NULL; 1717 job->cmdFILE = NULL;
1718 } 1718 }
1719 } 1719 }
1720 1720
1721 /* 1721 /*
1722 * We only want to work our way up the graph if we aren't here because 1722 * We only want to work our way up the graph if we aren't here because
1723 * the commands for the job were no good. 1723 * the commands for the job were no good.
1724 */ 1724 */
1725 if (cmdsOK && aborting == 0) { 1725 if (cmdsOK && aborting == 0) {
1726 if (job->tailCmds != NULL) { 1726 if (job->tailCmds != NULL) {
1727 Lst_ForEachFrom(job->node->commands, job->tailCmds, 1727 Lst_ForEachFromS(job->node->commands, job->tailCmds,
1728 JobSaveCommand, 1728 JobSaveCommand,
1729 job->node); 1729 job->node);
1730 } 1730 }
1731 job->node->made = MADE; 1731 job->node->made = MADE;
1732 Make_Update(job->node); 1732 Make_Update(job->node);
1733 } 1733 }
1734 job->job_state = JOB_ST_FREE; 1734 job->job_state = JOB_ST_FREE;
1735 return cmdsOK ? JOB_FINISHED : JOB_ERROR; 1735 return cmdsOK ? JOB_FINISHED : JOB_ERROR;
1736 } 1736 }
1737 1737
1738 /* 1738 /*
1739 * Set up the control arguments to the shell. This is based on the flags 1739 * Set up the control arguments to the shell. This is based on the flags
1740 * set earlier for this job. 1740 * set earlier for this job.
1741 */ 1741 */
1742 JobMakeArgv(job, argv); 1742 JobMakeArgv(job, argv);

cvs diff -r1.124 -r1.125 src/usr.bin/make/make.c (expand / switch to unified diff)

--- src/usr.bin/make/make.c 2020/08/26 22:55:46 1.124
+++ src/usr.bin/make/make.c 2020/08/27 06:31:46 1.125
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: make.c,v 1.124 2020/08/26 22:55:46 rillig Exp $ */ 1/* $NetBSD: make.c,v 1.125 2020/08/27 06:31:46 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -59,34 +59,34 @@ @@ -59,34 +59,34 @@
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE. 68 * SUCH DAMAGE.
69 */ 69 */
70 70
71#ifndef MAKE_NATIVE 71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: make.c,v 1.124 2020/08/26 22:55:46 rillig Exp $"; 72static char rcsid[] = "$NetBSD: make.c,v 1.125 2020/08/27 06:31:46 rillig Exp $";
73#else 73#else
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75#ifndef lint 75#ifndef lint
76#if 0 76#if 0
77static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; 77static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
78#else 78#else
79__RCSID("$NetBSD: make.c,v 1.124 2020/08/26 22:55:46 rillig Exp $"); 79__RCSID("$NetBSD: make.c,v 1.125 2020/08/27 06:31:46 rillig Exp $");
80#endif 80#endif
81#endif /* not lint */ 81#endif /* not lint */
82#endif 82#endif
83 83
84/*- 84/*-
85 * make.c -- 85 * make.c --
86 * The functions which perform the examination of targets and 86 * The functions which perform the examination of targets and
87 * their suitability for creation 87 * their suitability for creation
88 * 88 *
89 * Interface: 89 * Interface:
90 * Make_Run Initialize things for the module and recreate 90 * Make_Run Initialize things for the module and recreate
91 * whatever needs recreating. Returns TRUE if 91 * whatever needs recreating. Returns TRUE if
92 * work was (or would have been) done and FALSE 92 * work was (or would have been) done and FALSE
@@ -1446,27 +1446,27 @@ Make_ProcessWait(Lst targs) @@ -1446,27 +1446,27 @@ Make_ProcessWait(Lst targs)
1446 pgn->flags |= DONE_WAIT; 1446 pgn->flags |= DONE_WAIT;
1447 if (DEBUG(MAKE)) 1447 if (DEBUG(MAKE))
1448 fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name); 1448 fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name);
1449 1449
1450 if (pgn->type & OP_DOUBLEDEP) 1450 if (pgn->type & OP_DOUBLEDEP)
1451 Lst_PrependAllS(examine, pgn->cohorts); 1451 Lst_PrependAllS(examine, pgn->cohorts);
1452 1452
1453 owln = Lst_First(pgn->children); 1453 owln = Lst_First(pgn->children);
1454 Lst_OpenS(pgn->children); 1454 Lst_OpenS(pgn->children);
1455 for (; (ln = Lst_NextS(pgn->children)) != NULL; ) { 1455 for (; (ln = Lst_NextS(pgn->children)) != NULL; ) {
1456 cgn = Lst_DatumS(ln); 1456 cgn = Lst_DatumS(ln);
1457 if (cgn->type & OP_WAIT) { 1457 if (cgn->type & OP_WAIT) {
1458 /* Make the .WAIT node depend on the previous children */ 1458 /* Make the .WAIT node depend on the previous children */
1459 Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn); 1459 Lst_ForEachFromS(pgn->children, owln, add_wait_dep, cgn);
1460 owln = ln; 1460 owln = ln;
1461 } else { 1461 } else {
1462 Lst_AppendS(examine, cgn); 1462 Lst_AppendS(examine, cgn);
1463 } 1463 }
1464 } 1464 }
1465 Lst_CloseS(pgn->children); 1465 Lst_CloseS(pgn->children);
1466 } 1466 }
1467 1467
1468 Lst_FreeS(examine); 1468 Lst_FreeS(examine);
1469} 1469}
1470 1470
1471/*- 1471/*-
1472 *----------------------------------------------------------------------- 1472 *-----------------------------------------------------------------------