Source-Changes-HG archive

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

[src/trunk]: src/bin/sh factor out common code in macro.



details:   https://anonhg.NetBSD.org/src/rev/65b03584e0e6
branches:  trunk
changeset: 344177:65b03584e0e6
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 16 15:48:01 2016 +0000

description:
factor out common code in macro.

diffstat:

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

diffs (25 lines):

diff -r caca5acd87ac -r 65b03584e0e6 bin/sh/syntax.h
--- a/bin/sh/syntax.h   Wed Mar 16 15:45:40 2016 +0000
+++ b/bin/sh/syntax.h   Wed Mar 16 15:48:01 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syntax.h,v 1.3 2016/03/16 15:45:40 christos Exp $      */
+/*     $NetBSD: syntax.h,v 1.4 2016/03/16 15:48:01 christos Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -68,10 +68,11 @@
 
 /* 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 sh_ctype(c)    (is_type+SYNBASE)[(unsigned char)c]
+#define        is_alpha(c)     (sh_ctype(c) & (ISUPPER|ISLOWER))
+#define        is_name(c)      (sh_ctype(c) & (ISUPPER|ISLOWER|ISUNDER))
+#define        is_in_name(c)   (sh_ctype(c) & (ISUPPER|ISLOWER|ISUNDER|ISDIGIT))
+#define is_special(c)  (sh_ctype(c) & (ISSPECL|ISDIGIT))
 #define digit_val(c)   ((c) - '0')
 
 extern const char basesyntax[];



Home | Main Index | Thread Index | Old Index