aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2001-11-13 17:56:06 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:54 +0000
commitf73dda092b33638d2d5e9c35375f687a607b5403 (patch)
treef21584e70a444d6a1ecba0fb5e2cf79e8cce91db /include
parent28ef6c316f1aff914bb95ac09787a3c83c1815fd (diff)
downloadandroid_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.tar.gz
android_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.tar.bz2
android_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.zip
Imported from ../bash-2.05a.tar.gz.
Diffstat (limited to 'include')
-rw-r--r--include/ansi_stdlib.h16
-rw-r--r--include/chartypes.h119
-rw-r--r--include/memalloc.h6
-rw-r--r--include/stdc.h29
-rw-r--r--include/typemax.h80
5 files changed, 228 insertions, 22 deletions
diff --git a/include/ansi_stdlib.h b/include/ansi_stdlib.h
index 3a354f2..db13cd2 100644
--- a/include/ansi_stdlib.h
+++ b/include/ansi_stdlib.h
@@ -25,14 +25,24 @@
/* String conversion functions. */
extern int atoi ();
-extern long int atol ();
extern double atof ();
extern double strtod ();
/* Memory allocation functions. */
-extern char *malloc ();
-extern char *realloc ();
+/* Generic pointer type. */
+#ifndef PTR_T
+
+#if defined (__STDC__)
+# define PTR_T void *
+#else
+# define PTR_T char *
+#endif
+
+#endif /* PTR_T */
+
+extern PTR_T malloc ();
+extern PTR_T realloc ();
extern void free ();
/* Other miscellaneous functions. */
diff --git a/include/chartypes.h b/include/chartypes.h
new file mode 100644
index 0000000..d19b7f6
--- /dev/null
+++ b/include/chartypes.h
@@ -0,0 +1,119 @@
+/* chartypes.h -- extend ctype.h */
+
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+
+ 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 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. */
+
+#ifndef _SH_CHARTYPES_H
+#define _SH_CHARTYPES_H
+
+#include <ctype.h>
+
+/* Jim Meyering writes:
+
+ "... Some ctype macros are valid only for character codes that
+ isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
+ using /bin/cc or gcc but without giving an ansi option). So, all
+ ctype uses should be through macros like ISPRINT... If
+ STDC_HEADERS is defined, then autoconf has verified that the ctype
+ macros don't need to be guarded with references to isascii. ...
+ Defining IN_CTYPE_DOMAIN to 1 should let any compiler worth its salt
+ 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)
+# define IN_CTYPE_DOMAIN(c) 1
+#else
+# define IN_CTYPE_DOMAIN(c) isascii(c)
+#endif
+
+#if !defined (isspace) && !defined (HAVE_ISSPACE)
+# define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\f')
+#endif
+
+#if !defined (isprint) && !defined (HAVE_ISPRINT)
+# define isprint(c) (isalpha(c) || isdigit(c) || ispunct(c))
+#endif
+
+#if defined (isblank) || defined (HAVE_ISBLANK)
+# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
+#else
+# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
+#endif
+
+#if defined (isgraph) || defined (HAVE_ISGRAPH)
+# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
+#else
+# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
+#endif
+
+#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
+# define isxdigit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
+#endif
+
+#undef ISPRINT
+
+#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
+#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
+#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
+#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
+#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
+#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
+#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
+#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
+#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
+#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
+
+#define ISLETTER(c) (ISALPHA(c))
+
+#define DIGIT(c) ((c) >= '0' && (c) <= '9')
+
+#define HEXVALUE(c) \
+ (((c) >= 'a' && (c) <= 'f') \
+ ? (c)-'a'+10 \
+ : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
+
+#ifndef ISOCTAL
+# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
+#endif
+#define OCTVALUE(c) ((c) - '0')
+
+#define TODIGIT(c) ((c) - '0')
+#define TOCHAR(c) ((c) + '0')
+
+#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)
+#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)
+#endif
+
+#endif /* _SH_CHARTYPES_H */
diff --git a/include/memalloc.h b/include/memalloc.h
index a1a2706..d3ed041 100644
--- a/include/memalloc.h
+++ b/include/memalloc.h
@@ -30,7 +30,7 @@
# define HAVE_ALLOCA
#endif
-#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA)
+#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA) && !defined (C_ALLOCA)
# define HAVE_ALLOCA
#endif /* HAVE_ALLOCA_H && !HAVE_ALLOCA */
@@ -49,7 +49,11 @@
extern void *alloca ();
# else
# if !defined (alloca)
+# if defined (__STDC__)
+extern void *alloca (size_t);
+# else
extern char *alloca ();
+# endif /* !__STDC__ */
# endif /* !alloca */
# endif /* !__hpux || !__STDC__ && !alloca */
# endif /* !HAVE_ALLOCA_H || C_ALLOCA */
diff --git a/include/stdc.h b/include/stdc.h
index c216a69..3106a90 100644
--- a/include/stdc.h
+++ b/include/stdc.h
@@ -36,25 +36,15 @@
# endif
#endif
-#if defined (__STDC__)
-
+#if defined (HAVE_STRINGIZE)
# define __STRING(x) #x
-
-# if !defined (__GNUC__)
-# define inline
-# endif
-
-#else /* !__STDC__ */
-
+#else
# define __STRING(x) "x"
+#endif
+
+#if !defined (__STDC__)
#if defined (__GNUC__) /* gcc with -traditional */
-# if !defined (const)
-# define const __const
-# endif
-# if !defined (inline)
-# define inline __inline
-# endif
# if !defined (signed)
# define signed __signed
# endif
@@ -62,9 +52,6 @@
# define volatile __volatile
# endif
#else /* !__GNUC__ */
-# if !defined (const)
-# define const
-# endif
# if !defined (inline)
# define inline
# endif
@@ -78,4 +65,10 @@
#endif /* !__STDC__ */
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
+# define __attribute__(x)
+# endif
+#endif
+
#endif /* !_STDC_H_ */
diff --git a/include/typemax.h b/include/typemax.h
new file mode 100644
index 0000000..42ae517
--- /dev/null
+++ b/include/typemax.h
@@ -0,0 +1,80 @@
+/* typemax.h -- encapsulate max values for long, long long, etc. */
+
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+
+ 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 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. */
+
+/*
+ * NOTE: This should be included after config.h, limits.h, stdint.h, and
+ * inttypes.h
+ */
+
+#ifndef _SH_TYPEMAX_H
+#define _SH_TYPEMAX_H
+
+#ifndef CHAR_BIT
+# define CHAR_BIT 8
+#endif
+
+/* Nonzero if the integer type T is signed. */
+#ifndef TYPE_SIGNED
+# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+#endif
+
+#ifndef TYPE_MINIMUM
+# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
+ ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
+ : (t) 0))
+#endif
+
+#ifndef TYPE_MAXIMUM
+# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+#endif
+
+#ifdef HAVE_LONG_LONG
+# ifndef LLONG_MAX
+# define LLONG_MAX TYPE_MAXIMUM(long long int)
+# define LLONG_MIN TYPE_MINIMUM(long long int)
+# endif
+# ifndef ULLONG_MAX
+# define ULLONG_MAX TYPE_MAXIMUM(unsigned long long int)
+# endif
+#endif
+
+#ifndef ULONG_MAX
+# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
+#endif
+
+#ifndef LONG_MAX
+# define LONG_MAX ((long int) (ULONG_MAX >> 1))
+# define LONG_MIN ((long int) (-LONG_MAX - 1L))
+#endif
+
+#ifndef INT_MAX /* ouch */
+# define INT_MAX TYPE_MAXIMUM(int)
+# define INT_MIN TYPE_MINIMUM(int)
+# define UINT_MAX ((unsigned int) ~(unsigned int)0)
+#endif
+
+/* workaround for gcc bug in versions < 2.7 */
+#if defined (HAVE_LONG_LONG) && __GNUC__ == 2 && __GNUC_MINOR__ < 7
+static const unsigned long long int maxquad = ULLONG_MAX;
+# undef ULLONG_MAX
+# define ULLONG_MAX maxquad
+#endif
+
+#endif /* _SH_TYPEMAX_H */