allow setenv with 0 and 1 arugments:
[unix-history] / usr / src / bin / csh / csh.h
index 5bd3859..56d4208 100644 (file)
@@ -1,9 +1,13 @@
-/* csh.h 4.4 %G% */
+/* @(#)csh.h   4.12 (Berkeley) %G% */
 
 
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/signal.h>
+#include <errno.h>
+#include <setjmp.h>
 #include "sh.local.h"
 #include "sh.local.h"
-#ifdef VMUNIX
-#include <sys/vtimes.h>
-#endif
 
 /*
  * C shell
 
 /*
  * C shell
  * Jim Kulp, IIASA, Laxenburg Austria
  * April, 1980
  */
  * Jim Kulp, IIASA, Laxenburg Austria
  * April, 1980
  */
-#include <sys/param.h>
-#include <sys/stat.h>
 
 #define        isdir(d)        ((d.st_mode & S_IFMT) == S_IFDIR)
 
 
 #define        isdir(d)        ((d.st_mode & S_IFMT) == S_IFDIR)
 
-#include <errno.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <sys/times.h>
-
 typedef        char    bool;
 
 #define        eq(a, b)        (strcmp(a, b) == 0)
 typedef        char    bool;
 
 #define        eq(a, b)        (strcmp(a, b) == 0)
@@ -32,7 +29,6 @@ typedef       char    bool;
  * Global flags
  */
 bool   chkstop;                /* Warned of stopped jobs... allow exit */
  * Global flags
  */
 bool   chkstop;                /* Warned of stopped jobs... allow exit */
-bool   didcch;                 /* Have closed unused fd's for child */
 bool   didfds;                 /* Have setup i/o fd's for child */
 bool   doneinp;                /* EOF indicator after reset from readc */
 bool   exiterr;                /* Exit if error or non-zero exit status */
 bool   didfds;                 /* Have setup i/o fd's for child */
 bool   doneinp;                /* EOF indicator after reset from readc */
 bool   exiterr;                /* Exit if error or non-zero exit status */
@@ -47,6 +43,10 @@ bool noexec;                 /* Don't execute, just syntax check */
 bool   pjobs;                  /* want to print jobs if interrupted */
 bool   setintr;                /* Set interrupts on/off -> Wait intr... */
 bool   timflg;                 /* Time the next waited for command */
 bool   pjobs;                  /* want to print jobs if interrupted */
 bool   setintr;                /* Set interrupts on/off -> Wait intr... */
 bool   timflg;                 /* Time the next waited for command */
+bool   havhash;                /* path hashing is available */
+#ifdef FILEC
+bool   filec;                  /* doing filename expansion */
+#endif
 
 /*
  * Global i/o info
 
 /*
  * Global i/o info
@@ -58,7 +58,8 @@ char  *file;                  /* Name of shell file for $0 */
 char   *err;                   /* Error message from scanner/parser */
 int    errno;                  /* Error from C library routines */
 char   *shtemp;                /* Temp name for << shell files in /tmp */
 char   *err;                   /* Error message from scanner/parser */
 int    errno;                  /* Error from C library routines */
 char   *shtemp;                /* Temp name for << shell files in /tmp */
-time_t time0;                  /* Time at which the shell started */
+struct timeval time0;          /* Time at which the shell started */
+struct rusage ru0;
 
 /*
  * Miscellany
 
 /*
  * Miscellany
@@ -66,12 +67,11 @@ time_t      time0;                  /* Time at which the shell started */
 char   *doldol;                /* Character pid for $$ */
 int    uid;                    /* Invokers uid */
 time_t chktim;                 /* Time mail last checked */
 char   *doldol;                /* Character pid for $$ */
 int    uid;                    /* Invokers uid */
 time_t chktim;                 /* Time mail last checked */
-short  shpgrp;                 /* Pgrp of shell */
-short  tpgrp;                  /* Terminal process group */
+int    shpgrp;                 /* Pgrp of shell */
+int    tpgrp;                  /* Terminal process group */
 /* If tpgrp is -1, leave tty alone! */
 /* If tpgrp is -1, leave tty alone! */
-short  opgrp;                  /* Initial pgrp and tty pgrp */
+int    opgrp;                  /* Initial pgrp and tty pgrp */
 int    oldisc;                 /* Initial line discipline or -1 */
 int    oldisc;                 /* Initial line discipline or -1 */
-struct tms shtimes;            /* shell and child times for process timing */
 
 /*
  * These are declared here because they want to be
 
 /*
  * These are declared here because they want to be
@@ -83,13 +83,13 @@ struct      biltins {
        int     (*bfunct)();
        short   minargs, maxargs;
 } bfunc[];
        int     (*bfunct)();
        short   minargs, maxargs;
 } bfunc[];
-
-#define        INF     1000
+extern int nbfunc;
 
 struct srch {
        char    *s_name;
        short   s_value;
 } srchn[];
 
 struct srch {
        char    *s_name;
        short   s_value;
 } srchn[];
+extern int nsrchn;
 
 /*
  * To be able to redirect i/o for builtins easily, the shell moves the i/o
 
 /*
  * To be able to redirect i/o for builtins easily, the shell moves the i/o
@@ -114,8 +114,8 @@ short       OLDSTD;                 /* Old standard input (def for cmds) */
 
 jmp_buf        reslab;
 
 
 jmp_buf        reslab;
 
