Module Name: src Committed By: rillig Date: Fri Sep 25 23:39:51 UTC 2020
Modified Files: src/usr.bin/make: parse.c src/usr.bin/make/unit-tests: deptgt.mk Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.329 -r1.330 src/usr.bin/make/parse.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/deptgt.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/parse.c diff -u src/usr.bin/make/parse.c:1.329 src/usr.bin/make/parse.c:1.330 --- src/usr.bin/make/parse.c:1.329 Fri Sep 25 23:35:25 2020 +++ src/usr.bin/make/parse.c Fri Sep 25 23:39:51 2020 @@ -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 @@ static GNode *predecessor; /* 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 @@ SuffEndTransform(void *target, void *unu 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 @@ ParseLine_ShellCommand(char *cp) 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 @@ Parse_File(const char *name, int fd) lf = loadfile(name, fd); - inLine = FALSE; + assert(targets == NULL); fatals = 0; if (name == NULL) @@ -3012,7 +3006,7 @@ Parse_File(const char *name, int fd) 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 @@ Parse_File(const char *name, int fd) /* 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); Index: src/usr.bin/make/unit-tests/deptgt.mk diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.6 src/usr.bin/make/unit-tests/deptgt.mk:1.7 --- src/usr.bin/make/unit-tests/deptgt.mk:1.6 Fri Sep 25 23:35:25 2020 +++ src/usr.bin/make/unit-tests/deptgt.mk Fri Sep 25 23:39:51 2020 @@ -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