summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2301102)
SCCS-vsn: bin/csh/csh.c 5.29
SCCS-vsn: bin/csh/csh.h 5.19
SCCS-vsn: bin/csh/func.c 5.24
SCCS-vsn: bin/csh/lex.c 5.20
SCCS-vsn: bin/csh/extern.h 5.7
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)csh.c 5.28 (Berkeley) %G%";
+static char sccsid[] = "@(#)csh.c 5.29 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
* read fresh stuff. Otherwise, we are rereading input and don't
* need or want to prompt.
*/
* read fresh stuff. Otherwise, we are rereading input and don't
* need or want to prompt.
*/
+ if (aret == F_SEEK && fseekp == feobp)
printprompt();
(void) fflush(cshout);
}
printprompt();
(void) fflush(cshout);
}
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)csh.h 5.18 (Berkeley) %G%
+ * @(#)csh.h 5.19 (Berkeley) %G%
Char **Bfbuf; /* The array of buffer blocks */
} B;
Char **Bfbuf; /* The array of buffer blocks */
} B;
+/*
+ * This structure allows us to seek inside aliases
+ */
+struct Ain {
+ int type;
+#define I_SEEK -1 /* Invalid seek */
+#define A_SEEK 0 /* Alias seek */
+#define F_SEEK 1 /* File seek */
+#define E_SEEK 2 /* Eval seek */
+ off_t f_seek;
+ Char **a_seek;
+} ;
+extern int aret; /* What was the last character returned */
+#define SEEKEQ(a, b) ((a)->type == (b)->type && \
+ (a)->f_seek == (b)->f_seek && \
+ (a)->a_seek == (b)->a_seek)
+
#define fseekp B.Bfseekp
#define fbobp B.Bfbobp
#define feobp B.Bfeobp
#define fseekp B.Bfseekp
#define fbobp B.Bfbobp
#define feobp B.Bfeobp
* For whiles, in particular, it reseeks to the beginning of the
* line the while was on; hence the while placement restrictions.
*/
* For whiles, in particular, it reseeks to the beginning of the
* line the while was on; hence the while placement restrictions.
*/
bool cantell; /* Is current source tellable ? */
bool cantell; /* Is current source tellable ? */
* input. For foreach (fe), the word list is attached here.
*/
struct whyle {
* input. For foreach (fe), the word list is attached here.
*/
struct whyle {
- off_t w_start; /* Point to restart loop */
- off_t w_end; /* End of loop (0 if unknown) */
+ struct Ain w_start; /* Point to restart loop */
+ struct Ain w_end; /* End of loop (0 if unknown) */
Char **w_fe, **w_fe0; /* Current/initial wordlist for fe */
Char *w_fename; /* Name for fe */
struct whyle *w_next; /* Next (more outer) loop */
Char **w_fe, **w_fe0; /* Current/initial wordlist for fe */
Char *w_fename; /* Name for fe */
struct whyle *w_next; /* Next (more outer) loop */
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)extern.h 5.6 (Berkeley) %G%
+ * @(#)extern.h 5.7 (Berkeley) %G%
*/
#include <sys/cdefs.h>
*/
#include <sys/cdefs.h>
* lex.c
*/
void addla __P((Char *));
* lex.c
*/
void addla __P((Char *));
-void bseek __P((off_t));
+void bseek __P((struct Ain *));
+void btell __P((struct Ain *));
void btoeof __P((void));
void copylex __P((struct wordent *, struct wordent *));
Char *domod __P((Char *, int));
void btoeof __P((void));
void copylex __P((struct wordent *, struct wordent *));
Char *domod __P((Char *, int));
-static char sccsid[] = "@(#)func.c 5.23 (Berkeley) %G%";
+static char sccsid[] = "@(#)func.c 5.24 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
*/
zlast = T_GOTO;
for (wp = whyles; wp; wp = wp->w_next)
*/
zlast = T_GOTO;
for (wp = whyles; wp; wp = wp->w_next)
+ if (wp->w_end.type == I_SEEK) {
search(T_BREAK, 0, NULL);
search(T_BREAK, 0, NULL);
search(T_GOTO, 0, lp = globone(v[1], G_ERROR));
xfree((ptr_t) lp);
/*
search(T_GOTO, 0, lp = globone(v[1], G_ERROR));
xfree((ptr_t) lp);
/*
nwp = (struct whyle *) xcalloc(1, sizeof *nwp);
nwp->w_fe = nwp->w_fe0 = v;
gargv = 0;
nwp = (struct whyle *) xcalloc(1, sizeof *nwp);
nwp->w_fe = nwp->w_fe0 = v;
gargv = 0;
nwp->w_fename = Strsave(cp);
nwp->w_next = whyles;
whyles = nwp;
nwp->w_fename = Strsave(cp);
nwp->w_next = whyles;
whyles = nwp;
struct command *t;
{
register int status;
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++;
whyles->w_fename == 0;
v++;
(struct whyle *) xcalloc(1, sizeof(*nwp));
nwp->w_start = lineloc;
(struct whyle *) xcalloc(1, sizeof(*nwp));
nwp->w_start = lineloc;
+ nwp->w_end.type = I_SEEK;
nwp->w_next = whyles;
whyles = nwp;
zlast = T_WHILE;
nwp->w_next = whyles;
whyles = nwp;
zlast = T_WHILE;
+ 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));
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;
{
if (!whyles)
stderror(ERR_NAME | ERR_NOTWHILE);
{
if (!whyles)
stderror(ERR_NAME | ERR_NOTWHILE);
- whyles->w_end = fseekp;
{
/* Repeating a while is simple */
if (whyles->w_fename == 0) {
{
/* Repeating a while is simple */
if (whyles->w_fename == 0) {
- bseek(whyles->w_start);
+ bseek(&whyles->w_start);
return;
}
set(whyles->w_fename, Strsave(*whyles->w_fe++));
return;
}
set(whyles->w_fename, Strsave(*whyles->w_fe++));
- bseek(whyles->w_start);
+ bseek(&whyles->w_start);
Stype = type;
Sgoal = 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);
+ }
- if (intty && fseekp == feobp)
+ if (intty && fseekp == feobp && aret == F_SEEK)
(void) fprintf(cshout, "? "), (void) fflush(cshout);
aword[0] = 0;
(void) getword(aword);
(void) fprintf(cshout, "? "), (void) fflush(cshout);
aword[0] = 0;
(void) getword(aword);
- if (whyles->w_end == 0) {
+ if (whyles->w_end.type == I_SEEK) {
search(T_BREAK, 0, NULL);
search(T_BREAK, 0, NULL);
- whyles->w_end = fseekp - 1;
+ btell(&whyles->w_end);
+ whyles->w_end.f_seek--;
wfree();
}
void
wfree()
{
wfree();
}
void
wfree()
{
+ struct Ain o;
+ struct whyle *nwp;
+ btell(&o);
+
+ if (o.type != F_SEEK)
+ return;
+ for (; whyles; whyles = nwp) {
register struct whyle *wp = whyles;
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);
break;
if (wp->w_fe0)
blkfree(wp->w_fe0);
if (wp->w_fename)
xfree((ptr_t) wp->w_fename);
xfree((ptr_t) wp);
badscal:
stderror(ERR_NAME | ERR_SCALEF);
}
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));
}
return ((RLIM_TYPE) (f + 0.5));
}
-static char sccsid[] = "@(#)lex.c 5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c 5.20 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
/* "Globp" for alias resubstitution */
static Char *alvecp = NULL;
/* "Globp" for alias resubstitution */
static Char *alvecp = NULL;
/*
* Labuf implements a general buffer for lookahead during lexical operations.
/*
* Labuf implements a general buffer for lookahead during lexical operations.
register struct wordent *wdp;
int c;
register struct wordent *wdp;
int c;
hp->next = hp->prev = hp;
hp->word = STRNULL;
hp->next = hp->prev = hp;
hp->word = STRNULL;
- alvecp = 0, hadhist = 0;
do
c = readc(0);
while (c == ' ' || c == '\t');
do
c = readc(0);
while (c == ' ' || c == '\t');
- while (!any(": \t\\\n}'\"", c)) {
+ while (!cmap(c, _META | _Q | _Q1) && !any("{}:", c)) {
if (event != -1 && Isdigit(c))
event = event * 10 + c - '0';
else
if (event != -1 && Isdigit(c))
event = event * 10 + c - '0';
else
register int c;
static sincereal;
register int c;
static sincereal;
if (c = peekread) {
peekread = 0;
return (c);
}
top:
if (c = peekread) {
peekread = 0;
return (c);
}
top:
+ aret = A_SEEK;
+ if (c = *alvecp++)
return (c);
if (alvec && *alvec) {
return (c);
if (alvec && *alvec) {
- alvecp = *alvec++;
- return (' ');
+ alvecp = *alvec++;
+ return (' ');
+ }
+ else {
+ aret = F_SEEK;
+ alvecp = NULL;
+ return('\n');
return ('\n');
}
if (evalp) {
return ('\n');
}
if (evalp) {
if (c = *evalp++)
return (c);
if (c = *evalp++)
return (c);
+ if (evalvec && *evalvec) {
evalp = *evalvec++;
return (' ');
}
evalp = *evalvec++;
return (' ');
}
evalp = 0;
}
if (evalvec) {
evalp = 0;
}
if (evalvec) {
+ switch (aret = l->type) {
+ case E_SEEK:
+ evalvec = l->a_seek;
+ evalp = (Char *) l->f_seek;
+ return;
+ case A_SEEK:
+ alvec = l->a_seek;
+ alvecp = (Char *) l->f_seek;
+ return;
+ case F_SEEK:
+ fseekp = l->f_seek;
+ return;
+ default:
+ (void) fprintf(csherr, "Bad seek type %d\n", aret);
+ abort();
+ }
+}
- fseekp = l;
- if (!cantell) {
-#ifdef notdef
- register struct whyle *wp;
-#endif
-
- if (!whyles)
- return;
-#ifdef notdef
- /*
- * Christos: I don't understand this? both wp and l are local. What is
- * this used for? I suspect the author meant fseek = wp->w_start
- * This seek/tell stuff needs to be re-written...
- */
- for (wp = whyles; wp->w_next; wp = wp->w_next)
- continue;
- if (wp->w_start > l)
- l = wp->w_start;
-#endif
+void
+btell(l)
+ struct Ain *l;
+{
+ switch (l->type = aret) {
+ case E_SEEK:
+ l->a_seek = evalvec;
+ l->f_seek = (off_t) evalp;
+ return;
+ case A_SEEK:
+ l->a_seek = alvec;
+ l->f_seek = (off_t) alvecp;
+ return;
+ case F_SEEK:
+ l->f_seek = fseekp;
+ l->a_seek = NULL;
+ return;
+ default:
+ (void) fprintf(csherr, "Bad seek type %d\n", aret);
+ abort();