Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/usr.bin/config Addionally pull up for ticket ticket #776, ...
details: https://anonhg.NetBSD.org/src/rev/d4a368bd46e2
branches: netbsd-9
changeset: 745726:d4a368bd46e2
user: martin <martin%NetBSD.org@localhost>
date: Mon Mar 09 18:28:14 2020 +0000
description:
Addionally pull up for ticket ticket #776, requested by christos:
src/usr.bin/config/scan.l 1.31
Add an enabled bit to keep track of the parent state (if we are ignoring
or parsing). Idea from uwe.
diffstat:
usr.bin/config/scan.l | 47 +++++++++++++++++++++++++++--------------------
1 files changed, 27 insertions(+), 20 deletions(-)
diffs (127 lines):
diff -r b5b31369d378 -r d4a368bd46e2 usr.bin/config/scan.l
--- a/usr.bin/config/scan.l Mon Mar 09 15:23:55 2020 +0000
+++ b/usr.bin/config/scan.l Mon Mar 09 18:28:14 2020 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.26.16.1 2020/03/09 15:22:21 martin Exp $ */
+/* $NetBSD: scan.l,v 1.26.16.2 2020/03/09 18:28:14 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: scan.l,v 1.26.16.1 2020/03/09 15:22:21 martin Exp $");
+__RCSID("$NetBSD: scan.l,v 1.26.16.2 2020/03/09 18:28:14 martin Exp $");
#include <sys/param.h>
#include <errno.h>
@@ -68,19 +68,21 @@
/*
* The state is represented by 3 bits.
*/
-#define IDS_MATCH 1ll
-#define IDS_ELIF 2ll
-#define IDS_ELSE 4ll
+#define IDS_ENABLED 1ll
+#define IDS_MATCH 2ll
+#define IDS_ELIF 4ll
+#define IDS_ELSE 8ll
-#define IDS_BITS 7
-#define IDS_SHIFT 3
+#define IDS_BITS 0xf
+#define IDS_SHIFT 4
-#define IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
-#define IDS_PARENT_DISABLED \
- (ifdefshift > 0 && !IDS_ISMATCH(ifdefstate >> IDS_SHIFT))
-#define IDS_MAX_DEPTH 21 /* 64 / 3 */
+#define IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
+#define IDS_ISENABLED(st) (((st) & IDS_ENABLED) != 0)
+#define IDS_PARENT_DISABLED \
+ (ifdefshift > 0 && !IDS_ISENABLED(ifdefstate >> IDS_SHIFT))
+#define IDS_MAX_DEPTH 16 /* 64 / 4 */
-#ifdef IDS_DEBUG
+#ifdef IDS_DEBUG
# define IDS_PRINT(s, st, x) \
do { \
for (int i = 0; i < ifdefshift + 1; i++) \
@@ -90,12 +92,12 @@
ifdefstate); \
} while (/*CONSTCOND*/0)
#else
-# define IDS_PRINT(s, st, x) __nothing
+# define IDS_PRINT(s, st, x) ((void)0)
#endif
-#define IDS_ENTER(s, st) \
+#define IDS_ENTER(s, st) \
IDS_PRINT(s, st, ">")
-#define IDS_EXIT(s, st) \
+#define IDS_EXIT(s, st) \
IDS_PRINT(s, st, "<")
/*
@@ -195,9 +197,10 @@
}
IDS_ENTER(ifdef, 0);
if (IDS_PARENT_DISABLED || !getcurifdef()) {
+ ifdefstate &= (uint64_t)~IDS_ENABLED;
BEGIN(IGNORED);
} else {
- ifdefstate |= IDS_MATCH;
+ ifdefstate |= IDS_MATCH|IDS_ENABLED;
BEGIN(INITIAL);
}
IDS_EXIT(ifdef, 0);
@@ -211,9 +214,10 @@
}
IDS_ENTER(ifndef, 0);
if (IDS_PARENT_DISABLED || getcurifdef()) {
+ ifdefstate &= (uint64_t)~IDS_ENABLED;
BEGIN(IGNORED);
} else {
- ifdefstate |= IDS_MATCH;
+ ifdefstate |= IDS_MATCH|IDS_ENABLED;
BEGIN(INITIAL);
}
IDS_EXIT(ifndef, 0);
@@ -228,9 +232,10 @@
yyerror("mismatched elifdef");
}
if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || !getcurifdef()) {
+ ifdefstate &= (uint64_t)~IDS_ENABLED;
BEGIN(IGNORED);
} else {
- ifdefstate |= IDS_MATCH;
+ ifdefstate |= IDS_MATCH|IDS_ENABLED;
BEGIN(INITIAL);
}
ifdefstate |= IDS_ELIF;
@@ -245,9 +250,10 @@
yyerror("mismatched elifndef");
}
if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || getcurifdef()) {
+ ifdefstate &= (uint64_t)~IDS_ENABLED;
BEGIN(IGNORED);
} else {
- ifdefstate |= IDS_MATCH;
+ ifdefstate |= IDS_MATCH|IDS_ENABLED;
BEGIN(INITIAL);
}
ifdefstate |= IDS_ELIF;
@@ -262,9 +268,10 @@
yyerror("mismatched else");
}
if (IDS_PARENT_DISABLED || IDS_ISMATCH(st)) {
+ ifdefstate &= (uint64_t)~IDS_ENABLED;
BEGIN(IGNORED);
} else {
- ifdefstate |= IDS_MATCH;
+ ifdefstate |= IDS_MATCH|IDS_ENABLED;
BEGIN(INITIAL);
}
ifdefstate |= IDS_ELSE;
Home |
Main Index |
Thread Index |
Old Index