setexit -> setjmp, reset -> longjmp, isdir() -> S_ISDIR, ANSI
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 2 Apr 1991 08:37:20 +0000 (00:37 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 2 Apr 1991 08:37:20 +0000 (00:37 -0800)
Prof. Graham requested semantic changes to #defines in sh.h, removing the
last vestiges of the PWB/V6 shell

SCCS-vsn: bin/csh/csh.c 5.19
SCCS-vsn: bin/csh/err.c 5.4
SCCS-vsn: bin/csh/exec.c 5.9
SCCS-vsn: bin/csh/exp.c 5.5
SCCS-vsn: bin/csh/func.c 5.13
SCCS-vsn: bin/csh/glob.c 5.12
SCCS-vsn: bin/csh/csh.h 5.9
SCCS-vsn: bin/csh/init.c 5.6
SCCS-vsn: bin/csh/lex.c 5.9
SCCS-vsn: bin/csh/parse.c 5.5
SCCS-vsn: bin/csh/proc.c 5.14
SCCS-vsn: bin/csh/sem.c 5.10

12 files changed:
usr/src/bin/csh/csh.c
usr/src/bin/csh/csh.h
usr/src/bin/csh/err.c
usr/src/bin/csh/exec.c
usr/src/bin/csh/exp.c
usr/src/bin/csh/func.c
usr/src/bin/csh/glob.c
usr/src/bin/csh/init.c
usr/src/bin/csh/lex.c
usr/src/bin/csh/parse.c
usr/src/bin/csh/proc.c
usr/src/bin/csh/sem.c

index ba6fb5b..850cf35 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)csh.c       5.18 (Berkeley) %G%";
+static char *sccsid = "@(#)csh.c       5.19 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -317,7 +317,7 @@ notty:
         * Set an exit here in case of an interrupt or error reading
         * the shell start-up scripts.
         */
         * Set an exit here in case of an interrupt or error reading
         * the shell start-up scripts.
         */
