X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/0f4556f12c8f75078501c9d1338ae7648a97f975..95f51977ddc18faa2e212f30c00a39540b39f325:/usr/src/bin/csh/sh.h diff --git a/usr/src/bin/csh/sh.h b/usr/src/bin/csh/sh.h index 1d092f6a59..765df598c2 100644 --- a/usr/src/bin/csh/sh.h +++ b/usr/src/bin/csh/sh.h @@ -1,8 +1,20 @@ -/* sh.h 4.10 83/07/01 */ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley Software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)sh.h 5.3 (Berkeley) 3/29/86 + */ -#include "sh.local.h" #include #include +#include +#include +#include +#include +#include +#include "sh.local.h" +#include "sh.char.h" /* * C shell @@ -13,32 +25,17 @@ * Jim Kulp, IIASA, Laxenburg Austria * April, 1980 */ -#include -#include #define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR) -#include -#include -#include -#include - typedef char bool; #define eq(a, b) (strcmp(a, b) == 0) -/* - * For 4.2bsd signals. - */ -#define mask(s) (1 << ((s)-1)) -#define sigsys(s, a) signal(s, a) -#define sighold(s) sigblock(mask(s)) - /* * 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 */ @@ -53,6 +50,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 havhash; /* path hashing is available */ +#ifdef FILEC +bool filec; /* doing filename expansion */ +#endif /* * Global i/o info @@ -78,7 +79,6 @@ int tpgrp; /* Terminal process group */ /* If tpgrp is -1, leave tty alone! */ int opgrp; /* Initial pgrp and tty pgrp */ 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 @@ -90,13 +90,13 @@ struct biltins { int (*bfunct)(); short minargs, maxargs; } bfunc[]; - -#define INF 1000 +extern int nbfunc; 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 @@ -121,8 +121,8 @@ short OLDSTD; /* Old standard input (def for cmds) */ 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) @@ -162,7 +162,11 @@ struct Bin { #define fblocks B.Bfblocks #define fbuf B.Bfbuf +#define btell() fseekp + +#ifndef btell off_t btell(); +#endif /* * The shell finds commands in loops by reseeking the input @@ -172,7 +176,6 @@ off_t btell(); off_t lineloc; #ifdef TELL -off_t tell(); bool cantell; /* Is current source tellable ? */ #endif @@ -300,13 +303,21 @@ struct whyle { /* * 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 */ - 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; +#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 @@ -368,13 +379,25 @@ int lastev; /* Last event reference (default) */ 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(); -struct varent *adrof(), *adrof1(); char **blkcat(); char **blkcpy(); char **blkend(); char **blkspl(); char *calloc(); +char *malloc(); char *cname(); char **copyblk(); char **dobackp(); @@ -395,14 +418,17 @@ struct passwd *getpwnam(); struct wordent *gethent(); struct wordent *getsub(); char *getwd(); +char **glob(); char *globone(); +char *index(); struct biltins *isbfunc(); -char **glob(); +off_t lseek(); char *operate(); int phup(); int pintr(); int pchild(); char *putn(); +char *rindex(); char **saveblk(); char *savestr(); char *strcat(); @@ -419,9 +445,7 @@ struct command *syn1a(); struct command *syn1b(); struct command *syn2(); struct command *syn3(); -int tglob(); -int trim(); -char *value(), *value1(); +char *value1(); char *xhome(); char *xname(); char *xset(); @@ -432,7 +456,7 @@ char *xset(); * 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;