diff options
Diffstat (limited to 'contrib/tcsh/sh.exp.c')
-rw-r--r-- | contrib/tcsh/sh.exp.c | 164 |
1 files changed, 75 insertions, 89 deletions
diff --git a/contrib/tcsh/sh.exp.c b/contrib/tcsh/sh.exp.c index f6f557e..12ee56f 100644 --- a/contrib/tcsh/sh.exp.c +++ b/contrib/tcsh/sh.exp.c @@ -1,4 +1,4 @@ -/* $Header: /src/pub/tcsh/sh.exp.c,v 3.40 2002/03/08 17:36:46 christos Exp $ */ +/* $Header: /src/pub/tcsh/sh.exp.c,v 3.45 2005/01/18 20:24:50 christos Exp $ */ /* * sh.exp.c: Expression evaluations */ @@ -32,7 +32,7 @@ */ #include "sh.h" -RCSID("$Id: sh.exp.c,v 3.40 2002/03/08 17:36:46 christos Exp $") +RCSID("$Id: sh.exp.c,v 3.45 2005/01/18 20:24:50 christos Exp $") #include "tw.h" @@ -58,16 +58,16 @@ RCSID("$Id: sh.exp.c,v 3.40 2002/03/08 17:36:46 christos Exp $") #define NOTEQMATCH 8 static int sh_access __P((Char *, int)); -static int exp1 __P((Char ***, bool)); -static int exp2 __P((Char ***, bool)); -static int exp2a __P((Char ***, bool)); -static int exp2b __P((Char ***, bool)); -static int exp2c __P((Char ***, bool)); -static Char *exp3 __P((Char ***, bool)); -static Char *exp3a __P((Char ***, bool)); -static Char *exp4 __P((Char ***, bool)); -static Char *exp5 __P((Char ***, bool)); -static Char *exp6 __P((Char ***, bool)); +static int exp1 __P((Char ***, int)); +static int exp2x __P((Char ***, int)); +static int exp2a __P((Char ***, int)); +static int exp2b __P((Char ***, int)); +static int exp2c __P((Char ***, int)); +static Char *exp3 __P((Char ***, int)); +static Char *exp3a __P((Char ***, int)); +static Char *exp4 __P((Char ***, int)); +static Char *exp5 __P((Char ***, int)); +static Char *exp6 __P((Char ***, int)); static void evalav __P((Char **)); static int isa __P((Char *, int)); static int egetn __P((Char *)); @@ -147,23 +147,9 @@ sh_access(fname, mode) # ifdef NGROUPS_MAX else { -# if defined(__386BSD__) || defined(BSD4_4) - /* - * These two decided that setgroup() should take an array of int's - * and they define _SC_NGROUPS_MAX without having sysconf - */ -# undef _SC_NGROUPS_MAX -# if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) -# define GID_T gid_t -# else -# define GID_T int -# endif -# else -# define GID_T gid_t -# endif /* __386BSD__ || BSD4_4 */ /* you can be in several groups */ long n; - GID_T *groups; + GETGROUPS_T *groups; /* * Try these things to find a positive maximum groups value: @@ -172,15 +158,15 @@ sh_access(fname, mode) * 3) getgroups(0, unused) * Then allocate and scan the groups array if one of these worked. */ -# ifdef _SC_NGROUPS_MAX +# if defined (HAVE_SYSCONF) && defined (_SC_NGROUPS_MAX) if ((n = sysconf(_SC_NGROUPS_MAX)) == -1) # endif /* _SC_NGROUPS_MAX */ n = NGROUPS_MAX; if (n <= 0) - n = getgroups(0, (GID_T *) NULL); + n = getgroups(0, (GETGROUPS_T *) NULL); if (n > 0) { - groups = (GID_T *) xmalloc((size_t) (n * sizeof(GID_T))); + groups = xmalloc((size_t) (n * sizeof(*groups))); n = getgroups((int) n, groups); while (--n >= 0) if (groups[n] == statb.st_gid) { @@ -200,23 +186,23 @@ sh_access(fname, mode) int expr(vp) - register Char ***vp; + Char ***vp; { return (exp0(vp, 0)); } int exp0(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register int p1 = exp1(vp, ignore); + int p1 = exp1(vp, ignore); #ifdef EDEBUG etraci("exp0 p1", p1, vp); #endif /* EDEBUG */ if (**vp && eq(**vp, STRor2)) { - register int p2; + int p2; (*vp)++; p2 = exp0(vp, (ignore & TEXP_IGNORE) || p1); @@ -230,16 +216,16 @@ exp0(vp, ignore) static int exp1(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register int p1 = exp2(vp, ignore); + int p1 = exp2x(vp, ignore); #ifdef EDEBUG etraci("exp1 p1", p1, vp); #endif /* EDEBUG */ if (**vp && eq(**vp, STRand2)) { - register int p2; + int p2; (*vp)++; p2 = exp1(vp, (ignore & TEXP_IGNORE) || !p1); @@ -252,20 +238,20 @@ exp1(vp, ignore) } static int -exp2(vp, ignore) - register Char ***vp; - bool ignore; +exp2x(vp, ignore) + Char ***vp; + int ignore; { - register int p1 = exp2a(vp, ignore); + int p1 = exp2a(vp, ignore); #ifdef EDEBUG etraci("exp3 p1", p1, vp); #endif /* EDEBUG */ if (**vp && eq(**vp, STRor)) { - register int p2; + int p2; (*vp)++; - p2 = exp2(vp, ignore); + p2 = exp2x(vp, ignore); #ifdef EDEBUG etraci("exp3 p2", p2, vp); #endif /* EDEBUG */ @@ -276,16 +262,16 @@ exp2(vp, ignore) static int exp2a(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register int p1 = exp2b(vp, ignore); + int p1 = exp2b(vp, ignore); #ifdef EDEBUG etraci("exp2a p1", p1, vp); #endif /* EDEBUG */ if (**vp && eq(**vp, STRcaret)) { - register int p2; + int p2; (*vp)++; p2 = exp2a(vp, ignore); @@ -299,16 +285,16 @@ exp2a(vp, ignore) static int exp2b(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register int p1 = exp2c(vp, ignore); + int p1 = exp2c(vp, ignore); #ifdef EDEBUG etraci("exp2b p1", p1, vp); #endif /* EDEBUG */ if (**vp && eq(**vp, STRand)) { - register int p2; + int p2; (*vp)++; p2 = exp2b(vp, ignore); @@ -322,12 +308,12 @@ exp2b(vp, ignore) static int exp2c(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register Char *p1 = exp3(vp, ignore); - register Char *p2; - register int i; + Char *p1 = exp3(vp, ignore); + Char *p2; + int i; #ifdef EDEBUG etracc("exp2c p1", p1, vp); @@ -370,11 +356,11 @@ exp2c(vp, ignore) static Char * exp3(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register Char *p1, *p2; - register int i; + Char *p1, *p2; + int i; p1 = exp3a(vp, ignore); #ifdef EDEBUG @@ -416,11 +402,11 @@ exp3(vp, ignore) static Char * exp3a(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register Char *p1, *p2, *op; - register int i; + Char *p1, *p2, *op; + int i; p1 = exp4(vp, ignore); #ifdef EDEBUG @@ -446,18 +432,18 @@ exp3a(vp, ignore) static Char * exp4(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register Char *p1, *p2; - register int i = 0; + Char *p1, *p2; + int i = 0; p1 = exp5(vp, ignore); #ifdef EDEBUG etracc("exp4 p1", p1, vp); #endif /* EDEBUG */ if (isa(**vp, ADDOP)) { - register Char *op = *(*vp)++; + Char *op = *(*vp)++; p2 = exp4(vp, ignore); #ifdef EDEBUG @@ -483,11 +469,11 @@ exp4(vp, ignore) static Char * exp5(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { - register Char *p1, *p2; - register int i = 0; + Char *p1, *p2; + int i = 0; p1 = exp6(vp, ignore); #ifdef EDEBUG @@ -495,7 +481,7 @@ exp5(vp, ignore) #endif /* EDEBUG */ if (isa(**vp, MULOP)) { - register Char *op = *(*vp)++; + Char *op = *(*vp)++; if ((ignore & TEXP_NOGLOB) != 0) /* * We are just trying to get the right side of @@ -537,11 +523,11 @@ exp5(vp, ignore) static Char * exp6(vp, ignore) - register Char ***vp; - bool ignore; + Char ***vp; + int ignore; { int ccode, i = 0; - register Char *cp; + Char *cp; if (**vp == 0) stderror(ERR_NAME | ERR_EXPRESSION); @@ -577,7 +563,7 @@ exp6(vp, ignore) return (putn(ccode)); } if (eq(**vp, STRLbrace)) { - register Char **v; + Char **v; struct command faket; Char *fakecom[2]; @@ -635,7 +621,7 @@ exp6(vp, ignore) Char * filetest(cp, vp, ignore) Char *cp, ***vp; - bool ignore; + int ignore; { #ifdef convex struct cvxstat stb, *st = NULL; @@ -658,7 +644,7 @@ filetest(cp, vp, ignore) int i = 0; unsigned pmask = 0xffff; - bool altout = 0; + int altout = 0; Char *ft = cp, *dp, *ep, *strdev, *strino, *strF, *str, valtest = '\0', *errval = STR0; char *string, string0[8]; @@ -990,18 +976,18 @@ filetest(cp, vp, ignore) static void evalav(v) - register Char **v; + Char **v; { struct wordent paraml1; - register struct wordent *hp = ¶ml1; + struct wordent *hp = ¶ml1; struct command *t; - register struct wordent *wdp = hp; + struct wordent *wdp = hp; set(STRstatus, Strsave(STR0), VAR_READWRITE); hp->prev = hp->next = hp; hp->word = STRNULL; while (*v) { - register struct wordent *new = + struct wordent *new = (struct wordent *) xcalloc(1, sizeof *wdp); new->prev = wdp; @@ -1021,8 +1007,8 @@ evalav(v) static int isa(cp, what) - register Char *cp; - register int what; + Char *cp; + int what; { if (cp == 0) return ((what & RESTOP) != 0); @@ -1072,7 +1058,7 @@ isa(cp, what) static int egetn(cp) - register Char *cp; + Char *cp; { if (*cp && *cp != '-' && !Isdigit(*cp)) stderror(ERR_NAME | ERR_EXPRESSION); |