-       setexit();
+       (void)setjmp(reslab);
        haderr = 0;             /* In case second time through */
        if (!fast && reenter == 0) {
                reenter++;
        haderr = 0;             /* In case second time through */
        if (!fast && reenter == 0) {
                reenter++;
@@ -492,7 +492,7 @@ srcunit(unit, onlyown, hflg)
        reenter = 0;
        if (setintr)
                omask = sigblock(sigmask(SIGINT));
        reenter = 0;
        if (setintr)
                omask = sigblock(sigmask(SIGINT));
-       setexit();
+       (void)setjmp(reslab);
        reenter++;
        if (reenter == 1) {
                /* Setup the new values of the state stuff saved above */
        reenter++;
        if (reenter == 1) {
                /* Setup the new values of the state stuff saved above */
@@ -656,13 +656,13 @@ pintr1(wantnl)
         * so we needn't worry about that here.
         */
        if (gointr) {
         * so we needn't worry about that here.
         */
        if (gointr) {
-               search(ZGOTO, 0, gointr);
+               search(T_GOTO, 0, gointr);
                timflg = 0;
                if (v = pargv)
                        pargv = 0, blkfree(v);
                if (v = gargv)
                        gargv = 0, blkfree(v);
                timflg = 0;
                if (v = pargv)
                        pargv = 0, blkfree(v);
                if (v = gargv)
                        gargv = 0, blkfree(v);
-               reset();
+               longjmp(reslab, 0);
        } else if (intty && wantnl)
                printf("\n");           /* Some like this, others don't */
        error(NOSTR);
        } else if (intty && wantnl)
                printf("\n");           /* Some like this, others don't */
        error(NOSTR);
@@ -694,7 +694,7 @@ process(catch)
                paraml.next = paraml.prev = &paraml;
                paraml.word = "";
                t = 0;
                paraml.next = paraml.prev = &paraml;
                paraml.word = "";
                t = 0;
-               setexit();
+               (void)setjmp(reslab);
                justpr = enterhist;     /* execute if not entering history */
 
                /*
                justpr = enterhist;     /* execute if not entering history */
 
                /*
@@ -713,7 +713,7 @@ process(catch)
                                /* unwind */
                                doneinp = 0;
                                resexit(osetexit);
                                /* unwind */
                                doneinp = 0;
                                resexit(osetexit);
-                               reset();
+                               longjmp(reslab, 0);
                        }
                        haderr = 0;
                        /*
                        }
                        haderr = 0;
                        /*
@@ -787,7 +787,7 @@ process(catch)
                 * this is as far as we should go
                 */
                if (justpr)
                 * this is as far as we should go
                 */
                if (justpr)
-                       reset();
+                       longjmp(reslab, 0);
 
                alias(&paraml);
 
 
                alias(&paraml);
 
index cc25b87..5c7e82a 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley Software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley Software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)csh.h       5.8 (Berkeley) %G%
+ *     @(#)csh.h       5.9 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -26,8 +26,6 @@
  * April, 1980
  */
 
  * April, 1980
  */
 
-#define        isdir(d)        ((d.st_mode & S_IFMT) == S_IFDIR)
-
 typedef        char    bool;
 
 #define        eq(a, b)        (strcmp(a, b) == 0)
 typedef        char    bool;
 
 #define        eq(a, b)        (strcmp(a, b) == 0)
@@ -84,7 +82,7 @@ int   opgrp;                  /* Initial pgrp and tty pgrp */
  * initialized in sh.init.c (to allow them to be made readonly)
  */
 
  * initialized in sh.init.c (to allow them to be made readonly)
  */
 
-struct biltins {
+struct biltins {
        char    *bname;
        int     (*bfunct)();
        short   minargs, maxargs;
        char    *bname;
        int     (*bfunct)();
        short   minargs, maxargs;
@@ -120,11 +118,9 @@ short      OLDSTD;                 /* Old standard input (def for cmds) */
 
 jmp_buf        reslab;
 
 
 jmp_buf        reslab;
 
-#define        setexit()       ((void) setjmp(reslab))
-#define        reset()         longjmp(reslab, 0)
-       /* Should use structure assignment here */
-#define        getexit(a)      bcopy((char *)reslab, (char *)(a), sizeof reslab)
-#define        resexit(a)      bcopy(((char *)(a)), (char *)reslab, sizeof reslab)
+/* Should use structure assignment here. */
+#define        getexit(a)      bcopy((void *)reslab, (void *)(a), sizeof(reslab))
+#define        resexit(a)      bcopy(((void *)(a)), (void *)reslab, sizeof(reslab))
 
 char   *gointr;                /* Label for an onintr transfer */
 sig_t  parintr;                /* Parents interrupt catch */
 
 char   *gointr;                /* Label for an onintr transfer */
 sig_t  parintr;                /* Parents interrupt catch */
@@ -147,7 +143,7 @@ sig_t       parterm;                /* Parents terminate catch */
  * In other cases, the shell buffers enough blocks to keep all loops
  * in the buffer.
  */
  * In other cases, the shell buffers enough blocks to keep all loops
  * in the buffer.
  */
-struct Bin {
+struct Bin {
        off_t   Bfseekp;                /* Seek pointer */
        off_t   Bfbobp;                 /* Seekp of beginning of buffers */
        off_t   Bfeobp;                 /* Seekp of end of buffers */
        off_t   Bfseekp;                /* Seek pointer */
        off_t   Bfbobp;                 /* Seekp of beginning of buffers */
        off_t   Bfeobp;                 /* Seekp of end of buffers */
@@ -182,7 +178,7 @@ bool        cantell;                        /* Is current source tellable ? */
  * Input lines are parsed into doubly linked circular
  * lists of words of the following form.
  */
  * Input lines are parsed into doubly linked circular
  * lists of words of the following form.
  */
-struct wordent {
+struct wordent {
        char    *word;
        struct  wordent *prev;
        struct  wordent *next;
        char    *word;
        struct  wordent *prev;
        struct  wordent *next;
@@ -203,10 +199,10 @@ struct    wordent {
 
 /*
  * Labuf implements a general buffer for lookahead during lexical operations.
 
 /*
  * Labuf implements a general buffer for lookahead during lexical operations.
- * Text which is to be placed in the input stream can be stuck here.
- * We stick parsed ahead $ constructs during initial input,
- * process id's from `$$', and modified variable values (from qualifiers
- * during expansion in sh.dol.c) here.
+ * Text which is to be placed in the input stream can be stuck here.  We stick
+ * parsed ahead $ constructs during initial input, process id's from `$$',
+ * and modified variable values (from qualifiers during expansion in sh.dol.c)
+ * here.
  */
 char   labuf[BUFSIZ];
 
  */
 char   labuf[BUFSIZ];
 
@@ -215,76 +211,73 @@ char      *lap;
 /*
  * Parser structure
  *
 /*
  * Parser structure
  *
- * Each command is parsed to a tree of command structures and
- * flags are set bottom up during this process, to be propagated down
- * as needed during the semantics/exeuction pass (sh.sem.c).
+ * Each command is parsed to a tree of command structures and flags are set
+ * bottom up during this process, to be propagated down as needed during the
+ * semantics/exeuction pass (sh.sem.c).
  */
 struct command {
  */
 struct command {
-       short   t_dtyp;                         /* Type of node */
-       short   t_dflg;                         /* Flags, e.g. FAND|... */
+#define        NODE_COMMAND    1               /* t_dcom <t_dlef >t_drit       */
+#define        NODE_PAREN      2               /* ( t_dspr ) <t_dlef >t_drit   */
+#define        NODE_PIPE       3               /* t_dlef | t_drit              */
+#define        NODE_LIST       4               /* t_dlef ; t_drit              */
+#define        NODE_OR         5               /* t_dlef || t_drit             */
+#define        NODE_AND        6               /* t_dlef && t_drit             */
+       short t_dtyp;                   /* Node type */
+
+#define        F_SAVE  (F_NICE|F_TIME|F_NOHUP) /* save these when re-doing */
+
+#define        F_AMPERSAND     0x0001          /* executes in background       */
+#define        F_APPEND        0x0002          /* output is redirected >>      */
+#define        F_NICE          0x0004          /* t_nice is meaningful */
+#define        F_NOFORK        0x0008          /* don't fork, last ()ized cmd  */
+#define        F_NOHUP         0x0010          /* nohup this command */
+#define        F_NOINTERRUPT   0x0020          /* should be immune from intr's */
+#define        F_OVERWRITE     0x0040          /* output was !                 */
+#define        F_PIPEIN        0x0080          /* input is a pipe              */
+#define        F_PIPEOUT       0x0100          /* output is a pipe             */
+#define        F_READ          0x0200          /* input redirection is <<      */
+#define        F_REPEAT        0x0400          /* reexec aft if, repeat,...    */
+#define        F_STDERR        0x0800          /* redirect unit 2 with unit 1  */
+#define        F_TIME          0x1000          /* time this command */
+       short t_dflg;                   /* flags */
+
        union {
        union {
-               char    *T_dlef;                /* Input redirect word */
-               struct  command *T_dcar;        /* Left part of list/pipe */
+               char *T_dlef;           /* Input redirect word */
+               struct command *T_dcar; /* Left part of list/pipe */
        } L;
        union {
        } L;
        union {
-               char    *T_drit;                /* Output redirect word */
-               struct  command *T_dcdr;        /* Right part of list/pipe */
+               char *T_drit;           /* Output redirect word */
+               struct command *T_dcdr; /* Right part of list/pipe */
        } R;
 #define        t_dlef  L.T_dlef
 #define        t_dcar  L.T_dcar
 #define        t_drit  R.T_drit
 #define        t_dcdr  R.T_dcdr
        } R;
 #define        t_dlef  L.T_dlef
 #define        t_dcar  L.T_dcar
 #define        t_drit  R.T_drit
 #define        t_dcdr  R.T_dcdr
-       char    **t_dcom;                       /* Command/argument vector */
-       struct  command *t_dspr;                /* Pointer to ()'d subtree */
-       short   t_nice;
+       char **t_dcom;                  /* Command/argument vector */
+       struct command *t_dspr;         /* Pointer to ()'d subtree */
+       short t_nice;
 };
 
 };
 
-#define        TCOM    1               /* t_dcom <t_dlef >t_drit       */
-#define        TPAR    2               /* ( t_dspr ) <t_dlef >t_drit   */
-#define        TFIL    3               /* t_dlef | t_drit              */
-#define        TLST    4               /* t_dlef ; t_drit              */
-#define        TOR     5               /* t_dlef || t_drit             */
-#define        TAND    6               /* t_dlef && t_drit             */
-
-#define        FSAVE   (FNICE|FTIME|FNOHUP)    /* save these when re-doing */
-
-#define        FAND    (1<<0)          /* executes in background       */
-#define        FCAT    (1<<1)          /* output is redirected >>      */
-#define        FPIN    (1<<2)          /* input is a pipe              */
-#define        FPOU    (1<<3)          /* output is a pipe             */
-#define        FPAR    (1<<4)          /* don't fork, last ()ized cmd  */
-#define        FINT    (1<<5)          /* should be immune from intr's */
-/* spare */
-#define        FDIAG   (1<<7)          /* redirect unit 2 with unit 1  */
-#define        FANY    (1<<8)          /* output was !                 */
-#define        FHERE   (1<<9)          /* input redirection is <<      */
-#define        FREDO   (1<<10)         /* reexec aft if, repeat,...    */
-#define        FNICE   (1<<11)         /* t_nice is meaningful */
-#define        FNOHUP  (1<<12)         /* nohup this command */
-#define        FTIME   (1<<13)         /* time this command */
-
-/*
- * The keywords for the parser
- */
-#define        ZBREAK          0
-#define        ZBRKSW          1
-#define        ZCASE           2
-#define        ZDEFAULT        3
-#define        ZELSE           4
-#define        ZEND            5
-#define        ZENDIF          6
-#define        ZENDSW          7
-#define        ZEXIT           8
-#define        ZFOREACH        9
-#define        ZGOTO           10
-#define        ZIF             11
-#define        ZLABEL          12
-#define        ZLET            13
-#define        ZSET            14
-#define        ZSWITCH         15
-#define        ZTEST           16
-#define        ZTHEN           17
-#define        ZWHILE          18
+/* Parser tokens. */
+#define        T_BREAK         0
+#define        T_BRKSW         1
+#define        T_CASE          2
+#define        T_DEFAULT       3
+#define        T_ELSE          4
+#define        T_END           5
+#define        T_ENDIF         6
+#define        T_ENDSW         7
+#define        T_EXIT          8
+#define        T_FOREACH       9
+#define        T_GOTO          10
+#define        T_IF            11
+#define        T_LABEL         12
+#define        T_LET           13
+#define        T_SET           14
+#define        T_SWITCH        15
+#define        T_TEST          16
+#define        T_THEN          17
+#define        T_WHILE         18
 
 /*
  * Structure defining the existing while/foreach loops at this
 
 /*
  * Structure defining the existing while/foreach loops at this
@@ -387,8 +380,10 @@ char       HISTSUB;                        /* auto-substitute character */
                free(cp); \
 }
 char   *alloctmp;
                free(cp); \
 }
 char   *alloctmp;
-#define xalloc(i) ((alloctmp = malloc(i)) ? alloctmp : (char *)nomem(i))
-#define xrealloc(p, i) ((alloctmp = realloc(p, i)) ? alloctmp : (char *)nomem(i))
+#define xalloc(i) \
+       ((alloctmp = malloc(i)) ? alloctmp : (char *)nomem(i))
+#define xrealloc(p, i) \
+       ((alloctmp = realloc(p, i)) ? alloctmp : (char *)nomem(i))
 
 char   *Dfix1();
 char   **blkcat();
 
 char   *Dfix1();
 char   **blkcat();
index d0e549a..72c19d4 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)err.c       5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)err.c       5.4 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -80,7 +80,7 @@ error(s, arg)
        setq("status", onev, &shvhed);
        if (tpgrp > 0)
                (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp);
        setq("status", onev, &shvhed);
        if (tpgrp > 0)
                (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp);
-       reset();                /* Unwind */
+       longjmp(reslab, 0);             /* Unwind */
 }
 
 /*
 }
 
 /*
index 70c38a4..fffcf75 100644 (file)
@@ -294,7 +294,7 @@ dohash()
                dirp = opendir(*pv);
                if (dirp == NULL)
                        continue;
                dirp = opendir(*pv);
                if (dirp == NULL)
                        continue;
-               if (fstat(dirp->dd_fd, &stb) < 0 || !isdir(stb)) {
+               if (fstat(dirp->dd_fd, &stb) < 0 || !S_ISDIR(stb.st_mode)) {
                        closedir(dirp);
                        continue;
                }
                        closedir(dirp);
                        continue;
                }
index 01fe628..14eadf9 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)exp.c       5.4 (Berkeley) %G%";
+static char *sccsid = "@(#)exp.c       5.5 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -390,7 +390,7 @@ exp6(vp, ignore)
                struct command faket;
                char *fakecom[2];
 
                struct command faket;
                char *fakecom[2];
 
-               faket.t_dtyp = TCOM;
+               faket.t_dtyp = NODE_COMMAND;
                faket.t_dflg = 0;
                faket.t_dcar = faket.t_dcdr = faket.t_dspr = (struct command *)0;
                faket.t_dcom = fakecom;
                faket.t_dflg = 0;
                faket.t_dcar = faket.t_dcdr = faket.t_dspr = (struct command *)0;
                faket.t_dcom = fakecom;
index c20d8a6..e537ceb 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)func.c     5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)func.c     5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sh.h"
 #endif /* not lint */
 
 #include "sh.h"
@@ -32,8 +32,8 @@ isbfunc(t)
                return (&label);
        }
        if (*cp == '%') {
                return (&label);
        }
        if (*cp == '%') {
-               if (t->t_dflg & FAND) {
-                       t->t_dflg &= ~FAND;
+               if (t->t_dflg & F_AMPERSAND) {
+                       t->t_dflg &= ~F_AMPERSAND;
                        backgnd.bname = cp;
                        return (&backgnd);
                }
                        backgnd.bname = cp;
                        return (&backgnd);
                }
@@ -212,7 +212,7 @@ doif(v, kp)
                 * otherwise just fall into following code.
                 */
                if (!i)
                 * otherwise just fall into following code.
                 */
                if (!i)
-                       search(ZIF, 0);
+                       search(T_IF, 0);
                return;
        }
        /*
                return;
        }
        /*
@@ -235,8 +235,8 @@ reexecute(kp)
        register struct command *kp;
 {
 
        register struct command *kp;
 {
 
-       kp->t_dflg &= FSAVE;
-       kp->t_dflg |= FREDO;
+       kp->t_dflg &= F_SAVE;
+       kp->t_dflg |= F_REPEAT;
        /*
         * If tty is still ours to arbitrate, arbitrate it;
         * otherwise dont even set pgrp's as the jobs would
        /*
         * If tty is still ours to arbitrate, arbitrate it;
         * otherwise dont even set pgrp's as the jobs would
@@ -249,7 +249,7 @@ reexecute(kp)
 doelse()
 {
 
 doelse()
 {
 
-       search(ZELSE, 0);
+       search(T_ELSE, 0);
 }
 
 dogoto(v)
 }
 
 dogoto(v)
@@ -265,11 +265,11 @@ dogoto(v)
         */
        for (wp = whyles; wp; wp = wp->w_next)
                if (wp->w_end == 0) {
         */
        for (wp = whyles; wp; wp = wp->w_next)
                if (wp->w_end == 0) {
-                       search(ZBREAK, 0);
+                       search(T_BREAK, 0);
                        wp->w_end = btell();
                } else
                        bseek(wp->w_end);
                        wp->w_end = btell();
                } else
                        bseek(wp->w_end);
-       search(ZGOTO, 0, lp = globone(v[1]));
+       search(T_GOTO, 0, lp = globone(v[1]));
        xfree(lp);
        /*
         * Eliminate loops which were exited.
        xfree(lp);
        /*
         * Eliminate loops which were exited.
@@ -291,7 +291,7 @@ doswitch(v)
        if (*v)
 syntax:
                error("Syntax error");
        if (*v)
 syntax:
                error("Syntax error");
-       search(ZSWITCH, 0, lp = globone(cp));
+       search(T_SWITCH, 0, lp = globone(cp));
        xfree(lp);
 }
 
        xfree(lp);
 }
 
@@ -405,7 +405,7 @@ preread()
        whyles->w_end = -1;
        if (setintr)
                (void) sigsetmask(sigblock(0L) & ~sigmask(SIGINT));
        whyles->w_end = -1;
        if (setintr)
                (void) sigsetmask(sigblock(0L) & ~sigmask(SIGINT));
-       search(ZBREAK, 0);
+       search(T_BREAK, 0);
        if (setintr)
                (void) sigblock(sigmask(SIGINT));
        whyles->w_end = btell();
        if (setintr)
                (void) sigblock(sigmask(SIGINT));
        whyles->w_end = btell();
@@ -474,7 +474,7 @@ dorepeat(v, kp)
 doswbrk()
 {
 
 doswbrk()
 {
 
-       search(ZBRKSW, 0);
+       search(T_BRKSW, 0);
 }
 
 srchx(cp)
 }
 
 srchx(cp)
@@ -515,7 +515,7 @@ search(type, level, goal)
        register char *cp;
 
        Stype = type; Sgoal = goal;
        register char *cp;
 
        Stype = type; Sgoal = goal;
-       if (type == ZGOTO)
+       if (type == T_GOTO)
                bseek((off_t)0);
        do {
                if (intty && fseekp == feobp)
                bseek((off_t)0);
        do {
                if (intty && fseekp == feobp)
@@ -524,61 +524,63 @@ search(type, level, goal)
                (void) getword(aword);
                switch (srchx(aword)) {
 
                (void) getword(aword);
                switch (srchx(aword)) {
 
-               case ZELSE:
-                       if (level == 0 && type == ZIF)
+               case T_ELSE:
+                       if (level == 0 && type == T_IF)
                                return;
                        break;
 
                                return;
                        break;
 
-               case ZIF:
+               case T_IF:
                        while (getword(aword))
                                continue;
                        while (getword(aword))
                                continue;
-                       if ((type == ZIF || type == ZELSE) && eq(aword, "then"))
+                       if ((type == T_IF || type == T_ELSE) &&
+                           eq(aword, "then"))
                                level++;
                        break;
 
                                level++;
                        break;
 
-               case ZENDIF:
-                       if (type == ZIF || type == ZELSE)
+               case T_ENDIF:
+                       if (type == T_IF || type == T_ELSE)
                                level--;
                        break;
 
                                level--;
                        break;
 
-               case ZFOREACH:
-               case ZWHILE:
-                       if (type == ZBREAK)
+               case T_FOREACH:
+               case T_WHILE:
+                       if (type == T_BREAK)
                                level++;
                        break;
 
                                level++;
                        break;
 
-               case ZEND:
-                       if (type == ZBREAK)
+               case T_END:
+                       if (type == T_BREAK)
                                level--;
                        break;
 
                                level--;
                        break;
 
-               case ZSWITCH:
-                       if (type == ZSWITCH || type == ZBRKSW)
+               case T_SWITCH:
+                       if (type == T_SWITCH || type == T_BRKSW)
                                level++;
                        break;
 
                                level++;
                        break;
 
-               case ZENDSW:
-                       if (type == ZSWITCH || type == ZBRKSW)
+               case T_ENDSW:
+                       if (type == T_SWITCH || type == T_BRKSW)
                                level--;
                        break;
 
                                level--;
                        break;
 
-               case ZLABEL:
-                       if (type == ZGOTO && getword(aword) && eq(aword, goal))
+               case T_LABEL:
+                       if (type == T_GOTO && getword(aword) && eq(aword, goal))
                                level = -1;
                        break;
 
                default:
                                level = -1;
                        break;
 
                default:
-                       if (type != ZGOTO && (type != ZSWITCH || level != 0))
+                       if (type != T_GOTO && (type != T_SWITCH || level != 0))
                                break;
                        if (lastchr(aword) != ':')
                                break;
                        aword[strlen(aword) - 1] = 0;
                                break;
                        if (lastchr(aword) != ':')
                                break;
                        aword[strlen(aword) - 1] = 0;
-                       if (type == ZGOTO && eq(aword, goal) || type == ZSWITCH && eq(aword, "default"))
+                       if (type == T_GOTO && eq(aword, goal) ||
+                           type == T_SWITCH && eq(aword, "default"))
                                level = -1;
                        break;
 
                                level = -1;
                        break;
 
-               case ZCASE:
-                       if (type != ZSWITCH || level != 0)
+               case T_CASE:
+                       if (type != T_SWITCH || level != 0)
                                break;
                        (void) getword(aword);
                        if (lastchr(aword) == ':')
                                break;
                        (void) getword(aword);
                        if (lastchr(aword) == ':')
@@ -589,8 +591,8 @@ search(type, level, goal)
                        xfree(cp);
                        break;
 
                        xfree(cp);
                        break;
 
-               case ZDEFAULT:
-                       if (type == ZSWITCH && level == 0)
+               case T_DEFAULT:
+                       if (type == T_SWITCH && level == 0)
                                level = -1;
                        break;
                }
                                level = -1;
                        break;
                }
@@ -645,20 +647,20 @@ getword(wp)
 past:
        switch (Stype) {
 
 past:
        switch (Stype) {
 
-       case ZIF:
+       case T_IF:
                bferr("then/endif not found");
 
                bferr("then/endif not found");
 
-       case ZELSE:
+       case T_ELSE:
                bferr("endif not found");
 
                bferr("endif not found");
 
-       case ZBRKSW:
-       case ZSWITCH:
+       case T_BRKSW:
+       case T_SWITCH:
                bferr("endsw not found");
 
                bferr("endsw not found");
 
-       case ZBREAK:
+       case T_BREAK:
                bferr("end not found");
 
                bferr("end not found");
 
-       case ZGOTO:
+       case T_GOTO:
                setname(Sgoal);
                bferr("label not found");
        }
                setname(Sgoal);
                bferr("label not found");
        }
@@ -669,7 +671,7 @@ toend()
 {
 
        if (whyles->w_end == 0) {
 {
 
        if (whyles->w_end == 0) {
-               search(ZBREAK, 0);
+               search(T_BREAK, 0);
                whyles->w_end = btell() - 1;
        } else
                bseek(whyles->w_end);
                whyles->w_end = btell() - 1;
        } else
                bseek(whyles->w_end);
@@ -1111,7 +1113,7 @@ doeval(v)
                trim(v);
        getexit(osetexit);
        reenter = 0;
                trim(v);
        getexit(osetexit);
        reenter = 0;
-       setexit();
+       (void)setjmp(reslab);
        reenter++;
        if (reenter == 1) {
                evalvec = v;
        reenter++;
        if (reenter == 1) {
                evalvec = v;
index c98c84e..af55286 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)glob.c      5.11 (Berkeley) %G%";
+static char *sccsid = "@(#)glob.c      5.12 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -488,7 +488,7 @@ backeval(cp, literal)
        hadnl = 0;
        icnt = 0;
        quoted = (literal || (cp[0] & QUOTE)) ? QUOTE : 0;
        hadnl = 0;
        icnt = 0;
        quoted = (literal || (cp[0] & QUOTE)) ? QUOTE : 0;
-       faket.t_dtyp = TCOM;
+       faket.t_dtyp = NODE_COMMAND;
        faket.t_dflg = 0;
        faket.t_dlef = 0;
        faket.t_drit = 0;
        faket.t_dflg = 0;
        faket.t_dlef = 0;
        faket.t_drit = 0;
@@ -531,7 +531,7 @@ backeval(cp, literal)
                if (err)
                        error(err);
                if (t)
                if (err)
                        error(err);
                if (t)
-                       t->t_dflg |= FPAR;
+                       t->t_dflg |= F_NOFORK;
                (void) signal(SIGTSTP, SIG_IGN);
                (void) signal(SIGTTIN, SIG_IGN);
                (void) signal(SIGTTOU, SIG_IGN);
                (void) signal(SIGTSTP, SIG_IGN);
                (void) signal(SIGTTIN, SIG_IGN);
                (void) signal(SIGTTOU, SIG_IGN);
index 4fa1b29..02cef44 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)init.c      5.5 (Berkeley) %G%";
+static char *sccsid = "@(#)init.c      5.6 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -137,23 +137,23 @@ struct biltins bfunc[] = {
 int nbfunc = sizeof bfunc / sizeof *bfunc;
 
 struct srch srchn[] = {
 int nbfunc = sizeof bfunc / sizeof *bfunc;
 
 struct srch srchn[] = {
-       "@",            ZLET,
-       "break",        ZBREAK,
-       "breaksw",      ZBRKSW,
-       "case",         ZCASE,
-       "default",      ZDEFAULT,
-       "else",         ZELSE,
-       "end",          ZEND,
-       "endif",        ZENDIF,
-       "endsw",        ZENDSW,
-       "exit",         ZEXIT,
-       "foreach",      ZFOREACH,
-       "goto",         ZGOTO,
-       "if",           ZIF,
-       "label",        ZLABEL,
-       "set",          ZSET,
-       "switch",       ZSWITCH,
-       "while",        ZWHILE,
+       "@",            T_LET,
+       "break",        T_BREAK,
+       "breaksw",      T_BRKSW,
+       "case",         T_CASE,
+       "default",      T_DEFAULT,
+       "else",         T_ELSE,
+       "end",          T_END,
+       "endif",        T_ENDIF,
+       "endsw",        T_ENDSW,
+       "exit",         T_EXIT,
+       "foreach",      T_FOREACH,
+       "goto",         T_GOTO,
+       "if",           T_IF,
+       "label",        T_LABEL,
+       "set",          T_SET,
+       "switch",       T_SWITCH,
+       "while",        T_WHILE,
 };
 int nsrchn = sizeof srchn / sizeof *srchn;
 
 };
 int nsrchn = sizeof srchn / sizeof *srchn;
 
index a403108..125477d 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)lex.c       5.8 (Berkeley) %G%";
+static char *sccsid = "@(#)lex.c       5.9 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -1110,7 +1110,7 @@ top:
        if (evalvec) {
                if (evalvec == (char **)1) {
                        doneinp = 1;
        if (evalvec) {
                if (evalvec == (char **)1) {
                        doneinp = 1;
-                       reset();
+                       longjmp(reslab, 0);
                }
                if (evalp = *evalvec) {
                        evalvec++;
                }
                if (evalp = *evalvec) {
                        evalvec++;
@@ -1161,14 +1161,14 @@ printf("Reset tty pgrp from %d to %d\n", ctpgrp, tpgrp);
                                                printf("\nUse \"logout\" to logout.\n");
                                        else
                                                printf("\nUse \"exit\" to leave csh.\n");
                                                printf("\nUse \"logout\" to logout.\n");
                                        else
                                                printf("\nUse \"exit\" to leave csh.\n");
-                                       reset();
+                                       longjmp(reslab, 0);
                                }
                                if (chkstop == 0)
                                        panystop(1);
                        }
 oops:
                        doneinp = 1;
                                }
                                if (chkstop == 0)
                                        panystop(1);
                        }
 oops:
                        doneinp = 1;
-                       reset();
+                       longjmp(reslab, 0);
                }
                sincereal = 0;
                if (c == '\n' && onelflg)
                }
                sincereal = 0;
                if (c == '\n' && onelflg)
index 011086b..b1d2146 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)parse.c     5.4 (Berkeley) %G%";
+static char *sccsid = "@(#)parse.c     5.5 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -27,10 +27,10 @@ alias(lex)
        jmp_buf osetexit;
 
        getexit(osetexit);
        jmp_buf osetexit;
 
        getexit(osetexit);
-       setexit();
+       (void)setjmp(reslab);
        if (haderr) {
                resexit(osetexit);
        if (haderr) {
                resexit(osetexit);
-               reset();
+               longjmp(reslab, 0);
        }
        if (--aleft == 0)
                error("Alias loop");
        }
        if (--aleft == 0)
                error("Alias loop");
@@ -137,7 +137,7 @@ asyn3(p1, p2)
                XFREE(alout.prev->word)
                XFREE((char *)alout.prev)
        }
                XFREE(alout.prev->word)
                XFREE((char *)alout.prev)
        }
-       reset();                /* throw! */
+       longjmp(reslab, 0);             /* throw! */
 }
 
 struct wordent *
 }
 
 struct wordent *
@@ -224,18 +224,18 @@ syn0(p1, p2, flags)
                        if (p->word[1] == '&')
                                continue;
                        t1 = syn1(p1, p, flags);
                        if (p->word[1] == '&')
                                continue;
                        t1 = syn1(p1, p, flags);
-                       if (t1->t_dtyp == TLST ||
-                           t1->t_dtyp == TAND ||
-                           t1->t_dtyp == TOR) {
+                       if (t1->t_dtyp == NODE_LIST ||
+                           t1->t_dtyp == NODE_AND ||
+                           t1->t_dtyp == NODE_OR) {
                                t = (struct command *) calloc(1, sizeof (*t));
                                t = (struct command *) calloc(1, sizeof (*t));
-                               t->t_dtyp = TPAR;
-                               t->t_dflg = FAND|FINT;
+                               t->t_dtyp = NODE_PAREN;
+                               t->t_dflg = F_AMPERSAND|F_NOINTERRUPT;
                                t->t_dspr = t1;
                                t1 = t;
                        } else
                                t->t_dspr = t1;
                                t1 = t;
                        } else
-                               t1->t_dflg |= FAND|FINT;
+                               t1->t_dflg |= F_AMPERSAND|F_NOINTERRUPT;
                        t = (struct command *) calloc(1, sizeof (*t));
                        t = (struct command *) calloc(1, sizeof (*t));
-                       t->t_dtyp = TLST;
+                       t->t_dtyp = NODE_LIST;
                        t->t_dflg = 0;
                        t->t_dcar = t1;
                        t->t_dcdr = syntax(p, p2, flags);
                        t->t_dflg = 0;
                        t->t_dcar = t1;
                        t->t_dcdr = syntax(p, p2, flags);
@@ -278,7 +278,7 @@ syn1(p1, p2, flags)
                        if (l != 0)
                                break;
                        t = (struct command *) calloc(1, sizeof (*t));
                        if (l != 0)
                                break;
                        t = (struct command *) calloc(1, sizeof (*t));
-                       t->t_dtyp = TLST;
+                       t->t_dtyp = NODE_LIST;
                        t->t_dcar = syn1a(p1, p, flags);
                        t->t_dcdr = syntax(p->next, p2, flags);
                        if (t->t_dcdr == 0)
                        t->t_dcar = syn1a(p1, p, flags);
                        t->t_dcdr = syntax(p->next, p2, flags);
                        if (t->t_dcdr == 0)
@@ -318,7 +318,7 @@ syn1a(p1, p2, flags)
                                continue;
                        if (l == 0) {
                                t = (struct command *) calloc(1, sizeof (*t));
                                continue;
                        if (l == 0) {
                                t = (struct command *) calloc(1, sizeof (*t));
-                               t->t_dtyp = TOR;
+                               t->t_dtyp = NODE_OR;
                                t->t_dcar = syn1b(p1, p, flags);
                                t->t_dcdr = syn1a(p->next, p2, flags);
                                t->t_dflg = 0;
                                t->t_dcar = syn1b(p1, p, flags);
                                t->t_dcdr = syn1a(p->next, p2, flags);
                                t->t_dflg = 0;
@@ -358,7 +358,7 @@ syn1b(p1, p2, flags)
                case '&':
                        if (p->word[1] == '&' && l == 0) {
                                t = (struct command *) calloc(1, sizeof (*t));
                case '&':
                        if (p->word[1] == '&' && l == 0) {
                                t = (struct command *) calloc(1, sizeof (*t));
-                               t->t_dtyp = TAND;
+                               t->t_dtyp = NODE_AND;
                                t->t_dcar = syn2(p1, p, flags);
                                t->t_dcdr = syn1b(p->next, p2, flags);
                                t->t_dflg = 0;
                                t->t_dcar = syn2(p1, p, flags);
                                t->t_dcdr = syn1b(p->next, p2, flags);
                                t->t_dflg = 0;
@@ -404,9 +404,9 @@ syn2(p1, p2, flags)
                        pn = p->next;
                        if (pn != p2 && pn->word[0] == '&') {
                                f |= PDIAG;
                        pn = p->next;
                        if (pn != p2 && pn->word[0] == '&') {
                                f |= PDIAG;
-                               t->t_dflg |= FDIAG;
+                               t->t_dflg |= F_STDERR;
                        }
                        }
-                       t->t_dtyp = TFIL;
+                       t->t_dtyp = NODE_PIPE;
                        t->t_dcar = syn3(p1, p, f);
                        if (pn != p2 && pn->word[0] == '&')
                                p = pn;
                        t->t_dcar = syn3(p1, p, f);
                        if (pn != p2 && pn->word[0] == '&')
                                p = pn;
@@ -444,19 +444,19 @@ syn3(p1, p2, flags)
 again:
                switch (srchx(p->word)) {
 
 again:
                switch (srchx(p->word)) {
 
-               case ZELSE:
+               case T_ELSE:
                        p = p->next;
                        if (p != p2)
                                goto again;
                        break;
 
                        p = p->next;
                        if (p != p2)
                                goto again;
                        break;
 
-               case ZEXIT:
-               case ZFOREACH:
-               case ZIF:
-               case ZLET:
-               case ZSET:
-               case ZSWITCH:
-               case ZWHILE:
+               case T_EXIT:
+               case T_FOREACH:
+               case T_IF:
+               case T_LET:
+               case T_SET:
+               case T_SWITCH:
+               case T_WHILE:
                        specp = 1;
                        break;
                }
                        specp = 1;
                        break;
                }
@@ -505,7 +505,7 @@ again:
        t->t_dcom = av;
        n = 0;
        if (p2->word[0] == ')')
        t->t_dcom = av;
        n = 0;
        if (p2->word[0] == ')')
-               t->t_dflg = FPAR;
+               t->t_dflg = F_NOFORK;
        lp = 0;
        rp = 0;
        l = 0;
        lp = 0;
        rp = 0;
        l = 0;
@@ -532,14 +532,17 @@ again:
                        if (l != 0)
                                goto savep;
                        if (p->word[1] == '>')
                        if (l != 0)
                                goto savep;
                        if (p->word[1] == '>')
-                               t->t_dflg |= FCAT;
+                               t->t_dflg |= F_APPEND;
                        if (p->next != p2 && eq(p->next->word, "&")) {
                        if (p->next != p2 && eq(p->next->word, "&")) {
-                               t->t_dflg |= FDIAG, p = p->next;
+                               t->t_dflg |= F_STDERR;
+                               p = p->next;
                                if (flags & (POUT|PDIAG))
                                        goto badout;
                        }
                                if (flags & (POUT|PDIAG))
                                        goto badout;
                        }
-                       if (p->next != p2 && eq(p->next->word, "!"))
-                               t->t_dflg |= FANY, p = p->next;
+                       if (p->next != p2 && eq(p->next->word, "!")) {
+                               t->t_dflg |= F_OVERWRITE;
+                               p = p->next;
+                       }
                        if (p->next == p2) {
 missfile:
                                seterr("Missing name for redirect");
                        if (p->next == p2) {
 missfile:
                                seterr("Missing name for redirect");
@@ -559,13 +562,13 @@ badout:
                        if (l != 0)
                                goto savep;
                        if (p->word[1] == '<')
                        if (l != 0)
                                goto savep;
                        if (p->word[1] == '<')
-                               t->t_dflg |= FHERE;
+                               t->t_dflg |= F_READ;
                        if (p->next == p2)
                                goto missfile;
                        p = p->next;
                        if (index(RELPAR, p->word[0]))
                                goto missfile;
                        if (p->next == p2)
                                goto missfile;
                        p = p->next;
                        if (index(RELPAR, p->word[0]))
                                goto missfile;
-                       if ((flags & PHERE) && (t->t_dflg & FHERE))
+                       if ((flags & PHERE) && (t->t_dflg & F_READ))
                                seterr("Can't << within ()'s");
                        else if ((flags & PIN) || t->t_dlef)
                                seterr("Ambiguous input redirect");
                                seterr("Can't << within ()'s");
                        else if ((flags & PIN) || t->t_dlef)
                                seterr("Ambiguous input redirect");
@@ -588,12 +591,12 @@ savep:
        if (lp != 0 && !specp) {
                if (n != 0)
                        seterr("Badly placed ()'s");
        if (lp != 0 && !specp) {
                if (n != 0)
                        seterr("Badly placed ()'s");
-               t->t_dtyp = TPAR;
+               t->t_dtyp = NODE_PAREN;
                t->t_dspr = syn0(lp, rp, PHERE);
        } else {
                if (n == 0)
                        seterr("Invalid null command");
                t->t_dspr = syn0(lp, rp, PHERE);
        } else {
                if (n == 0)
                        seterr("Invalid null command");
-               t->t_dtyp = TCOM;
+               t->t_dtyp = NODE_COMMAND;
        }
        return (t);
 }
        }
        return (t);
 }
@@ -607,13 +610,13 @@ freesyn(t)
                return;
        switch (t->t_dtyp) {
 
                return;
        switch (t->t_dtyp) {
 
-       case TCOM:
+       case NODE_COMMAND:
                for (v = t->t_dcom; *v; v++)
                        XFREE(*v)
                XFREE((char *)t->t_dcom)
                goto lr;
 
                for (v = t->t_dcom; *v; v++)
                        XFREE(*v)
                XFREE((char *)t->t_dcom)
                goto lr;
 
-       case TPAR:
+       case NODE_PAREN:
                freesyn(t->t_dspr);
                /* fall into ... */
 
                freesyn(t->t_dspr);
                /* fall into ... */
 
@@ -622,11 +625,12 @@ lr:
                XFREE(t->t_drit)
                break;
 
                XFREE(t->t_drit)
                break;
 
-       case TAND:
-       case TOR:
-       case TFIL:
-       case TLST:
-               freesyn(t->t_dcar), freesyn(t->t_dcdr);
+       case NODE_AND:
+       case NODE_OR:
+       case NODE_PIPE:
+       case NODE_LIST:
+               freesyn(t->t_dcar);
+               freesyn(t->t_dcdr);
                break;
        }
        XFREE((char *)t)
                break;
        }
        XFREE((char *)t)
index bd36abd..7df8eba 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)proc.c      5.13 (Berkeley) %G%";
+static char *sccsid = "@(#)proc.c      5.14 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -346,16 +346,16 @@ palloc(pid, t)
 
        pp = (struct process *)calloc(1, sizeof(struct process));
        pp->p_pid = pid;
 
        pp = (struct process *)calloc(1, sizeof(struct process));
        pp->p_pid = pid;
-       pp->p_flags = t->t_dflg & FAND ? PRUNNING : PRUNNING|PFOREGND;
-       if (t->t_dflg & FTIME)
+       pp->p_flags = t->t_dflg & F_AMPERSAND ? PRUNNING : PRUNNING|PFOREGND;
+       if (t->t_dflg & F_TIME)
                pp->p_flags |= PPTIME;
        cmdp = command;
        cmdlen = 0;
        padd(t);
        *cmdp++ = 0;
                pp->p_flags |= PPTIME;
        cmdp = command;
        cmdlen = 0;
        padd(t);
        *cmdp++ = 0;
-       if (t->t_dflg & FPOU) {
+       if (t->t_dflg & F_PIPEOUT) {
                pp->p_flags |= PPOU;
                pp->p_flags |= PPOU;
-               if (t->t_dflg & FDIAG)
+               if (t->t_dflg & F_STDERR)
                        pp->p_flags |= PDIAG;
        }
        pp->p_command = savestr(command);
                        pp->p_flags |= PDIAG;
        }
        pp->p_command = savestr(command);
@@ -410,13 +410,13 @@ padd(t)
                return;
        switch (t->t_dtyp) {
 
                return;
        switch (t->t_dtyp) {
 
-       case TPAR:
+       case NODE_PAREN:
                pads("( ");
                padd(t->t_dspr);
                pads(" )");
                break;
 
                pads("( ");
                padd(t->t_dspr);
                pads(" )");
                break;
 
-       case TCOM:
+       case NODE_COMMAND:
                for (argp = t->t_dcom; *argp; argp++) {
                        pads(*argp);
                        if (argp[1])
                for (argp = t->t_dcom; *argp; argp++) {
                        pads(*argp);
                        if (argp[1])
@@ -424,35 +424,35 @@ padd(t)
                }
                break;
 
                }
                break;
 
-       case TOR:
-       case TAND:
-       case TFIL:
-       case TLST:
+       case NODE_OR:
+       case NODE_AND:
+       case NODE_PIPE:
+       case NODE_LIST:
                padd(t->t_dcar);
                switch (t->t_dtyp) {
                padd(t->t_dcar);
                switch (t->t_dtyp) {
-               case TOR:
+               case NODE_OR:
                        pads(" || ");
                        break;
                        pads(" || ");
                        break;
-               case TAND:
+               case NODE_AND:
                        pads(" && ");
                        break;
                        pads(" && ");
                        break;
-               case TFIL:
+               case NODE_PIPE:
                        pads(" | ");
                        break;
                        pads(" | ");
                        break;
-               case TLST:
+               case NODE_LIST:
                        pads("; ");
                        break;
                }
                padd(t->t_dcdr);
                return;
        }
                        pads("; ");
                        break;
                }
                padd(t->t_dcdr);
                return;
        }
-       if ((t->t_dflg & FPIN) == 0 && t->t_dlef) {
-               pads((t->t_dflg & FHERE) ? " << " : " < ");
+       if ((t->t_dflg & F_PIPEIN) == 0 && t->t_dlef) {
+               pads((t->t_dflg & F_READ) ? " << " : " < ");
                pads(t->t_dlef);
        }
                pads(t->t_dlef);
        }
-       if ((t->t_dflg & FPOU) == 0 && t->t_drit) {
-               pads((t->t_dflg & FCAT) ? " >>" : " >");
-               if (t->t_dflg & FDIAG)
+       if ((t->t_dflg & F_PIPEOUT) == 0 && t->t_drit) {
+               pads((t->t_dflg & F_APPEND) ? " >>" : " >");
+               if (t->t_dflg & F_STDERR)
                        pads("&");
                pads(" ");
                pads(t->t_drit);
                        pads("&");
                pads(" ");
                pads(t->t_drit);
@@ -1028,7 +1028,7 @@ pfork(t, wanttty)
         *      we are not playing with signals (inherit action)
         */
        if (setintr)
         *      we are not playing with signals (inherit action)
         */
        if (setintr)
-               ignint = (tpgrp == -1 && (t->t_dflg&FINT))
+               ignint = (tpgrp == -1 && (t->t_dflg&F_NOINTERRUPT))
                    || (gointr && eq(gointr, "-"));
        /*
         * Hold SIGCHLD until we have the process installed in our table.
                    || (gointr && eq(gointr, "-"));
        /*
         * Hold SIGCHLD until we have the process installed in our table.
@@ -1062,7 +1062,7 @@ pfork(t, wanttty)
                                (void) signal(SIGTTOU, SIG_DFL);
                        }
                        (void) signal(SIGTERM, parterm);
                                (void) signal(SIGTTOU, SIG_DFL);
                        }
                        (void) signal(SIGTERM, parterm);
-               } else if (tpgrp == -1 && (t->t_dflg&FINT)) {
+               } else if (tpgrp == -1 && (t->t_dflg&F_NOINTERRUPT)) {
                        (void) signal(SIGINT, SIG_IGN);
                        (void) signal(SIGQUIT, SIG_IGN);
                }
                        (void) signal(SIGINT, SIG_IGN);
                        (void) signal(SIGQUIT, SIG_IGN);
                }
@@ -1073,13 +1073,13 @@ pfork(t, wanttty)
                if (tpgrp > 0)
                        tpgrp = 0;              /* gave tty away */
                /*
                if (tpgrp > 0)
                        tpgrp = 0;              /* gave tty away */
                /*
-                * Nohup and nice apply only to TCOM's but it would be
-                * nice (?!?) if you could say "nohup (foo;bar)"
-                * Then the parser would have to know about nice/nohup/time
+                * Nohup and nice apply only to NODE_COMMAND's but it would be
+                * nice (?!?) if you could say "nohup (foo;bar)".  Then the
+                * parser would have to know about nice/nohup/time.
                 */
                 */
-               if (t->t_dflg & FNOHUP)
+               if (t->t_dflg & F_NOHUP)
                        (void) signal(SIGHUP, SIG_IGN);
                        (void) signal(SIGHUP, SIG_IGN);
-               if (t->t_dflg & FNICE)
+               if (t->t_dflg & F_NICE)
                        (void) setpriority(PRIO_PROCESS, 0, t->t_nice);
        } else {
                if (wanttty >= 0 && tpgrp >= 0)
                        (void) setpriority(PRIO_PROCESS, 0, t->t_nice);
        } else {
                if (wanttty >= 0 && tpgrp >= 0)
index 8dbbe53..6a94a8c 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)sem.c       5.9 (Berkeley) %G%";
+static char *sccsid = "@(#)sem.c       5.10 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -32,28 +32,28 @@ execute(t, wanttty, pipein, pipeout)
 
        if (t == 0)
                return;
 
        if (t == 0)
                return;
-       if ((t->t_dflg & FAND) && wanttty > 0)
+       if ((t->t_dflg & F_AMPERSAND) && wanttty > 0)
                wanttty = 0;
        switch (t->t_dtyp) {
 
                wanttty = 0;
        switch (t->t_dtyp) {
 
-       case TCOM:
+       case NODE_COMMAND:
                if ((t->t_dcom[0][0] & (QUOTE|TRIM)) == QUOTE)
                        (void) strcpy(t->t_dcom[0], t->t_dcom[0] + 1);
                if ((t->t_dcom[0][0] & (QUOTE|TRIM)) == QUOTE)
                        (void) strcpy(t->t_dcom[0], t->t_dcom[0] + 1);
-               if ((t->t_dflg & FREDO) == 0)
+               if ((t->t_dflg & F_REPEAT) == 0)
                        Dfix(t);                /* $ " ' \ */
                if (t->t_dcom[0] == 0)
                        return;
                /* fall into... */
 
                        Dfix(t);                /* $ " ' \ */
                if (t->t_dcom[0] == 0)
                        return;
                /* fall into... */
 
-       case TPAR:
-               if (t->t_dflg & FPOU)
+       case NODE_PAREN:
+               if (t->t_dflg & F_PIPEOUT)
                        mypipe(pipeout);
                /*
                 * Must do << early so parent will know
                 * where input pointer should be.
                 * If noexec then this is all we do.
                 */
                        mypipe(pipeout);
                /*
                 * Must do << early so parent will know
                 * where input pointer should be.
                 * If noexec then this is all we do.
                 */
-               if (t->t_dflg & FHERE) {
+               if (t->t_dflg & F_READ) {
                        (void) close(0);
                        heredoc(t->t_dlef);
                        if (noexec)
                        (void) close(0);
                        heredoc(t->t_dlef);
                        if (noexec)
@@ -70,7 +70,7 @@ execute(t, wanttty, pipein, pipeout)
                 * be used by themselves, and this is not handled here.
                 * This will also work when loops are parsed.
                 */
                 * be used by themselves, and this is not handled here.
                 * This will also work when loops are parsed.
                 */
-               while (t->t_dtyp == TCOM)
+               while (t->t_dtyp == NODE_COMMAND)
                        if (eq(t->t_dcom[0], "nice"))
                                if (t->t_dcom[1])
                                        if (index("+-", t->t_dcom[1][0]))
                        if (eq(t->t_dcom[0], "nice"))
                                if (t->t_dcom[1])
                                        if (index("+-", t->t_dcom[1][0]))
@@ -78,25 +78,25 @@ execute(t, wanttty, pipein, pipeout)
                                                        setname("nice");
                                                        t->t_nice = getn(t->t_dcom[1]);
                                                        lshift(t->t_dcom, 2);
                                                        setname("nice");
                                                        t->t_nice = getn(t->t_dcom[1]);
                                                        lshift(t->t_dcom, 2);
-                                                       t->t_dflg |= FNICE;
+                                                       t->t_dflg |= F_NICE;
                                                } else
                                                        break;
                                        else {
                                                t->t_nice = 4;
                                                lshift(t->t_dcom, 1);
                                                } else
                                                        break;
                                        else {
                                                t->t_nice = 4;
                                                lshift(t->t_dcom, 1);
-                                               t->t_dflg |= FNICE;
+                                               t->t_dflg |= F_NICE;
                                        }
                                else
                                        break;
                        else if (eq(t->t_dcom[0], "nohup"))
                                if (t->t_dcom[1]) {
                                        }
                                else
                                        break;
                        else if (eq(t->t_dcom[0], "nohup"))
                                if (t->t_dcom[1]) {
-                                       t->t_dflg |= FNOHUP;
+                                       t->t_dflg |= F_NOHUP;
                                        lshift(t->t_dcom, 1);
                                } else
                                        break;
                        else if (eq(t->t_dcom[0], "time"))
                                if (t->t_dcom[1]) {
                                        lshift(t->t_dcom, 1);
                                } else
                                        break;
                        else if (eq(t->t_dcom[0], "time"))
                                if (t->t_dcom[1]) {
-                                       t->t_dflg |= FTIME;
+                                       t->t_dflg |= F_TIME;
                                        lshift(t->t_dcom, 1);
                                } else
                                        break;
                                        lshift(t->t_dcom, 1);
                                } else
                                        break;
@@ -105,7 +105,8 @@ execute(t, wanttty, pipein, pipeout)
                /*
                 * Check if we have a builtin function and remember which one.
                 */
                /*
                 * Check if we have a builtin function and remember which one.
                 */
-               bifunc = t->t_dtyp == TCOM ? isbfunc(t) : (struct biltins *) 0;
+               bifunc = t->t_dtyp ==
+                   NODE_COMMAND ? isbfunc(t) : (struct biltins *) 0;
 
                /*
                 * We fork only if we are timed, or are not the end of
 
                /*
                 * We fork only if we are timed, or are not the end of
@@ -114,10 +115,12 @@ execute(t, wanttty, pipein, pipeout)
                 * or &'d.
                 * It would be nice(?) to not fork in some of these cases.
                 */
                 * or &'d.
                 * It would be nice(?) to not fork in some of these cases.
                 */
-               if (((t->t_dflg & FTIME) || (t->t_dflg & FPAR) == 0 &&
-                    (!bifunc || t->t_dflg & (FPOU|FAND|FNICE|FNOHUP))))
+               if (((t->t_dflg & F_TIME) || (t->t_dflg & F_NOFORK) == 0 &&
+                   (!bifunc ||
+                   t->t_dflg & (F_PIPEOUT|F_AMPERSAND|F_NICE|F_NOHUP))))
 #ifdef VFORK
 #ifdef VFORK
-                   if (t->t_dtyp == TPAR || t->t_dflg&(FREDO|FAND) || bifunc)
+                   if (t->t_dtyp == NODE_PAREN ||
+                       t->t_dflg&(F_REPEAT|F_AMPERSAND) || bifunc)
 #endif
                        { forked++; 
                          if (wanttty >= 0 && !nosigchld) {
 #endif
                        { forked++; 
                          if (wanttty >= 0 && !nosigchld) {
@@ -188,9 +191,9 @@ execute(t, wanttty, pipein, pipeout)
                                        nosigchld = 0;
                                }
                                if (setintr)
                                        nosigchld = 0;
                                }
                                if (setintr)
-                                       ignint =
-                                           (tpgrp == -1 && (t->t_dflg&FINT))
-                                           || gointr && eq(gointr, "-");
+                                       ignint = (tpgrp == -1 &&
+                                           (t->t_dflg&F_NOINTERRUPT)) ||
+                                           gointr && eq(gointr, "-");
                                pgrp = pcurrjob ? pcurrjob->p_jobid : getpid();
                                child++;
                                if (setintr) {
                                pgrp = pcurrjob ? pcurrjob->p_jobid : getpid();
                                child++;
                                if (setintr) {
@@ -208,7 +211,8 @@ execute(t, wanttty, pipein, pipeout)
                                                (void) signal(SIGTTOU, SIG_DFL);
                                        }
                                        (void) signal(SIGTERM, parterm);
                                                (void) signal(SIGTTOU, SIG_DFL);
                                        }
                                        (void) signal(SIGTERM, parterm);
-                               } else if (tpgrp == -1 && (t->t_dflg&FINT)) {
+                               } else if (tpgrp == -1 &&
+                                   (t->t_dflg&F_NOINTERRUPT)) {
                                        (void) signal(SIGINT, SIG_IGN);
                                        (void) signal(SIGQUIT, SIG_IGN);
                                }
                                        (void) signal(SIGINT, SIG_IGN);
                                        (void) signal(SIGQUIT, SIG_IGN);
                                }
@@ -219,9 +223,9 @@ execute(t, wanttty, pipein, pipeout)
                                                (char *)&pgrp);
                                if (tpgrp > 0)
                                        tpgrp = 0;
                                                (char *)&pgrp);
                                if (tpgrp > 0)
                                        tpgrp = 0;
-                               if (t->t_dflg & FNOHUP)
+                               if (t->t_dflg & F_NOHUP)
                                        (void) signal(SIGHUP, SIG_IGN);
                                        (void) signal(SIGHUP, SIG_IGN);
-                               if (t->t_dflg & FNICE)
+                               if (t->t_dflg & F_NICE)
                                        (void) setpriority(PRIO_PROCESS,
                                                0, t->t_nice);
                        }
                                        (void) setpriority(PRIO_PROCESS,
                                                0, t->t_nice);
                        }
@@ -236,11 +240,11 @@ execute(t, wanttty, pipein, pipeout)
                         * wait for the whole job anyway, but this test
                         * doesn't really express our intentions.
                         */
                         * wait for the whole job anyway, but this test
                         * doesn't really express our intentions.
                         */
-                       if (didfds==0 && t->t_dflg&FPIN) {
+                       if (didfds==0 && t->t_dflg&F_PIPEIN) {
                                (void) close(pipein[0]);
                                (void) close(pipein[1]);
                        }
                                (void) close(pipein[0]);
                                (void) close(pipein[1]);
                        }
-                       if ((t->t_dflg & FPOU) == 0) {
+                       if ((t->t_dflg & F_PIPEOUT) == 0) {
                                if (nosigchld) {
 #ifdef foobarbaz
                                        printf("DID\n");
                                if (nosigchld) {
 #ifdef foobarbaz
                                        printf("DID\n");
@@ -248,13 +252,13 @@ execute(t, wanttty, pipein, pipeout)
                                        sigsetmask(osigmask);
                                        nosigchld = 0;
                                }
                                        sigsetmask(osigmask);
                                        nosigchld = 0;
                                }
-                               if ((t->t_dflg & FAND) == 0)
+                               if ((t->t_dflg & F_AMPERSAND) == 0)
                                        pwait();
                        }
                        break;
                }
                doio(t, pipein, pipeout);
                                        pwait();
                        }
                        break;
                }
                doio(t, pipein, pipeout);
-               if (t->t_dflg & FPOU) {
+               if (t->t_dflg & F_PIPEOUT) {
                        (void) close(pipeout[0]);
                        (void) close(pipeout[1]);
                }
                        (void) close(pipeout[0]);
                        (void) close(pipeout[1]);
                }
@@ -269,7 +273,7 @@ execute(t, wanttty, pipein, pipeout)
                                exitstat();
                        break;
                }
                                exitstat();
                        break;
                }
-               if (t->t_dtyp != TPAR) {
+               if (t->t_dtyp != NODE_PAREN) {
                        doexec(t);
                        /*NOTREACHED*/
                }
                        doexec(t);
                        /*NOTREACHED*/
                }
@@ -283,61 +287,64 @@ execute(t, wanttty, pipein, pipeout)
                SHIN = -1;
                didfds = 0;
                wanttty = -1;
                SHIN = -1;
                didfds = 0;
                wanttty = -1;
-               t->t_dspr->t_dflg |= t->t_dflg & FINT;
+               t->t_dspr->t_dflg |= t->t_dflg & F_NOINTERRUPT;
                execute(t->t_dspr, wanttty);
                exitstat();
 
                execute(t->t_dspr, wanttty);
                exitstat();
 
-       case TFIL:
-               t->t_dcar->t_dflg |= FPOU |
-                   (t->t_dflg & (FPIN|FAND|FDIAG|FINT));
+       case NODE_PIPE:
+               t->t_dcar->t_dflg |= F_PIPEOUT |
+                   (t->t_dflg & (F_PIPEIN|F_AMPERSAND|F_STDERR|F_NOINTERRUPT));
                execute(t->t_dcar, wanttty, pipein, pv);
                execute(t->t_dcar, wanttty, pipein, pv);
