X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/454c2aa30569ed6e6c52e32e5fca633e9a7b1397..f52b918007dc218cdf8cd43fe2d631fecebc3bf2:/usr/src/bin/csh/func.c diff --git a/usr/src/bin/csh/func.c b/usr/src/bin/csh/func.c index 647325cf72..9011738cbf 100644 --- a/usr/src/bin/csh/func.c +++ b/usr/src/bin/csh/func.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)func.c 5.21 (Berkeley) %G%"; +static char sccsid[] = "@(#)func.c 5.25 (Berkeley) %G%"; #endif /* not lint */ #include @@ -309,12 +309,12 @@ dogoto(v, t) */ zlast = T_GOTO; for (wp = whyles; wp; wp = wp->w_next) - if (wp->w_end == 0) { + if (wp->w_end.type == I_SEEK) { search(T_BREAK, 0, NULL); - wp->w_end = fseekp; + btell(&wp->w_end); } else - bseek(wp->w_end); + bseek(&wp->w_end); search(T_GOTO, 0, lp = globone(v[1], G_ERROR)); xfree((ptr_t) lp); /* @@ -407,7 +407,7 @@ doforeach(v, t) nwp = (struct whyle *) xcalloc(1, sizeof *nwp); nwp->w_fe = nwp->w_fe0 = v; gargv = 0; - nwp->w_start = fseekp; + btell(&nwp->w_start); nwp->w_fename = Strsave(cp); nwp->w_next = whyles; whyles = nwp; @@ -427,7 +427,7 @@ dowhile(v, t) struct command *t; { register int status; - register bool again = whyles != 0 && whyles->w_start == lineloc && + register bool again = whyles != 0 && SEEKEQ(&whyles->w_start, &lineloc) && whyles->w_fename == 0; v++; @@ -446,7 +446,7 @@ dowhile(v, t) (struct whyle *) xcalloc(1, sizeof(*nwp)); nwp->w_start = lineloc; - nwp->w_end = 0; + nwp->w_end.type = I_SEEK; nwp->w_next = whyles; whyles = nwp; zlast = T_WHILE; @@ -467,14 +467,14 @@ dowhile(v, t) static void preread() { - whyles->w_end = -1; + whyles->w_end.type = I_SEEK; if (setintr) (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT)); search(T_BREAK, 0, NULL); /* read the expression in */ if (setintr) (void) sigblock(sigmask(SIGINT)); - whyles->w_end = fseekp; + btell(&whyles->w_end); } void @@ -485,7 +485,7 @@ doend(v, t) { if (!whyles) stderror(ERR_NAME | ERR_NOTWHILE); - whyles->w_end = fseekp; + btell(&whyles->w_end); doagain(); } @@ -505,7 +505,7 @@ doagain() { /* Repeating a while is simple */ if (whyles->w_fename == 0) { - bseek(whyles->w_start); + bseek(&whyles->w_start); return; } /* @@ -518,7 +518,7 @@ doagain() return; } set(whyles->w_fename, Strsave(*whyles->w_fe++)); - bseek(whyles->w_start); + bseek(&whyles->w_start); } void @@ -593,10 +593,14 @@ search(type, level, goal) Stype = type; Sgoal = goal; - if (type == T_GOTO) - bseek((off_t) 0); + if (type == T_GOTO) { + struct Ain a; + a.type = F_SEEK; + a.f_seek = 0; + bseek(&a); + } do { - if (intty && fseekp == feobp) + if (intty && fseekp == feobp && aret == F_SEEK) (void) fprintf(cshout, "? "), (void) fflush(cshout); aword[0] = 0; (void) getword(aword); @@ -790,32 +794,40 @@ keyword(wp) static void toend() { - if (whyles->w_end == 0) { + if (whyles->w_end.type == I_SEEK) { search(T_BREAK, 0, NULL); - whyles->w_end = fseekp - 1; + btell(&whyles->w_end); + whyles->w_end.f_seek--; } else - bseek(whyles->w_end); + bseek(&whyles->w_end); wfree(); } void wfree() { - long o = fseekp; + struct Ain o; + struct whyle *nwp; + btell(&o); + + if (o.type != F_SEEK) + return; - while (whyles) { + for (; whyles; whyles = nwp) { register struct whyle *wp = whyles; - register struct whyle *nwp = wp->w_next; + nwp = wp->w_next; + if (wp->w_start.type != F_SEEK || wp->w_end.type != F_SEEK) + continue; - if (o >= wp->w_start && (wp->w_end == 0 || o < wp->w_end)) + if (o.f_seek >= wp->w_start.f_seek && + (wp->w_end.f_seek == 0 || o.f_seek < wp->w_end.f_seek)) break; if (wp->w_fe0) blkfree(wp->w_fe0); if (wp->w_fename) xfree((ptr_t) wp->w_fename); xfree((ptr_t) wp); - whyles = nwp; } } @@ -902,7 +914,7 @@ dosetenv(v, t) } if ((lp = *v++) == 0) lp = STRNULL; - Setenv(vp, lp = globone(lp, G_ERROR)); + Setenv(vp, lp = globone(lp, G_APPEND)); if (eq(vp, STRPATH)) { importpath(lp); dohash(NULL, NULL); @@ -970,7 +982,8 @@ dounsetenv(v, t) Unsetenv(name); break; } - xfree((ptr_t) name), name = NULL; + xfree((ptr_t) name); + name = NULL; } void @@ -1193,6 +1206,8 @@ getval(lp, v) badscal: stderror(ERR_NAME | ERR_SCALEF); } + if ((f + 0.5) >= (float) 0x7fffffff || (f + 0.5) < (float) 0x80000000) + stderror(ERR_NAME | ERR_SCALEF); return ((RLIM_TYPE) (f + 0.5)); } @@ -1408,3 +1423,21 @@ doeval(v, t) if (my_reenter) stderror(ERR_SILENT); } + +void +/*ARGSUSED*/ +doprintf(v, t) + Char **v; + struct command *t; +{ + char **c; + extern int progprintf __P((int, char **)); + int ret; + + ret = progprintf(blklen(v), c = short2blk(v)); + + blkfree((Char **) c); + if (ret) + stderror(ERR_SILENT); +} +