Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Revert (kind of) the change in 1.12 of the ancient mk...



details:   https://anonhg.NetBSD.org/src/rev/caca5acd87ac
branches:  trunk
changeset: 344176:caca5acd87ac
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 16 15:45:40 2016 +0000

description:
Revert (kind of) the change in 1.12 of the ancient mksyntax.sh script
(undoing the effect of that commit on syntax.h when it was
being dynamically generated) from 1996.   This means that the shell
parser is now locale independent, so scripts that work anywhere will
work consistently everywhere.   Inspired by a similar change in
FreeBSD's sh (from 2010) - the original change in the other direction
came from FreeBSD as well....   Note that this does not in any way
add any kind of support for locales to sh (which is a whole different
problem.) (from kre)

diffstat:

 bin/sh/syntax.h |  14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diffs (35 lines):

diff -r 0c9638be213d -r caca5acd87ac bin/sh/syntax.h
--- a/bin/sh/syntax.h   Wed Mar 16 15:44:35 2016 +0000
+++ b/bin/sh/syntax.h   Wed Mar 16 15:45:40 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syntax.h,v 1.2 2004/01/17 17:38:12 dsl Exp $   */
+/*     $NetBSD: syntax.h,v 1.3 2016/03/16 15:45:40 christos Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -59,8 +59,6 @@
 
 #define PEOF (CHAR_MIN - 1)
 #define SYNBASE (-PEOF)
-/* XXX UPEOF is CHAR_MAX, so is a valid 'char' value... */
-#define UPEOF ((char)PEOF)
 
 
 #define BASESYNTAX (basesyntax + SYNBASE)
@@ -68,11 +66,11 @@
 #define SQSYNTAX (sqsyntax + SYNBASE)
 #define ARISYNTAX (arisyntax + SYNBASE)
 
-/* These defines assume that the digits are contiguous */
-#define is_digit(c)    ((unsigned)((c) - '0') <= 9)
-#define is_alpha(c)    (((char)(c)) != UPEOF && ((c) < CTL_FIRST || (c) > CTL_LAST) && isalpha((unsigned char)(c)))
-#define is_name(c)     (((char)(c)) != UPEOF && ((c) < CTL_FIRST || (c) > CTL_LAST) && ((c) == '_' || isalpha((unsigned char)(c))))
-#define is_in_name(c)  (((char)(c)) != UPEOF && ((c) < CTL_FIRST || (c) > CTL_LAST) && ((c) == '_' || isalnum((unsigned char)(c))))
+/* These defines assume that the digits are contiguous (which is guaranteed) */
+#define        is_digit(c)     ((unsigned)((c) - '0') <= 9)
+#define        is_alpha(c)     ((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER))
+#define        is_name(c)      ((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER|ISUNDER))
+#define        is_in_name(c)   ((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER|ISUNDER|ISDIGIT))
 #define is_special(c)  ((is_type+SYNBASE)[c] & (ISSPECL|ISDIGIT))
 #define digit_val(c)   ((c) - '0')
 



Home | Main Index | Thread Index | Old Index