summaryrefslogtreecommitdiffstats
path: root/contrib/tcsh/sh.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tcsh/sh.h')
-rw-r--r--contrib/tcsh/sh.h234
1 files changed, 79 insertions, 155 deletions
diff --git a/contrib/tcsh/sh.h b/contrib/tcsh/sh.h
index 92c2f95..6bd594e 100644
--- a/contrib/tcsh/sh.h
+++ b/contrib/tcsh/sh.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.h,v 3.133 2005/03/25 18:46:41 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.h,v 3.146 2006/07/03 22:59:01 mitr Exp $ */
/*
* sh.h: Catch it all globals and includes file!
*/
@@ -36,6 +36,7 @@
#include "config.h"
#include <stddef.h>
+#include <signal.h>
#ifdef HAVE_ICONV
# include <iconv.h>
@@ -72,7 +73,7 @@ typedef unsigned long intptr_t;
#ifndef WINNT_NATIVE
# define INIT_ZERO
# define INIT_ZERO_STRUCT
-# define force_read read
+# define force_read xread
#endif /*!WINNT_NATIVE */
/*
* Sanity
@@ -85,13 +86,9 @@ typedef unsigned long intptr_t;
# define BSDJOBS
#endif
-#if defined(POSIXSIGS) && !defined(BSDSIGS)
-# define BSDSIGS
-#endif
-
#ifdef SHORT_STRINGS
-#include <wchar.h>
# ifdef WIDE_STRINGS
+#include <wchar.h>
typedef wchar_t Char;
typedef unsigned long uChar;
typedef wint_t eChar; /* Can contain any Char value or CHAR_ERR */
@@ -115,12 +112,6 @@ typedef int eChar;
#define normal_mbtowc(PWC, S, N) ((void)(N), *(PWC) = (unsigned char)*(S), 1)
#define reset_mbtowc() ((void)0)
# define SAVE(a) (strsave(a))
-#endif
-#if SIZEOF_WCHAR_T >= 4
-typedef wchar_t NLSChar;
-#else
-/* Assumes sizeof (int) >= 4, unlike some parts of tcsh */
-typedef int NLSChar;
#endif
/* Elide unused argument warnings */
@@ -312,8 +303,8 @@ typedef int NLSChar;
# undef calloc
# undef realloc
# endif /* glibc || sgi */
-# include <limits.h>
#endif /* POSIX && !WINNT_NATIVE */
+#include <limits.h>
#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(linux) || defined(__GNU__) || defined(__GLIBC__)
# if !defined(pyr) && !defined(stellar)
@@ -328,7 +319,7 @@ typedef int NLSChar;
* versions of DECOSF1 will get TIOCGWINSZ. This might break older versions...
*/
#if !((defined(SUNOS4) || defined(_MINIX) /* || defined(DECOSF1) */) && defined(TERMIO))
-# if !defined(COHERENT) && !defined(_VMS_POSIX) && !defined(WINNT_NATIVE)
+# if !defined(_VMS_POSIX) && !defined(WINNT_NATIVE)
# include <sys/ioctl.h>
# endif
#endif
@@ -342,9 +333,9 @@ typedef int NLSChar;
# include <sys/filio.h>
#endif /* (!FIOCLEX && SUNOS4) || (SYSVREL == 4 && !_SEQUENT_ && !SCO && !_SX ) */
-#if !defined(_MINIX) && !defined(COHERENT) && !defined(supermax) && !defined(WINNT_NATIVE) && !defined(IRIS4D)
+#if !defined(_MINIX) && !defined(supermax) && !defined(WINNT_NATIVE) && !defined(IRIS4D)
# include <sys/file.h>
-#endif /* !_MINIX && !COHERENT && !supermax && !WINNT_NATIVE && !defined(IRIS4D) */
+#endif /* !_MINIX && !supermax && !WINNT_NATIVE && !defined(IRIS4D) */
#if !defined(O_RDONLY) || !defined(O_NDELAY)
# include <fcntl.h>
@@ -357,15 +348,7 @@ typedef int NLSChar;
#include <setjmp.h>
-#if defined(PROTOTYPES)
-# include <stdarg.h>
-#else
-#ifdef _MINIX
-# include "mi.varargs.h"
-#else
-# include <varargs.h>
-#endif /* _MINIX */
-#endif
+#include <stdarg.h>
#ifdef HAVE_DIRENT_H
# include <dirent.h>
@@ -380,9 +363,9 @@ typedef int NLSChar;
#ifndef HAVE_STRUCT_DIRENT_D_INO
# define d_ino d_fileno
#endif
-#if defined(hpux) || defined(sgi) || defined(OREO) || defined(COHERENT)
+#if defined(hpux) || defined(sgi) || defined(OREO)
# include <stdio.h> /* So the fgetpwent() prototypes work */
-#endif /* hpux || sgi || OREO || COHERENT */
+#endif /* hpux || sgi || OREO */
#ifndef WINNT_NATIVE
#include <pwd.h>
#include <grp.h>
@@ -420,27 +403,15 @@ typedef int NLSChar;
# if (defined(_SS_SIZE) || defined(_SS_MAXSIZE)) && defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)
# if !defined(__APPLE__) /* Damnit, where is getnameinfo() folks? */
# if !defined(sgi)
-# define INET6
+# if !defined(__CYGWIN__)
+# define INET6
+# endif /* __CYGWIN__ */
# endif /* sgi */
# endif /* __APPLE__ */
# endif
# include <sys/uio.h> /* For struct iovec */
#endif /* REMOTEHOST */
-/*
- * ANSIisms... These must be *after* the system include and
- * *before* our includes, so that BSDreno has time to define __P
- */
-#undef __P
-#ifndef __P
-# if defined(PROTOTYPES)
-# define __P(a) a
-# else
-# define __P(a) ()
-# endif
-#endif
-
-
#ifdef PURIFY
/* exit normally, allowing purify to trace leaks */
# define _exit exit
@@ -471,18 +442,14 @@ typedef void pret_t;
#include "sh.types.h"
-#ifndef __NetBSD__ /* XXX */
-#ifndef WINNT_NATIVE
+#if !HAVE_DECL_GETPGRP
# ifndef GETPGRP_VOID
-extern pid_t getpgrp __P((int));
+extern pid_t getpgrp (int);
# else
-extern pid_t getpgrp __P((void));
+extern pid_t getpgrp (void);
# endif
-#endif /* !WINNT_NATIVE */
#endif
-typedef RETSIGTYPE (*signalfun_t) __P((int));
-
#ifndef lint
typedef ptr_t memalign_t;
#else
@@ -501,29 +468,17 @@ typedef union {
# define calloc lint_calloc
#endif
-#ifdef MDEBUG
-extern memalign_t DebugMalloc __P((unsigned, char *, int));
-extern memalign_t DebugRealloc __P((ptr_t, unsigned, char *, int));
-extern memalign_t DebugCalloc __P((unsigned, unsigned, char *, int));
-extern void DebugFree __P((ptr_t, char *, int));
-# define xmalloc(i) DebugMalloc(i, __FILE__, __LINE__)
-# define xrealloc(p, i)((p) ? DebugRealloc(p, i, __FILE__, __LINE__) : \
- DebugMalloc(i, __FILE__, __LINE__))
-# define xcalloc(n, s) DebugCalloc(n, s, __FILE__, __LINE__)
-# define xfree(p) if (p) DebugFree(p, __FILE__, __LINE__)
+#ifdef SYSMALLOC
+# define xmalloc(i) smalloc(i)
+# define xrealloc(p, i) srealloc(p, i)
+# define xcalloc(n, s) scalloc(n, s)
+# define xfree sfree
#else
-# ifdef SYSMALLOC
-# define xmalloc(i) smalloc(i)
-# define xrealloc(p, i) srealloc(p, i)
-# define xcalloc(n, s) scalloc(n, s)
-# define xfree(p) sfree(p)
-# else
-# define xmalloc(i) malloc(i)
-# define xrealloc(p, i) realloc(p, i)
-# define xcalloc(n, s) calloc(n, s)
-# define xfree(p) free(p)
-# endif /* SYSMALLOC */
-#endif /* MDEBUG */
+# define xmalloc(i) malloc(i)
+# define xrealloc(p, i) realloc(p, i)
+# define xcalloc(n, s) calloc(n, s)
+# define xfree free
+#endif /* SYSMALLOC */
#include "sh.char.h"
#include "sh.err.h"
#include "sh.dir.h"
@@ -542,10 +497,6 @@ extern void DebugFree __P((ptr_t, char *, int));
* April, 1980
*/
-#if !defined(MAXNAMLEN) && defined(_D_NAME_MAX)
-# define MAXNAMLEN _D_NAME_MAX
-#endif /* MAXNAMLEN */
-
#ifdef HESIOD
# include <hesiod.h>
#endif /* HESIOD */
@@ -555,7 +506,9 @@ extern void DebugFree __P((ptr_t, char *, int));
#endif /* REMOTEHOST */
#ifndef MAXHOSTNAMELEN
-# if defined(SCO) && (SYSVREL > 3)
+# ifdef HOST_NAME_MAX
+# define MAXHOSTNAMELEN (HOST_NAME_MAX + 1)
+# elif defined(SCO) && (SYSVREL > 3)
# include <sys/socket.h>
# else
# define MAXHOSTNAMELEN 256
@@ -595,7 +548,6 @@ EXTERN int neednote IZERO; /* Need to pnotify() */
EXTERN int noexec IZERO; /* Don't execute, just syntax check */
EXTERN int pjobs IZERO; /* want to print jobs if interrupted */
EXTERN int setintr IZERO; /* Set interrupts on/off -> Wait intr... */
-EXTERN int timflg IZERO; /* Time the next waited for command */
EXTERN int havhash IZERO; /* path hashing is available */
EXTERN int editing IZERO; /* doing filename expansion and line editing */
EXTERN int noediting IZERO; /* initial $term defaulted to noedit */
@@ -607,7 +559,8 @@ EXTERN int is2atty IZERO; /* is file descriptor 2 a tty (didfds mode) */
EXTERN int arun IZERO; /* Currently running multi-line-aliases */
EXTERN int implicit_cd IZERO;/* implicit cd enabled?(1=enabled,2=verbose) */
EXTERN int inheredoc IZERO; /* Currently parsing a heredoc */
-EXTERN int windowchg IZERO; /* We received a window change event */
+/* We received a window change event */
+EXTERN volatile sig_atomic_t windowchg IZERO;
#if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
EXTERN int dspmbyte_ls;
#endif
@@ -625,7 +578,8 @@ extern char *seterr; /* Error message from scanner/parser */
extern int errno; /* Error from C library routines */
#endif
extern int exitset;
-EXTERN Char *shtemp IZERO; /* Temp name for << shell files in /tmp */
+/* Temp name for << shell files in /tmp, for xfree() */
+EXTERN Char *shtemp IZERO;
#ifdef BSDTIMES
EXTERN struct timeval time0; /* Time at which the shell started */
@@ -643,7 +597,7 @@ EXTERN clock_t clk_tck;
# endif /* POSIX */
EXTERN struct tms shtimes; /* shell and child times for process timing */
# endif /* _SEQUENT_ */
-EXTERN long seconds0;
+EXTERN time_t seconds0;
#endif /* BSDTIMES */
#ifndef HZ
@@ -654,7 +608,7 @@ EXTERN long seconds0;
* Miscellany
*/
EXTERN Char *doldol; /* Character pid for $$ */
-EXTERN int backpid; /* pid of the last background job */
+EXTERN pid_t backpid; /* pid of the last background job */
/*
* Ideally these should be uid_t, gid_t, pid_t. I cannot do that right now
@@ -669,12 +623,8 @@ EXTERN pid_t opgrp, /* Initial pgrp and tty pgrp */
tpgrp; /* Terminal process group */
/* If tpgrp is -1, leave tty alone! */
-EXTERN Char PromptBuf[INBUFSIZE*2]; /* buffer for the actual printed prompt.
- * this must be large enough to contain
- * the input line and the prompt, in
- * case a correction occurred...
- */
-EXTERN Char RPromptBuf[INBUFSIZE]; /* buffer for right-hand side prompt */
+EXTERN Char *Prompt; /* The actual printed prompt or NULL */
+EXTERN Char *RPrompt; /* Right-hand side prompt or NULL */
/*
* To be able to redirect i/o for builtins easily, the shell moves the i/o
@@ -706,49 +656,27 @@ EXTERN int OLDSTD IZERO; /* Old standard input (def for cmds) */
* Because of source commands and .cshrc we need nested error catches.
*/
-#ifdef NO_STRUCT_ASSIGNMENT
-
-# ifdef SIGSETJMP
- typedef sigjmp_buf jmp_buf_t;
- /* bugfix by Jak Kirman @ Brown U.: remove the (void) cast here, see sh.c */
-# define setexit() sigsetjmp(reslab)
-# define reset() siglongjmp(reslab, 1)
-# else
- typedef jmp_buf jmp_buf_t;
- /* bugfix by Jak Kirman @ Brown U.: remove the (void) cast here, see sh.c */
-# define setexit() setjmp(reslab)
-# define reset() longjmp(reslab, 1)
-# endif
-# define getexit(a) (void) memmove((ptr_t)&(a), (ptr_t)&reslab, sizeof(reslab))
-# define resexit(a) (void) memmove((ptr_t)&reslab, (ptr_t)&(a), sizeof(reslab))
-
-# define cpybin(a, b) (void) memmove((ptr_t)&(a), (ptr_t)&(b), sizeof(Bin))
-
-#else
-
-# ifdef SIGSETJMP
+#ifdef SIGSETJMP
typedef struct { sigjmp_buf j; } jmp_buf_t;
-# define setexit() sigsetjmp(reslab.j)
-# define reset() siglongjmp(reslab.j, 1)
-# else
+# define setexit() sigsetjmp(reslab.j)
+# define _reset() siglongjmp(reslab.j, 1)
+#else
typedef struct { jmp_buf j; } jmp_buf_t;
-# define setexit() setjmp(reslab.j)
-# define reset() longjmp(reslab.j, 1)
-# endif
-
-# define getexit(a) (void) ((a) = reslab)
-# define resexit(a) (void) (reslab = (a))
+# define setexit() setjmp(reslab.j)
+# define _reset() longjmp(reslab.j, 1)
+#endif
-# define cpybin(a, b) (void) ((a) = (b))
+#define getexit(a) (void) ((a) = reslab)
+#define resexit(a) (void) (reslab = (a))
-#endif /* NO_STRUCT_ASSIGNMENT */
+#define cpybin(a, b) (void) ((a) = (b))
extern jmp_buf_t reslab;
EXTERN Char *gointr; /* Label for an onintr transfer */
-extern signalfun_t parintr; /* Parents interrupt catch */
-extern signalfun_t parterm; /* Parents terminate catch */
+extern struct sigaction parintr; /* Parents interrupt catch */
+extern struct sigaction parterm; /* Parents terminate catch */
/*
* Lexical definitions.
@@ -790,7 +718,7 @@ extern signalfun_t parterm; /* Parents terminate catch */
# define ATTRIBUTES 0200 /* The bits used for attributes */
# define INVALID_BYTE 0
# define CHAR 0000177 /* Mask to mask out the character */
-#endif
+#endif
#define CHAR_DBWIDTH (LITERAL|(LITERAL-1))
EXTERN int AsciiOnly; /* If set only 7 bits expected in characters */
@@ -801,6 +729,13 @@ EXTERN int AsciiOnly; /* If set only 7 bits expected in characters */
* exactly one if the input is seekable and tell is available.
* In other cases, the shell buffers enough blocks to keep all loops
* in the buffer.
+ *
+ * If (WIDE_STRINGS && cantell), fbobp is always a byte offset, but
+ * (fseekp - fbobp) and (feobp - fbobp) are character offsets (usable for
+ * fbuf indexing).
+ *
+ * If (!cantell), all offsets are character offsets; if (!WIDE_STRINGS), there
+ * is no difference between byte and character offsets.
*/
EXTERN struct Bin {
off_t Bfseekp; /* Seek pointer, generally != lseek() value */
@@ -824,7 +759,7 @@ struct Ain {
#define TCSH_F_SEEK 2 /* File seek */
#define TCSH_E_SEEK 3 /* Eval seek */
union {
- off_t _f_seek;
+ off_t _f_seek; /* A byte offset if (cantell) */
Char* _c_seek;
} fc;
#define f_seek fc._f_seek
@@ -883,7 +818,8 @@ struct wordent {
* process id's from `$$', and modified variable values (from qualifiers
* during expansion in sh.dol.c) here.
*/
-EXTERN Char *lap;
+extern struct Strbuf labuf;
+EXTERN size_t lap; /* N/A if == labuf.len, index into labuf.s otherwise */
/*
* Parser structure
@@ -979,10 +915,10 @@ struct command {
/* Avoid hpux ansi mode spurious warnings */
typedef void (*bfunc_t) ();
#else
-typedef void (*bfunc_t) __P((Char **, struct command *));
+typedef void (*bfunc_t) (Char **, struct command *);
#endif /* hpux && __STDC__ && !__GNUC__ */
-extern struct biltins {
+extern const struct biltins {
const char *bname;
bfunc_t bfunct;
int minargs, maxargs;
@@ -1051,22 +987,19 @@ EXTERN Char **alvec IZERO_STRUCT,
/*
* Filename/command name expansion variables
*/
-EXTERN int gflag; /* After tglob -> is globbing needed? */
-
-#define MAXVARLEN 256 /* Maximum number of char in a variable name */
#ifdef __CYGWIN__
# undef MAXPATHLEN
#endif /* __CYGWIN__ */
#ifndef MAXPATHLEN
-# define MAXPATHLEN 2048
+# ifdef PATH_MAX
+# define MAXPATHLEN PATH_MAX
+# else
+# define MAXPATHLEN 2048
+# endif
#endif /* MAXPATHLEN */
-#ifndef MAXNAMLEN
-# define MAXNAMLEN 512
-#endif /* MAXNAMLEN */
-
#ifndef HAVENOLIMIT
/*
* resource limits
@@ -1080,20 +1013,6 @@ extern struct limits {
#endif /* !HAVENOLIMIT */
/*
- * Variables for filename expansion
- */
-extern Char **gargv; /* Pointer to the (stack) arglist */
-extern int gargc; /* Number args in gargv */
-
-/*
- * Variables for command expansion.
- */
-extern Char **pargv; /* Pointer to the argv list space */
-EXTERN Char *pargs; /* Pointer to start current word */
-EXTERN long pnleft; /* Number of chars left in pargs */
-EXTERN Char *pargcp; /* Current index into pargs */
-
-/*
* History list
*
* Each history list entry contains an embedded wordlist
@@ -1152,6 +1071,7 @@ EXTERN Char PRCHROOT; /* Prompt symbol for root */
#define Strcasecmp(a, b) strcasecmp(a, b)
#define Strspl(a, b) strspl(a, b)
+#define Strnsave(a, b) strnsave(a, b)
#define Strsave(a) strsave(a)
#define Strend(a) strend(a)
#define Strstr(a, b) strstr(a, b)
@@ -1159,7 +1079,7 @@ EXTERN Char PRCHROOT; /* Prompt symbol for root */
#define str2short(a) (a)
#define blk2short(a) saveblk(a)
#define short2blk(a) saveblk(a)
-#define short2str(a) strip(a)
+#define short2str(a) caching_strip(a)
#else
#ifdef WIDE_STRINGS
#define Strchr(a, b) wcschr(a, b)
@@ -1185,6 +1105,7 @@ EXTERN Char PRCHROOT; /* Prompt symbol for root */
#define Strcasecmp(a, b) s_strcasecmp(a, b)
#define Strspl(a, b) s_strspl(a, b)
+#define Strnsave(a, b) s_strnsave(a, b)
#define Strsave(a) s_strsave(a)
#define Strend(a) s_strend(a)
#define Strstr(a, b) s_strstr(a, b)
@@ -1248,6 +1169,9 @@ extern int use_fork;
#endif
extern int tellwhat;
extern int NoNLSRebind;
+#if !HAVE_DECL_ENVIRON
+extern char **environ;
+#endif
#include "tc.h"
@@ -1266,9 +1190,9 @@ extern int NoNLSRebind;
* This does not link right now...
*/
typedef void *nl_catd;
- extern const char * catgets __P((nl_catd, int, int, const char *));
- nl_catd catopen __P((const char *, int));
- int catclose __P((nl_catd));
+ extern const char * catgets (nl_catd, int, int, const char *);
+ nl_catd catopen (const char *, int);
+ int catclose (nl_catd);
# else
# ifdef __uxps__
# define gettxt gettxt_ds
@@ -1282,10 +1206,10 @@ extern int NoNLSRebind;
# define MCLoadBySet 0
# endif
EXTERN nl_catd catd;
-# ifdef HAVE_ICONV
+# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
# define CGETS(b, c, d) iconv_catgets(catd, b, c, d)
# else
-# define CGETS(b, c, d) catgets(catd, b, c, d)
+# define CGETS(b, c, d) xcatgets(catd, b, c, d)
# endif
# define CSAVS(b, c, d) strsave(CGETS(b, c, d))
# else
OpenPOWER on IntegriCloud