Module Name: src
Committed By: rillig
Date: Wed Jul 29 21:35:35 UTC 2020
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: modmisc.exp modmisc.mk
Log Message:
make(1): remove unnecessary assignments to st->next
No change in the size of the resulting binary. Apparently GCC already
knew these assignments were redundant.
To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/usr.bin/make/var.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/modmisc.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/var.c
diff -u src/usr.bin/make/var.c:1.357 src/usr.bin/make/var.c:1.358
--- src/usr.bin/make/var.c:1.357 Wed Jul 29 21:23:26 2020
+++ src/usr.bin/make/var.c Wed Jul 29 21:35:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.357 2020/07/29 21:23:26 rillig Exp $ */
+/* $NetBSD: var.c,v 1.358 2020/07/29 21:35:35 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.357 2020/07/29 21:23:26 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.358 2020/07/29 21:35:35 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.357 2020/07/29 21:23:26 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.358 2020/07/29 21:35:35 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -2039,7 +2039,8 @@ VarStrftime(const char *fmt, int zulu, t
/* The ApplyModifier functions all work in the same way.
* They parse the modifier (often until the next colon) and store the
- * updated position for the parser into st->next.
+ * updated position for the parser into st->next
+ * (except when returning AMR_UNKNOWN).
* They take the st->val and generate st->newVal from it.
* On failure, many of them update st->missing_delim.
*/
@@ -2195,10 +2196,8 @@ ApplyModifier_Defined(const char *mod, A
static ApplyModifierResult
ApplyModifier_Gmtime(const char *mod, ApplyModifiersState *st)
{
- if (!ModMatchEq(mod, "gmtime", st->endc)) {
- st->next = mod + 1;
+ if (!ModMatchEq(mod, "gmtime", st->endc))
return AMR_UNKNOWN;
- }
time_t utc;
if (mod[6] == '=') {
@@ -2217,10 +2216,8 @@ ApplyModifier_Gmtime(const char *mod, Ap
static Boolean
ApplyModifier_Localtime(const char *mod, ApplyModifiersState *st)
{
- if (!ModMatchEq(mod, "localtime", st->endc)) {
- st->next = mod + 1;
+ if (!ModMatchEq(mod, "localtime", st->endc))
return AMR_UNKNOWN;
- }
time_t utc;
if (mod[9] == '=') {
@@ -2239,10 +2236,8 @@ ApplyModifier_Localtime(const char *mod,
static ApplyModifierResult
ApplyModifier_Hash(const char *mod, ApplyModifiersState *st)
{
- if (!ModMatch(mod, "hash", st->endc)) {
- st->next = mod + 1;
+ if (!ModMatch(mod, "hash", st->endc))
return AMR_UNKNOWN;
- }
st->newVal = VarHash(st->val);
st->next = mod + 4;
@@ -2301,10 +2296,8 @@ ApplyModifier_Exclam(const char *mod, Ap
static ApplyModifierResult
ApplyModifier_Range(const char *mod, ApplyModifiersState *st)
{
- if (!ModMatchEq(mod, "range", st->endc)) {
- st->next = mod + 1;
+ if (!ModMatchEq(mod, "range", st->endc))
return AMR_UNKNOWN;
- }
int n;
if (mod[5] == '=') {
@@ -2910,10 +2903,8 @@ ApplyModifier_Assign(const char *mod, Ap
static ApplyModifierResult
ApplyModifier_Remember(const char *mod, ApplyModifiersState *st)
{
- if (!ModMatchEq(mod, "_", st->endc)) {
- st->next = mod + 1;
+ if (!ModMatchEq(mod, "_", st->endc))
return AMR_UNKNOWN;
- }
if (mod[1] == '=') {
size_t n = strcspn(mod + 2, ":)}");
Index: src/usr.bin/make/unit-tests/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.31 src/usr.bin/make/unit-tests/modmisc.exp:1.32
--- src/usr.bin/make/unit-tests/modmisc.exp:1.31 Wed Jul 29 18:48:47 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp Wed Jul 29 21:35:35 2020
@@ -97,6 +97,7 @@ mod-gmtime:
%Y
2020
%Y
+%Y
mod-localtime:
%Y
2020
Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.28 src/usr.bin/make/unit-tests/modmisc.mk:1.29
--- src/usr.bin/make/unit-tests/modmisc.mk:1.28 Wed Jul 29 18:48:47 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk Wed Jul 29 21:35:35 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.28 2020/07/29 18:48:47 rillig Exp $
+# $Id: modmisc.mk,v 1.29 2020/07/29 21:35:35 rillig Exp $
#
# miscellaneous modifier tests
@@ -261,6 +261,7 @@ mod-gmtime:
@echo ${%Y:L:gmtim=1593536400} # modifier name too short
@echo ${%Y:L:gmtime=1593536400} # 2020-07-01T00:00:00Z
@echo ${%Y:L:gmtimer=1593536400} # modifier name too long
+ @echo ${%Y:L:gm=gm:M*}
mod-localtime:
@echo $@: