summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/csh/sh.c18
-rw-r--r--usr/src/cmd/csh/sh.char.c3
-rw-r--r--usr/src/cmd/csh/sh.char.h4
-rw-r--r--usr/src/cmd/csh/sh.dir.c8
-rw-r--r--usr/src/cmd/csh/sh.dir.h6
-rw-r--r--usr/src/cmd/csh/sh.dol.c15
-rw-r--r--usr/src/cmd/csh/sh.err.c46
-rw-r--r--usr/src/cmd/csh/sh.exec.c15
-rw-r--r--usr/src/cmd/csh/sh.exp.c10
-rw-r--r--usr/src/cmd/csh/sh.func.c15
-rw-r--r--usr/src/cmd/csh/sh.glob.c15
-rw-r--r--usr/src/cmd/csh/sh.h156
-rw-r--r--usr/src/cmd/csh/sh.hist.c5
-rw-r--r--usr/src/cmd/csh/sh.lex.c13
-rw-r--r--usr/src/cmd/csh/sh.parse.c8
-rw-r--r--usr/src/cmd/csh/sh.proc.c12
-rw-r--r--usr/src/cmd/csh/sh.proc.h13
-rw-r--r--usr/src/cmd/csh/sh.set.c3
-rw-r--r--usr/src/cmd/csh/sh.tchar.c3
-rw-r--r--usr/src/cmd/csh/sh.time.c5
20 files changed, 195 insertions, 178 deletions
diff --git a/usr/src/cmd/csh/sh.c b/usr/src/cmd/csh/sh.c
index 3c7a898409..aacffdefed 100644
--- a/usr/src/cmd/csh/sh.c
+++ b/usr/src/cmd/csh/sh.c
@@ -48,6 +48,8 @@ bool fast;
bool batch;
bool prompt = 1;
bool enterhist = 0;
+static time_t chktim;
+char *err_msg; /* Error message from scanner/parser */
extern gid_t getegid(), getgid();
extern uid_t geteuid(), getuid();
@@ -123,6 +125,7 @@ main(int c, char **av)
tchar s_prompt[MAXHOSTNAMELEN+3];
char *c_max_var_len;
int c_max_var_len_size;
+ bool intact;
/*
* set up the error exit, if there is an error before
@@ -883,7 +886,6 @@ pintr1(bool wantnl)
*/
if (gointr) {
search(ZGOTO, 0, gointr);
- timflg = 0;
if (v = pargv)
pargv = 0, blkfree(v);
if (v = gargv)
@@ -974,7 +976,7 @@ process(bool catch)
if (fseekp == feobp)
printprompt();
}
- err = 0;
+ err_msg = NULL;
/*
* Echo not only on VERBOSE, but also with history expansion.
@@ -1005,8 +1007,8 @@ process(bool catch)
* Print lexical error messages, except when sourcing
* history lists.
*/
- if (!enterhist && err)
- error("%s", gettext(err));
+ if (!enterhist && err_msg)
+ error("%s", gettext(err_msg));
/*
* If had a history command :p modifier then
@@ -1021,8 +1023,8 @@ process(bool catch)
* Parse the words of the input into a parse tree.
*/
t = syntax(paraml.next, &paraml, 0);
- if (err)
- error("%s", gettext(err));
+ if (err_msg)
+ error("%s", gettext(err_msg));
/*
* Execute the parse tree
@@ -1041,8 +1043,8 @@ process(bool catch)
(void) sigsetmask(omask &~ sigmask(SIGCHLD));
}
- if (err)
- error("%s", gettext(err));
+ if (err_msg)
+ error("%s", gettext(err_msg));
/*
* Made it!
*/
diff --git a/usr/src/cmd/csh/sh.char.c b/usr/src/cmd/csh/sh.char.c
index 8c79005dd7..303c9d2270 100644
--- a/usr/src/cmd/csh/sh.char.c
+++ b/usr/src/cmd/csh/sh.char.c
@@ -12,10 +12,9 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.char.h"
+unsigned int Z;
unsigned short _cmap[128] = {
/* nul soh stx etx */
0, 0, 0, 0,
diff --git a/usr/src/cmd/csh/sh.char.h b/usr/src/cmd/csh/sh.char.h
index 3a46db7ba9..a76808b854 100644
--- a/usr/src/cmd/csh/sh.char.h
+++ b/usr/src/cmd/csh/sh.char.h
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Macros to classify characters.
*/
@@ -35,7 +33,7 @@
#define isauxspZ 0
#endif
extern unsigned short _cmap[];/* Defined in sh.char.c */
-unsigned int Z; /* A place to save macro arg to avoid side-effect!*/
+extern unsigned int Z; /* A place to save macro arg to avoid side-effect!*/
#define _Q 0x01 /* '" */
#define _Q1 0x02 /* ` */
diff --git a/usr/src/cmd/csh/sh.dir.c b/usr/src/cmd/csh/sh.dir.c
index 29031692f5..3ba63280a5 100644
--- a/usr/src/cmd/csh/sh.dir.c
+++ b/usr/src/cmd/csh/sh.dir.c
@@ -13,8 +13,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include "sh.dir.h"
#include "sh.tconst.h"
@@ -30,9 +28,15 @@ void dtildepr(tchar *, tchar *);
void dfree(struct directory *);
void dnewcwd(struct directory *);
+int didchdir;
+bool loginsh;
+bool havhash2;
+struct varent shvhed;
+struct directory *dcwd;
struct directory dhead; /* "head" of loop */
int printd; /* force name to be printed */
static tchar *fakev[] = { S_dirs, NOSTR };
+char xhash2[HSHSIZ / 8];
/*
* dinit - initialize current working directory
diff --git a/usr/src/cmd/csh/sh.dir.h b/usr/src/cmd/csh/sh.dir.h
index 78ece4a533..47d705534a 100644
--- a/usr/src/cmd/csh/sh.dir.h
+++ b/usr/src/cmd/csh/sh.dir.h
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Structure for entries in directory stack.
*/
@@ -21,6 +19,6 @@ struct directory {
struct directory *di_next; /* next in loop */
struct directory *di_prev; /* prev in loop */
unsigned short *di_count; /* refcount of processes */
- tchar *di_name; /* actual name */
+ tchar *di_name; /* actual name */
};
-struct directory *dcwd; /* the one we are in now */
+extern struct directory *dcwd; /* the one we are in now */
diff --git a/usr/src/cmd/csh/sh.dol.c b/usr/src/cmd/csh/sh.dol.c
index fe0b88f4b0..8d963e7239 100644
--- a/usr/src/cmd/csh/sh.dol.c
+++ b/usr/src/cmd/csh/sh.dol.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <unistd.h> /* for lseek prototype */
#include "sh.h"
#include "sh.tconst.h"
@@ -22,6 +20,17 @@
* C shell
*/
+bool noexec;
+long gargc;
+short OLDSTD;
+short gflag;
+tchar *bname;
+tchar *file;
+tchar **gargv;
+tchar *doldol;
+tchar *lap;
+tchar **pargv;
+
/*
* These routines perform variable substitution and quoting via ' and ".
* To this point these constructs have been preserved in the divided
@@ -297,7 +306,7 @@ quotspec:
* the input is original, not from a substitution and
* therefore should not be quoted
*/
- if (!err && cmap(c, QUOTES))
+ if (!err_msg && cmap(c, QUOTES))
return (c | QUOTE);
return (c);
}
diff --git a/usr/src/cmd/csh/sh.err.c b/usr/src/cmd/csh/sh.err.c
index 813450b297..99644044b2 100644
--- a/usr/src/cmd/csh/sh.err.c
+++ b/usr/src/cmd/csh/sh.err.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include <locale.h>
#include <dirent.h>
@@ -27,11 +25,18 @@
* C Shell
*/
-
+bool child;
+bool didfds;
+bool exiterr;
bool errspl; /* Argument to error was spliced by seterr2 */
+bool haderr;
+jmp_buf reslab;
tchar one[2] = { '1', 0 };
tchar *onev[2] = { one, NOSTR };
-/*
+short SHDIAG;
+int tpgrp;
+
+/*
* contains DIR * for last opendir_(), its left open if an error
* longjmp (reset) occurs before it gets closed via closedir.
* if its not null in the error handler, then closedir it.
@@ -65,7 +70,6 @@ error(s, a1, a2)
*/
flush();
haderr = 1; /* Now to diagnostic output */
- timflg = 0; /* This isn't otherwise reset */
if (v = pargv)
pargv = 0, blkfree(v);
if (v = gargv)
@@ -76,12 +80,12 @@ error(s, a1, a2)
* an error diagnostic here.
*/
if (s) {
- printf(s, a1, a2), printf("\n");
+ printf(s, a1, a2), printf("\n");
}
-
+
didfds = 0; /* Forget about 0,1,2 */
- if ((ep = err) && errspl) {
+ if ((ep = err_msg) && errspl) {
errspl = 0;
xfree(ep);
}
@@ -155,8 +159,8 @@ void
seterr(char *s)
{
- if (err == 0)
- err = s, errspl = 0;
+ if (err_msg == NULL)
+ err_msg = s, errspl = 0;
}
/* Set err to a splice of cp and dp, to be freed later in error() */
@@ -166,27 +170,27 @@ seterr2(tchar *cp, char *dp)
char chbuf[BUFSIZ];
char *gdp;
- if (err)
+ if (err_msg)
return;
/* Concatinate cp and dp in the allocated space. */
tstostr(chbuf, cp);
gdp = gettext(dp);
- err = (char *)xalloc(strlen(chbuf)+strlen(gdp)+1);
- strcpy(err, chbuf);
- strcat(err, gdp);
+ err_msg = (char *)xalloc(strlen(chbuf)+strlen(gdp)+1);
+ strcpy(err_msg, chbuf);
+ strcat(err_msg, gdp);
- errspl++;/* Remember to xfree(err). */
+ errspl++;/* Remember to xfree(err_msg). */
}
/* Set err to a splice of cp with a string form of character d */
void
seterrc(char *cp, tchar d)
{
- char chbuf[MB_LEN_MAX+1];
+ char chbuf[MB_LEN_MAX+1];
/* don't overwrite an existing error message */
- if (err)
+ if (err_msg)
return;
#ifdef MBCHAR
@@ -203,9 +207,9 @@ seterrc(char *cp, tchar d)
/* Concatinate cp and d in the allocated space. */
- err = (char *)xalloc(strlen(cp)+strlen(chbuf)+1);
- strcpy(err, cp);
- strcat(err, chbuf);
+ err_msg = (char *)xalloc(strlen(cp)+strlen(chbuf)+1);
+ strcpy(err_msg, cp);
+ strcat(err_msg, chbuf);
- errspl++; /* Remember to xfree(err). */
+ errspl++; /* Remember to xfree(err_msg). */
}
diff --git a/usr/src/cmd/csh/sh.exec.c b/usr/src/cmd/csh/sh.exec.c
index eee2d16440..06648c9c35 100644
--- a/usr/src/cmd/csh/sh.exec.c
+++ b/usr/src/cmd/csh/sh.exec.c
@@ -28,6 +28,21 @@
* If there is no search path then we execute only full path names.
*/
+char xhash[HSHSIZ / 8];
+tchar **Vav;
+tchar *Vdp;
+tchar *Vsav;
+
+struct varent aliases;
+bool havhash;
+static int hits;
+static int misses;
+short SHOUT;
+short SHIN;
+
+void (*parintr)();
+void (*parterm)();
+
/*
* As we search for the command we note the first non-trivial error
* message for presentation to the user. This allows us often
diff --git a/usr/src/cmd/csh/sh.exp.c b/usr/src/cmd/csh/sh.exp.c
index 2447692682..ad94bf5b04 100644
--- a/usr/src/cmd/csh/sh.exp.c
+++ b/usr/src/cmd/csh/sh.exp.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include "sh.tconst.h"
@@ -38,6 +36,8 @@
#define EQMATCH 7
#define NOTEQMATCH 8
+int uid;
+
int exp0(tchar ***, bool);
int exp1(tchar ***, bool);
int exp2(tchar ***, bool);
@@ -72,7 +72,7 @@ chk_access(tchar *path, mode_t mode)
unsigned char name[MAXPATHLEN*MB_LEN_MAX]; /* General use buffer. */
/* convert tchar * to char * */
- tstostr(name, path);
+ tstostr((char *)name, path);
if (flag == 0) {
euid = geteuid();
@@ -611,8 +611,8 @@ evalav(tchar **v)
hp->prev = wdp;
alias(&paraml);
t = syntax(paraml.next, &paraml, 0);
- if (err)
- error("%s", gettext(err));
+ if (err_msg)
+ error("%s", gettext(err_msg));
execute(t, -1);
freelex(&paraml), freesyn(t);
}
diff --git a/usr/src/cmd/csh/sh.func.c b/usr/src/cmd/csh/sh.func.c
index 79350599df..7d3740cef8 100644
--- a/usr/src/cmd/csh/sh.func.c
+++ b/usr/src/cmd/csh/sh.func.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include <locale.h> /* For LC_ALL */
#include "sh.tconst.h"
@@ -50,6 +48,19 @@ struct limits {
-1, 0,
};
+struct Bin B;
+struct whyle *whyles;
+bool chkstop;
+bool doneinp;
+bool intty;
+bool setintr;
+int shpgrp;
+int opgrp;
+off_t lineloc;
+tchar *evalp;
+tchar **evalvec;
+tchar *gointr;
+
static int getval(struct limits *lp, tchar **v, rlim_t *);
void islogin(void);
diff --git a/usr/src/cmd/csh/sh.glob.c b/usr/src/cmd/csh/sh.glob.c
index db0122c0c6..db878615da 100644
--- a/usr/src/cmd/csh/sh.glob.c
+++ b/usr/src/cmd/csh/sh.glob.c
@@ -25,13 +25,18 @@
* C Shell
*/
+static long pargc;
+static long gnleft;
+static long pnleft;
int globcnt;
-
+tchar *arginp;
+static tchar *pargs;
tchar *gpath, *gpathp, *lastgpathp;
int globbed;
bool noglob;
bool nonomatch;
tchar *entp;
+static tchar *pargcp;
tchar **sortbas;
int sortscmp(tchar **, tchar **);
void ginit(tchar **);
@@ -800,12 +805,12 @@ backeval(tchar *cp, bool literal)
HIST = 0;
(void) lex(&paraml);
HIST = oHIST;
- if (err)
- error("%s", gettext(err));
+ if (err_msg)
+ error("%s", gettext(err_msg));
alias(&paraml);
t = syntax(paraml.next, &paraml, 0);
- if (err)
- error("%s", gettext(err));
+ if (err_msg)
+ error("%s", gettext(err_msg));
if (t)
t->t_dflg |= FPAR;
(void) signal(SIGTSTP, SIG_IGN);
diff --git a/usr/src/cmd/csh/sh.h b/usr/src/cmd/csh/sh.h
index 6aaf4a716f..b394ca2bbc 100644
--- a/usr/src/cmd/csh/sh.h
+++ b/usr/src/cmd/csh/sh.h
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdlib.h> /* MB_xxx, mbxxx(), wcxxx() etc. */
#include <limits.h>
#include <sys/time.h>
@@ -71,7 +69,7 @@
* However, if the user set $cwd, we want the globbing
* done; so, didchdir would be equal to 0 in that case.
*/
-int didchdir;
+extern int didchdir;
#define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR)
@@ -104,51 +102,45 @@ typedef unsigned short int tchar;
/*
* Global flags
*/
-bool chkstop; /* Warned of stopped jobs... allow exit */
-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 child; /* Child shell ... errors cause exit */
-bool haderr; /* Reset was because of an error */
-bool intty; /* Input is a tty */
-bool cflg; /* invoked with -c option */
-bool intact; /* We are interactive... therefore prompt */
-bool justpr; /* Just print because of :p hist mod */
-bool loginsh; /* We are a loginsh -> .login/.logout */
-bool neednote; /* Need to pnotify() */
-bool noexec; /* Don't execute, just syntax check */
-bool pjobs; /* want to print jobs if interrupted */
-bool pfcshflag; /* set to 0 for pfcsh */
-bool setintr; /* Set interrupts on/off -> Wait intr... */
-bool timflg; /* Time the next waited for command */
-bool havhash; /* path hashing is available */
-bool havhash2; /* cdpath hashing is available */
+extern bool chkstop; /* Warned of stopped jobs... allow exit */
+extern bool didfds; /* Have setup i/o fd's for child */
+extern bool doneinp; /* EOF indicator after reset from readc */
+extern bool exiterr; /* Exit if error or non-zero exit status */
+extern bool child; /* Child shell ... errors cause exit */
+extern bool haderr; /* Reset was because of an error */
+extern bool intty; /* Input is a tty */
+extern bool cflg; /* invoked with -c option */
+extern bool justpr; /* Just print because of :p hist mod */
+extern bool loginsh; /* We are a loginsh -> .login/.logout */
+extern bool neednote; /* Need to pnotify() */
+extern bool noexec; /* Don't execute, just syntax check */
+extern bool pjobs; /* want to print jobs if interrupted */
+extern bool setintr; /* Set interrupts on/off -> Wait intr... */
+extern bool havhash; /* path hashing is available */
+extern bool havhash2; /* cdpath hashing is available */
#ifdef FILEC
-bool filec; /* doing filename expansion */
+extern bool filec; /* doing filename expansion */
#endif
/*
* Global i/o info
*/
-tchar *arginp; /* Argument input for sh -c and internal `xx` */
-int onelflg; /* 2 -> need line for -t, 1 -> exit on read */
-tchar *file; /* Name of shell file for $0 */
+extern tchar *arginp; /* Argument input for sh -c and internal `xx` */
+extern int onelflg; /* 2 -> need line for -t, 1 -> exit on read */
+extern tchar *file; /* Name of shell file for $0 */
-char *err; /* Error message from scanner/parser */
-struct timeval time0; /* Time at which the shell started */
-struct rusage ru0;
+extern char *err_msg; /* Error message from scanner/parser */
+extern struct timeval time0; /* Time at which the shell started */
/*
* Miscellany
*/
-tchar *doldol; /* Character pid for $$ */
-int uid; /* Invokers uid */
-time_t chktim; /* Time mail last checked */
-int shpgrp; /* Pgrp of shell */
-int tpgrp; /* Terminal process group */
+extern tchar *doldol; /* Character pid for $$ */
+extern int uid; /* Invokers uid */
+extern int shpgrp; /* Pgrp of shell */
+extern 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 */
+extern int opgrp; /* Initial pgrp and tty pgrp */
/*
* These are declared here because they want to be
@@ -176,10 +168,10 @@ extern int nsrchn;
* The desired initial values for these descriptors are defined in
* sh.local.h.
*/
-short SHIN; /* Current shell input (script) */
-short SHOUT; /* Shell output */
-short SHDIAG; /* Diagnostic output... shell errs go here */
-short OLDSTD; /* Old standard input (def for cmds) */
+extern short SHIN; /* Current shell input (script) */
+extern short SHOUT; /* Shell output */
+extern short SHDIAG; /* Diagnostic output... shell errs go here */
+extern short OLDSTD; /* Old standard input (def for cmds) */
/*
* Error control
@@ -189,7 +181,7 @@ short OLDSTD; /* Old standard input (def for cmds) */
* Because of source commands and .cshrc we need nested error catches.
*/
-jmp_buf reslab;
+extern jmp_buf reslab;
#define setexit() ((void) setjmp(reslab))
#define reset() longjmp(reslab, 0)
@@ -197,9 +189,9 @@ jmp_buf reslab;
#define getexit(a) copy((void *)(a), (void *)reslab, sizeof reslab)
#define resexit(a) copy((void *)reslab, ((void *)(a)), sizeof reslab)
-tchar *gointr; /* Label for an onintr transfer */
-void (*parintr)(); /* Parents interrupt catch */
-void (*parterm)(); /* Parents terminate catch */
+extern tchar *gointr; /* Label for an onintr transfer */
+extern void (*parintr)(); /* Parents interrupt catch */
+extern void (*parterm)(); /* Parents terminate catch */
/*
@@ -209,7 +201,7 @@ void (*parterm)(); /* Parents terminate catch */
* In other cases, the shell buffers enough blocks to keep all loops
* in the buffer.
*/
-struct Bin {
+extern struct Bin {
off_t Bfseekp; /* Seek pointer */
off_t Bfbobp; /* Seekp of beginning of buffers */
off_t Bfeobp; /* Seekp of end of buffers */
@@ -226,7 +218,7 @@ struct Bin {
#define btell() fseekp
#ifndef btell
-off_t btell(void);
+extern off_t btell(void);
#endif
/*
@@ -234,10 +226,10 @@ off_t btell(void);
* For whiles, in particular, it reseeks to the beginning of the
* line the while was on; hence the while placement restrictions.
*/
-off_t lineloc;
+extern off_t lineloc;
#ifdef TELL
-bool cantell; /* Is current source tellable ? */
+extern bool cantell; /* Is current source tellable ? */
#endif
/*
@@ -263,16 +255,7 @@ struct wordent {
#define DOEXCL 2
#define DOALL DODOL|DOEXCL
-/*
- * 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.
- */
-tchar *labuf;
-
-tchar *lap;
+extern tchar *lap;
/*
* Parser structure
@@ -355,7 +338,7 @@ struct command {
* source level. Loops are implemented by seeking back in the
* input. For foreach (fe), the word list is attached here.
*/
-struct whyle {
+extern struct whyle {
off_t w_start; /* Point to restart loop */
off_t w_end; /* End of loop (0 if unknown) */
tchar **w_fe, **w_fe0; /* Current/initial wordlist for fe */
@@ -368,7 +351,7 @@ struct whyle {
*
* Aliases and variables are stored in AVL balanced binary trees.
*/
-struct varent {
+extern struct varent {
tchar **vec; /* Array of words which is the value */
tchar *v_name; /* Name of variable/alias */
struct varent *v_link[3]; /* The links, see below */
@@ -398,14 +381,14 @@ struct varent *adrof1();
* The following are for interfacing redo substitution in
* aliases to the lexical routines.
*/
-struct wordent *alhistp; /* Argument list (first) */
-struct wordent *alhistt; /* Node after last in arg list */
-tchar **alvec; /* The (remnants of) alias vector */
+extern struct wordent *alhistp; /* Argument list (first) */
+extern struct wordent *alhistt; /* Node after last in arg list */
+extern tchar **alvec; /* The (remnants of) alias vector */
/*
* Filename/command name expansion variables
*/
-short gflag; /* After tglob -> is globbing needed? */
+extern short gflag; /* After tglob -> is globbing needed? */
/*
* A reasonable limit on number of arguments would seem to be
@@ -427,18 +410,13 @@ short gflag; /* After tglob -> is globbing needed? */
/*
* Variables for filename expansion
*/
-tchar **gargv; /* Pointer to the (stack) arglist */
-long gargc; /* Number args in gargv */
-long gnleft;
+extern tchar **gargv; /* Pointer to the (stack) arglist */
+extern long gargc; /* Number args in gargv */
/*
* Variables for command expansion.
*/
-tchar **pargv; /* Pointer to the argv list space */
-tchar *pargs; /* Pointer to start current word */
-long pargc; /* Count of arguments in pargv */
-long pnleft; /* Number of chars left in pargs */
-tchar *pargcp; /* Current index into pargs */
+extern tchar **pargv; /* Pointer to the argv list space */
/*
* History list
@@ -451,19 +429,18 @@ tchar *pargcp; /* Current index into pargs */
* when history substitution includes modifiers, and thrown away
* at the next discarding since their event numbers are very negative.
*/
-struct Hist {
+extern struct Hist {
struct wordent Hlex;
int Hnum;
int Href;
struct Hist *Hnext;
} Histlist;
-struct wordent paraml; /* Current lexical word list */
-int eventno; /* Next events number */
-int lastev; /* Last event reference (default) */
+extern struct wordent paraml; /* Current lexical word list */
+extern int eventno; /* Next events number */
-tchar HIST; /* history invocation character */
-tchar HISTSUB; /* auto-substitute character */
+extern tchar HIST; /* history invocation character */
+extern tchar HISTSUB; /* auto-substitute character */
extern void *xalloc(size_t);
extern void *xcalloc(size_t, size_t);
@@ -511,7 +488,7 @@ extern tchar *value1(tchar *, struct varent *);
* Here we are dynamically reallocating the bname to the new length
* to store the new path
*/
-tchar *bname;
+extern tchar *bname;
#define setname(a) { \
bname = xrealloc(bname, (strlen_(a)+1) * sizeof (tchar)); \
strcpy_(bname, a); \
@@ -519,17 +496,17 @@ tchar *bname;
}
#ifdef VFORK
-tchar *Vsav;
-tchar **Vav;
-tchar *Vdp;
+extern tchar *Vsav;
+extern tchar **Vav;
+extern tchar *Vdp;
#endif
-tchar **evalvec;
-tchar *evalp;
+extern tchar **evalvec;
+extern tchar *evalp;
/* Conversion functions between char and tchar strings. */
-tchar *strtots(/* tchar * , char * */);
-char *tstostr(/* char * , tchar * */);
+tchar *strtots(tchar *, char *);
+char *tstostr(char *, tchar *);
#ifndef NULL
#define NULL 0
@@ -559,11 +536,8 @@ char *tstostr(/* char * , tchar * */);
* variable.
*/
-char xhash[HSHSIZ / 8];
-char xhash2[HSHSIZ / 8];
+extern char xhash[HSHSIZ / 8];
+extern char xhash2[HSHSIZ / 8];
#define hash(a, b) ((a) * HSHMUL + (b) & HSHMASK)
#define bit(h, b) ((h)[(b) >> 3] & 1 << ((b) & 7)) /* bit test */
#define bis(h, b) ((h)[(b) >> 3] |= 1 << ((b) & 7)) /* bit set */
-#ifdef VFORK
-int hits, misses;
-#endif
diff --git a/usr/src/cmd/csh/sh.hist.c b/usr/src/cmd/csh/sh.hist.c
index fb8b5e06ce..c1bc5a2851 100644
--- a/usr/src/cmd/csh/sh.hist.c
+++ b/usr/src/cmd/csh/sh.hist.c
@@ -12,11 +12,12 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include "sh.tconst.h"
+struct Hist Histlist;
+int eventno;
+
struct Hist *enthist(int, struct wordent *, bool);
void hfree(struct Hist *);
void dohist1(struct Hist *, int *, int, int);
diff --git a/usr/src/cmd/csh/sh.lex.c b/usr/src/cmd/csh/sh.lex.c
index 4286f8669a..8b1522067e 100644
--- a/usr/src/cmd/csh/sh.lex.c
+++ b/usr/src/cmd/csh/sh.lex.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <unistd.h> /* for lseek prototype */
#include "sh.h"
#include "sh.tconst.h"
@@ -24,6 +22,14 @@
* C shell
*/
+bool justpr;
+static int lastev;
+int onelflg;
+tchar **alvec;
+struct wordent *alhistp;
+struct wordent *alhistt;
+struct wordent paraml;
+
/*
* These lexical routines read input and form lists of words.
* There is some involved processing here, because of the complications
@@ -330,7 +336,7 @@ top:
* the input is original, not from a substitution and
* therefore should not be quoted
*/
- if (!err && cmap(c, _META|_Q|_Q1)||isauxsp(c))
+ if (!err_msg && cmap(c, _META|_Q|_Q1)||isauxsp(c))
c |= QUOTE;
return (c);
}
@@ -480,6 +486,7 @@ void
addla(tchar *cp)
{
tchar *buf;
+ static tchar *labuf = NULL;
int len = 0;
#ifdef TRACE
diff --git a/usr/src/cmd/csh/sh.parse.c b/usr/src/cmd/csh/sh.parse.c
index b936126c8d..60801ec25e 100644
--- a/usr/src/cmd/csh/sh.parse.c
+++ b/usr/src/cmd/csh/sh.parse.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include "sh.tconst.h"
@@ -150,9 +148,9 @@ asyn3(struct wordent *p1, struct wordent *p2)
redid = lex(&alout);
alhistp = alhistt = 0;
alvec = 0;
- if (err) {
+ if (err_msg) {
freelex(&alout);
- error("%s", gettext(err));
+ error("%s", gettext(err_msg));
}
if (p1->word[0] && eq(p1->word, alout.next->word)) {
tchar *cp = alout.next->word;
@@ -623,7 +621,7 @@ savep:
default:
if (l != 0 && !specp)
continue;
- if (err == 0)
+ if (err_msg == NULL)
av[n] = savestr(p->word);
n++;
continue;
diff --git a/usr/src/cmd/csh/sh.proc.c b/usr/src/cmd/csh/sh.proc.c
index 298c2e718a..4dc608c88c 100644
--- a/usr/src/cmd/csh/sh.proc.c
+++ b/usr/src/cmd/csh/sh.proc.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include "sh.dir.h"
#include "sh.proc.h"
@@ -24,6 +22,15 @@
* C Shell - functions that manage processes, handling hanging, termination
*/
+bool neednote;
+bool pjobs;
+static struct process *pprevious;
+static short pmaxindex;
+static struct process proclist;
+static struct process *pcurrent;
+struct process *pcurrjob;
+static struct process *pholdjob;
+
#define BIGINDEX 9 /* largest desirable job index */
void pjwait(struct process *);
@@ -71,7 +78,6 @@ loop:
errno = 0;
goto loop;
}
- pnoprocesses = pid == -1;
return;
}
for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next)
diff --git a/usr/src/cmd/csh/sh.proc.h b/usr/src/cmd/csh/sh.proc.h
index 67aa69f763..eb275ba39d 100644
--- a/usr/src/cmd/csh/sh.proc.h
+++ b/usr/src/cmd/csh/sh.proc.h
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* C shell - process structure declarations
*/
@@ -78,13 +76,4 @@ struct process {
#define JOBDIR 0100 /* print job's dir if not the same */
#define AREASON 0200
-struct process proclist; /* list head of all processes */
-bool pnoprocesses; /* pchild found nothing to wait for */
-
-struct process *pholdjob; /* one level stack of current jobs */
-
-struct process *pcurrjob; /* current job */
-struct process *pcurrent; /* current job in table */
-struct process *pprevious; /* previous job in table */
-
-short pmaxindex; /* current maximum job index */
+extern struct process *pcurrjob; /* current job */
diff --git a/usr/src/cmd/csh/sh.set.c b/usr/src/cmd/csh/sh.set.c
index 51f49ae4f4..6ce3eb93c9 100644
--- a/usr/src/cmd/csh/sh.set.c
+++ b/usr/src/cmd/csh/sh.set.c
@@ -12,11 +12,8 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include "sh.tconst.h"
-extern int didchdir;
/*
* C Shell
diff --git a/usr/src/cmd/csh/sh.tchar.c b/usr/src/cmd/csh/sh.tchar.c
index acd7856e0e..767294af16 100644
--- a/usr/src/cmd/csh/sh.tchar.c
+++ b/usr/src/cmd/csh/sh.tchar.c
@@ -12,8 +12,6 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This module provides with system/library function substitutes for tchar
* datatype. This also includes two conversion functions between tchar and
@@ -51,6 +49,7 @@
#include <fcntl.h>
#include <unistd.h>
+bool cflg;
/*
* strtots(to, from): convert a char string 'from' into a tchar buffer 'to'.
diff --git a/usr/src/cmd/csh/sh.time.c b/usr/src/cmd/csh/sh.time.c
index 1c92bc61ef..e53db7fe80 100644
--- a/usr/src/cmd/csh/sh.time.c
+++ b/usr/src/cmd/csh/sh.time.c
@@ -12,11 +12,12 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "sh.h"
#include "sh.tconst.h"
+struct timeval time0;
+static struct rusage ru0;
+
void ruadd(struct rusage *ru, struct rusage *ru2);
void prusage(struct rusage *r0, struct rusage *r1, struct timeval *e,
struct timeval *b);