diff options
Diffstat (limited to 'contrib/tcsh/sh.func.c')
-rw-r--r-- | contrib/tcsh/sh.func.c | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/contrib/tcsh/sh.func.c b/contrib/tcsh/sh.func.c index bd253e7..f064ec8 100644 --- a/contrib/tcsh/sh.func.c +++ b/contrib/tcsh/sh.func.c @@ -1,4 +1,4 @@ -/* $Header: /src/pub/tcsh/sh.func.c,v 3.103 2002/07/09 12:56:55 christos Exp $ */ +/* $Header: /src/pub/tcsh/sh.func.c,v 3.111 2004/05/13 15:23:39 christos Exp $ */ /* * sh.func.c: csh builtin functions */ @@ -32,7 +32,7 @@ */ #include "sh.h" -RCSID("$Id: sh.func.c,v 3.103 2002/07/09 12:56:55 christos Exp $") +RCSID("$Id: sh.func.c,v 3.111 2004/05/13 15:23:39 christos Exp $") #include "ed.h" #include "tw.h" @@ -63,6 +63,7 @@ static int getword __P((Char *)); static void toend __P((void)); static void xecho __P((int, Char **)); static bool islocale_var __P((Char *)); +static void wpfree __P((struct whyle *)); struct biltins * isbfunc(t) @@ -342,15 +343,18 @@ dologin(v, c) Char **v; struct command *c; { - USE(c); #ifdef WINNT_NATIVE + USE(c); USE(v); #else /* !WINNT_NATIVE */ + char **p = short2blk(v); + USE(c); islogin(); rechist(NULL, adrof(STRsavehist) != NULL); (void) signal(SIGTERM, parterm); - (void) execl(_PATH_BIN_LOGIN, "login", short2str(v[1]), NULL); - (void) execl(_PATH_USRBIN_LOGIN, "login", short2str(v[1]), NULL); + (void) execv(_PATH_BIN_LOGIN, p); + (void) execv(_PATH_USRBIN_LOGIN, p); + blkfree((Char **) p); untty(); xexit(1); #endif /* !WINNT_NATIVE */ @@ -829,6 +833,8 @@ search(type, level, goal) Char wordbuf[BUFSIZE]; register Char *aword = wordbuf; register Char *cp; + struct whyle *wp; + int wlevel = 0; Stype = (Char) type; Sgoal = goal; @@ -866,13 +872,24 @@ search(type, level, goal) case TC_FOREACH: case TC_WHILE: + wlevel++; if (type == TC_BREAK) level++; break; case TC_END: + if (type == TC_BRKSW) { + if (wlevel == 0) { + wp = whyles; + if (wp) { + whyles = wp->w_next; + wpfree(wp); + } + } + } if (type == TC_BREAK) level--; + wlevel--; break; case TC_SWITCH: @@ -1029,6 +1046,17 @@ toend() wfree(); } +static void +wpfree(wp) + struct whyle *wp; +{ + if (wp->w_fe0) + blkfree(wp->w_fe0); + if (wp->w_fename) + xfree((ptr_t) wp->w_fename); + xfree((ptr_t) wp); +} + void wfree() { @@ -1078,11 +1106,7 @@ wfree() } } - if (wp->w_fe0) - blkfree(wp->w_fe0); - if (wp->w_fename) - xfree((ptr_t) wp->w_fename); - xfree((ptr_t) wp); + wpfree(wp); } } @@ -1245,8 +1269,8 @@ islocale_var(var) Char *var; { static Char *locale_vars[] = { - STRLANG, STRLC_CTYPE, STRLC_NUMERIC, STRLC_TIME, - STRLC_COLLATE, STRLC_MESSAGES, STRLC_MONETARY, 0 + STRLANG, STRLC_ALL, STRLC_CTYPE, STRLC_NUMERIC, + STRLC_TIME, STRLC_COLLATE, STRLC_MESSAGES, STRLC_MONETARY, 0 }; register Char **v; @@ -1312,15 +1336,11 @@ dosetenv(v, c) vp = *v++; lp = vp; - if (!letter(*lp)) - stderror(ERR_NAME | ERR_VARBEGIN); - - for (; alnum(*lp); lp++) - continue; - - if (*lp != '\0') - stderror(ERR_NAME | ERR_SYNTAX); + for (; *lp != '\0' ; lp++) { + if (*lp == '=') + stderror(ERR_NAME | ERR_SYNTAX); + } if ((lp = *v++) == 0) lp = STRNULL; @@ -1732,7 +1752,7 @@ doumask(v, c) # define toset(a) ((a) + 1) # endif /* aiws */ # else /* BSDLIMIT */ -# if (defined(BSD4_4) || defined(__linux__)) && !defined(__386BSD__) +# if (defined(BSD4_4) || defined(__linux__) || (HPUXVERSION >= 1100)) && !defined(__386BSD__) typedef rlim_t RLIM_TYPE; # else # if defined(SOLARIS2) || (defined(sgi) && SYSVREL > 3) @@ -1747,7 +1767,7 @@ doumask(v, c) # endif /* BSD4_4 && !__386BSD__ */ # endif /* BSDLIMIT */ -# if (HPUXVERSION > 700) && defined(BSDLIMIT) +# if (HPUXVERSION > 700) && (HPUXVERSION < 1100) && defined(BSDLIMIT) /* Yes hpux8.0 has limits but <sys/resource.h> does not make them public */ /* Yes, we could have defined _KERNEL, and -I/etc/conf/h, but is that better? */ # ifndef RLIMIT_CPU @@ -1768,7 +1788,7 @@ doumask(v, c) # ifndef SIGRTMIN # define FILESIZE512 # endif /* SIGRTMIN */ -# endif /* (HPUXVERSION > 700) && BSDLIMIT */ +# endif /* (HPUXVERSION > 700) && (HPUXVERSION < 1100) && BSDLIMIT */ # if SYSVREL > 3 && defined(BSDLIMIT) && !defined(_SX) /* In order to use rusage, we included "/usr/ucbinclude/sys/resource.h" in */ @@ -2064,7 +2084,7 @@ plim(lp, hard) RLIM_TYPE limit; int div = lp->limdiv; - xprintf("%s \t", lp->limname); + xprintf("%-13.13s", lp->limname); # ifndef BSDLIMIT limit = ulimit(lp->limconst, 0); @@ -2224,6 +2244,8 @@ dosuspend(v, c) if (tpgrp != -1) { retry: ctpgrp = tcgetpgrp(FSHTTY); + if (ctpgrp == -1) + stderror(ERR_SYSTEM, "tcgetpgrp", strerror(errno)); if (ctpgrp != opgrp) { old = signal(SIGTTIN, SIG_DFL); (void) kill(0, SIGTTIN); |