-#define        setexit()       setjmp(reslab)
-#define        reset()         longjmp(reslab)
+#define        setexit()       ((void) setjmp(reslab))
+#define        reset()         longjmp(reslab, 0)
        /* Should use structure assignment here */
 #define        getexit(a)      copy((char *)(a), (char *)reslab, sizeof reslab)
 #define        resexit(a)      copy((char *)reslab, ((char *)(a)), sizeof reslab)
        /* Should use structure assignment here */
 #define        getexit(a)      copy((char *)(a), (char *)reslab, sizeof reslab)
 #define        resexit(a)      copy((char *)reslab, ((char *)(a)), sizeof reslab)
@@ -165,7 +165,6 @@ off_t       btell();
 off_t  lineloc;
 
 #ifdef TELL
 off_t  lineloc;
 
 #ifdef TELL
-off_t  tell();
 bool   cantell;                        /* Is current source tellable ? */
 #endif
 
 bool   cantell;                        /* Is current source tellable ? */
 #endif
 
@@ -199,11 +198,7 @@ struct     wordent {
  * process id's from `$$', and modified variable values (from qualifiers
  * during expansion in sh.dol.c) here.
  */
  * process id's from `$$', and modified variable values (from qualifiers
  * during expansion in sh.dol.c) here.
  */
-#ifdef VMUNIX
 char   labuf[BUFSIZ];
 char   labuf[BUFSIZ];
-#else
-char   labuf[256];
-#endif
 
 char   *lap;
 
 
 char   *lap;
 
@@ -297,13 +292,21 @@ struct    whyle {
 /*
  * Variable structure
  *
 /*
  * Variable structure
  *
- * Lists of aliases and variables are sorted alphabetically by name
+ * Aliases and variables are stored in AVL balanced binary trees.
  */
 struct varent {
        char    **vec;          /* Array of words which is the value */
  */
 struct varent {
        char    **vec;          /* Array of words which is the value */
-       char    *name;          /* Name of variable/alias */
-       struct  varent *link;
+       char    *v_name;        /* Name of variable/alias */
+       struct  varent *v_link[3];      /* The links, see below */
+       int     v_bal;          /* Balance factor */
 } shvhed, aliases;
 } shvhed, aliases;
+#define v_left         v_link[0]
+#define v_right                v_link[1]
+#define v_parent       v_link[2]
+
+struct varent *adrof1();
+#define adrof(v)       adrof1(v, &shvhed)
+#define value(v)       value1(v, &shvhed)
 
 /*
  * The following are for interfacing redo substitution in
 
 /*
  * The following are for interfacing redo substitution in
@@ -365,13 +368,25 @@ int       lastev;                         /* Last event reference (default) */
 char   HIST;                           /* history invocation character */
 char   HISTSUB;                        /* auto-substitute character */
 
 char   HIST;                           /* history invocation character */
 char   HISTSUB;                        /* auto-substitute character */
 
+/*
+ * In lines for frequently called functions
+ */
+#define XFREE(cp) { \
+       extern char end[]; \
+       char stack; \
+       if ((cp) >= end && (cp) < &stack) \
+               free(cp); \
+}
+char   *alloctmp;
+#define xalloc(i) ((alloctmp = malloc(i)) ? alloctmp : (char *)nomem(i))
+
 char   *Dfix1();
 char   *Dfix1();
-struct varent *adrof(), *adrof1();
 char   **blkcat();
 char   **blkcpy();
 char   **blkend();
 char   **blkspl();
 char   *calloc();
 char   **blkcat();
 char   **blkcpy();
 char   **blkend();
 char   **blkspl();
 char   *calloc();
+char   *malloc();
 char   *cname();
 char   **copyblk();
 char   **dobackp();
 char   *cname();
 char   **copyblk();
 char   **dobackp();
@@ -392,14 +407,17 @@ struct    passwd *getpwnam();
 struct wordent *gethent();
 struct wordent *getsub();
 char   *getwd();
 struct wordent *gethent();
 struct wordent *getsub();
 char   *getwd();
+char   **glob();
 char   *globone();
 char   *globone();
+char   *index();
 struct biltins *isbfunc();
 struct biltins *isbfunc();
-char   **glob();
+off_t  lseek();
 char   *operate();
 int    phup();
 int    pintr();
 int    pchild();
 char   *putn();
 char   *operate();
 int    phup();
 int    pintr();
 int    pchild();
 char   *putn();
+char   *rindex();
 char   **saveblk();
 char   *savestr();
 char   *strcat();
 char   **saveblk();
 char   *savestr();
 char   *strcat();
@@ -416,9 +434,7 @@ struct      command *syn1a();
 struct command *syn1b();
 struct command *syn2();
 struct command *syn3();
 struct command *syn1b();
 struct command *syn2();
 struct command *syn3();
-int    tglob();
-int    trim();
-char   *value(), *value1();
+char   *value1();
 char   *xhome();
 char   *xname();
 char   *xset();
 char   *xhome();
 char   *xname();
 char   *xset();
@@ -429,7 +445,7 @@ char        *xset();
  * setname is a macro to save space (see sh.err.c)
  */
 char   *bname;
  * setname is a macro to save space (see sh.err.c)
  */
 char   *bname;
-#define        setname(a)      bname = (a);
+#define        setname(a)      (bname = (a))
 
 #ifdef VFORK
 char   *Vsav;
 
 #ifdef VFORK
 char   *Vsav;
@@ -437,10 +453,6 @@ char       **Vav;
 char   *Vdp;
 #endif
 
 char   *Vdp;
 #endif
 
-#ifdef VMUNIX
-struct vtimes zvms;
-#endif
-
 char   **evalvec;
 char   *evalp;
 
 char   **evalvec;
 char   *evalp;