summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 06:17:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 06:17:24 +0000
commit9d8085074991d5c0a42d6fc96a2d1a3ee918aad1 (patch)
treec85bca1e6c11eb872edfc64c524d20f2b7e3307b /include
parentInitial commit. (diff)
downloadbash-9d8085074991d5c0a42d6fc96a2d1a3ee918aad1.tar.xz
bash-9d8085074991d5c0a42d6fc96a2d1a3ee918aad1.zip
Adding upstream version 5.1.upstream/5.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include')
-rw-r--r--include/ansi_stdlib.h54
-rw-r--r--include/chartypes.h113
-rw-r--r--include/filecntl.h53
-rw-r--r--include/gettext.h70
-rw-r--r--include/maxpath.h75
-rw-r--r--include/memalloc.h62
-rw-r--r--include/ocache.h133
-rw-r--r--include/posixdir.h71
-rw-r--r--include/posixjmp.h46
-rw-r--r--include/posixselect.h47
-rw-r--r--include/posixstat.h162
-rw-r--r--include/posixtime.h61
-rw-r--r--include/posixwait.h107
-rw-r--r--include/shmbchar.h112
-rw-r--r--include/shmbutil.h551
-rw-r--r--include/shtty.h112
-rw-r--r--include/stat-time.h214
-rw-r--r--include/stdc.h89
-rw-r--r--include/systimes.h55
-rw-r--r--include/typemax.h131
-rw-r--r--include/unionwait.h98
21 files changed, 2416 insertions, 0 deletions
diff --git a/include/ansi_stdlib.h b/include/ansi_stdlib.h
new file mode 100644
index 0000000..7dc2ee0
--- /dev/null
+++ b/include/ansi_stdlib.h
@@ -0,0 +1,54 @@
+/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
+/* A minimal stdlib.h containing extern declarations for those functions
+ that bash uses. */
+
+/* Copyright (C) 1993 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_STDLIB_H_)
+#define _STDLIB_H_ 1
+
+/* String conversion functions. */
+extern int atoi ();
+
+extern double atof ();
+extern double strtod ();
+
+/* Memory allocation functions. */
+/* 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. */
+extern void abort ();
+extern void exit ();
+extern char *getenv ();
+extern void qsort ();
+
+#endif /* _STDLIB_H */
diff --git a/include/chartypes.h b/include/chartypes.h
new file mode 100644
index 0000000..098cfb9
--- /dev/null
+++ b/include/chartypes.h
@@ -0,0 +1,113 @@
+/* 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 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.
+
+ 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
+
+#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 STDC_HEADERS || (!defined (isascii) && !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((unsigned char)c) || isdigit((unsigned char)c) || ispunct((unsigned char)c))
+#endif
+
+#if defined (isblank) || defined (HAVE_ISBLANK)
+# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank ((unsigned char)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 ((unsigned char)c) && !isspace ((unsigned char)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 ((unsigned char)c))
+#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit ((unsigned char)c))
+#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum ((unsigned char)c))
+#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha ((unsigned char)c))
+#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl ((unsigned char)c))
+#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower ((unsigned char)c))
+#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct ((unsigned char)c))
+#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace ((unsigned char)c))
+#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper ((unsigned char)c))
+#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit ((unsigned char)c))
+
+#define ISLETTER(c) (ISALPHA(c))
+
+#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 \
+ : (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))
+
+#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) ((x) == '?' ? 0x7f : (TOUPPER(x) & 0x1f))
+#endif
+#ifndef UNCTRL
+ /* control char to letter -- ASCII */
+# define UNCTRL(x) (TOUPPER(x) ^ 0x40)
+#endif
+
+#endif /* _SH_CHARTYPES_H */
diff --git a/include/filecntl.h b/include/filecntl.h
new file mode 100644
index 0000000..9bcbab8
--- /dev/null
+++ b/include/filecntl.h
@@ -0,0 +1,53 @@
+/* filecntl.h - Definitions to set file descriptors to close-on-exec. */
+
+/* Copyright (C) 1993 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_FILECNTL_H_)
+#define _FILECNTL_H_
+
+#include <fcntl.h>
+
+/* Definitions to set file descriptors to close-on-exec, the Posix way. */
+#if !defined (FD_CLOEXEC)
+#define FD_CLOEXEC 1
+#endif
+
+#define FD_NCLOEXEC 0
+
+#define SET_CLOSE_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_CLOEXEC))
+#define SET_OPEN_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_NCLOEXEC))
+
+/* How to open a file in non-blocking mode, the Posix.1 way. */
+#if !defined (O_NONBLOCK)
+# if defined (O_NDELAY)
+# define O_NONBLOCK O_NDELAY
+# else
+# define O_NONBLOCK 0
+# endif
+#endif
+
+/* Make sure O_BINARY and O_TEXT are defined to avoid Windows-specific code. */
+#if !defined (O_BINARY)
+# define O_BINARY 0
+#endif
+#if !defined (O_TEXT)
+# define O_TEXT 0
+#endif
+
+#endif /* ! _FILECNTL_H_ */
diff --git a/include/gettext.h b/include/gettext.h
new file mode 100644
index 0000000..97a1f36
--- /dev/null
+++ b/include/gettext.h
@@ -0,0 +1,70 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+ Copyright (C) 1995-1998, 2000-2002, 2008,2009 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option. */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+# define gettext(Msgid) ((const char *) (Msgid))
+# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
+# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define textdomain(Domainname) ((const char *) (Domainname))
+# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
+
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+#endif /* _LIBGETTEXT_H */
diff --git a/include/maxpath.h b/include/maxpath.h
new file mode 100644
index 0000000..db2e1fb
--- /dev/null
+++ b/include/maxpath.h
@@ -0,0 +1,75 @@
+/* maxpath.h - Find out what this system thinks PATH_MAX and NAME_MAX are. */
+
+/* Copyright (C) 1993 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_MAXPATH_H_)
+#define _MAXPATH_H_
+
+/* These values are supposed to be in <limits.h> or one of the files
+ it includes. */
+#if defined (HAVE_LIMITS_H)
+# include <limits.h>
+#endif /* !HAVE_LIMITS_H */
+
+/* If PATH_MAX is not defined, look for MAXPATHLEN */
+#if !defined (PATH_MAX)
+# if defined (HAVE_SYS_PARAM_H)
+# include <sys/param.h>
+# define maxpath_param_h
+# endif
+# if defined (MAXPATHLEN) && !defined (PATH_MAX)
+# define PATH_MAX MAXPATHLEN
+# endif /* MAXPATHLEN && !PATH_MAX */
+#endif /* !PATH_MAX */
+
+/* If NAME_MAX is not defined, look for MAXNAMLEN */
+#if !defined (NAME_MAX)
+# if defined (HAVE_SYS_PARAM_H) && !defined (maxpath_param_h)
+# include <sys/param.h>
+# endif
+# if defined (MAXNAMLEN) && !defined (NAME_MAX)
+# define NAME_MAX MAXNAMLEN
+# endif /* MAXNAMLEN && !NAME_MAX */
+#endif /* !NAME_MAX */
+
+/* Default POSIX values */
+#if !defined (PATH_MAX) && defined (_POSIX_PATH_MAX)
+# define PATH_MAX _POSIX_PATH_MAX
+#endif
+
+#if !defined (NAME_MAX) && defined (_POSIX_NAME_MAX)
+# define NAME_MAX _POSIX_NAME_MAX
+#endif
+
+
+/* Default values */
+#if !defined (PATH_MAX)
+# define PATH_MAX 1024
+#endif
+
+#if !defined (NAME_MAX)
+# define NAME_MAX 14
+#endif
+
+#if PATH_MAX < 1024
+# undef PATH_MAX
+# define PATH_MAX 1024
+#endif
+
+#endif /* _MAXPATH_H_ */
diff --git a/include/memalloc.h b/include/memalloc.h
new file mode 100644
index 0000000..57318b9
--- /dev/null
+++ b/include/memalloc.h
@@ -0,0 +1,62 @@
+/* memalloc.h -- consolidate code for including alloca.h or malloc.h and
+ defining alloca. */
+
+/* Copyright (C) 1993 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_MEMALLOC_H_)
+# define _MEMALLOC_H_
+
+#if defined (sparc) && defined (sun) && !defined (HAVE_ALLOCA_H)
+# define HAVE_ALLOCA_H
+#endif
+
+#if defined (__GNUC__) && !defined (HAVE_ALLOCA)
+# define HAVE_ALLOCA
+#endif
+
+#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA) && !defined (C_ALLOCA)
+# define HAVE_ALLOCA
+#endif /* HAVE_ALLOCA_H && !HAVE_ALLOCA */
+
+#if defined (__GNUC__) && !defined (C_ALLOCA)
+# undef alloca
+# define alloca __builtin_alloca
+#else /* !__GNUC__ || C_ALLOCA */
+# if defined (HAVE_ALLOCA_H) && !defined (C_ALLOCA)
+# if defined (IBMESA)
+# include <malloc.h>
+# else /* !IBMESA */
+# include <alloca.h>
+# endif /* !IBMESA */
+# else /* !HAVE_ALLOCA_H || C_ALLOCA */
+# if defined (__hpux) && defined (__STDC__) && !defined (alloca)
+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 */
+#endif /* !__GNUC__ || C_ALLOCA */
+
+#endif /* _MEMALLOC_H_ */
diff --git a/include/ocache.h b/include/ocache.h
new file mode 100644
index 0000000..c596c27
--- /dev/null
+++ b/include/ocache.h
@@ -0,0 +1,133 @@
+/* ocache.h -- a minimal object caching implementation. */
+
+/* Copyright (C) 2002 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_OCACHE_H_)
+#define _OCACHE_H_ 1
+
+#ifndef PTR_T
+
+#if defined (__STDC__)
+# define PTR_T void *
+#else
+# define PTR_T char *
+#endif
+
+#endif /* PTR_T */
+
+#define OC_MEMSET(memp, xch, nbytes) \
+do { \
+ if ((nbytes) <= 32) { \
+ register char * mzp = (char *)(memp); \
+ unsigned long mctmp = (nbytes); \
+ register long mcn; \
+ if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp &= 7; } \
+ switch (mctmp) { \
+ case 0: for(;;) { *mzp++ = xch; \
+ case 7: *mzp++ = xch; \
+ case 6: *mzp++ = xch; \
+ case 5: *mzp++ = xch; \
+ case 4: *mzp++ = xch; \
+ case 3: *mzp++ = xch; \
+ case 2: *mzp++ = xch; \
+ case 1: *mzp++ = xch; if(mcn <= 0) break; mcn--; } \
+ } \
+ } else \
+ memset ((memp), (xch), (nbytes)); \
+} while(0)
+
+typedef struct objcache {
+ PTR_T data;
+ int cs; /* cache size, number of objects */
+ int nc; /* number of cache entries */
+} sh_obj_cache_t;
+
+/* Create an object cache C of N pointers to OTYPE. */
+#define ocache_create(c, otype, n) \
+ do { \
+ (c).data = xmalloc((n) * sizeof (otype *)); \
+ (c).cs = (n); \
+ (c).nc = 0; \
+ } while (0)
+
+/* Destroy an object cache C. */
+#define ocache_destroy(c) \
+ do { \
+ if ((c).data) \
+ xfree ((c).data); \
+ (c).data = 0; \
+ (c).cs = (c).nc = 0; \
+ } while (0)
+
+/* Free all cached items, which are pointers to OTYPE, in object cache C. */
+#define ocache_flush(c, otype) \
+ do { \
+ while ((c).nc > 0) \
+ xfree (((otype **)((c).data))[--(c).nc]); \
+ } while (0)
+
+/*
+ * Allocate a new item of type pointer to OTYPE, using data from object
+ * cache C if any cached items exist, otherwise calling xmalloc. Return
+ * the object in R.
+ */
+#define ocache_alloc(c, otype, r) \
+ do { \
+ if ((c).nc > 0) { \
+ (r) = (otype *)((otype **)((c).data))[--(c).nc]; \
+ } else \
+ (r) = (otype *)xmalloc (sizeof (otype)); \
+ } while (0)
+
+/*
+ * Free an item R of type pointer to OTYPE, adding to object cache C if
+ * there is room and calling xfree if the cache is full. If R is added
+ * to the object cache, the contents are scrambled.
+ */
+#define ocache_free(c, otype, r) \
+ do { \
+ if ((c).nc < (c).cs) { \
+ OC_MEMSET ((r), 0xdf, sizeof(otype)); \
+ ((otype **)((c).data))[(c).nc++] = (r); \
+ } else \
+ xfree (r); \
+ } while (0)
+
+/*
+ * One may declare and use an object cache as (for instance):
+ *
+ * sh_obj_cache_t wdcache = {0, 0, 0};
+ * sh_obj_cache_t wlcache = {0, 0, 0};
+ *
+ * ocache_create(wdcache, WORD_DESC, 30);
+ * ocache_create(wlcache, WORD_LIST, 30);
+ *
+ * WORD_DESC *wd;
+ * ocache_alloc (wdcache, WORD_DESC, wd);
+ *
+ * WORD_LIST *wl;
+ * ocache_alloc (wlcache, WORD_LIST, wl);
+ *
+ * ocache_free(wdcache, WORD_DESC, wd);
+ * ocache_free(wlcache, WORD_LIST, wl);
+ *
+ * The use is almost arbitrary.
+ */
+
+#endif /* _OCACHE_H */
diff --git a/include/posixdir.h b/include/posixdir.h
new file mode 100644
index 0000000..af5be80
--- /dev/null
+++ b/include/posixdir.h
@@ -0,0 +1,71 @@
+/* posixdir.h -- Posix directory reading includes and defines. */
+
+/* Copyright (C) 1987,1991,2012 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
+
+#if !defined (_POSIXDIR_H_)
+#define _POSIXDIR_H_
+
+#if defined (HAVE_DIRENT_H)
+# include <dirent.h>
+# if defined (HAVE_STRUCT_DIRENT_D_NAMLEN)
+# define D_NAMLEN(d) ((d)->d_namlen)
+# else
+# define D_NAMLEN(d) (strlen ((d)->d_name))
+# endif /* !HAVE_STRUCT_DIRENT_D_NAMLEN */
+#else
+# if defined (HAVE_SYS_NDIR_H)
+# include <sys/ndir.h>
+# endif
+# if defined (HAVE_SYS_DIR_H)
+# include <sys/dir.h>
+# endif
+# if defined (HAVE_NDIR_H)
+# include <ndir.h>
+# endif
+# if !defined (dirent)
+# define dirent direct
+# endif /* !dirent */
+# define D_NAMLEN(d) ((d)->d_namlen)
+#endif /* !HAVE_DIRENT_H */
+
+/* The bash code fairly consistently uses d_fileno; make sure it's available */
+#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
+# define d_fileno d_ino
+#endif
+
+/* Posix does not require that the d_ino field be present, and some
+ systems do not provide it. */
+#if !defined (HAVE_STRUCT_DIRENT_D_INO) || defined (BROKEN_DIRENT_D_INO)
+# define REAL_DIR_ENTRY(dp) 1
+#else
+# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
+#endif /* _POSIX_SOURCE */
+
+#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (BROKEN_DIRENT_D_INO)
+# define D_INO_AVAILABLE
+#endif
+
+/* Signal the rest of the code that it can safely use dirent.d_fileno */
+#if defined (D_INO_AVAILABLE) || defined (HAVE_STRUCT_DIRENT_D_FILENO)
+# define D_FILENO_AVAILABLE 1
+#endif
+
+#endif /* !_POSIXDIR_H_ */
diff --git a/include/posixjmp.h b/include/posixjmp.h
new file mode 100644
index 0000000..9c7e99e
--- /dev/null
+++ b/include/posixjmp.h
@@ -0,0 +1,46 @@
+/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
+
+/* Copyright (C) 1987,1991-2015 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _POSIXJMP_H_
+#define _POSIXJMP_H_
+
+#include <setjmp.h>
+
+/* This *must* be included *after* config.h */
+
+#if defined (HAVE_POSIX_SIGSETJMP)
+# define procenv_t sigjmp_buf
+
+# define setjmp_nosigs(x) sigsetjmp((x), 0)
+# define setjmp_sigs(x) sigsetjmp((x), 1)
+
+# define _rl_longjmp(x, n) siglongjmp((x), (n))
+# define sh_longjmp(x, n) siglongjmp((x), (n))
+#else
+# define procenv_t jmp_buf
+
+# define setjmp_nosigs setjmp
+# define setjmp_sigs setjmp
+
+# define _rl_longjmp(x, n) longjmp((x), (n))
+# define sh_longjmp(x, n) longjmp((x), (n))
+#endif
+
+#endif /* _POSIXJMP_H_ */
diff --git a/include/posixselect.h b/include/posixselect.h
new file mode 100644
index 0000000..da6a1ac
--- /dev/null
+++ b/include/posixselect.h
@@ -0,0 +1,47 @@
+/* posixselect.h -- wrapper for select(2) includes and definitions */
+
+/* Copyright (C) 2009 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _POSIXSELECT_H_
+#define _POSIXSELECT_H_
+
+#if defined (FD_SET) && !defined (HAVE_SELECT)
+# define HAVE_SELECT 1
+#endif
+
+#if defined (HAVE_SELECT)
+# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
+# include <sys/time.h>
+# endif
+#endif /* HAVE_SELECT */
+#if defined (HAVE_SYS_SELECT_H)
+# include <sys/select.h>
+#endif
+
+#ifndef USEC_PER_SEC
+# define USEC_PER_SEC 1000000
+#endif
+
+#define USEC_TO_TIMEVAL(us, tv) \
+do { \
+ (tv).tv_sec = (us) / USEC_PER_SEC; \
+ (tv).tv_usec = (us) % USEC_PER_SEC; \
+} while (0)
+
+#endif /* _POSIXSELECT_H_ */
diff --git a/include/posixstat.h b/include/posixstat.h
new file mode 100644
index 0000000..b607786
--- /dev/null
+++ b/include/posixstat.h
@@ -0,0 +1,162 @@
+/* posixstat.h -- Posix stat(2) definitions for systems that
+ don't have them. */
+
+/* Copyright (C) 1987-2019 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file should be included instead of <sys/stat.h>.
+ It relies on the local sys/stat.h to work though. */
+#if !defined (_POSIXSTAT_H_)
+#define _POSIXSTAT_H_
+
+#include <sys/stat.h>
+
+#if defined (STAT_MACROS_BROKEN)
+# undef S_ISBLK
+# undef S_ISCHR
+# undef S_ISDIR
+# undef S_ISFIFO
+# undef S_ISREG
+# undef S_ISLNK
+#endif /* STAT_MACROS_BROKEN */
+
+/* These are guaranteed to work only on isc386 */
+#if !defined (S_IFDIR) && !defined (S_ISDIR)
+# define S_IFDIR 0040000
+#endif /* !S_IFDIR && !S_ISDIR */
+#if !defined (S_IFMT)
+# define S_IFMT 0170000
+#endif /* !S_IFMT */
+
+/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
+
+/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
+ do not provide the S_IS* macros that Posix requires. */
+
+#if defined (_S_IFMT) && !defined (S_IFMT)
+#define S_IFMT _S_IFMT
+#endif
+#if defined (_S_IFIFO) && !defined (S_IFIFO)
+#define S_IFIFO _S_IFIFO
+#endif
+#if defined (_S_IFCHR) && !defined (S_IFCHR)
+#define S_IFCHR _S_IFCHR
+#endif
+#if defined (_S_IFDIR) && !defined (S_IFDIR)
+#define S_IFDIR _S_IFDIR
+#endif
+#if defined (_S_IFBLK) && !defined (S_IFBLK)
+#define S_IFBLK _S_IFBLK
+#endif
+#if defined (_S_IFREG) && !defined (S_IFREG)
+#define S_IFREG _S_IFREG
+#endif
+#if defined (_S_IFLNK) && !defined (S_IFLNK)
+#define S_IFLNK _S_IFLNK
+#endif
+#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
+#define S_IFSOCK _S_IFSOCK
+#endif
+
+/* Test for each symbol individually and define the ones necessary (some
+ systems claiming Posix compatibility define some but not all). */
+
+#if defined (S_IFBLK) && !defined (S_ISBLK)
+#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
+#endif
+
+#if defined (S_IFCHR) && !defined (S_ISCHR)
+#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
+#endif
+
+#if defined (S_IFDIR) && !defined (S_ISDIR)
+#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
+#endif
+
+#if defined (S_IFREG) && !defined (S_ISREG)
+#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
+#endif
+
+#if defined (S_IFIFO) && !defined (S_ISFIFO)
+#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
+#endif
+
+#if defined (S_IFLNK) && !defined (S_ISLNK)
+#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
+#endif
+
+#if defined (S_IFSOCK) && !defined (S_ISSOCK)
+#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
+#endif
+
+/*
+ * POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
+ */
+
+#if !defined (S_IRWXU)
+# if !defined (S_IREAD)
+# define S_IREAD 00400
+# define S_IWRITE 00200
+# define S_IEXEC 00100
+# endif /* S_IREAD */
+
+# if !defined (S_IRUSR)
+# define S_IRUSR S_IREAD /* read, owner */
+# define S_IWUSR S_IWRITE /* write, owner */
+# define S_IXUSR S_IEXEC /* execute, owner */
+
+# define S_IRGRP (S_IREAD >> 3) /* read, group */
+# define S_IWGRP (S_IWRITE >> 3) /* write, group */
+# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
+
+# define S_IROTH (S_IREAD >> 6) /* read, other */
+# define S_IWOTH (S_IWRITE >> 6) /* write, other */
+# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
+# endif /* !S_IRUSR */
+
+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+#else /* !S_IRWXU */
+ /* S_IRWXU is defined, but "group" and "other" bits might not be
+ (happens in certain versions of MinGW). */
+# if !defined (S_IRGRP)
+# define S_IRGRP (S_IREAD >> 3) /* read, group */
+# define S_IWGRP (S_IWRITE >> 3) /* write, group */
+# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
+# endif /* !S_IRGRP */
+
+# if !defined (S_IROTH)
+# define S_IROTH (S_IREAD >> 6) /* read, other */
+# define S_IWOTH (S_IWRITE >> 6) /* write, other */
+# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
+# endif /* !S_IROTH */
+# if !defined (S_IRWXG)
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+# endif
+# if !defined (S_IRWXO)
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+# endif
+#endif /* !S_IRWXU */
+
+/* These are non-standard, but are used in builtins.c$symbolic_umask() */
+#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
+#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
+#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
+
+#endif /* _POSIXSTAT_H_ */
diff --git a/include/posixtime.h b/include/posixtime.h
new file mode 100644
index 0000000..a83e436
--- /dev/null
+++ b/include/posixtime.h
@@ -0,0 +1,61 @@
+/* posixtime.h -- wrapper for time.h, sys/times.h mess. */
+
+/* Copyright (C) 1999 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _POSIXTIME_H_
+#define _POSIXTIME_H_
+
+/* include this after config.h */
+/* Some systems require this, mostly for the definition of `struct timezone'.
+ For example, Dynix/ptx has that definition in <time.h> rather than
+ sys/time.h */
+#if defined (TIME_WITH_SYS_TIME)
+# include <sys/time.h>
+# include <time.h>
+#else
+# if defined (HAVE_SYS_TIME_H)
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#if !defined (HAVE_SYSCONF) || !defined (_SC_CLK_TCK)
+# if !defined (CLK_TCK)
+# if defined (HZ)
+# define CLK_TCK HZ
+# else
+# define CLK_TCK 60 /* 60HZ */
+# endif
+# endif /* !CLK_TCK */
+#endif /* !HAVE_SYSCONF && !_SC_CLK_TCK */
+
+#if !HAVE_TIMEVAL
+struct timeval
+{
+ time_t tv_sec;
+ long int tv_usec;
+};
+#endif
+
+#if !HAVE_GETTIMEOFDAY
+extern int gettimeofday PARAMS((struct timeval *, void *));
+#endif
+
+#endif /* _POSIXTIME_H_ */
diff --git a/include/posixwait.h b/include/posixwait.h
new file mode 100644
index 0000000..63b59c2
--- /dev/null
+++ b/include/posixwait.h
@@ -0,0 +1,107 @@
+/* posixwait.h -- job control definitions from POSIX 1003.1 */
+
+/* Copyright (C) 1997 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_POSIXWAIT_H_)
+# define _POSIXWAIT_H_
+
+/* If _POSIX_VERSION is not defined, we assume that <sys/wait.h> defines
+ a `union wait' and various macros used to manipulate it. Look in
+ unionwait.h for the things we expect to find. */
+#if defined (HAVE_SYS_WAIT_H)
+# include <sys/wait.h>
+#else /* !HAVE_SYS_WAIT_H */
+# if !defined (_POSIX_VERSION)
+# include "unionwait.h"
+# endif
+#endif /* !HAVE_SYS_WAIT_H */
+
+/* How to get the status of a job. For Posix, this is just an
+ int, but for other systems we have to crack the union wait. */
+#if !defined (_POSIX_VERSION)
+typedef union wait WAIT;
+# define WSTATUS(t) (t.w_status)
+#else /* _POSIX_VERSION */
+typedef int WAIT;
+# define WSTATUS(t) (t)
+#endif /* _POSIX_VERSION */
+
+/* Make sure that parameters to wait3 are defined. */
+#if !defined (WNOHANG)
+# define WNOHANG 1
+# define WUNTRACED 2
+#endif /* WNOHANG */
+
+/* More Posix P1003.1 definitions. In the POSIX versions, the parameter is
+ passed as an `int', in the non-POSIX version, as `union wait'. */
+#if defined (_POSIX_VERSION)
+
+# if !defined (WSTOPSIG)
+# define WSTOPSIG(s) ((s) >> 8)
+# endif /* !WSTOPSIG */
+
+# if !defined (WTERMSIG)
+# define WTERMSIG(s) ((s) & 0177)
+# endif /* !WTERMSIG */
+
+# if !defined (WEXITSTATUS)
+# define WEXITSTATUS(s) ((s) >> 8)
+# endif /* !WEXITSTATUS */
+
+# if !defined (WIFSTOPPED)
+# define WIFSTOPPED(s) (((s) & 0177) == 0177)
+# endif /* !WIFSTOPPED */
+
+# if !defined (WIFEXITED)
+# define WIFEXITED(s) (((s) & 0377) == 0)
+# endif /* !WIFEXITED */
+
+# if !defined (WIFSIGNALED)
+# define WIFSIGNALED(s) (!WIFSTOPPED(s) && !WIFEXITED(s))
+# endif /* !WIFSIGNALED */
+
+# if !defined (WIFCORED)
+# if defined (WCOREDUMP)
+# define WIFCORED(s) (WCOREDUMP(s))
+# else
+# define WIFCORED(s) ((s) & 0200)
+# endif
+# endif /* !WIFCORED */
+
+#else /* !_POSIX_VERSION */
+
+# if !defined (WSTOPSIG)
+# define WSTOPSIG(s) ((s).w_stopsig)
+# endif /* !WSTOPSIG */
+
+# if !defined (WTERMSIG)
+# define WTERMSIG(s) ((s).w_termsig)
+# endif /* !WTERMSIG */
+
+# if !defined (WEXITSTATUS)
+# define WEXITSTATUS(s) ((s).w_retcode)
+# endif /* !WEXITSTATUS */
+
+# if !defined (WIFCORED)
+# define WIFCORED(s) ((s).w_coredump)
+# endif /* !WIFCORED */
+
+#endif /* !_POSIX_VERSION */
+
+#endif /* !_POSIXWAIT_H_ */
diff --git a/include/shmbchar.h b/include/shmbchar.h
new file mode 100644
index 0000000..a4f3f24
--- /dev/null
+++ b/include/shmbchar.h
@@ -0,0 +1,112 @@
+/* Multibyte character data type.
+ Copyright (C) 2001, 2005-2007, 2009-2010 Free Software Foundation, Inc.
+
+ This program 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.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>. */
+
+#ifndef _SHMBCHAR_H
+#define _SHMBCHAR_H 1
+
+#if defined (HANDLE_MULTIBYTE)
+
+#include <string.h>
+
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+ <wchar.h>.
+ BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
+ <wchar.h>. */
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+#include <wctype.h>
+
+
+/* is_basic(c) tests whether the single-byte character c is in the
+ ISO C "basic character set". */
+
+#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
+/* The character set is ISO-646, not EBCDIC. */
+# define IS_BASIC_ASCII 1
+
+extern const unsigned int is_basic_table[];
+
+static inline int
+is_basic (char c)
+{
+ return (is_basic_table [(unsigned char) c >> 5] >> ((unsigned char) c & 31))
+ & 1;
+}
+
+#else
+
+static inline int
+is_basic (char c)
+{
+ switch (c)
+ {
+ case '\b': case '\r': case '\n':
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+#endif
+
+#endif /* HANDLE_MULTIBYTE */
+#endif /* _SHMBCHAR_H */
diff --git a/include/shmbutil.h b/include/shmbutil.h
new file mode 100644
index 0000000..835fb80
--- /dev/null
+++ b/include/shmbutil.h
@@ -0,0 +1,551 @@
+/* shmbutil.h -- utility functions for multibyte characters. */
+
+/* Copyright (C) 2002-2019 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_SH_MBUTIL_H_)
+#define _SH_MBUTIL_H_
+
+#include "stdc.h"
+
+/* Include config.h for HANDLE_MULTIBYTE */
+#include <config.h>
+
+#if defined (HANDLE_MULTIBYTE)
+#include "shmbchar.h"
+
+extern size_t xwcsrtombs PARAMS((char *, const wchar_t **, size_t, mbstate_t *));
+extern size_t xmbsrtowcs PARAMS((wchar_t *, const char **, size_t, mbstate_t *));
+extern size_t xdupmbstowcs PARAMS((wchar_t **, char ***, const char *));
+
+extern size_t mbstrlen PARAMS((const char *));
+
+extern char *xstrchr PARAMS((const char *, int));
+
+extern int locale_mb_cur_max; /* XXX */
+extern int locale_utf8locale; /* XXX */
+
+#ifndef MB_INVALIDCH
+#define MB_INVALIDCH(x) ((x) == (size_t)-1 || (x) == (size_t)-2)
+#define MB_NULLWCH(x) ((x) == 0)
+#endif
+
+#define MBSLEN(s) (((s) && (s)[0]) ? ((s)[1] ? mbstrlen (s) : 1) : 0)
+#define MB_STRLEN(s) ((MB_CUR_MAX > 1) ? MBSLEN (s) : STRLEN (s))
+
+#define MBLEN(s, n) ((MB_CUR_MAX > 1) ? mblen ((s), (n)) : 1)
+#define MBRLEN(s, n, p) ((MB_CUR_MAX > 1) ? mbrlen ((s), (n), (p)) : 1)
+
+#define UTF8_SINGLEBYTE(c) (((c) & 0x80) == 0)
+#define UTF8_MBFIRSTCHAR(c) (((c) & 0xc0) == 0xc0)
+#define UTF8_MBCHAR(c) (((c) & 0xc0) == 0x80)
+
+#else /* !HANDLE_MULTIBYTE */
+
+#undef MB_LEN_MAX
+#undef MB_CUR_MAX
+
+#define MB_LEN_MAX 1
+#define MB_CUR_MAX 1
+
+#undef xstrchr
+#define xstrchr(s, c) strchr(s, c)
+
+#ifndef MB_INVALIDCH
+#define MB_INVALIDCH(x) (0)
+#define MB_NULLWCH(x) (0)
+#endif
+
+#define MB_STRLEN(s) (STRLEN(s))
+
+#define MBLEN(s, n) 1
+#define MBRLEN(s, n, p) 1
+
+#ifndef wchar_t
+# define wchar_t int
+#endif
+
+#define UTF8_SINGLEBYTE(c) (1)
+#define UTF8_MBFIRSTCHAR(c) (0)
+
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Declare and initialize a multibyte state. Call must be terminated
+ with `;'. */
+#if defined (HANDLE_MULTIBYTE)
+# define DECLARE_MBSTATE \
+ mbstate_t state; \
+ memset (&state, '\0', sizeof (mbstate_t))
+#else
+# define DECLARE_MBSTATE
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Initialize or reinitialize a multibyte state named `state'. Call must be
+ terminated with `;'. */
+#if defined (HANDLE_MULTIBYTE)
+# define INITIALIZE_MBSTATE memset (&state, '\0', sizeof (mbstate_t))
+#else
+# define INITIALIZE_MBSTATE
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Advance one (possibly multi-byte) character in string _STR of length
+ _STRSIZE, starting at index _I. STATE must have already been declared. */
+#if defined (HANDLE_MULTIBYTE)
+# define ADVANCE_CHAR(_str, _strsize, _i) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ int _f; \
+\
+ _f = is_basic ((_str)[_i]); \
+ if (_f) \
+ mblength = 1; \
+ else if (locale_utf8locale && (((_str)[_i] & 0x80) == 0)) \
+ mblength = (_str)[_i] != 0; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_str) + (_i), (_strsize) - (_i), &state); \
+ } \
+\
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ (_i)++; \
+ } \
+ else if (mblength == 0) \
+ (_i)++; \
+ else \
+ (_i) += mblength; \
+ } \
+ else \
+ (_i)++; \
+ } \
+ while (0)
+#else
+# define ADVANCE_CHAR(_str, _strsize, _i) (_i)++
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Advance one (possibly multibyte) character in the string _STR of length
+ _STRSIZE.
+ SPECIAL: assume that _STR will be incremented by 1 after this call. */
+#if defined (HANDLE_MULTIBYTE)
+# define ADVANCE_CHAR_P(_str, _strsize) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ int _f; \
+\
+ _f = is_basic (*(_str)); \
+ if (_f) \
+ mblength = 1; \
+ else if (locale_utf8locale && ((*(_str) & 0x80) == 0)) \
+ mblength = *(_str) != 0; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_str), (_strsize), &state); \
+ } \
+\
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ else \
+ (_str) += (mblength < 1) ? 0 : (mblength - 1); \
+ } \
+ } \
+ while (0)
+#else
+# define ADVANCE_CHAR_P(_str, _strsize)
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Back up one (possibly multi-byte) character in string _STR of length
+ _STRSIZE, starting at index _I. STATE must have already been declared. */
+#if defined (HANDLE_MULTIBYTE)
+# define BACKUP_CHAR(_str, _strsize, _i) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ int _x, _p; /* _x == temp index into string, _p == prev index */ \
+\
+ _x = _p = 0; \
+ while (_x < (_i)) \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_str) + (_x), (_strsize) - (_x), &state); \
+\
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ _x++; \
+ } \
+ else if (mblength == 0) \
+ _x++; \
+ else \
+ { \
+ _p = _x; /* _p == start of prev mbchar */ \
+ _x += mblength; \
+ } \
+ } \
+ (_i) = _p; \
+ } \
+ else \
+ (_i)--; \
+ } \
+ while (0)
+#else
+# define BACKUP_CHAR(_str, _strsize, _i) (_i)--
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Back up one (possibly multibyte) character in the string _BASE of length
+ _STRSIZE starting at _STR (_BASE <= _STR <= (_BASE + _STRSIZE) ).
+ SPECIAL: DO NOT assume that _STR will be decremented by 1 after this call. */
+#if defined (HANDLE_MULTIBYTE)
+# define BACKUP_CHAR_P(_base, _strsize, _str) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ char *_x, _p; /* _x == temp pointer into string, _p == prev pointer */ \
+\
+ _x = _p = _base; \
+ while (_x < (_str)) \
+ { \
+ state_bak = state; \
+ mblength = mbrlen (_x, (_strsize) - _x, &state); \
+\
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ _x++; \
+ } \
+ else if (mblength == 0) \
+ _x++; \
+ else \
+ { \
+ _p = _x; /* _p == start of prev mbchar */ \
+ _x += mblength; \
+ } \
+ } \
+ (_str) = _p; \
+ } \
+ else \
+ (_str)--; \
+ } \
+ while (0)
+#else
+# define BACKUP_CHAR_P(_base, _strsize, _str) (_str)--
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Copy a single character from the string _SRC to the string _DST.
+ _SRCEND is a pointer to the end of _SRC. */
+#if defined (HANDLE_MULTIBYTE)
+# define COPY_CHAR_P(_dst, _src, _srcend) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ int _k; \
+\
+ _k = is_basic (*(_src)); \
+ if (_k) \
+ mblength = 1; \
+ else if (locale_utf8locale && ((*(_src) & 0x80) == 0)) \
+ mblength = *(_src) != 0; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_src), (_srcend) - (_src), &state); \
+ } \
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ else \
+ mblength = (mblength < 1) ? 1 : mblength; \
+\
+ for (_k = 0; _k < mblength; _k++) \
+ *(_dst)++ = *(_src)++; \
+ } \
+ else \
+ *(_dst)++ = *(_src)++; \
+ } \
+ while (0)
+#else
+# define COPY_CHAR_P(_dst, _src, _srcend) *(_dst)++ = *(_src)++
+#endif /* !HANDLE_MULTIBYTE */
+
+/* Copy a single character from the string _SRC at index _SI to the string
+ _DST at index _DI. _SRCEND is a pointer to the end of _SRC. */
+#if defined (HANDLE_MULTIBYTE)
+# define COPY_CHAR_I(_dst, _di, _src, _srcend, _si) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ int _k; \
+\
+ _k = is_basic (*((_src) + (_si))); \
+ if (_k) \
+ mblength = 1; \
+ else \
+ {\
+ state_bak = state; \
+ mblength = mbrlen ((_src) + (_si), (_srcend) - ((_src)+(_si)), &state); \
+ } \
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ else \
+ mblength = (mblength < 1) ? 1 : mblength; \
+\
+ for (_k = 0; _k < mblength; _k++) \
+ _dst[_di++] = _src[_si++]; \
+ } \
+ else \
+ _dst[_di++] = _src[_si++]; \
+ } \
+ while (0)
+#else
+# define COPY_CHAR_I(_dst, _di, _src, _srcend, _si) _dst[_di++] = _src[_si++]
+#endif /* !HANDLE_MULTIBYTE */
+
+/****************************************************************
+ * *
+ * The following are only guaranteed to work in subst.c *
+ * *
+ ****************************************************************/
+
+#if defined (HANDLE_MULTIBYTE)
+# define SCOPY_CHAR_I(_dst, _escchar, _sc, _src, _si, _slen) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ int _i; \
+\
+ _i = is_basic (*((_src) + (_si))); \
+ if (_i) \
+ mblength = 1; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_src) + (_si), (_slen) - (_si), &state); \
+ } \
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ else \
+ mblength = (mblength < 1) ? 1 : mblength; \
+\
+ temp = xmalloc (mblength + 2); \
+ temp[0] = _escchar; \
+ for (_i = 0; _i < mblength; _i++) \
+ temp[_i + 1] = _src[_si++]; \
+ temp[mblength + 1] = '\0'; \
+\
+ goto add_string; \
+ } \
+ else \
+ { \
+ _dst[0] = _escchar; \
+ _dst[1] = _sc; \
+ } \
+ } \
+ while (0)
+#else
+# define SCOPY_CHAR_I(_dst, _escchar, _sc, _src, _si, _slen) \
+ _dst[0] = _escchar; \
+ _dst[1] = _sc
+#endif /* !HANDLE_MULTIBYTE */
+
+#if defined (HANDLE_MULTIBYTE)
+# define SCOPY_CHAR_M(_dst, _src, _srcend, _si) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ mbstate_t state_bak; \
+ size_t mblength; \
+ int _i; \
+\
+ _i = is_basic (*((_src) + (_si))); \
+ if (_i) \
+ mblength = 1; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_src) + (_si), (_srcend) - ((_src) + (_si)), &state); \
+ } \
+ if (mblength == (size_t)-2 || mblength == (size_t)-1) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ else \
+ mblength = (mblength < 1) ? 1 : mblength; \
+\
+ FASTCOPY(((_src) + (_si)), (_dst), mblength); \
+\
+ (_dst) += mblength; \
+ (_si) += mblength; \
+ } \
+ else \
+ { \
+ *(_dst)++ = _src[(_si)]; \
+ (_si)++; \
+ } \
+ } \
+ while (0)
+#else
+# define SCOPY_CHAR_M(_dst, _src, _srcend, _si) \
+ *(_dst)++ = _src[(_si)]; \
+ (_si)++
+#endif /* !HANDLE_MULTIBYTE */
+
+#if HANDLE_MULTIBYTE
+# define SADD_MBCHAR(_dst, _src, _si, _srcsize) \
+ do \
+ { \
+ if (locale_mb_cur_max > 1) \
+ { \
+ int i; \
+ mbstate_t state_bak; \
+ size_t mblength; \
+\
+ i = is_basic (*((_src) + (_si))); \
+ if (i) \
+ mblength = 1; \
+ else if (locale_utf8locale && (((_src)[_si] & 0x80) == 0)) \
+ mblength = (_src)[_si] != 0; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_src) + (_si), (_srcsize) - (_si), &state); \
+ } \
+ if (mblength == (size_t)-1 || mblength == (size_t)-2) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ if (mblength < 1) \
+ mblength = 1; \
+\
+ _dst = (char *)xmalloc (mblength + 1); \
+ for (i = 0; i < mblength; i++) \
+ (_dst)[i] = (_src)[(_si)++]; \
+ (_dst)[mblength] = '\0'; \
+\
+ goto add_string; \
+ } \
+ } \
+ while (0)
+
+#else
+# define SADD_MBCHAR(_dst, _src, _si, _srcsize)
+#endif
+
+/* Watch out when using this -- it's just straight textual substitution */
+#if defined (HANDLE_MULTIBYTE)
+# define SADD_MBQCHAR_BODY(_dst, _src, _si, _srcsize) \
+\
+ int i; \
+ mbstate_t state_bak; \
+ size_t mblength; \
+\
+ i = is_basic (*((_src) + (_si))); \
+ if (i) \
+ mblength = 1; \
+ else if (locale_utf8locale && (((_src)[_si] & 0x80) == 0)) \
+ mblength = (_src)[_si] != 0; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_src) + (_si), (_srcsize) - (_si), &state); \
+ } \
+ if (mblength == (size_t)-1 || mblength == (size_t)-2) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ if (mblength < 1) \
+ mblength = 1; \
+\
+ (_dst) = (char *)xmalloc (mblength + 2); \
+ (_dst)[0] = CTLESC; \
+ for (i = 0; i < mblength; i++) \
+ (_dst)[i+1] = (_src)[(_si)++]; \
+ (_dst)[mblength+1] = '\0'; \
+\
+ goto add_string
+
+# define SADD_MBCHAR_BODY(_dst, _src, _si, _srcsize) \
+\
+ int i; \
+ mbstate_t state_bak; \
+ size_t mblength; \
+\
+ i = is_basic (*((_src) + (_si))); \
+ if (i) \
+ mblength = 1; \
+ else \
+ { \
+ state_bak = state; \
+ mblength = mbrlen ((_src) + (_si), (_srcsize) - (_si), &state); \
+ } \
+ if (mblength == (size_t)-1 || mblength == (size_t)-2) \
+ { \
+ state = state_bak; \
+ mblength = 1; \
+ } \
+ if (mblength < 1) \
+ mblength = 1; \
+\
+ (_dst) = (char *)xmalloc (mblength + 1); \
+ for (i = 0; i < mblength; i++) \
+ (_dst)[i+1] = (_src)[(_si)++]; \
+ (_dst)[mblength+1] = '\0'; \
+\
+ goto add_string
+
+#endif /* HANDLE_MULTIBYTE */
+#endif /* _SH_MBUTIL_H_ */
diff --git a/include/shtty.h b/include/shtty.h
new file mode 100644
index 0000000..fdf379b
--- /dev/null
+++ b/include/shtty.h
@@ -0,0 +1,112 @@
+/* Copyright (C) 1999-2020 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * shtty.h -- include the correct system-dependent files to manipulate the
+ * tty
+ */
+
+#ifndef __SH_TTY_H_
+#define __SH_TTY_H_
+
+#include "stdc.h"
+
+#if defined (_POSIX_VERSION) && defined (HAVE_TERMIOS_H) && defined (HAVE_TCGETATTR) && !defined (TERMIOS_MISSING)
+# define TERMIOS_TTY_DRIVER
+#else
+# if defined (HAVE_TERMIO_H)
+# define TERMIO_TTY_DRIVER
+# else
+# define NEW_TTY_DRIVER
+# endif
+#endif
+
+/*
+ * The _POSIX_SOURCE define is to avoid multiple symbol definitions
+ * between sys/ioctl.h and termios.h. Ditto for the test against SunOS4
+ * and the undefining of several symbols.
+ */
+
+#ifdef TERMIOS_TTY_DRIVER
+# if (defined (SunOS4) || defined (SunOS5)) && !defined (_POSIX_SOURCE)
+# define _POSIX_SOURCE
+# endif
+# if defined (SunOS4)
+# undef ECHO
+# undef NOFLSH
+# undef TOSTOP
+# endif /* SunOS4 */
+# include <termios.h>
+# define TTYSTRUCT struct termios
+#else
+# ifdef TERMIO_TTY_DRIVER
+# include <termio.h>
+# define TTYSTRUCT struct termio
+# else /* NEW_TTY_DRIVER */
+# include <sgtty.h>
+# define TTYSTRUCT struct sgttyb
+# endif
+#endif
+
+/* Functions imported from lib/sh/shtty.c */
+
+/* Get and set terminal attributes for the file descriptor passed as
+ an argument. */
+extern int ttgetattr PARAMS((int, TTYSTRUCT *));
+extern int ttsetattr PARAMS((int, TTYSTRUCT *));
+
+/* Save and restore the terminal's attributes from static storage. */
+extern void ttsave PARAMS((void));
+extern void ttrestore PARAMS((void));
+
+/* Return the attributes corresponding to the file descriptor (0 or 1)
+ passed as an argument. */
+extern TTYSTRUCT *ttattr PARAMS((int));
+
+/* These functions only operate on the passed TTYSTRUCT; they don't
+ actually change anything with the kernel's current tty settings. */
+extern int tt_setonechar PARAMS((TTYSTRUCT *));
+extern int tt_setnoecho PARAMS((TTYSTRUCT *));
+extern int tt_seteightbit PARAMS((TTYSTRUCT *));
+extern int tt_setnocanon PARAMS((TTYSTRUCT *));
+extern int tt_setcbreak PARAMS((TTYSTRUCT *));
+
+/* These functions are all generally mutually exclusive. If you call
+ more than one (bracketed with calls to ttsave and ttrestore, of
+ course), the right thing will happen, but more system calls will be
+ executed than absolutely necessary. You can do all of this yourself
+ with the other functions; these are only conveniences. */
+
+/* These functions work with a given file descriptor and set terminal
+ attributes */
+extern int ttfd_onechar PARAMS((int, TTYSTRUCT *));
+extern int ttfd_noecho PARAMS((int, TTYSTRUCT *));
+extern int ttfd_eightbit PARAMS((int, TTYSTRUCT *));
+extern int ttfd_nocanon PARAMS((int, TTYSTRUCT *));
+
+extern int ttfd_cbreak PARAMS((int, TTYSTRUCT *));
+
+/* These functions work with fd 0 and the TTYSTRUCT saved with ttsave () */
+extern int ttonechar PARAMS((void));
+extern int ttnoecho PARAMS((void));
+extern int tteightbit PARAMS((void));
+extern int ttnocanon PARAMS((void));
+
+extern int ttcbreak PARAMS((void));
+
+#endif
diff --git a/include/stat-time.h b/include/stat-time.h
new file mode 100644
index 0000000..e04cc61
--- /dev/null
+++ b/include/stat-time.h
@@ -0,0 +1,214 @@
+/* stat-related time functions.
+
+ Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc.
+
+ This program 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.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef STAT_TIME_H
+#define STAT_TIME_H 1
+
+#include <sys/stat.h>
+
+#if defined (TIME_H_DEFINES_STRUCT_TIMESPEC)
+# include <time.h>
+#elif defined (SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)
+# include <sys/time.h>
+#elif defined (PTHREAD_H_DEFINES_STRUCT_TIMESPEC)
+# include <pthread.h>
+#endif
+
+#ifndef HAVE_STRUCT_TIMESPEC
+struct timespec
+{
+ time_t tv_sec;
+ long int tv_nsec;
+};
+#endif
+
+/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type
+ struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST,
+ ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST,
+ if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim
+ for access, status change, data modification, or birth (creation)
+ time respectively.
+
+ These macros are private to stat-time.h. */
+#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
+# ifdef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
+# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
+# else
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
+# endif
+#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
+# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec)
+#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec)
+#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec)
+#endif
+
+/* Return the nanosecond component of *ST's access time. */
+static inline long int
+get_stat_atime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_atim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_atim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's status change time. */
+static inline long int
+get_stat_ctime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_ctim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_ctim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's data modification time. */
+static inline long int
+get_stat_mtime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_mtim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_mtim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's birth time. */
+static inline long int
+get_stat_birthtime_ns (struct stat const *st)
+{
+# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
+ return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
+# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
+ return STAT_TIMESPEC_NS (st, st_birthtim);
+# else
+ /* Avoid a "parameter unused" warning. */
+ (void) st;
+ return 0;
+# endif
+}
+
+/* Return *ST's access time. */
+static inline struct timespec
+get_stat_atime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_atim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_atime;
+ t.tv_nsec = get_stat_atime_ns (st);
+ return t;
+#endif
+}
+
+/* Return *ST's status change time. */
+static inline struct timespec
+get_stat_ctime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_ctim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_ctime;
+ t.tv_nsec = get_stat_ctime_ns (st);
+ return t;
+#endif
+}
+
+/* Return *ST's data modification time. */
+static inline struct timespec
+get_stat_mtime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_mtim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_mtime;
+ t.tv_nsec = get_stat_mtime_ns (st);
+ return t;
+#endif
+}
+
+static inline int
+timespec_cmp (struct timespec a, struct timespec b)
+{
+ return (a.tv_sec < b.tv_sec
+ ? -1
+ : (a.tv_sec > b.tv_sec
+ ? 1
+ : (int) (a.tv_nsec - b.tv_nsec)));
+}
+
+/* Return *ST's birth time, if available; otherwise return a value
+ with tv_sec and tv_nsec both equal to -1. */
+static inline struct timespec
+get_stat_birthtime (struct stat const *st)
+{
+ struct timespec t;
+
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
+ t = STAT_TIMESPEC (st, st_birthtim);
+#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
+ t.tv_sec = st->st_birthtime;
+ t.tv_nsec = st->st_birthtimensec;
+#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Native Windows platforms (but not Cygwin) put the "file creation
+ time" in st_ctime (!). See
+ <http://msdn2.microsoft.com/de-de/library/14h5k7ff(VS.80).aspx>. */
+ t.tv_sec = st->st_ctime;
+ t.tv_nsec = 0;
+#else
+ /* Birth time is not supported. */
+ t.tv_sec = -1;
+ t.tv_nsec = -1;
+ /* Avoid a "parameter unused" warning. */
+ (void) st;
+#endif
+
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
+ /* FreeBSD and NetBSD sometimes signal the absence of knowledge by
+ using zero. Attempt to work around this problem. Alas, this can
+ report failure even for valid time stamps. Also, NetBSD
+ sometimes returns junk in the birth time fields; work around this
+ bug if it is detected. */
+ if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
+ {
+ t.tv_sec = -1;
+ t.tv_nsec = -1;
+ }
+#endif
+
+ return t;
+}
+
+#endif
diff --git a/include/stdc.h b/include/stdc.h
new file mode 100644
index 0000000..7b9282c
--- /dev/null
+++ b/include/stdc.h
@@ -0,0 +1,89 @@
+/* stdc.h -- macros to make source compile on both ANSI C and K&R C
+ compilers. */
+
+/* Copyright (C) 1993 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if !defined (_STDC_H_)
+#define _STDC_H_
+
+/* Adapted from BSD /usr/include/sys/cdefs.h. */
+
+/* A function can be defined using prototypes and compile on both ANSI C
+ and traditional C compilers with something like this:
+ extern char *func PARAMS((char *, char *, int)); */
+
+#if !defined (PARAMS)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || defined (PROTOTYPES)
+# define PARAMS(protos) protos
+# else
+# define PARAMS(protos) ()
+# endif
+#endif
+
+/* Fortify, at least, has trouble with this definition */
+#if defined (HAVE_STRINGIZE)
+# define CPP_STRING(x) #x
+#else
+# define CPP_STRING(x) "x"
+#endif
+
+#if !defined (__STDC__)
+
+#if defined (__GNUC__) /* gcc with -traditional */
+# if !defined (signed)
+# define signed __signed
+# endif
+# if !defined (volatile)
+# define volatile __volatile
+# endif
+#else /* !__GNUC__ */
+# if !defined (inline)
+# define inline
+# endif
+# if !defined (signed)
+# define signed
+# endif
+# if !defined (volatile)
+# define volatile
+# endif
+#endif /* !__GNUC__ */
+
+#endif /* !__STDC__ */
+
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
+# define __attribute__(x)
+# endif
+#endif
+
+/* For those situations when gcc handles inlining a particular function but
+ other compilers complain. */
+#ifdef __GNUC__
+# define INLINE inline
+#else
+# define INLINE
+#endif
+
+#if defined (PREFER_STDARG)
+# define SH_VA_START(va, arg) va_start(va, arg)
+#else
+# define SH_VA_START(va, arg) va_start(va)
+#endif
+
+#endif /* !_STDC_H_ */
diff --git a/include/systimes.h b/include/systimes.h
new file mode 100644
index 0000000..aefcab7
--- /dev/null
+++ b/include/systimes.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991-2020 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * POSIX Standard: 4.5.2 Process Times <sys/times.h>
+ */
+
+/*
+ * If we don't have a standard system clock_t type, this must be included
+ * after config.h
+ */
+
+#ifndef _BASH_SYSTIMES_H
+#define _BASH_SYSTIMES_H 1
+
+#if defined (HAVE_SYS_TIMES_H)
+# include <sys/times.h>
+#else /* !HAVE_SYS_TIMES_H */
+
+#include <stdc.h>
+
+/* Structure describing CPU time used by a process and its children. */
+struct tms
+ {
+ clock_t tms_utime; /* User CPU time. */
+ clock_t tms_stime; /* System CPU time. */
+
+ clock_t tms_cutime; /* User CPU time of dead children. */
+ clock_t tms_cstime; /* System CPU time of dead children. */
+ };
+
+/* Store the CPU time used by this process and all its
+ dead descendants in BUFFER.
+ Return the elapsed real time from an arbitrary point in the
+ past (the bash emulation uses the epoch), or (clock_t) -1 for
+ errors. All times are in CLK_TCKths of a second. */
+extern clock_t times PARAMS((struct tms *buffer));
+
+#endif /* !HAVE_SYS_TIMES_H */
+#endif /* _BASH_SYSTIMES_H */
diff --git a/include/typemax.h b/include/typemax.h
new file mode 100644
index 0000000..9853d56
--- /dev/null
+++ b/include/typemax.h
@@ -0,0 +1,131 @@
+/* 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * 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_SIGNED_MAGNITUDE
+# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
+#endif
+
+#ifndef TYPE_WIDTH
+# define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+#endif
+
+#ifndef TYPE_MINIMUM
+# define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
+#endif
+
+#ifndef TYPE_MAXIMUM
+# define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
+#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
+
+#if !defined (INTMAX_MAX) || !defined (INTMAX_MIN)
+
+#if SIZEOF_INTMAX_T == SIZEOF_LONG_LONG
+# define INTMAX_MAX LLONG_MAX
+# define INTMAX_MIN LLONG_MIN
+#elif SIZEOF_INTMAX_T == SIZEOF_LONG
+# define INTMAX_MAX LONG_MAX
+# define INTMAX_MIN LONG_MIN
+#else
+# define INTMAX_MAX INT_MAX
+# define INTMAX_MIN INT_MIN
+#endif
+
+#endif
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX 32767 /* POSIX minimum max */
+#endif
+
+#ifndef SIZE_MAX
+# define SIZE_MAX 65535 /* POSIX minimum max */
+#endif
+
+#ifndef sh_imaxabs
+# define sh_imaxabs(x) (((x) >= 0) ? (x) : -(x))
+#endif
+
+/* Handle signed arithmetic overflow and underflow. Have to do it this way
+ to avoid compilers optimizing out simpler overflow checks. */
+
+/* Make sure that a+b does not exceed MAXV or is smaller than MINV (if b < 0).
+ Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
+#define ADDOVERFLOW(a,b,minv,maxv) \
+ ((((a) > 0) && ((b) > ((maxv) - (a)))) || \
+ (((a) < 0) && ((b) < ((minv) - (a)))))
+
+/* Make sure that a-b is not smaller than MINV or exceeds MAXV (if b < 0).
+ Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
+#define SUBOVERFLOW(a,b,minv,maxv) \
+ ((((b) > 0) && ((a) < ((minv) + (b)))) || \
+ (((b) < 0) && ((a) > ((maxv) + (b)))))
+
+#endif /* _SH_TYPEMAX_H */
diff --git a/include/unionwait.h b/include/unionwait.h
new file mode 100644
index 0000000..b1b4dfa
--- /dev/null
+++ b/include/unionwait.h
@@ -0,0 +1,98 @@
+/* unionwait.h -- definitions for using a `union wait' on systems without
+ one. */
+
+/* Copyright (C) 1996 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _UNIONWAIT_H
+#define _UNIONWAIT_H
+
+#if !defined (WORDS_BIGENDIAN)
+union wait
+ {
+ int w_status; /* used in syscall */
+
+ /* Terminated process status. */
+ struct
+ {
+ unsigned short
+ w_Termsig : 7, /* termination signal */
+ w_Coredump : 1, /* core dump indicator */
+ w_Retcode : 8, /* exit code if w_termsig==0 */
+ w_Fill1 : 16; /* high 16 bits unused */
+ } w_T;
+
+ /* Stopped process status. Returned
+ only for traced children unless requested
+ with the WUNTRACED option bit. */
+ struct
+ {
+ unsigned short
+ w_Stopval : 8, /* == W_STOPPED if stopped */
+ w_Stopsig : 8, /* actually zero on XENIX */
+ w_Fill2 : 16; /* high 16 bits unused */
+ } w_S;
+ };
+
+#else /* WORDS_BIGENDIAN */
+
+/* This is for big-endian machines like the IBM RT, HP 9000, or Sun-3 */
+
+union wait
+ {
+ int w_status; /* used in syscall */
+
+ /* Terminated process status. */
+ struct
+ {
+ unsigned short w_Fill1 : 16; /* high 16 bits unused */
+ unsigned w_Retcode : 8; /* exit code if w_termsig==0 */
+ unsigned w_Coredump : 1; /* core dump indicator */
+ unsigned w_Termsig : 7; /* termination signal */
+ } w_T;
+
+ /* Stopped process status. Returned
+ only for traced children unless requested
+ with the WUNTRACED option bit. */
+ struct
+ {
+ unsigned short w_Fill2 : 16; /* high 16 bits unused */
+ unsigned w_Stopsig : 8; /* signal that stopped us */
+ unsigned w_Stopval : 8; /* == W_STOPPED if stopped */
+ } w_S;
+ };
+
+#endif /* WORDS_BIGENDIAN */
+
+#define w_termsig w_T.w_Termsig
+#define w_coredump w_T.w_Coredump
+#define w_retcode w_T.w_Retcode
+#define w_stopval w_S.w_Stopval
+#define w_stopsig w_S.w_Stopsig
+
+#define WSTOPPED 0177
+#define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED)
+#define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0)
+#define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0)
+
+#define WTERMSIG(x) ((x).w_termsig)
+#define WSTOPSIG(x) ((x).w_stopsig)
+#define WEXITSTATUS(x) ((x).w_retcode)
+#define WIFCORED(x) ((x).w_coredump)
+
+#endif /* _UNIONWAIT_H */