-               t->t_dcdr->t_dflg |= FPIN |
-                   (t->t_dflg & (FPOU|FAND|FPAR|FINT));
+               t->t_dcdr->t_dflg |= F_PIPEIN |
+                   (t->t_dflg &
+                   (F_PIPEOUT|F_AMPERSAND|F_NOFORK|F_NOINTERRUPT));
                if (wanttty > 0)
                        wanttty = 0;            /* got tty already */
                execute(t->t_dcdr, wanttty, pv, pipeout);
                break;
 
                if (wanttty > 0)
                        wanttty = 0;            /* got tty already */
                execute(t->t_dcdr, wanttty, pv, pipeout);
                break;
 
-       case TLST:
+       case NODE_LIST:
                if (t->t_dcar) {
                if (t->t_dcar) {
-                       t->t_dcar->t_dflg |= t->t_dflg & FINT;
+                       t->t_dcar->t_dflg |= t->t_dflg & F_NOINTERRUPT;
                        execute(t->t_dcar, wanttty);
                        /*
                         * In strange case of A&B make a new job after A
                         */
                        execute(t->t_dcar, wanttty);
                        /*
                         * In strange case of A&B make a new job after A
                         */
-                       if (t->t_dcar->t_dflg&FAND && t->t_dcdr &&
-                           (t->t_dcdr->t_dflg&FAND) == 0)
+                       if (t->t_dcar->t_dflg&F_AMPERSAND && t->t_dcdr &&
+                           (t->t_dcdr->t_dflg&F_AMPERSAND) == 0)
                                pendjob();
                }
                if (t->t_dcdr) {
                                pendjob();
                }
                if (t->t_dcdr) {
-                       t->t_dcdr->t_dflg |= t->t_dflg & (FPAR|FINT);
+                       t->t_dcdr->t_dflg |=
+                           t->t_dflg & (F_NOFORK|F_NOINTERRUPT);
                        execute(t->t_dcdr, wanttty);
                }
                break;
 
                        execute(t->t_dcdr, wanttty);
                }
                break;
 
