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): replace large switch with if-else in C...
details: https://anonhg.NetBSD.org/src/rev/a83371d419c0
branches: trunk
changeset: 956982:a83371d419c0
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Nov 13 07:35:27 2020 +0000
description:
make(1): replace large switch with if-else in Cond_EvalLine
diffstat:
usr.bin/make/cond.c | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
diffs (44 lines):
diff -r a142ab01be64 -r a83371d419c0 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Fri Nov 13 06:19:27 2020 +0000
+++ b/usr.bin/make/cond.c Fri Nov 13 07:35:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.211 2020/11/13 06:19:27 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.212 2020/11/13 07:35:27 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.211 2020/11/13 06:19:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.212 2020/11/13 07:35:27 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -1167,19 +1167,12 @@
}
state = cond_states[cond_depth];
- switch (state) {
- case SEARCH_FOR_ELIF:
- state = ELSE_ACTIVE;
- break;
- case ELSE_ACTIVE:
- case SKIP_TO_ENDIF:
- Parse_Error(PARSE_WARNING, "extra else");
- /* FALLTHROUGH */
- default:
- case IF_ACTIVE:
- case SKIP_TO_ELSE:
- state = SKIP_TO_ENDIF;
- break;
+ if (state == SEARCH_FOR_ELIF) {
+ state = ELSE_ACTIVE;
+ } else {
+ if (state == ELSE_ACTIVE || state == SKIP_TO_ENDIF)
+ Parse_Error(PARSE_WARNING, "extra else");
+ state = SKIP_TO_ENDIF;
}
cond_states[cond_depth] = state;
return state <= ELSE_ACTIVE ? COND_PARSE : COND_SKIP;
Home |
Main Index |
Thread Index |
Old Index