Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / include / chartypes.h
index d19b7f6..c708018 100644 (file)
@@ -4,19 +4,19 @@
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
-   Bash is free software; you can redistribute it and/or modify it under
-   the terms of the GNU General Public License as published by the Free
-   Software Foundation; either version 2, or (at your option) any later
-   version.
+   Bash is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-   Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-   WARRANTY; without even the implied warranty of MERCHANTABILITY or
-   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-   for more details.
+   Bash is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License along
-   with Bash; see the file COPYING.  If not, write to the Free Software
-   Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+   You should have received a copy of the GNU General Public License
+   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
 #ifndef _SH_CHARTYPES_H
 #define _SH_CHARTYPES_H
@@ -35,7 +35,7 @@
    eliminate the && through constant folding."
    Solaris defines some of these symbols so we must undefine them first.  */
 
-#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
+#if STDC_HEADERS || (!defined (isascii) && !HAVE_ISASCII)
 #  define IN_CTYPE_DOMAIN(c) 1
 #else
 #  define IN_CTYPE_DOMAIN(c) isascii(c)
@@ -82,6 +82,8 @@
 
 #define DIGIT(c)       ((c) >= '0' && (c) <= '9')
 
+#define ISWORD(c)      (ISLETTER(c) || DIGIT(c) || ((c) == '_'))
+
 #define HEXVALUE(c) \
   (((c) >= 'a' && (c) <= 'f') \
        ? (c)-'a'+10 \
 #define TOLOWER(c)     (ISUPPER(c) ? tolower(c) : (c))
 #define TOUPPER(c)     (ISLOWER(c) ? toupper(c) : (c))
 
-#ifdef toascii
-#  define TOASCII(c)   (toascii(c))
-#else
-#  define TOASCII(c)   ((c) & 0x7F)
+#ifndef TOCTRL
+   /* letter to control char -- ASCII.  The TOUPPER is in there so \ce and
+      \cE will map to the same character in $'...' expansions. */
+#  define TOCTRL(x)    (TOUPPER(x) & 037)
 #endif
-
-/* We remove any previous definition of `SIGN_EXTEND_CHAR',
-   since ours (we hope) works properly with all combinations of
-   machines, compilers, `char' and `unsigned char' argument types.
-   (Per Bothner suggested the basic approach.)  */
-#undef SIGN_EXTEND_CHAR
-#if __STDC__
-#  define SIGN_EXTEND_CHAR(c) ((signed char) (c))
-#else  /* not __STDC__ */
-   /* As in Harbison and Steele.  */
-#  define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
+#ifndef UNCTRL
+   /* control char to letter -- ASCII */
+#  define UNCTRL(x)    (TOUPPER(x) ^ 0x40)
 #endif
 
 #endif /* _SH_CHARTYPES_H */