-       case TOR:
-       case TAND:
+       case NODE_OR:
+       case NODE_AND:
                if (t->t_dcar) {
                if (t->t_dcar) {
-                       t->t_dcar->t_dflg |= t->t_dflg & FINT;
+                       t->t_dcar->t_dflg |= t->t_dflg & F_NOINTERRUPT;
                        execute(t->t_dcar, wanttty);
                        execute(t->t_dcar, wanttty);
-                       if ((getn(value("status")) == 0) != (t->t_dtyp == TAND))
+                       if ((getn(value("status")) == 0) !=
+                           (t->t_dtyp == NODE_AND))
                                return;
                }
                if (t->t_dcdr) {
                                return;
                }
                if (t->t_dcdr) {
-                       t->t_dcdr->t_dflg |= t->t_dflg & (FPAR|FINT);
+                       t->t_dcdr->t_dflg |=
+                           t->t_dflg & (F_NOFORK|F_NOINTERRUPT);
                        execute(t->t_dcdr, wanttty);
                }
                break;
        }
        /*
                        execute(t->t_dcdr, wanttty);
                }
                break;
        }
        /*
-        * Fall through for all breaks from switch
+        * Fall through for all breaks from switch.
         *
         *
-        * If there will be no more executions of this
-        * command, flush all file descriptors.
-        * Places that turn on the FREDO bit are responsible
-        * for doing donefds after the last re-execution
+        * If there will be no more executions of this command, flush all
+        * file descriptors.  Places that turn on the F_REPEAT bit are
+        * responsible for doing donefds after the last re-execution
         */
         */
