Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): remove redundant variable inLine from ...
details: https://anonhg.NetBSD.org/src/rev/ca3169d9f3f6
branches: trunk
changeset: 1014541:ca3169d9f3f6
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Sep 25 23:39:51 2020 +0000
description:
make(1): remove redundant variable inLine from parse.c
This variable has served at least 27 years bringing unnecessary
redundancy to the code. It was already redundant at 1993-03-21, when
the code was imported to NetBSD.
diffstat:
usr.bin/make/parse.c | 32 +++++++++++---------------------
usr.bin/make/unit-tests/deptgt.mk | 4 ++--
2 files changed, 13 insertions(+), 23 deletions(-)
diffs (112 lines):
diff -r 183bb5334a3f -r ca3169d9f3f6 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Fri Sep 25 23:35:25 2020 +0000
+++ b/usr.bin/make/parse.c Fri Sep 25 23:39:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.329 2020/09/25 23:35:25 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.330 2020/09/25 23:39:51 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.329 2020/09/25 23:35:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.330 2020/09/25 23:39:51 rillig Exp $");
/* types and constants */
@@ -232,9 +232,6 @@
/* parser state */
-/* true if currently in a dependency line or its commands */
-static Boolean inLine;
-
/* number of fatal errors */
static int fatals = 0;
@@ -2849,14 +2846,11 @@
static void
FinishDependencyGroup(void)
{
- if (inLine) {
- if (targets != NULL) {
- Lst_ForEachUntil(targets, SuffEndTransform, NULL);
- Lst_Destroy(targets, ParseHasCommands);
- }
- targets = NULL;
- inLine = FALSE;
+ if (targets != NULL) {
+ Lst_ForEachUntil(targets, SuffEndTransform, NULL);
+ Lst_Destroy(targets, ParseHasCommands);
}
+ targets = NULL;
}
/* Add the command to each target from the current dependency spec. */
@@ -2869,10 +2863,10 @@
if (*cp == '\0')
return; /* skip empty commands */
- if (!inLine)
+ if (targets == NULL) {
Parse_Error(PARSE_FATAL, "Unassociated shell command \"%s\"", cp);
- if (targets == NULL)
return;
+ }
{
char *cmd = bmake_strdup(cp);
@@ -2904,7 +2898,7 @@
lf = loadfile(name, fd);
- inLine = FALSE;
+ assert(targets == NULL);
fatals = 0;
if (name == NULL)
@@ -3012,7 +3006,7 @@
cp++;
}
if (*cp == '\0') {
- if (inLine) {
+ if (targets == NULL) {
Parse_Error(PARSE_WARNING,
"Shell command needs a leading tab");
goto shellCommand;
@@ -3094,14 +3088,10 @@
/* TODO: handle errors */
}
- /*
- * Need a list for the target nodes
- */
+ /* Need a fresh list for the target nodes */
if (targets != NULL)
Lst_Free(targets);
-
targets = Lst_Init();
- inLine = TRUE;
ParseDoDependency(line);
free(line);
diff -r 183bb5334a3f -r ca3169d9f3f6 usr.bin/make/unit-tests/deptgt.mk
--- a/usr.bin/make/unit-tests/deptgt.mk Fri Sep 25 23:35:25 2020 +0000
+++ b/usr.bin/make/unit-tests/deptgt.mk Fri Sep 25 23:39:51 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.6 2020/09/25 23:35:25 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.7 2020/09/25 23:39:51 rillig Exp $
#
# Tests for special targets like .BEGIN or .SUFFIXES in dependency
# declarations.
@@ -16,7 +16,7 @@
# FinishDependencyGroup at "targets = NULL"
# Parse_File at "Lst_Free(targets)"
# Parse_File at "targets = Lst_Init()"
-# Parse_File at "!inLine"
+# ParseLine_ShellCommand at "targets == NULL"
#
# Keywords:
# parse.c:targets
Home |
Main Index |
Thread Index |
Old Index