*.a
*.allprotos
+*.cproto
*.nocomm
*.o
*.oldprotos
LIBES=
SCCS= sccs
-OBJS= malloc.o doprnt.o printf.o sh.o sh.char.o sh.data.o sh.dir.o sh.dol.o \
- sh.err.o sh.exec.o sh.exp.o sh.file.o sh.func.o sh.glob.o sh.hist.o \
- sh.init.o sh.lex.o sh.misc.o sh.parse.o sh.print.o sh.proc.o sh.sem.o \
- sh.set.o sh.time.o sh.end.o
+OBJS= malloc.o doprnt.o printf.o vprintf.o sh.o sh.char.o sh.data.o \
+ sh.dir.o sh.dol.o sh.err.o sh.exec.o sh.exp.o sh.file.o sh.func.o \
+ sh.glob.o sh.hist.o sh.init.o sh.lex.o sh.misc.o sh.parse.o \
+ sh.print.o sh.proc.o sh.sem.o sh.set.o sh.time.o sh.end.o
# do things the standard way for Linux hosted version, fix this properly later
csh: ${OBJS}
-/*#include <ctype.h> sh.h*/
+#include <ctype.h>
/*#include <math.h> sh.h*/
#include <memory.h>
/*#include <strings.h> sh.h*/
#endif
#include "sh.h"
+#ifdef __STDC__
+#include <stdint.h>
+#else
+typedef long intptr_t;
+#ypedef u_long uintptr_t;
+#endif
+
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
static char *round __P((double fract, int *exp, register char *start, register char *end, int ch, char *signp));
static char *exponent __P((register char *p, register int exp, int fmtch));
-int _doprnt(fmt0, argp) u_char *fmt0; va_list argp;
+int _doprnt(fmt, argp) char *fmt; va_list argp;
/*register FILE *fp;*/ {
- register u_char *fmt; /* format string */
register int ch; /* character from fmt */
register int cnt; /* return value accumulator */
register int n; /* random handy integer */
register char *t; /* buffer pointer */
double _double; /* double precision arguments %[eEfgG] */
- u_long _ulong; /* integer arguments %[diouxX] */
+ uintptr_t _ulong; /* integer arguments %[diouxX] */
int base; /* base for [diouxX] conversion */
int dprec; /* decimal precision in [diouxX] */
int fieldsz; /* field size expanded by sign, etc */
return (EOF);
#endif
- fmt = fmt0;
digs = "0123456789abcdef";
for (cnt = 0;; ++fmt) {
#if 1 /* for csh */
case 'd':
case 'i':
ARG();
- if ((long)_ulong < 0) {
+ if ((intptr_t)_ulong < 0) {
_ulong = -_ulong;
sign = '-';
}
* -- ANSI X3J11
*/
/* NOSTRICT */
- _ulong = (u_long)va_arg(argp, void *);
+ _ulong = (uintptr_t)va_arg(argp, void *);
base = 16;
goto nosign;
case 's':
#if defined(DEBUG) || defined(RCHECK)
#define ASSERT(p) if (!(p)) botch("p")
-static void botch __P((char *s));
-static findbucket __P((union overhead *freep, int srchlen));
-
static void botch(s) char *s; {
printf("\r\nassertion botched: %s\r\n", s);
abort();
#define ASSERT(p)
#endif
+static findbucket __P((union overhead *freep, int srchlen));
+
void *malloc(nbytes) unsigned nbytes; {
register union overhead *op;
register int bucket;
amt = 16; /* size of first bucket */
bucket = 1;
#endif
- n = -(sizeof (*op) + RSLOP);
+ n = -(int)(sizeof (*op) + RSLOP);
} else {
amt = pagesz;
bucket = pagebucket;
}
op = (union overhead *)sbrk(amt);
/* no more room! */
- if ((int)op == -1)
+ if (op == (union overhead *)-1)
return;
/*
* Add new memory allocated to that on
* for each size category, the second showing the number of mallocs -
* frees for each size category.
*/
-void showall(s) char **s; {
+void showall(s, kp) char **s; struct command *kp; {
register int i, j;
register union overhead *p;
int totfree = 0,
/*extern gid_t getegid(), getgid();*/
/*extern uid_t geteuid(), getuid();*/
-int main(c, av) int c; char **av; {
+void main(c, av) int c; char **av; {
register char **v, *cp;
register int f;
struct sigvec osv;
*/
/* parents interruptibility */
(void) sigvec(SIGINT, (struct sigvec *)0, &osv);
- parintr = osv.sv_handler;
+ parintr = (void (*) __P((int sig)))osv.sv_handler;
/* parents terminability */
(void) sigvec(SIGTERM, (struct sigvec *)0, &osv);
- parterm = osv.sv_handler;
+ parterm = (void (*) __P((int sig)))osv.sv_handler;
if (loginsh) {
- (void) signal(SIGHUP, phup); /* exit processing on HUP */
- (void) signal(SIGXCPU, phup); /* ...and on XCPU */
- (void) signal(SIGXFSZ, phup); /* ...and on XFSZ */
+ (void) signal(SIGHUP, (void (*) __P((int sig)))phup); /* exit processing on HUP */
+ (void) signal(SIGXCPU, (void (*) __P((int sig)))phup); /* ...and on XCPU */
+ (void) signal(SIGXFSZ, (void (*) __P((int sig)))phup); /* ...and on XFSZ */
}
/*
**av = '-';
if (!quitit) /* Wary! */
(void) signal(SIGQUIT, SIG_IGN);
- (void) signal(SIGINT, pintr);
+ (void) signal(SIGINT, (void (*) __P((int sig)))pintr);
(void) sigblock(sigmask(SIGINT));
(void) signal(SIGTERM, SIG_IGN);
if (quitit == 0 && arginp == 0) {
tpgrp != -1) {
int ldisc;
if (tpgrp != shpgrp) {
- int (*old)() = signal(SIGTTIN, SIG_DFL);
+ void (*old) __P((int sig)) = signal(SIGTTIN, SIG_DFL);
(void) kill(0, SIGTTIN);
(void) signal(SIGTTIN, old);
goto retry;
}
if (setintr == 0 && parintr == SIG_DFL)
setintr++;
- (void) signal(SIGCHLD, pchild); /* while signals not ready */
+ (void) signal(SIGCHLD, (void (*) __P((int sig)))pchild); /* while signals not ready */
/*
* Set an exit here in case of an interrupt or error reading
/* Will have value("home") here because set fast if don't */
srccat(value("home"), "/.cshrc");
if (!fast && !arginp && !onelflg && !havhash)
+#if defined(__STDC__) || defined(lint)
+ dohash(0, 0);
+#else
dohash();
+#endif
if (loginsh) {
srccat(value("home"), "/.login");
}
+#if defined(__STDC__) || defined(lint)
+ dosource(loadhist, 0);
+#else
dosource(loadhist);
+#endif
}
/*
exitstat();
}
-int untty() {
+void untty() {
if (tpgrp > 0) {
(void) setpgrp(0, opgrp);
}
}
-int importpath(cp) char *cp; {
+void importpath(cp) char *cp; {
register int i = 0;
register char *dp;
register char **pv;
/*
* Source to the file which is the catenation of the argument names.
*/
-int srccat(cp, dp) char *cp; char *dp; {
+void srccat(cp, dp) char *cp; char *dp; {
register char *ep = strspl(cp, dp);
register int unit = dmove(open(ep, 0), -1);
* Source to a unit. If onlyown it must be our file or our group or
* we don't chance it. This occurs on ".cshrc"s and the like.
*/
-int srcunit(unit, onlyown, hflg) register int unit; int onlyown; int hflg; {
+void srcunit(unit, onlyown, hflg) register int unit; int onlyown; int hflg; {
/* We have to push down a lot of state here */
/* All this could go into a structure */
int oSHIN = -1, oldintty = intty;
error(NOSTR);
}
-int rechist() {
+void rechist() {
char buf[BUFSIZ];
int fp, ftmp, oldidfds;
SHOUT = fp;
(void) strcpy(buf, value("savehist"));
dumphist[2] = buf;
+#if defined(__STDC__) || defined(lint)
+ dohist(dumphist, 0);
+#else
dohist(dumphist);
+#endif
(void) close(fp);
SHOUT = ftmp;
didfds = oldidfds;
}
}
-int goodbye() {
+void goodbye() {
if (loginsh) {
(void) signal(SIGQUIT, SIG_IGN);
(void) signal(SIGINT, SIG_IGN);
exitstat();
}
-int exitstat() {
+void exitstat() {
#ifdef PROF
monitor(0);
/*
* in the event of a HUP we want to save the history
*/
-int phup() {
+void phup() {
rechist();
exit(1);
}
* and finally go through the normal error mechanism, which
* gets a chance to make the shell go away.
*/
-int pintr() {
+void pintr() {
pintr1(1);
}
-int pintr1(wantnl) int wantnl; {
+void pintr1(wantnl) int wantnl; {
register char **v;
int omask;
if (pjobs) {
pjobs = 0;
printf("\n");
+#if defined(__STDC__) || defined(lint)
+ dojobs(jobargv, 0);
+#else
dojobs(jobargv);
+#endif
bferr("Interrupted");
}
}
* Note that if catch is not set then we will unwind on any error.
* If an end-of-file occurs, we return.
*/
-int process(catch) int catch; {
+void process(catch) int catch; {
jmp_buf osetexit;
register struct command *t;
resexit(osetexit);
}
-int dosource(t) register char **t; {
+void dosource(t, kp) char **t; struct command *kp; {
register char *f;
register int u;
bool hflg = 0;
* knows, since the login program insists on saying
* "You have mail."
*/
-int mailchk() {
+void mailchk() {
register struct varent *v;
register char **vp;
time_t t;
* Move the initial descriptors to their eventual
* resting places, closin all other units.
*/
-int initdesc() {
+void initdesc() {
didfds = 0; /* 0, 1, 2 aren't set up */
(void) ioctl(SHIN = dcopy(0, FSHIN), FIOCLEX, (char *)0);
_exit(i);
}
-int printprompt() {
+void printprompt() {
register char *cp;
if (!whyles) {
#ifndef _SH_CHAR_H_
#define _SH_CHAR_H_
-#include <ctype.h>
-
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley Software License Agreement
#define cmap(c, bits) (_cmap[(unsigned char)(c)] & (bits))
#define isglob(c) cmap(c, _GLOB)
-#define isspace(c) cmap(c, _SP)
+#define _isspace(c) cmap(c, _SP)
#define isspnl(c) cmap(c, _SP|_NL)
#define ismeta(c) cmap(c, _META)
#define digit(c) cmap(c, _DIG)
/*
* In lines for frequently called functions
*/
-char *alloctmp;
+void *alloctmp;
/*
* setname is a macro to save space (see sh.err.c)
/*
* dinit - initialize current working directory
*/
-int dinit(hp) char *hp; {
+void dinit(hp) char *hp; {
register char *cp;
register struct directory *dp;
char path[MAXPATHLEN];
/*
* dodirs - list all directories in directory loop
*/
-int dodirs(v) char **v; {
+void dodirs(v, kp) char **v; struct command *kp; {
register struct directory *dp;
bool lflag;
char *hp = value("home");
printf("\n");
}
-int dtildepr(home, dir) register char *home; register char *dir; {
+void dtildepr(home, dir) register char *home; register char *dir; {
if (!eq(home, "/") && prefix(home, dir))
printf("~%s", dir + strlen(home));
/*
* dochngd - implement chdir command.
*/
-int dochngd(v) char **v; {
+void dochngd(v, kp) char **v; struct command *kp; {
register char *cp;
register struct directory *dp;
* with no arguments exchange top and second.
* with numeric argument (+n) bring it to top.
*/
-int dopushd(v) char **v; {
+void dopushd(v, kp) char **v; struct command *kp; {
register struct directory *dp;
printd = 1;
* dopopd - pop a directory out of the directory stack
* with a numeric argument just discard it.
*/
-int dopopd(v) char **v; {
+void dopopd(v, kp) char **v; struct command *kp; {
register struct directory *dp, *p;
printd = 1;
if (dp == dcwd)
dnewcwd(p);
else
+#if defined(__STDC__) || defined(lint)
+ dodirs(fakev, 0);
+#else
dodirs(fakev);
+#endif
dfree(dp);
}
/*
* dfree - free the directory (or keep it if it still has ref count)
*/
-int dfree(dp) register struct directory *dp; {
+void dfree(dp) register struct directory *dp; {
if (dp->di_count != 0)
dp->di_next = dp->di_prev = 0;
/*
* dnewcwd - make a new directory in the loop the current one
*/
-int dnewcwd(dp) register struct directory *dp; {
+void dnewcwd(dp) register struct directory *dp; {
dcwd = dp;
set("cwd", savestr(dcwd->di_name));
if (printd)
+#if defined(__STDC__) || defined(lint)
+ dodirs(fakev, 0);
+#else
dodirs(fakev);
+#endif
}
#ifndef _SH_DIR_H_
#define _SH_DIR_H_
+#include "sh.h"
+
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley Software License Agreement
#endif
/* sh.dir.c */
-int dinit __P((char *hp));
-int dodirs __P((char **v));
-int dtildepr __P((register char *home, register char *dir));
-int dochngd __P((char **v));
+void dinit __P((char *hp));
+void dodirs __P((char **v, struct command *kp));
+void dtildepr __P((register char *home, register char *dir));
+void dochngd __P((char **v, struct command *kp));
char *dfollow __P((register char *cp));
-int dopushd __P((char **v));
+void dopushd __P((char **v, struct command *kp));
struct directory *dfind __P((register char *cp));
-int dopopd __P((char **v));
-int dfree __P((register struct directory *dp));
+void dopopd __P((char **v, struct command *kp));
+void dfree __P((register struct directory *dp));
char *dcanon __P((register char *cp, register char *p));
-int dnewcwd __P((register struct directory *dp));
+void dnewcwd __P((register struct directory *dp));
#endif
* Fix up the $ expansions and quotations in the
* argument list to command t.
*/
-int Dfix(t) register struct command *t; {
+void Dfix(t) register struct command *t; {
register char **pp;
register char *p;
/*
* Subroutine to do actual fixing after state initialization.
*/
-int Dfix2(v) char **v; {
+void Dfix2(v) char **v; {
char *agargv[GAVSIZ];
ginit(agargv); /* Initialize glob's area pointers */
}
char *nulvec[] = { 0 };
-struct varent nulargv = { nulvec, "argv", 0 };
+struct varent nulargv = { nulvec, "argv", { 0, 0, 0 }, 0 };
/*
* Handle the multitudinous $ expansion forms.
* Ugh.
*/
-int Dgetdol() {
+void Dgetdol() {
register char *np;
register struct varent *vp;
char name[20];
}
}
-int setDolp(cp) register char *cp; {
+void setDolp(cp) register char *cp; {
register char *dp;
if (dolmod == 0 || dolmcnt == 0) {
dolp = "";
}
-int unDredc(c) int c; {
+void unDredc(c) int c; {
Dpeekrd = c;
}
return (' ');
}
-int Dtestq(c) register int c; {
+void Dtestq(c) register int c; {
if (cmap(c, QUOTES))
gflag = 1;
* of the shell input up to a line the same as "term".
* Unit 0 should have been closed before this call.
*/
-int heredoc(term) char *term; {
+void heredoc(term) char *term; {
register int c;
char *Dv[2];
char obuf[BUFSIZ], lbuf[BUFSIZ], mbuf[BUFSIZ];
* an error diagnostic here.
*/
if (s) {
- _va_start(argp, fmt);
+ _va_start(argp, s);
vprintf(s, argp), printf(".\n");
va_end(argp);
}
* Perror is the shells version of perror which should otherwise
* never be called.
*/
-int Perror(s) char *s; {
+void Perror(s) char *s; {
/*
* Perror uses unit 2, thus if we didn't set up the fd's
error(NOSTR); /* To exit or unwind */
}
-int bferr(cp) char *cp; {
+void bferr(cp) char *cp; {
flush();
haderr = 1;
* which sets the variable err as a side effect; later to be tested,
* e.g. in process.
*/
-int seterr(s) char *s; {
+void seterr(s) char *s; {
if (err == 0)
err = s, errspl = 0;
}
/* Set err to a splice of cp and dp, to be freed later in error() */
-int seterr2(cp, dp) char *cp; char *dp; {
+void seterr2(cp, dp) char *cp; char *dp; {
if (err)
return;
}
/* Set err to a splice of cp with a string form of character d */
-int seterrc(cp, d) char *cp; int d; {
+void seterrc(cp, d) char *cp; int d; {
char chbuf[2];
chbuf[0] = d;
/* Dummy search path for just absolute search when no path */
char *justabs[] = { "", 0 };
-int doexec(t) register struct command *t; {
+void doexec(t) register struct command *t; {
char *sav;
register char *dp, **pv, **av;
register struct varent *v;
pexerr();
}
-int pexerr() {
+void pexerr() {
/* Couldn't find the damn thing */
setname(expath);
* Record error message if not found.
* Also do shell scripts here.
*/
-int texec(f, t) char *f; register char **t; {
+void texec(f, t) char *f; register char **t; {
register struct varent *v;
register char **vp;
extern char *sys_errlist[];
}
/*ARGSUSED*/
-int execash(t, kp) char **t; register struct command *kp; {
+void execash(t, kp) char **t; register struct command *kp; {
rechist();
(void) signal(SIGINT, parintr);
/*NOTREACHED*/
}
-int xechoit(t) char **t; {
+void xechoit(t) char **t; {
if (adrof("echo")) {
flush();
}
}
-int dohash() {
+void dohash(t, kp) char **t; struct command *kp; {
struct stat stb;
DIR *dirp;
register struct direct *dp;
}
}
-int dounhash() {
+void dounhash(v, kp) char **v; struct command *kp; {
havhash = 0;
}
#ifdef VFORK
-int hashstat() {
+void hashstat(v, kp) char **v; struct command *kp; {
if (hits+misses)
printf("%d hits, %d misses, %d%%\n",
return (ignore&NOGLOB ? savestr(cp) : globone(cp));
}
-int evalav(v) register char **v; {
+void evalav(v) register char **v; {
struct wordent paraml;
register struct wordent *hp = ¶ml;
struct command *t;
*/
bool filec = 0;
-static setup_tty __P((int on));
-static back_to_col_1 __P((void));
-static pushback __P((char *string));
-static catn __P((register char *des, register char *src, register count));
-static copyn __P((register char *des, register char *src, register count));
+static void setup_tty __P((int on));
+static void back_to_col_1 __P((void));
+static void pushback __P((char *string));
+static void catn __P((register char *des, register char *src, register count));
+static void copyn __P((register char *des, register char *src, register count));
static char filetype __P((char *dir, char *file));
-static print_by_column __P((char *dir, char *items[], int count));
+static void print_by_column __P((char *dir, char *items[], int count));
static char *tilde __P((char *new, char *old));
-static retype __P((void));
-static beep __P((void));
-static print_recognized_stuff __P((char *recognized_part));
-static extract_dir_and_name __P((char *path, char *dir, char *name));
+static void retype __P((void));
+static void beep __P((void));
+static void print_recognized_stuff __P((char *recognized_part));
+static void extract_dir_and_name __P((char *path, char *dir, char *name));
static char *getentry __P((DIR *dir_fd, int looking_for_lognames));
-static free_items __P((register char **items));
+static void free_items __P((register char **items));
static _search __P((char *word, COMMAND command, int max_word_length));
static recognize __P((char *extended_name, char *entry, int name_length, int numitems));
static is_prefix __P((register char *check, register char *template));
static is_suffix __P((char *check, char *template));
static ignored __P((register char *entry));
-static setup_tty(on) int on; {
+static void setup_tty(on) int on; {
struct sgttyb sgtty;
static struct tchars tchars; /* INT, QUIT, XON, XOFF, EOF, BRK */
/*
* Move back to beginning of current line
*/
-static back_to_col_1() {
+static void back_to_col_1() {
struct sgttyb tty, tty_normal;
int omask;
/*
* Push string contents back into tty queue
*/
-static pushback(string) char *string; {
+static void pushback(string) char *string; {
register char *p;
struct sgttyb tty, tty_normal;
int omask;
* Des is a string whose maximum length is count.
* Always null terminate.
*/
-static catn(des, src, count) register char *des; register char *src; register count; {
+static void catn(des, src, count) register char *des; register char *src; register count; {
while (--count >= 0 && *des)
des++;
* Like strncpy but always leave room for trailing \0
* and always null terminate.
*/
-static copyn(des, src, count) register char *des; register char *src; register count; {
+static void copyn(des, src, count) register char *des; register char *src; register count; {
while (--count >= 0)
if ((*des++ = *src++) == 0)
/*
* Print sorted down columns
*/
-static print_by_column(dir, items, count) char *dir; char *items[]; int count; {
+static void print_by_column(dir, items, count) char *dir; char *items[]; int count; {
register int i, rows, r, c, maxwidth = 0, columns;
if (ioctl(SHOUT, TIOCGWINSZ, (char *)&win) < 0 || win.ws_col == 0)
/*
* Cause pending line to be printed
*/
-static retype() {
+static void retype() {
int pending_input = LPENDIN;
(void) ioctl(SHOUT, TIOCLBIS, (char *)&pending_input);
}
-static beep() {
+static void beep() {
if (adrof("nobeep") == 0)
(void) write(SHOUT, "\007", 1);
* Erase that silly ^[ and
* print the recognized part of the string
*/
-static print_recognized_stuff(recognized_part) char *recognized_part; {
+static void print_recognized_stuff(recognized_part) char *recognized_part; {
/* An optimized erasing of that silly ^[ */
switch (strlen(recognized_part)) {
* Parse full path in file into 2 parts: directory and file names
* Should leave final slash (/) at end of dir.
*/
-static extract_dir_and_name(path, dir, name) char *path; char *dir; char *name; {
+static void extract_dir_and_name(path, dir, name) char *path; char *dir; char *name; {
register char *p;
p = rindex(path, '/');
return (NULL);
}
-static free_items(items) register char **items; {
+static void free_items(items) register char **items; {
register int i;
for (i = 0; items[i]; i++)
return (numitems);
}
else { /* LIST */
- qsort((char *)items, numitems, sizeof(items[1]), sortscmp);
+ qsort((char *)items, numitems, sizeof(items[1]), (int (*) __P((void *p0, void *p1)))sortscmp);
print_by_column(looking_for_lognames ? NULL : tilded_dir,
items, numitems);
if (items != NULL)
struct biltins *isbfunc(t) struct command *t; {
register char *cp = t->t_dcom[0];
register struct biltins *bp, *bp1, *bp2;
- int dolabel(), dofg1(), dobg1();
+ void dolabel(), dofg1(), dobg1();
static struct biltins label = { "", dolabel, 0, 0 };
static struct biltins foregnd = { "%job", dofg1, 0, 0 };
static struct biltins backgnd = { "%job &", dobg1, 0, 0 };
return (0);
}
-int func(t, bp) register struct command *t; register struct biltins *bp; {
+void func(t, bp) register struct command *t; register struct biltins *bp; {
int i;
xechoit(t->t_dcom);
(*bp->bfunct)(t->t_dcom, t);
}
-int dolabel() {
+void dolabel(v, kp) char **v; struct command *kp; {
}
-int doonintr(v) char **v; {
+void doonintr(v, kp) char **v; struct command *kp; {
register char *cp;
register char *vv = v[1];
gointr = "-";
} else {
gointr = savestr(vv);
- (void) signal(SIGINT, pintr);
+ (void) signal(SIGINT, (void (*) __P((int sig)))pintr);
}
}
-int donohup() {
+void donohup(v, kp) char **v; struct command *kp; {
if (intty)
bferr("Can't from terminal");
}
}
-int dozip() {
+void dozip(v, kp) char **v; struct command *kp; {
;
}
-int prvars() {
+void prvars() {
plist(&shvhed);
}
-int doalias(v) register char **v; {
+void doalias(v, kp) char **v; struct command *kp; {
register struct varent *vp;
register char *p;
}
}
-int unalias(v) char **v; {
+void unalias(v, kp) char **v; struct command *kp; {
unset1(v, &aliases);
}
-int dologout() {
+void dologout(v, kp) char **v; struct command *kp; {
islogin();
goodbye();
}
-int dologin(v) char **v; {
+void dologin(v, kp) char **v; struct command *kp; {
islogin();
rechist();
}
#endif
-int islogin() {
+void islogin() {
if (chkstop == 0 && setintr)
panystop(0);
error("Not login shell");
}
-int doif(v, kp) char **v; struct command *kp; {
+void doif(v, kp) char **v; struct command *kp; {
register int i;
register char **vv;
* Reexecute a command, being careful not
* to redo i/o redirection, which is already set up.
*/
-int reexecute(kp) register struct command *kp; {
+void reexecute(kp) register struct command *kp; {
kp->t_dflg &= FSAVE;
kp->t_dflg |= FREDO;
#endif
}
-int doelse() {
+void doelse(v, kp) char **v; struct command *kp; {
#if defined(__STDC__) || defined(lint)
search(ZELSE, 0, 0);
#else
#endif
}
-int dogoto(v) char **v; {
+void dogoto(v, kp) char **v; struct command *kp; {
register struct whyle *wp;
char *lp;
wfree();
}
-int doswitch(v) register char **v; {
+void doswitch(v, kp) char **v; struct command *kp; {
register char *cp, *lp;
v++;
xfree(lp);
}
-int dobreak() {
+void dobreak(v, kp) char **v; struct command *kp; {
if (whyles)
toend();
bferr("Not in while/foreach");
}
-int doexit(v) char **v; {
+void doexit(v, kp) char **v; struct command *kp; {
if (chkstop == 0)
panystop(0);
(void) close(SHIN);
}
-int doforeach(v) register char **v; {
+void doforeach(v, kp) char **v; struct command *kp; {
register char *cp;
register struct whyle *nwp;
doagain();
}
-int dowhile(v) char **v; {
+void dowhile(v, kp) char **v; struct command *kp; {
register int status;
register bool again = whyles != 0 && whyles->w_start == lineloc &&
whyles->w_fename == 0;
toend();
}
-int preread() {
+void preread() {
whyles->w_end = -1;
if (setintr)
whyles->w_end = btell();
}
-int doend() {
+void doend(v, kp) char **v; struct command *kp; {
if (!whyles)
bferr("Not in while/foreach");
doagain();
}
-int docontin() {
+void docontin(v, kp) char **v; struct command *kp; {
if (!whyles)
bferr("Not in while/foreach");
doagain();
}
-int doagain() {
+void doagain() {
/* Repeating a while is simple */
if (whyles->w_fename == 0) {
* of the list if one word beyond this is 0.
*/
if (!whyles->w_fe[1]) {
+#if defined(__STDC__) || defined(lint)
+ dobreak(0, 0);
+#else
dobreak();
+#endif
return;
}
set(whyles->w_fename, savestr(*whyles->w_fe++));
bseek(whyles->w_start);
}
-int dorepeat(v, kp) char **v; struct command *kp; {
+void dorepeat(v, kp) char **v; struct command *kp; {
register int i, omask;
i = getn(v[1]);
(void) sigsetmask(omask);
}
-int doswbrk() {
+void doswbrk(v, kp) char **v; struct command *kp; {
#if defined(__STDC__) || defined(lint)
search(ZBRKSW, 0, 0);
#else
char *Sgoal;
/*VARARGS2*/
-int search(type, level, goal) int type; register int level; char *goal; {
+void search(type, level, goal) int type; register int level; char *goal; {
char wordbuf[BUFSIZ];
register char *aword = wordbuf;
register char *cp;
bferr("label not found");
}
/*NOTREACHED*/
+#ifdef __GNUC__
+ return 0;
+#endif
}
-int toend() {
+void toend() {
if (whyles->w_end == 0) {
#if defined(__STDC__) || defined(lint)
wfree();
}
-int wfree() {
+void wfree() {
long o = btell();
while (whyles) {
}
}
-int doecho(v) char **v; {
+void doecho(v, kp) char **v; struct command *kp; {
echo(' ', v);
}
-int doglob(v) char **v; {
+void doglob(v, kp) char **v; struct command *kp; {
echo(0, v);
flush();
}
-int echo(sep, v) int sep; register char **v; {
+void echo(sep, v) int sep; register char **v; {
register char *cp;
int nonl = 0;
char **environ;
-int dosetenv(v) register char **v; {
+void dosetenv(v, kp) char **v; struct command *kp; {
char *vp, *lp;
v++;
setenv(vp, lp = globone(lp));
if (eq(vp, "PATH")) {
importpath(lp);
+#if defined(__STDC__) || defined(lint)
+ dohash(0, 0);
+#else
dohash();
+#endif
}
xfree(lp);
}
-int dounsetenv(v) register char **v; {
+void dounsetenv(v, kp) char **v; struct command *kp; {
v++;
do
while (*v);
}
-int setenv(name, val) char *name; char *val; {
+void setenv(name, val) char *name; char *val; {
register char **ep = environ;
register char *cp, *dp;
char *blk[2], **oep = ep;
setenv(name, val);
}
-int unsetenv(name) char *name; {
+void unsetenv(name) char *name; {
register char **ep = environ;
register char *cp, *dp;
char **oep = ep;
}
}
-int doumask(v) register char **v; {
+void doumask(v, kp) char **v; struct command *kp; {
register char *cp = v[1];
register int i;
int limdiv;
char *limscale;
} limits[] = {
- RLIMIT_CPU, "cputime", 1, "seconds",
- RLIMIT_FSIZE, "filesize", 1024, "kbytes",
- RLIMIT_DATA, "datasize", 1024, "kbytes",
- RLIMIT_STACK, "stacksize", 1024, "kbytes",
- RLIMIT_CORE, "coredumpsize", 1024, "kbytes",
- RLIMIT_RSS, "memoryuse", 1024, "kbytes",
- -1, 0,
+ {RLIMIT_CPU, "cputime", 1, "seconds"},
+ {RLIMIT_FSIZE, "filesize", 1024, "kbytes"},
+ {RLIMIT_DATA, "datasize", 1024, "kbytes"},
+ {RLIMIT_STACK, "stacksize", 1024, "kbytes"},
+ {RLIMIT_CORE, "coredumpsize", 1024, "kbytes"},
+ {RLIMIT_RSS, "memoryuse", 1024, "kbytes"},
+ {-1, 0, 0, 0}
};
struct limits *findlim(cp) char *cp; {
/*NOTREACHED*/
}
-int dolimit(v) register char **v; {
+void dolimit(v, kp) char **v; struct command *kp; {
register struct limits *lp;
register int limit;
char hard = 0;
return ((int)(f+0.5));
}
-int limtail(cp, str0) char *cp; char *str0; {
+void limtail(cp, str0) char *cp; char *str0; {
register char *str = str0;
while (*cp && *cp == *str)
error("Bad scaling; did you mean ``%s''?", str0);
}
-int plim(lp, hard) register struct limits *lp; int hard; {
+void plim(lp, hard) register struct limits *lp; int hard; {
struct rlimit rlim;
int limit;
printf("\n");
}
-int dounlimit(v) register char **v; {
+void dounlimit(v, kp) char **v; struct command *kp; {
register struct limits *lp;
int err = 0;
char hard = 0;
return (0);
}
-int dosuspend() {
+void dosuspend(v, kp) char **v; struct command *kp; {
int ldisc, ctpgrp;
- int (*old)();
+ void (*old) __P((int sig));
if (loginsh)
error("Can't suspend a login shell (yet)");
}
}
-int doeval(v) char **v; {
+void doeval(v, kp) char **v; struct command *kp; {
char **oevalvec = evalvec;
char *oevalp = evalp;
jmp_buf osetexit;
char **sortbas;
/*int sortscmp();*/
-#define sort() qsort((char *)sortbas, &gargv[gargc] - sortbas, \
- sizeof(*sortbas), sortscmp), sortbas = &gargv[gargc]
+#define sort() qsort( \
+ (char *)sortbas, \
+ &gargv[gargc] - sortbas, \
+ sizeof(*sortbas), \
+ (int (*) __P((void *p0, void *p1)))sortscmp \
+ ), sortbas = &gargv[gargc]
char **glob(v) register char **v; {
char agpath[BUFSIZ];
return (gargv = copyblk(gargv));
}
-int ginit(agargv) char **agargv; {
+void ginit(agargv) char **agargv; {
agargv[0] = 0; gargv = agargv; sortbas = agargv; gargc = 0;
gnleft = NCARGS - 4;
}
-int collect(as) register char *as; {
+void collect(as) register char *as; {
register int i;
if (any('`', as)) {
acollect(as);
}
-int acollect(as) register char *as; {
+void acollect(as) register char *as; {
register int ogargc = gargc;
gpathp = gpath; *gpathp = 0; globbed = 0;
return (strcmp(*a1, *a2));
}
-int expand(as) char *as; {
+void expand(as) char *as; {
register char *cs;
register char *sgpathp, *oldcs;
struct stat stb;
*gpathp = 0;
}
-int matchdir(pattern) char *pattern; {
+void matchdir(pattern) char *pattern; {
struct stat stb;
register struct direct *dp;
register DIR *dirp;
}
}
-int Gcat(s1, s2) char *s1; char *s2; {
+void Gcat(s1, s2) char *s1; char *s2; {
register char *p, *q;
int n;
;
}
-int addpath(c) int c; {
+void addpath(c) int c; {
if (gpathp >= lastgpathp)
error("Pathname too long");
*gpathp = 0;
}
-int rscan(t, f) register char **t; int (*f)(); {
+void rscan(t, f) register char **t; void (*f) __P((register int c)); {
register char *p;
while (p = *t++)
(*f)(*p++);
}
-int trim(t) register char **t; {
+void trim(t) register char **t; {
register char *p;
while (p = *t++)
*p++ &= TRIM;
}
-int tglob(t) register char **t; {
+void tglob(t) register char **t; {
register char *p, c;
while (p = *t++) {
}
}
-int backeval(cp, literal) char *cp; int literal; {
+void backeval(cp, literal) char *cp; int literal; {
int pvec[2];
int quoted = (literal || (cp[0] & QUOTE)) ? QUOTE : 0;
char ibuf[BUFSIZ];
prestjob();
}
-int psave(c) int c; {
+void psave(c) int c; {
if (--pnleft <= 0)
error("Word too long");
*pargcp++ = c;
}
-int pword() {
+void pword() {
psave(0);
if (pargc == GAVSIZ)
* initialized in sh.init.c (to allow them to be made readonly)
*/
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+struct command; /* forward declaration for bfunct below */
+
extern struct biltins {
char *bname;
- int (*bfunct)();
+ void (*bfunct) __P((char **v, struct command *kp));
short minargs, maxargs;
} bfunc[];
extern int nbfunc;
#define resexit(a) bcopy((char *)(a), (char *)reslab, sizeof reslab)
extern char *gointr; /* Label for an onintr transfer */
-int (*parintr)(); /* Parents interrupt catch */
-int (*parterm)(); /* Parents terminate catch */
+void (*parintr) __P((int sig)); /* Parents interrupt catch */
+void (*parterm) __P((int sig)); /* Parents terminate catch */
/*
* Lexical definitions.
if ((cp) >= end && (cp) < &stack) \
free(cp); \
}
-extern char *alloctmp;
-#define xalloc(i) ((alloctmp = malloc(i)) ? alloctmp : (char *)nomem(i))
+extern void *alloctmp;
+#define xalloc(i) ((alloctmp = malloc(i)) ? alloctmp : nomem(i))
/*char *Dfix1();*/
/*char **blkcat();*/
char *pname; /* print name */
} mesg[];
-#ifndef __P
-#ifdef __STDC__
-#define __P(args) args
+#ifndef NORETURN
+#ifdef __GNUC__
+#define NORETURN __attribute__ ((__noreturn__))
#else
-#define __P(args) ()
+#define NORETURN
#endif
#endif
/* doprnt.c */
-int _doprnt __P((u_char *fmt0, va_list argp));
+int _doprnt __P((char *fmt, va_list argp));
/* malloc.c */
void *malloc __P((unsigned nbytes));
void morecore __P((int bucket));
void free __P((void *cp));
void *realloc __P((void *cp, unsigned nbytes));
-void showall __P((char **s));
+void showall __P((char **s, struct command *kp));
/* printf.c */
int printf __P((char *fmt, ...));
/* sh.c */
-int main __P((int c, char **av));
-int untty __P((void));
-int importpath __P((char *cp));
-int srccat __P((char *cp, char *dp));
-int srcunit __P((register int unit, int onlyown, int hflg));
-int rechist __P((void));
-int goodbye __P((void));
-int exitstat __P((void));
-int phup __P((void));
-int pintr __P((void));
-int pintr1 __P((int wantnl));
-int process __P((int catch));
-int dosource __P((register char **t));
-int mailchk __P((void));
+void main __P((int c, char **av));
+void untty __P((void));
+void importpath __P((char *cp));
+void srccat __P((char *cp, char *dp));
+void srcunit __P((register int unit, int onlyown, int hflg));
+void rechist __P((void));
+void goodbye __P((void));
+void exitstat __P((void));
+void phup __P((void));
+void pintr __P((void));
+void pintr1 __P((int wantnl));
+void process __P((int catch));
+void dosource __P((char **v, struct command *kp));
+void mailchk __P((void));
int gethdir __P((char *home));
-int initdesc __P((void));
-int exit __P((int i));
-int printprompt __P((void));
+void initdesc __P((void));
+int exit __P((int i)) NORETURN;
+void printprompt __P((void));
/* sh.dol.c */
-int Dfix __P((register struct command *t));
+void Dfix __P((register struct command *t));
char *Dfix1 __P((register char *cp));
-int Dfix2 __P((char **v));
+void Dfix2 __P((char **v));
int Dword __P((void));
int DgetC __P((register int flag));
-int Dgetdol __P((void));
-int setDolp __P((register char *cp));
-int unDredc __P((int c));
+void Dgetdol __P((void));
+void setDolp __P((register char *cp));
+void unDredc __P((int c));
int Dredc __P((void));
-int Dtestq __P((register int c));
-int heredoc __P((char *term));
+void Dtestq __P((register int c));
+void heredoc __P((char *term));
/* sh.err.c */
-int error __P((char *s, ...));
-int Perror __P((char *s));
-int bferr __P((char *cp));
-int seterr __P((char *s));
-int seterr2 __P((char *cp, char *dp));
-int seterrc __P((char *cp, int d));
+int error __P((char *s, ...)) NORETURN;
+void Perror __P((char *s));
+void bferr __P((char *cp)) NORETURN;
+void seterr __P((char *s));
+void seterr2 __P((char *cp, char *dp));
+void seterrc __P((char *cp, int d));
/* sh.exec.c */
-int doexec __P((register struct command *t));
-int pexerr __P((void));
-int texec __P((char *f, register char **t));
-int execash __P((char **t, register struct command *kp));
-int xechoit __P((char **t));
-int dohash __P((void));
-int dounhash __P((void));
-int hashstat __P((void));
+void doexec __P((register struct command *t));
+void pexerr __P((void));
+void texec __P((char *f, register char **t));
+void execash __P((char **t, register struct command *kp));
+void xechoit __P((char **t));
+void dohash __P((char **t, struct command *kp));
+void dounhash __P((char **v, struct command *kp));
+void hashstat __P((char **v, struct command *kp));
int hashname __P((register char *cp));
/* sh.exp.c */
char *exp4 __P((register char ***vp, int ignore));
char *exp5 __P((register char ***vp, int ignore));
char *exp6 __P((register char ***vp, int ignore));
-int evalav __P((register char **v));
+void evalav __P((register char **v));
int isa __P((register char *cp, register int what));
int egetn __P((register char *cp));
int etraci __P((char *str, int i, char ***vp));
/* sh.func.c */
struct biltins *isbfunc __P((struct command *t));
-int func __P((register struct command *t, register struct biltins *bp));
-int dolabel __P((void));
-int doonintr __P((char **v));
-int donohup __P((void));
-int dozip __P((void));
-int prvars __P((void));
-int doalias __P((register char **v));
-int unalias __P((char **v));
-int dologout __P((void));
-int dologin __P((char **v));
+void func __P((register struct command *t, register struct biltins *bp));
+void dolabel __P((char **v, struct command *kp));
+void doonintr __P((char **v, struct command *kp));
+void donohup __P((char **v, struct command *kp));
+void dozip __P((char **v, struct command *kp));
+void prvars __P((void));
+void doalias __P((char **v, struct command *kp));
+void unalias __P((char **v, struct command *kp));
+void dologout __P((char **v, struct command *kp));
+void dologin __P((char **v, struct command *kp));
int donewgrp __P((char **v));
-int islogin __P((void));
-int doif __P((char **v, struct command *kp));
-int reexecute __P((register struct command *kp));
-int doelse __P((void));
-int dogoto __P((char **v));
-int doswitch __P((register char **v));
-int dobreak __P((void));
-int doexit __P((char **v));
-int doforeach __P((register char **v));
-int dowhile __P((char **v));
-int preread __P((void));
-int doend __P((void));
-int docontin __P((void));
-int doagain __P((void));
-int dorepeat __P((char **v, struct command *kp));
-int doswbrk __P((void));
+void islogin __P((void));
+void doif __P((char **v, struct command *kp));
+void reexecute __P((register struct command *kp));
+void doelse __P((char **v, struct command *kp));
+void dogoto __P((char **v, struct command *kp));
+void doswitch __P((char **v, struct command *kp));
+void dobreak __P((char **v, struct command *kp));
+void doexit __P((char **v, struct command *kp));
+void doforeach __P((char **v, struct command *kp));
+void dowhile __P((char **v, struct command *kp));
+void preread __P((void));
+void doend __P((char **v, struct command *kp));
+void docontin __P((char **v, struct command *kp));
+void doagain __P((void));
+void dorepeat __P((char **v, struct command *kp));
+void doswbrk __P((char **v, struct command *kp));
int srchx __P((register char *cp));
-int search __P((int type, register int level, char *goal));
+void search __P((int type, register int level, char *goal));
int getword __P((register char *wp));
-int toend __P((void));
-int wfree __P((void));
-int doecho __P((char **v));
-int doglob __P((char **v));
-int echo __P((int sep, register char **v));
-int dosetenv __P((register char **v));
-int dounsetenv __P((register char **v));
-int setenv __P((char *name, char *val));
-int unsetenv __P((char *name));
-int doumask __P((register char **v));
+void toend __P((void));
+void wfree __P((void));
+void doecho __P((char **v, struct command *kp));
+void doglob __P((char **v, struct command *kp));
+void echo __P((int sep, register char **v));
+void dosetenv __P((char **v, struct command *kp));
+void dounsetenv __P((char **v, struct command *kp));
+void setenv __P((char *name, char *val));
+void unsetenv __P((char *name));
+void doumask __P((char **v, struct command *kp));
struct limits *findlim __P((char *cp));
-int dolimit __P((register char **v));
+void dolimit __P((char **v, struct command *kp));
int getval __P((register struct limits *lp, char **v));
-int limtail __P((char *cp, char *str0));
-int plim __P((register struct limits *lp, int hard));
-int dounlimit __P((register char **v));
+void limtail __P((char *cp, char *str0));
+void plim __P((register struct limits *lp, int hard));
+void dounlimit __P((char **v, struct command *kp));
int setlim __P((register struct limits *lp, int hard, int limit));
-int dosuspend __P((void));
-int doeval __P((char **v));
+void dosuspend __P((char **v, struct command *kp));
+void doeval __P((char **v, struct command *kp));
/* sh.glob.c */
char **glob __P((register char **v));
-int ginit __P((char **agargv));
-int collect __P((register char *as));
-int acollect __P((register char *as));
+void ginit __P((char **agargv));
+void collect __P((register char *as));
+void acollect __P((register char *as));
int sortscmp __P((char **a1, char **a2));
-int expand __P((char *as));
-int matchdir __P((char *pattern));
+void expand __P((char *as));
+void matchdir __P((char *pattern));
int execbrc __P((char *p, char *s));
int match __P((char *s, char *p));
int amatch __P((register char *s, register char *p));
int Gmatch __P((register char *s, register char *p));
-int Gcat __P((char *s1, char *s2));
-int addpath __P((int c));
-int rscan __P((register char **t, int (*f)(void)));
-int trim __P((register char **t));
-int tglob __P((register char **t));
+void Gcat __P((char *s1, char *s2));
+void addpath __P((int c));
+void rscan __P((register char **t, void (*f)(register int c)));
+void trim __P((register char **t));
+void tglob __P((register char **t));
char *globone __P((register char *str));
char **dobackp __P((char *cp, int literal));
-int backeval __P((char *cp, int literal));
-int psave __P((int c));
-int pword __P((void));
+void backeval __P((char *cp, int literal));
+void psave __P((int c));
+void pword __P((void));
/* sh.hist.c */
-int savehist __P((struct wordent *sp));
+void savehist __P((struct wordent *sp));
struct Hist *enthist __P((int event, register struct wordent *lp, int docopy));
-int hfree __P((register struct Hist *hp));
-int dohist __P((char **vp));
-int dohist1 __P((struct Hist *hp, int *np, int rflg, int hflg));
-int phist __P((register struct Hist *hp, int hflg));
+void hfree __P((register struct Hist *hp));
+void dohist __P((char **vp, struct command *kp));
+void dohist1 __P((struct Hist *hp, int *np, int rflg, int hflg));
+void phist __P((register struct Hist *hp, int hflg));
/* sh.lex.c */
int lex __P((register struct wordent *hp));
-int prlex __P((struct wordent *sp0));
-int copylex __P((register struct wordent *hp, register struct wordent *fp));
-int freelex __P((register struct wordent *vp));
+void prlex __P((struct wordent *sp0));
+void copylex __P((register struct wordent *hp, register struct wordent *fp));
+void freelex __P((register struct wordent *vp));
char *word __P((void));
int getC1 __P((register int flag));
-int getdol __P((void));
-int addla __P((char *cp));
-int getexcl __P((int sc));
+void getdol __P((void));
+void addla __P((char *cp));
+void getexcl __P((int sc));
struct wordent *getsub __P((struct wordent *en));
struct wordent *dosub __P((int sc, struct wordent *en, int global));
char *subword __P((char *cp, int type, bool *adid));
int getsel __P((register int *al, register int *ar, int dol));
struct wordent *gethent __P((int sc));
struct Hist *findev __P((char *cp, int anyarg));
-int noev __P((char *cp));
-int setexclp __P((register char *cp));
-int unreadc __P((int c));
+void noev __P((char *cp));
+void setexclp __P((register char *cp));
+void unreadc __P((int c));
int readc __P((int wanteof));
int bgetc __P((void));
-int bfree __P((void));
-int bseek __P((off_t l));
-int btoeof __P((void));
-int settell __P((void));
+void bfree __P((void));
+void bseek __P((off_t l));
+void btoeof __P((void));
+void settell __P((void));
/* sh.misc.c */
int any __P((register int c, register char *s));
int onlyread __P((char *cp));
-int xfree __P((char *cp));
+void xfree __P((char *cp));
char *savestr __P((register char *s));
void *calloc __P((register unsigned i, unsigned j));
-int nomem __P((unsigned i));
+void *nomem __P((unsigned i)) NORETURN;
char **blkend __P((register char **up));
-int blkpr __P((register char **av));
+void blkpr __P((register char **av));
int blklen __P((register char **av));
char **blkcpy __P((char **oav, register char **bv));
char **blkcat __P((char **up, char **vp));
-int blkfree __P((char **av0));
+void blkfree __P((char **av0));
char **saveblk __P((register char **v));
char *strspl __P((char *cp, char *dp));
char **blkspl __P((register char **up, register char **vp));
int lastchr __P((register char *cp));
-int closem __P((void));
-int donefds __P((void));
+void closem __P((void));
+void donefds __P((void));
int dmove __P((register int i, register int j));
int dcopy __P((register int i, register int j));
int renum __P((register int i, register int j));
-int lshift __P((register char **v, register int c));
+void lshift __P((register char **v, register int c));
int number __P((char *cp));
char **copyblk __P((register char **v));
char *strend __P((register char *cp));
char *strip __P((char *cp));
-int udvar __P((char *name));
+void udvar __P((char *name));
int prefix __P((register char *sub, register char *str));
/* sh.parse.c */
-int alias __P((register struct wordent *lex));
-int asyntax __P((register struct wordent *p1, register struct wordent *p2));
-int asyn0 __P((struct wordent *p1, register struct wordent *p2));
-int asyn3 __P((struct wordent *p1, register struct wordent *p2));
+void alias __P((register struct wordent *lex));
+void asyntax __P((register struct wordent *p1, register struct wordent *p2));
+void asyn0 __P((struct wordent *p1, register struct wordent *p2));
+void asyn3 __P((struct wordent *p1, register struct wordent *p2));
struct wordent *freenod __P((register struct wordent *p1, register struct wordent *p2));
struct command *syntax __P((register struct wordent *p1, register struct wordent *p2, int flags));
struct command *syn0 __P((struct wordent *p1, struct wordent *p2, int flags));
struct command *syn1b __P((struct wordent *p1, struct wordent *p2, int flags));
struct command *syn2 __P((struct wordent *p1, struct wordent *p2, int flags));
struct command *syn3 __P((struct wordent *p1, struct wordent *p2, int flags));
-int freesyn __P((register struct command *t));
+void freesyn __P((register struct command *t));
/* sh.print.c */
-int psecs __P((long l));
-int p2dig __P((register int i));
-int putchar __P((register int c));
-int draino __P((void));
-int flush __P((void));
+void psecs __P((long l));
+void p2dig __P((register int i));
+void putchar __P((register int c));
+void draino __P((void));
+void flush __P((void));
/* sh.set.c */
-int doset __P((register char **v));
+void doset __P((char **v, struct command *kp));
char *getinx __P((register char *cp, register int *ip));
-int asx __P((char *vp, int subscr, char *p));
+void asx __P((char *vp, int subscr, char *p));
struct varent *getvx __P((char *vp, int subscr));
-int dolet __P((char **v));
+void dolet __P((char **v, struct command *kp));
char *xset __P((char *cp, char ***vp));
char *operate __P((int op, char *vp, char *p));
char *putn __P((register int n));
-int putn1 __P((register int n));
+void putn1 __P((register int n));
int getn __P((register char *cp));
char *value1 __P((char *var, struct varent *head));
struct varent *madrof __P((char *pat, register struct varent *vp));
struct varent *adrof1 __P((register char *name, register struct varent *v));
-int set __P((char *var, char *val));
-int set1 __P((char *var, char **vec, struct varent *head));
-int setq __P((char *name, char **vec, register struct varent *p));
-int unset __P((char *v[]));
-int unset1 __P((register char *v[], struct varent *head));
-int unsetv __P((char *var));
-int unsetv1 __P((register struct varent *p));
-int setNS __P((char *cp));
-int shift __P((register char **v));
-int exportpath __P((char **val));
-int balance __P((register struct varent *p, register f, int d));
-int plist __P((register struct varent *p));
+void set __P((char *var, char *val));
+void set1 __P((char *var, char **vec, struct varent *head));
+void setq __P((char *name, char **vec, register struct varent *p));
+void unset __P((char **v, struct command *kp));
+void unset1 __P((register char **v, struct varent *head));
+void unsetv __P((char *var));
+void unsetv1 __P((register struct varent *p));
+void setNS __P((char *cp));
+void shift __P((char **v, struct command *kp));
+void exportpath __P((char **val));
+void balance __P((register struct varent *p, register f, int d));
+void plist __P((register struct varent *p));
/* sh.time.c */
-int settimes __P((void));
-int dotime __P((void));
-int donice __P((register char **v));
-int ruadd __P((register struct rusage *ru, register struct rusage *ru2));
-int prusage __P((register struct rusage *r0, register struct rusage *r1, struct timeval *e, struct timeval *b));
-int pdeltat __P((struct timeval *t1, struct timeval *t0));
-int tvadd __P((struct timeval *tsum, struct timeval *t0));
-int tvsub __P((struct timeval *tdiff, struct timeval *t1, struct timeval *t0));
+void settimes __P((void));
+void dotime __P((char **v, struct command *kp));
+void donice __P((char **v, struct command *kp));
+void ruadd __P((register struct rusage *ru, register struct rusage *ru2));
+void prusage __P((register struct rusage *r0, register struct rusage *r1, struct timeval *e, struct timeval *b));
+void pdeltat __P((struct timeval *t1, struct timeval *t0));
+void tvadd __P((struct timeval *tsum, struct timeval *t0));
+void tvsub __P((struct timeval *tdiff, struct timeval *t1, struct timeval *t0));
+
+/* vprintf.c */
+int vprintf __P((char *fmt, va_list argp));
#endif
* C shell
*/
-int savehist(sp) struct wordent *sp; {
+void savehist(sp) struct wordent *sp; {
register struct Hist *hp, *np;
register int histlen = 0;
char *cp;
return (np);
}
-int hfree(hp) register struct Hist *hp; {
+void hfree(hp) register struct Hist *hp; {
freelex(&hp->Hlex);
xfree((char *)hp);
}
-int dohist(vp) char **vp; {
+void dohist(vp, kp) char **vp; struct command *kp; {
int n, rflg = 0, hflg = 0;
if (getn(value("history")) == 0)
return;
dohist1(Histlist.Hnext, &n, rflg, hflg);
}
-int dohist1(hp, np, rflg, hflg) struct Hist *hp; int *np; int rflg; int hflg; {
+void dohist1(hp, np, rflg, hflg) struct Hist *hp; int *np; int rflg; int hflg; {
bool print = (*np) > 0;
top:
if (hp == 0)
goto top;
}
-int phist(hp, hflg) register struct Hist *hp; int hflg; {
+void phist(hp, hflg) register struct Hist *hp; int hflg; {
if (hflg == 0)
printf("%6d\t", hp->Hnum);
-#include "sh.h"
+#include "sh.dir.h"
+/*#include "sh.h" sh.dir.h*/
+#include "sh.proc.h"
/*
* Copyright (c) 1980 Regents of the University of California.
#define INF 1000
struct biltins bfunc[] = {
- "@", dolet, 0, INF,
- "alias", doalias, 0, INF,
- "alloc", showall, 0, 1,
- "bg", dobg, 0, INF,
- "break", dobreak, 0, 0,
- "breaksw", doswbrk, 0, 0,
+ {"@", dolet, 0, INF},
+ {"alias", doalias, 0, INF},
+ {"alloc", showall, 0, 1},
+ {"bg", dobg, 0, INF},
+ {"break", dobreak, 0, 0},
+ {"breaksw", doswbrk, 0, 0},
#ifdef IIASA
- "bye", goodbye, 0, 0,
+ {"bye", goodbye, 0, 0},
#endif
- "case", dozip, 0, 1,
- "cd", dochngd, 0, 1,
- "chdir", dochngd, 0, 1,
- "continue", docontin, 0, 0,
- "default", dozip, 0, 0,
- "dirs", dodirs, 0, 1,
- "echo", doecho, 0, INF,
- "else", doelse, 0, INF,
- "end", doend, 0, 0,
- "endif", dozip, 0, 0,
- "endsw", dozip, 0, 0,
- "eval", doeval, 0, INF,
- "exec", execash, 1, INF,
- "exit", doexit, 0, INF,
- "fg", dofg, 0, INF,
- "foreach", doforeach, 3, INF,
+ {"case", dozip, 0, 1},
+ {"cd", dochngd, 0, 1},
+ {"chdir", dochngd, 0, 1},
+ {"continue", docontin, 0, 0},
+ {"default", dozip, 0, 0},
+ {"dirs", dodirs, 0, 1},
+ {"echo", doecho, 0, INF},
+ {"else", doelse, 0, INF},
+ {"end", doend, 0, 0},
+ {"endif", dozip, 0, 0},
+ {"endsw", dozip, 0, 0},
+ {"eval", doeval, 0, INF},
+ {"exec", execash, 1, INF},
+ {"exit", doexit, 0, INF},
+ {"fg", dofg, 0, INF},
+ {"foreach", doforeach, 3, INF},
#ifdef IIASA
- "gd", dopushd, 0, 1,
+ {"gd", dopushd, 0, 1},
#endif
- "glob", doglob, 0, INF,
- "goto", dogoto, 1, 1,
+ {"glob", doglob, 0, INF},
+ {"goto", dogoto, 1, 1},
#ifdef VFORK
- "hashstat", hashstat, 0, 0,
+ {"hashstat", hashstat, 0, 0},
#endif
- "history", dohist, 0, 2,
- "if", doif, 1, INF,
- "jobs", dojobs, 0, 1,
- "kill", dokill, 1, INF,
- "limit", dolimit, 0, 3,
- "login", dologin, 0, 1,
- "logout", dologout, 0, 0,
+ {"history", dohist, 0, 2},
+ {"if", doif, 1, INF},
+ {"jobs", dojobs, 0, 1},
+ {"kill", dokill, 1, INF},
+ {"limit", dolimit, 0, 3},
+ {"login", dologin, 0, 1},
+ {"logout", dologout, 0, 0},
#ifdef NEWGRP
- "newgrp", donewgrp, 1, 1,
+ {"newgrp", donewgrp, 1, 1},
#endif
- "nice", donice, 0, INF,
- "nohup", donohup, 0, INF,
- "notify", donotify, 0, INF,
- "onintr", doonintr, 0, 2,
- "popd", dopopd, 0, 1,
- "pushd", dopushd, 0, 1,
+ {"nice", donice, 0, INF},
+ {"nohup", donohup, 0, INF},
+ {"notify", donotify, 0, INF},
+ {"onintr", doonintr, 0, 2},
+ {"popd", dopopd, 0, 1},
+ {"pushd", dopushd, 0, 1},
#ifdef IIASA
- "rd", dopopd, 0, 1,
+ {"rd", dopopd, 0, 1},
#endif
- "rehash", dohash, 0, 0,
- "repeat", dorepeat, 2, INF,
- "set", doset, 0, INF,
- "setenv", dosetenv, 0, 2,
- "shift", shift, 0, 1,
- "source", dosource, 1, 2,
- "stop", dostop, 1, INF,
- "suspend", dosuspend, 0, 0,
- "switch", doswitch, 1, INF,
- "time", dotime, 0, INF,
- "umask", doumask, 0, 1,
- "unalias", unalias, 1, INF,
- "unhash", dounhash, 0, 0,
- "unlimit", dounlimit, 0, INF,
- "unset", unset, 1, INF,
- "unsetenv", dounsetenv, 1, INF,
- "wait", dowait, 0, 0,
- "while", dowhile, 1, INF,
+ {"rehash", dohash, 0, 0},
+ {"repeat", dorepeat, 2, INF},
+ {"set", doset, 0, INF},
+ {"setenv", dosetenv, 0, 2},
+ {"shift", shift, 0, 1},
+ {"source", dosource, 1, 2},
+ {"stop", dostop, 1, INF},
+ {"suspend", dosuspend, 0, 0},
+ {"switch", doswitch, 1, INF},
+ {"time", dotime, 0, INF},
+ {"umask", doumask, 0, 1},
+ {"unalias", unalias, 1, INF},
+ {"unhash", dounhash, 0, 0},
+ {"unlimit", dounlimit, 0, INF},
+ {"unset", unset, 1, INF},
+ {"unsetenv", dounsetenv, 1, INF},
+ {"wait", dowait, 0, 0},
+ {"while", dowhile, 1, INF}
};
int nbfunc = sizeof bfunc / sizeof *bfunc;
#define ZWHILE 18
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,
+ {"@", 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}
};
int nsrchn = sizeof srchn / sizeof *srchn;
struct mesg mesg[] = {
- 0, 0,
- "HUP", "Hangup",
- "INT", "Interrupt",
- "QUIT", "Quit",
- "ILL", "Illegal instruction",
- "TRAP", "Trace/BPT trap",
- "IOT", "IOT trap",
- "EMT", "EMT trap",
- "FPE", "Floating exception",
- "KILL", "Killed",
- "BUS", "Bus error",
- "SEGV", "Segmentation fault",
- "SYS", "Bad system call",
- "PIPE", "Broken pipe",
- "ALRM", "Alarm clock",
- "TERM", "Terminated",
- "URG", "Urgent I/O condition",
- "STOP", "Stopped (signal)",
- "TSTP", "Stopped",
- "CONT", "Continued",
- "CHLD", "Child exited",
- "TTIN", "Stopped (tty input)",
- "TTOU", "Stopped (tty output)",
- "IO", "I/O possible",
- "XCPU", "Cputime limit exceeded",
- "XFSZ", "Filesize limit exceeded",
- "VTALRM","Virtual timer expired",
- "PROF", "Profiling timer expired",
- "WINCH","Window size changed",
- 0, "Signal 29",
- "USR1", "User defined signal 1",
- "USR2", "User defined signal 2",
- 0, "Signal 32"
+ {0, 0},
+ {"HUP", "Hangup"},
+ {"INT", "Interrupt"},
+ {"QUIT", "Quit"},
+ {"ILL", "Illegal instruction"},
+ {"TRAP", "Trace/BPT trap"},
+ {"IOT", "IOT trap"},
+ {"EMT", "EMT trap"},
+ {"FPE", "Floating exception"},
+ {"KILL", "Killed"},
+ {"BUS", "Bus error"},
+ {"SEGV", "Segmentation fault"},
+ {"SYS", "Bad system call"},
+ {"PIPE", "Broken pipe"},
+ {"ALRM", "Alarm clock"},
+ {"TERM", "Terminated"},
+ {"URG", "Urgent I/O condition"},
+ {"STOP", "Stopped (signal)"},
+ {"TSTP", "Stopped"},
+ {"CONT", "Continued"},
+ {"CHLD", "Child exited"},
+ {"TTIN", "Stopped (tty input)"},
+ {"TTOU", "Stopped (tty output)"},
+ {"IO", "I/O possible"},
+ {"XCPU", "Cputime limit exceeded"},
+ {"XFSZ", "Filesize limit exceeded"},
+ {"VTALRM", "Virtual timer expired"},
+ {"PROF", "Profiling timer expired"},
+ {"WINCH", "Window size changed"},
+ {0, "Signal 29"},
+ {"USR1", "User defined signal 1"},
+ {"USR2", "User defined signal 2"},
+ {0, "Signal 32"}
};
return (hadhist);
}
-int prlex(sp0) struct wordent *sp0; {
+void prlex(sp0) struct wordent *sp0; {
register struct wordent *sp = sp0->next;
for (;;) {
}
}
-int copylex(hp, fp) register struct wordent *hp; register struct wordent *fp; {
+void copylex(hp, fp) register struct wordent *hp; register struct wordent *fp; {
register struct wordent *wdp;
wdp = hp;
hp->prev = wdp;
}
-int freelex(vp) register struct wordent *vp; {
+void freelex(vp) register struct wordent *vp; {
register struct wordent *fp;
while (vp->next != vp) {
return (c);
}
-int getdol() {
+void getdol() {
register char *np;
char name[40];
register int c;
goto ret;
}
-int addla(cp) char *cp; {
+void addla(cp) char *cp; {
char buf[BUFSIZ];
if (lap != 0 && strlen(cp) + strlen(lap) >= sizeof (labuf) - 4) {
char rhsb[64];
int quesarg;
-int getexcl(sc) int sc; {
+void getexcl(sc) int sc; {
register struct wordent *hp, *ip;
int left, right, dol;
register int c;
return (0);
}
-int noev(cp) char *cp; {
+void noev(cp) char *cp; {
seterr2(cp, ": Event not found");
}
-int setexclp(cp) register char *cp; {
+void setexclp(cp) register char *cp; {
if (cp && cp[0] == '\n')
return;
exclp = cp;
}
-int unreadc(c) int c; {
+void unreadc(c) int c; {
peekread = c;
}
return (c);
}
-int bfree() {
+void bfree() {
register int sb, i;
#ifdef TELL
}
}
-int bseek(l) off_t l; {
+void bseek(l) off_t l; {
register struct whyle *wp;
fseekp = l;
#endif
}
-int btoeof() {
+void btoeof() {
(void) lseek(SHIN, (off_t)0, 2);
fseekp = feobp;
}
#ifdef TELL
-int settell() {
+void settell() {
cantell = 0;
if (arginp || onelflg || intty)
return (cp < end);
}
-int xfree(cp) char *cp; {
+void xfree(cp) char *cp; {
extern char end[];
if (cp >= end && cp < (char *) &cp)
return (cp);
}
-int nomem(i) unsigned i; {
+/*ARGSUSED*/
+void *nomem(i) unsigned i; {
#ifdef debug
static char *av[2] = {0, 0};
#endif
child++;
#ifndef debug
error("Out of memory");
-#ifdef lint
- i = i;
-#endif
#else
showall(av);
printf("i=%d: Out of memory\n", i);
chdir("/usr/bill/cshcore");
abort();
#endif
- return 0; /* fool lint */
+ /*NOTREACHED*/
}
char **blkend(up) register char **up; {
return (up);
}
-int blkpr(av) register char **av; {
+void blkpr(av) register char **av; {
for (; *av; av++) {
printf("%s", *av);
return (up);
}
-int blkfree(av0) char **av0; {
+void blkfree(av0) char **av0; {
register char **av = av0;
for (; *av; av++)
* This routine is called after an error to close up
* any units which may have been left open accidentally.
*/
-int closem() {
+void closem() {
register int f;
for (f = 0; f < NOFILE; f++)
(void) close(f);
}
-int donefds() {
+void donefds() {
(void) close(0);
(void) close(1);
* the first c arguments. Used in "shift" commands
* as well as by commands like "repeat".
*/
-int lshift(v, c) register char **v; register int c; {
+void lshift(v, c) register char **v; register int c; {
register char **u = v;
while (*u && --c >= 0)
return (cp);
}
-int udvar(name) char *name; {
+void udvar(name) char *name; {
setname(name);
bferr("Undefined variable");
* If word 0 of a command has an alias, do it.
* Repeat a maximum of 20 times.
*/
-int alias(lex) register struct wordent *lex; {
+void alias(lex) register struct wordent *lex; {
int aleft = 21;
jmp_buf osetexit;
resexit(osetexit);
}
-int asyntax(p1, p2) register struct wordent *p1; register struct wordent *p2; {
+void asyntax(p1, p2) register struct wordent *p1; register struct wordent *p2; {
while (p1 != p2)
if (any(p1->word[0], ";&\n"))
}
}
-int asyn0(p1, p2) struct wordent *p1; register struct wordent *p2; {
+void asyn0(p1, p2) struct wordent *p1; register struct wordent *p2; {
register struct wordent *p;
register int l = 0;
asyn3(p1, p2);
}
-int asyn3(p1, p2) struct wordent *p1; register struct wordent *p2; {
+void asyn3(p1, p2) struct wordent *p1; register struct wordent *p2; {
register struct varent *ap;
struct wordent alout;
register bool redid;
#define PHERE 1
#define PIN 2
#define POUT 4
-#define PDIAG 8
+#define _PDIAG 8
/*
* syntax
f = flags | POUT;
pn = p->next;
if (pn != p2 && pn->word[0] == '&') {
- f |= PDIAG;
+ f |= _PDIAG;
t->t_dflg |= FDIAG;
}
t->t_dtyp = TFIL;
t->t_dflg |= FCAT;
if (p->next != p2 && eq(p->next->word, "&")) {
t->t_dflg |= FDIAG, p = p->next;
- if (flags & (POUT|PDIAG))
+ if (flags & (POUT|_PDIAG))
goto badout;
}
if (p->next != p2 && eq(p->next->word, "!"))
p = p->next;
if (any(p->word[0], RELPAR))
goto missfile;
- if ((flags & POUT) && (flags & PDIAG) == 0 || t->t_drit)
+ if ((flags & POUT) && (flags & _PDIAG) == 0 || t->t_drit)
badout:
seterr("Ambiguous output redirect");
else
return (t);
}
-int freesyn(t) register struct command *t; {
+void freesyn(t) register struct command *t; {
register char **v;
if (t == 0)
* C Shell
*/
-int psecs(l) long l; {
+void psecs(l) long l; {
register int i;
i = l / 3600;
p2dig(i);
}
-int p2dig(i) register int i; {
+void p2dig(i) register int i; {
printf("%d%d", i / 10, i % 10);
}
char linbuf[128];
char *linp = linbuf;
-int putchar(c) register int c; {
+void putchar(c) register int c; {
if ((c & QUOTE) == 0 && (c == 0177 || c < ' ' && c != '\t' && c != '\n')) {
putchar('^');
flush();
}
-int draino() {
+void draino() {
linp = linbuf;
}
-int flush() {
+void flush() {
register int unit;
int lmode;
* childs status. Top level routines (like pwait) must be sure
* to mask interrupts when playing with the proclist data structures!
*/
-int pchild() {
+void pchild() {
register struct process *pp;
register struct process *fp;
register int pid;
struct rusage ru;
loop:
- pid = wait3(&w, (setintr ? WNOHANG|WUNTRACED:WNOHANG), &ru);
+ pid = wait3(&w.w_status, (setintr ? WNOHANG|WUNTRACED:WNOHANG), &ru);
if (pid <= 0) {
if (errno == EINTR) {
errno = 0;
goto loop;
}
-int pnote() {
+void pnote() {
register struct process *pp;
int flags, omask;
* pwait - wait for current job to terminate, maintaining integrity
* of current and previous job indicators.
*/
-int pwait() {
+void pwait() {
register struct process *fp, *pp;
int omask;
* pjwait - wait for a job to finish or become stopped
* It is assumed to be in the foreground state (PFOREGND)
*/
-int pjwait(pp) register struct process *pp; {
+void pjwait(pp) register struct process *pp; {
register struct process *fp;
int jobflags, reason, omask;
/*
* dowait - wait for all processes to finish
*/
-int dowait() {
+void dowait(v, kp) char **v; struct command *kp; {
register struct process *pp;
int omask;
/*
* pflushall - flush all jobs from list (e.g. at fork())
*/
-int pflushall() {
+void pflushall() {
register struct process *pp;
for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next)
* the argument process for deletion. The actual free of the
* space is not done here since pflush is called at interrupt level.
*/
-int pflush(pp) register struct process *pp; {
+void pflush(pp) register struct process *pp; {
register struct process *np;
register int index;
* pclrcurr - make sure the given job is not the current or previous job;
* pp MUST be the job leader
*/
-int pclrcurr(pp) register struct process *pp; {
+void pclrcurr(pp) register struct process *pp; {
if (pp == pcurrent)
if (pprevious != PNULL) {
* palloc - allocate a process structure and fill it up.
* an important assumption is made that the process is running.
*/
-int palloc(pid, t) int pid; register struct command *t; {
+void palloc(pid, t) int pid; register struct command *t; {
register struct process *pp;
int i;
(void) gettimeofday(&pp->p_btime, (struct timezone *)0);
}
-int padd(t) register struct command *t; {
+void padd(t) register struct command *t; {
char **argp;
if (t == 0)
}
}
-int pads(cp) char *cp; {
+void pads(cp) char *cp; {
register int i = strlen(cp);
if (cmdlen >= PMAXLEN)
* so another job can be created. Used for { } in exp6
* and `` in globbing.
*/
-int psavejob() {
+void psavejob() {
pholdjob = pcurrjob;
pcurrjob = PNULL;
* prestjob - opposite of psavejob. This may be missed if we are interrupted
* somewhere, but pendjob cleans up anyway.
*/
-int prestjob() {
+void prestjob() {
pcurrjob = pholdjob;
pholdjob = PNULL;
* pendjob - indicate that a job (set of commands) has been completed
* or is about to begin.
*/
-int pendjob() {
+void pendjob() {
register struct process *pp, *tp;
if (pcurrjob && (pcurrjob->p_flags&(PFOREGND|PSTOPPED)) == 0) {
return (jobflags);
}
-int ptprint(tp) register struct process *tp; {
+void ptprint(tp) register struct process *tp; {
struct timeval tetime, diff;
static struct timeval ztime;
struct rusage ru;
/*
* dojobs - print all jobs
*/
-int dojobs(v) char **v; {
+void dojobs(v, kp) char **v; struct command *kp; {
register struct process *pp;
register int flag = NUMBER|NAME|REASON;
int i;
/*
* dofg - builtin - put the job into the foreground
*/
-int dofg(v) char **v; {
+void dofg(v, kp) char **v; struct command *kp; {
register struct process *pp;
okpcntl();
/*
* %... - builtin - put the job into the foreground
*/
-int dofg1(v) char **v; {
+void dofg1(v, kp) char **v; struct command *kp; {
register struct process *pp;
okpcntl();
/*
* dobg - builtin - put the job into the background
*/
-int dobg(v) char **v; {
+void dobg(v, kp) char **v; struct command *kp; {
register struct process *pp;
okpcntl();
/*
* %... & - builtin - put the job into the background
*/
-int dobg1(v) char **v; {
+void dobg1(v, kp) char **v; struct command *kp; {
register struct process *pp;
pp = pfind(v[0]);
/*
* dostop - builtin - stop the job
*/
-int dostop(v) char **v; {
+void dostop(v, kp) char **v; struct command *kp; {
pkill(++v, SIGSTOP);
}
/*
* dokill - builtin - superset of kill (1)
*/
-int dokill(v) char **v; {
+void dokill(v, kp) char **v; struct command *kp; {
register int signum;
register char *name;
pkill(v, signum);
}
-int pkill(v, signum) char **v; int signum; {
+void pkill(v, signum) char **v; int signum; {
register struct process *pp, *np;
register int jobflags = 0;
int omask, pid, err = 0;
/*
* pstart - start the job in foreground/background
*/
-int pstart(pp, foregnd) register struct process *pp; int foregnd; {
+void pstart(pp, foregnd) register struct process *pp; int foregnd; {
register struct process *np;
int omask, jobflags = 0;
(void) sigsetmask(omask);
}
-int panystop(neednl) int neednl; {
+void panystop(neednl) int neednl; {
register struct process *pp;
chkstop = 2;
/*
* donotify - flag the job so as to report termination asynchronously
*/
-int donotify(v) char **v; {
+void donotify(v, kp) char **v; struct command *kp; {
register struct process *pp;
pp = pfind(*++v);
return (pid);
}
-int okpcntl() {
+void okpcntl() {
if (tpgrp == -1)
error("No job control in this shell");
#endif
/* sh.proc.c */
-int pchild __P((void));
-int pnote __P((void));
-int pwait __P((void));
-int pjwait __P((register struct process *pp));
-int dowait __P((void));
-int pflushall __P((void));
-int pflush __P((register struct process *pp));
-int pclrcurr __P((register struct process *pp));
-int palloc __P((int pid, register struct command *t));
-int padd __P((register struct command *t));
-int pads __P((char *cp));
-int psavejob __P((void));
-int prestjob __P((void));
-int pendjob __P((void));
+void pchild __P((void));
+void pnote __P((void));
+void pwait __P((void));
+void pjwait __P((register struct process *pp));
+void dowait __P((char **v, struct command *kp));
+void pflushall __P((void));
+void pflush __P((register struct process *pp));
+void pclrcurr __P((register struct process *pp));
+void palloc __P((int pid, register struct command *t));
+void padd __P((register struct command *t));
+void pads __P((char *cp));
+void psavejob __P((void));
+void prestjob __P((void));
+void pendjob __P((void));
int pprint __P((register struct process *pp, int flag));
-int ptprint __P((register struct process *tp));
-int dojobs __P((char **v));
-int dofg __P((char **v));
-int dofg1 __P((char **v));
-int dobg __P((char **v));
-int dobg1 __P((char **v));
-int dostop __P((char **v));
-int dokill __P((char **v));
-int pkill __P((char **v, int signum));
-int pstart __P((register struct process *pp, int foregnd));
-int panystop __P((int neednl));
+void ptprint __P((register struct process *tp));
+void dojobs __P((char **v, struct command *kp));
+void dofg __P((char **v, struct command *kp));
+void dofg1 __P((char **v, struct command *kp));
+void dobg __P((char **v, struct command *kp));
+void dobg1 __P((char **v, struct command *kp));
+void dostop __P((char **v, struct command *kp));
+void dokill __P((char **v, struct command *kp));
+void pkill __P((char **v, int signum));
+void pstart __P((register struct process *pp, int foregnd));
+void panystop __P((int neednl));
struct process *pfind __P((char *cp));
struct process *pgetcurr __P((register struct process *pp));
-int donotify __P((char **v));
+void donotify __P((char **v, struct command *kp));
int pfork __P((struct command *t, int wanttty));
-int okpcntl __P((void));
+void okpcntl __P((void));
/* sh.sem.c */
-int execute __P((register struct command *t, int wanttty, int *pipein, int *pipeout));
-int vffree __P((void));
-int doio __P((register struct command *t, int *pipein, int *pipeout));
-int mypipe __P((register int *pv));
-int chkclob __P((register char *cp));
+void execute __P((register struct command *t, int wanttty, int *pipein, int *pipeout));
+void vffree __P((void));
+void doio __P((register struct command *t, int *pipein, int *pipeout));
+void mypipe __P((register int *pv));
+void chkclob __P((register char *cp));
#endif
* C shell
*/
-int execute(t, wanttty, pipein, pipeout) register struct command *t; int wanttty; int *pipein; int *pipeout; {
+void execute(t, wanttty, pipein, pipeout) register struct command *t; int wanttty; int *pipein; int *pipeout; {
bool forked = 0;
struct biltins *bifunc;
int pid = 0;
{ forked++; pid = pfork(t, wanttty); }
#ifdef VFORK
else {
- int vffree();
+ void vffree();
int ochild, osetintr, ohaderr, odidfds;
int oSHIN, oSHOUT, oSHDIAG, oOLDSTD, otpgrp;
int omask;
(void) signal(SIGCHLD, SIG_DFL);
#endif
(void) signal(SIGINT, ignint ?
- SIG_IGN : vffree);
+ SIG_IGN : (void (*) __P((int sig)))vffree);
(void) signal(SIGQUIT, ignint ?
SIG_IGN : SIG_DFL);
if (wanttty >= 0) {
}
#ifdef VFORK
-int vffree() {
+void vffree() {
register char **v;
if (v = gargv)
* Perform io redirection.
* We may or maynot be forked here.
*/
-int doio(t, pipein, pipeout) register struct command *t; int *pipein; int *pipeout; {
+void doio(t, pipein, pipeout) register struct command *t; int *pipein; int *pipeout; {
register char *cp;
register int flags = t->t_dflg;
didfds = 1;
}
-int mypipe(pv) register int *pv; {
+void mypipe(pv) register int *pv; {
if (pipe(pv) < 0)
goto oops;
error("Can't make pipe");
}
-int chkclob(cp) register char *cp; {
+void chkclob(cp) register char *cp; {
struct stat stb;
if (stat(cp, &stb) < 0)
* C Shell
*/
-int doset(v) register char **v; {
+void doset(v, kp) char **v; struct command *kp; {
register char *p;
char *vp, op;
char **vecp;
set(vp, savestr(p));
if (eq(vp, "path")) {
exportpath(adrof("path")->vec);
+#if defined(__STDC__) || defined(lint)
+ dohash(0, 0);
+#else
dohash();
+#endif
} else if (eq(vp, "histchars")) {
register char *p = value("histchars");
return (cp);
}
-int asx(vp, subscr, p) char *vp; int subscr; char *p; {
+void asx(vp, subscr, p) char *vp; int subscr; char *p; {
register struct varent *v = getvx(vp, subscr);
xfree(v->vec[subscr - 1]);
char plusplus[2] = { '1', 0 };
-int dolet(v) char **v; {
+void dolet(v, kp) char **v; struct command *kp; {
register char *p;
char *vp, c, op;
bool hadsub;
set(vp, operate(op, value(vp), p));
if (eq(vp, "path")) {
exportpath(adrof("path")->vec);
+#if defined(__STDC__) || defined(lint)
+ dohash(0, 0);
+#else
dohash();
+#endif
}
XFREE(vp)
if (c != '=')
return (savestr(number));
}
-int putn1(n) register int n; {
+void putn1(n) register int n; {
if (n > 9)
putn1(n / 10);
*putp++ = n % 10 + '0';
/*
* The caller is responsible for putting value in a safe place
*/
-int set(var, val) char *var; char *val; {
+void set(var, val) char *var; char *val; {
register char **vec = (char **) xalloc(2 * sizeof (char **));
vec[0] = onlyread(val) ? savestr(val) : val;
set1(var, vec, &shvhed);
}
-int set1(var, vec, head) char *var; char **vec; struct varent *head; {
+void set1(var, vec, head) char *var; char **vec; struct varent *head; {
register char **oldv = vec;
gflag = 0; tglob(oldv);
setq(var, vec, head);
}
-int setq(name, vec, p) char *name; char **vec; register struct varent *p; {
+void setq(name, vec, p) char *name; char **vec; register struct varent *p; {
register struct varent *c;
register f;
trim(c->vec = vec);
}
-int unset(v) char *v[]; {
+void unset(v, kp) char **v; struct command *kp; {
unset1(v, &shvhed);
if (adrof("histchars") == 0) {
#endif
}
-int unset1(v, head) register char *v[]; struct varent *head; {
+void unset1(v, head) register char **v; struct varent *head; {
register struct varent *vp;
register int cnt;
}
}
-int unsetv(var) char *var; {
+void unsetv(var) char *var; {
register struct varent *vp;
if ((vp = adrof1(var, &shvhed)) == 0)
unsetv1(vp);
}
-int unsetv1(p) register struct varent *p; {
+void unsetv1(p) register struct varent *p; {
register struct varent *c, *pp;
register f;
balance(pp, f, 1);
}
-int setNS(cp) char *cp; {
+void setNS(cp) char *cp; {
set(cp, "");
}
-int shift(v) register char **v; {
+void shift(v, kp) char **v; struct command *kp; {
register struct varent *argv;
register char *name;
lshift(argv->vec, 1);
}
-int exportpath(val) char **val; {
+void exportpath(val) char **val; {
char exppath[BUFSIZ];
exppath[0] = 0;
* F == 0 means we've come from p's left child.
* D == 1 means we've just done a delete, otherwise an insert.
*/
-int balance(p, f, d) register struct varent *p; register f; int d; {
+void balance(p, f, d) register struct varent *p; register f; int d; {
register struct varent *pp;
register struct varent *t; /* used by the rotate macros */
register ff;
}
}
-int plist(p) register struct varent *p; {
+void plist(p) register struct varent *p; {
register struct varent *c;
register len;
* C Shell - routines handling process timing and niceing
*/
-int settimes() {
+void settimes() {
struct rusage ruch;
(void) gettimeofday(&time0, (struct timezone *)0);
* dotime is only called if it is truly a builtin function and not a
* prefix to another command
*/
-int dotime() {
+void dotime(v, kp) char **v; struct command *kp; {
struct timeval timedol;
struct rusage ru1, ruch;
/*
* donice is only called when it on the line by itself or with a +- value
*/
-int donice(v) register char **v; {
+void donice(v, kp) char **v; struct command *kp; {
register char *cp;
int nval;
(void) setpriority(PRIO_PROCESS, 0, nval);
}
-int ruadd(ru, ru2) register struct rusage *ru; register struct rusage *ru2; {
+void ruadd(ru, ru2) register struct rusage *ru; register struct rusage *ru2; {
register long *lp, *lp2;
register int cnt;
while (--cnt > 0);
}
-int prusage(r0, r1, e, b) register struct rusage *r0; register struct rusage *r1; struct timeval *e; struct timeval *b; {
+void prusage(r0, r1, e, b) register struct rusage *r0; register struct rusage *r1; struct timeval *e; struct timeval *b; {
register time_t t =
(r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+
(r1->ru_utime.tv_usec-r0->ru_utime.tv_usec)/10000+
putchar('\n');
}
-int pdeltat(t1, t0) struct timeval *t1; struct timeval *t0; {
+void pdeltat(t1, t0) struct timeval *t1; struct timeval *t0; {
struct timeval td;
tvsub(&td, t1, t0);
printf("%d.%01d", td.tv_sec, td.tv_usec/100000);
}
-int tvadd(tsum, t0) struct timeval *tsum; struct timeval *t0; {
+void tvadd(tsum, t0) struct timeval *tsum; struct timeval *t0; {
tsum->tv_sec += t0->tv_sec;
tsum->tv_usec += t0->tv_usec;
tsum->tv_sec++, tsum->tv_usec -= 1000000;
}
-int tvsub(tdiff, t1, t0) struct timeval *tdiff; struct timeval *t1; struct timeval *t0; {
+void tvsub(tdiff, t1, t0) struct timeval *tdiff; struct timeval *t1; struct timeval *t0; {
tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
tdiff->tv_usec = t1->tv_usec - t0->tv_usec;
--- /dev/null
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+s/[^A-Za-z0-9_]\+/@&@/g
+
+s/@isspace@/@_isspace@/g
+
+s/@//g
+s/ATSIGN/@/g
--- /dev/null
+#ifdef __STDC__
+#include <stdarg.h>
+#define _va_start(argp, arg) va_start(argp, arg)
+#else
+#include <varargs.h>
+#define _va_start(argp, arg) va_start(argp)
+#endif
+#include "sh.h"
+
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)vprintf.c 5.2 (Berkeley) 6/27/88";
+#endif
+
+/*#include <stdio.h>*/
+/*#include <varargs.h>*/
+
+int vprintf(fmt, argp) char *fmt; va_list argp; {
+ int len;
+
+ len = _doprnt(fmt, argp/*, stdout*/);
+ return (/*ferror(stdout) ? EOF :*/ len);
+}
amt = 16; /* size of first bucket */
bucket = 1;
#endif
- n = -(intptr_t)(sizeof (*op) + RSLOP);
+ n = -(int)(sizeof (*op) + RSLOP);
} else {
amt = pagesz;
bucket = pagebucket;
}
op = (union overhead *)sbrk(amt);
/* no more room! */
- if ((intptr_t)op == -1)
+ if (op == (union overhead *)-1)
return;
/*
* Add new memory allocated to that on
static char *round __P((double fract, int *exp, register char *start, register char *end, int ch, char *signp));
static char *exponent __P((register char *p, register int exp, int fmtch));
-int _doprnt(fmt0, argp, fp) u_char *fmt0; va_list argp; register FILE *fp; {
- register u_char *fmt; /* format string */
+int _doprnt(fmt, argp, fp) char *fmt; va_list argp; register FILE *fp; {
register int ch; /* character from fmt */
register int cnt; /* return value accumulator */
register int n; /* random handy integer */
register char *t; /* buffer pointer */
double _double; /* double precision arguments %[eEfgG] */
- uintptr_t _ulong; /* integer arguments %[diouxX] */
+ uintptr_t _ulong; /* integer arguments %[diouxX] */
int base; /* base for [diouxX] conversion */
int dprec; /* decimal precision in [diouxX] */
int fieldsz; /* field size expanded by sign, etc */
if ((fp->_flag & _IOWRT) == 0)
return (EOF);
- fmt = fmt0;
digs = "0123456789abcdef";
for (cnt = 0;; ++fmt) {
n = fp->_cnt;
case 'd':
case 'i':
ARG();
- if ((intptr_t)_ulong < 0)
- {
+ if ((intptr_t)_ulong < 0) {
_ulong = -_ulong;
sign = '-';
}