-       if (didfds && !(t->t_dflg & FREDO))
+       if (didfds && !(t->t_dflg & F_REPEAT))
                donefds();
 }
 
                donefds();
 }
 
@@ -365,20 +372,20 @@ doio(t, pipein, pipeout)
        register char *cp;
        register int flags = t->t_dflg;
 
        register char *cp;
        register int flags = t->t_dflg;
 
-       if (didfds || (flags & FREDO))
+       if (didfds || (flags & F_REPEAT))
                return;
                return;
-       if ((flags & FHERE) == 0) {     /* FHERE already done */
+       if ((flags & F_READ) == 0) {    /* F_READ already done */
                (void) close(0);
                if (cp = t->t_dlef) {
                        cp = globone(Dfix1(cp));
                        xfree(cp);
                        if (open(cp, 0) < 0)
                                Perror(cp);
                (void) close(0);
                if (cp = t->t_dlef) {
                        cp = globone(Dfix1(cp));
                        xfree(cp);
                        if (open(cp, 0) < 0)
                                Perror(cp);
-               } else if (flags & FPIN) {
+               } else if (flags & F_PIPEIN) {
                        (void) dup(pipein[0]);
                        (void) close(pipein[0]);
                        (void) close(pipein[1]);
                        (void) dup(pipein[0]);
                        (void) close(pipein[0]);
                        (void) close(pipein[1]);
-               } else if ((flags & FINT) && tpgrp == -1) {
+               } else if ((flags & F_NOINTERRUPT) && tpgrp == -1) {
                        (void) close(0);
                        (void) open(_PATH_DEVNULL, 0);
                } else
                        (void) close(0);
                        (void) open(_PATH_DEVNULL, 0);
                } else
@@ -388,22 +395,22 @@ doio(t, pipein, pipeout)
        if (cp = t->t_drit) {
                cp = globone(Dfix1(cp));
                xfree(cp);
        if (cp = t->t_drit) {
                cp = globone(Dfix1(cp));
                xfree(cp);
-               if (!(flags & FCAT) || open(cp, O_WRONLY|O_APPEND, 0) < 0) {
-                       if (!(flags & FANY) && adrof("noclobber")) {
-                               if (flags & FCAT)
+               if (!(flags & F_APPEND) || open(cp, O_WRONLY|O_APPEND, 0) < 0) {
+                       if (!(flags & F_OVERWRITE) && adrof("noclobber")) {
+                               if (flags & F_APPEND)
                                        Perror(cp);
                                chkclob(cp);
                        }
                        if (creat(cp, 0666) < 0)
                                Perror(cp);
                }
                                        Perror(cp);
                                chkclob(cp);
                        }
                        if (creat(cp, 0666) < 0)
                                Perror(cp);
                }
-       } else if (flags & FPOU)
+       } else if (flags & F_PIPEOUT)
                (void) dup(pipeout[1]);
        else
                (void) dup(SHOUT);
 
        (void) close(2);
                (void) dup(pipeout[1]);
        else
                (void) dup(SHOUT);
 
        (void) close(2);
-       if (flags & FDIAG)
+       if (flags & F_STDERR)
                (void) dup(1);
        else
                (void) dup(SHDIAG);
                (void) dup(1);
        else
                (void) dup(SHDIAG);