Post-ansification changes for bin/csh
authorNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 05:32:43 +0000 (16:32 +1100)
committerNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 14:45:03 +0000 (01:45 +1100)
32 files changed:
.gitignore
bin/csh/Makefile
bin/csh/doprnt.c
bin/csh/malloc.c
bin/csh/sh.c
bin/csh/sh.char.h
bin/csh/sh.data.c
bin/csh/sh.dir.c
bin/csh/sh.dir.h
bin/csh/sh.dol.c
bin/csh/sh.err.c
bin/csh/sh.exec.c
bin/csh/sh.exp.c
bin/csh/sh.file.c
bin/csh/sh.func.c
bin/csh/sh.glob.c
bin/csh/sh.h
bin/csh/sh.hist.c
bin/csh/sh.init.c
bin/csh/sh.lex.c
bin/csh/sh.misc.c
bin/csh/sh.parse.c
bin/csh/sh.print.c
bin/csh/sh.proc.c
bin/csh/sh.proc.h
bin/csh/sh.sem.c
bin/csh/sh.set.c
bin/csh/sh.time.c
bin/csh/uniqify.sed [new file with mode: 0644]
bin/csh/vprintf.c [new file with mode: 0644]
lib/libc/gen/malloc.c
lib/libc/stdio/doprnt.c

index b5f7df3..1e263c6 100644 (file)
@@ -1,5 +1,6 @@
 *.a
 *.allprotos
+*.cproto
 *.nocomm
 *.o
 *.oldprotos
index 0ff7f3c..34e1982 100644 (file)
@@ -21,10 +21,10 @@ CTAGS=      /usr/ucb/ctags
 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}
index 6e76511..b53b2c4 100644 (file)
@@ -1,4 +1,4 @@
-/*#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.
@@ -75,15 +82,14 @@ static cvt __P((double number, register int prec, int flags, char *signp, int fm
 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 */
@@ -107,7 +113,6 @@ int _doprnt(fmt0, argp) u_char *fmt0; va_list argp;
                return (EOF);
 #endif
 
-       fmt = fmt0;
        digs = "0123456789abcdef";
        for (cnt = 0;; ++fmt) {
 #if 1 /* for csh */
@@ -217,7 +222,7 @@ rflag:              switch (*++fmt) {
                case 'd':
                case 'i':
                        ARG();
-                       if ((long)_ulong < 0) {
+                       if ((intptr_t)_ulong < 0) {
                                _ulong = -_ulong;
                                sign = '-';
                        }
@@ -286,7 +291,7 @@ rflag:              switch (*++fmt) {
                         *      -- ANSI X3J11
                         */
                        /* NOSTRICT */
-                       _ulong = (u_long)va_arg(argp, void *);
+                       _ulong = (uintptr_t)va_arg(argp, void *);
                        base = 16;
                        goto nosign;
                case 's':
index 22c06a1..1678d0a 100644 (file)
@@ -88,9 +88,6 @@ static        u_int nmalloc[NBUCKETS];
 
 #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();
@@ -99,6 +96,8 @@ static void botch(s) char *s; {
 #define        ASSERT(p)
 #endif
 
+static findbucket __P((union overhead *freep, int srchlen));
+
 void *malloc(nbytes) unsigned nbytes; {
        register union overhead *op;
        register int bucket;
@@ -140,7 +139,7 @@ void *malloc(nbytes) unsigned nbytes; {
                amt = 16;       /* size of first bucket */
                bucket = 1;
 #endif
-               n = -(sizeof (*op) + RSLOP);
+               n = -(int)(sizeof (*op) + RSLOP);
        } else {
                amt = pagesz;
                bucket = pagebucket;
@@ -206,7 +205,7 @@ void morecore(bucket) int bucket; {
        }
        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
@@ -348,7 +347,7 @@ static findbucket(freep, srchlen) union overhead *freep; int srchlen; {
  * 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,
index 66f9686..f13ba7f 100644 (file)
@@ -55,7 +55,7 @@ bool  enterhist = 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;
@@ -119,14 +119,14 @@ int main(c, av) int c; char **av; {
         */
                /* 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 */
        }
 
        /*
@@ -267,7 +267,7 @@ int main(c, av) int c; char **av; {
                **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) {
@@ -293,7 +293,7 @@ retry:
                            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;
@@ -325,7 +325,7 @@ notty:
        }
        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
@@ -338,11 +338,19 @@ notty:
                /* 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
        }
 
        /*
@@ -374,7 +382,7 @@ notty:
        exitstat();
 }
 
-int untty() {
+void untty() {
 
        if (tpgrp > 0) {
                (void) setpgrp(0, opgrp);
@@ -388,7 +396,7 @@ int untty() {
        }
 }
 
-int importpath(cp) char *cp; {
+void importpath(cp) char *cp; {
        register int i = 0;
        register char *dp;
        register char **pv;
@@ -426,7 +434,7 @@ int importpath(cp) char *cp; {
 /*
  * 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);
 
@@ -443,7 +451,7 @@ int srccat(cp, dp) char *cp; char *dp; {
  * 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;
@@ -550,7 +558,7 @@ int srcunit(unit, onlyown, hflg) register int unit; int onlyown; int hflg; {
                error(NOSTR);
 }
 
-int rechist() {
+void rechist() {
        char buf[BUFSIZ];
        int fp, ftmp, oldidfds;
 
@@ -568,14 +576,18 @@ int rechist() {
                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);
@@ -588,7 +600,7 @@ int goodbye() {
        exitstat();
 }
 
-int exitstat() {
+void exitstat() {
 
 #ifdef PROF
        monitor(0);
@@ -605,7 +617,7 @@ int exitstat() {
 /*
  * in the event of a HUP we want to save the history
  */
-int phup() {
+void phup() {
        rechist();
        exit(1);
 }
@@ -618,11 +630,11 @@ char      *jobargv[2] = { "jobs", 0 };
  * 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;
 
@@ -632,7 +644,11 @@ int pintr1(wantnl) int wantnl; {
                if (pjobs) {
                        pjobs = 0;
                        printf("\n");
+#if defined(__STDC__) || defined(lint)
+                       dojobs(jobargv, 0);
+#else
                        dojobs(jobargv);
+#endif
                        bferr("Interrupted");
                }
        }
@@ -671,7 +687,7 @@ int pintr1(wantnl) int wantnl; {
  * 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;
 
@@ -802,7 +818,7 @@ int process(catch) int catch; {
        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;
@@ -832,7 +848,7 @@ int dosource(t) register char **t; {
  * 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;
@@ -887,7 +903,7 @@ int gethdir(home) char *home; {
  * 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);
@@ -907,7 +923,7 @@ int exit(i)
        _exit(i);
 }
 
-int printprompt() {
+void printprompt() {
        register char *cp;
 
        if (!whyles) {
index 0ff14bc..3c2c3b5 100644 (file)
@@ -1,8 +1,6 @@
 #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
@@ -33,7 +31,7 @@ extern unsigned short _cmap[];
 #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)
index ee674fd..6253c77 100644 (file)
@@ -179,7 +179,7 @@ char        HISTSUB;                        /* auto-substitute character */
 /*
  * In lines for frequently called functions
  */
-char   *alloctmp;
+void   *alloctmp;
 
 /*
  * setname is a macro to save space (see sh.err.c)
index 8d2ef56..d85f2e6 100644 (file)
@@ -35,7 +35,7 @@ static        char *fakev[] = { "dirs", NOSTR };
 /*
  * 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];
@@ -61,7 +61,7 @@ int dinit(hp) char *hp; {
 /*
  * 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");
@@ -88,7 +88,7 @@ int dodirs(v) char **v; {
        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));
@@ -99,7 +99,7 @@ int dtildepr(home, dir) register char *home; register char *dir; {
 /*
  * 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;
 
@@ -207,7 +207,7 @@ gotcha:
  *     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;
@@ -272,7 +272,7 @@ struct directory *dfind(cp) register char *cp; {
  * 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;
@@ -293,14 +293,18 @@ int dopopd(v) char **v; {
        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;
@@ -449,10 +453,14 @@ char *dcanon(cp, p) register char *cp; register char *p; {
 /*
  * 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
 }
index 17a22be..83cf6ec 100644 (file)
@@ -1,6 +1,8 @@
 #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
@@ -29,16 +31,16 @@ struct directory *dcwd;             /* the one we are in now */
 #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
index 358b701..40be35c 100644 (file)
@@ -57,7 +57,7 @@ int   dolmcnt;                /* :gx -> 10000, else 1 */
  * 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;
 
@@ -97,7 +97,7 @@ char *Dfix1(cp) register char *cp; {
 /*
  * 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 */
@@ -280,13 +280,13 @@ quotspec:
 }
 
 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];
@@ -502,7 +502,7 @@ eatbrac:
        }
 }
 
-int setDolp(cp) register char *cp; {
+void setDolp(cp) register char *cp; {
        register char *dp;
 
        if (dolmod == 0 || dolmcnt == 0) {
@@ -519,7 +519,7 @@ int setDolp(cp) register char *cp; {
        dolp = "";
 }
 
-int unDredc(c) int c; {
+void unDredc(c) int c; {
 
        Dpeekrd = c;
 }
@@ -541,7 +541,7 @@ int Dredc() {
        return (' ');
 }
 
-int Dtestq(c) register int c; {
+void Dtestq(c) register int c; {
 
        if (cmap(c, QUOTES))
                gflag = 1;
@@ -552,7 +552,7 @@ int Dtestq(c) register int c; {
  * 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];
index 5fb16d4..3af4b3b 100644 (file)
@@ -70,7 +70,7 @@ int error(s, va_alist) char *s; va_dcl
         * an error diagnostic here.
         */
        if (s) {
-               _va_start(argp, fmt);
+               _va_start(argp, s);
                vprintf(s, argp), printf(".\n");
                va_end(argp);
        }
@@ -105,7 +105,7 @@ int error(s, va_alist) char *s; va_dcl
  * 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
@@ -121,7 +121,7 @@ int Perror(s) char *s; {
        error(NOSTR);           /* To exit or unwind */
 }
 
-int bferr(cp) char *cp; {
+void bferr(cp) char *cp; {
 
        flush();
        haderr = 1;
@@ -134,14 +134,14 @@ int bferr(cp) char *cp; {
  * 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;
@@ -150,7 +150,7 @@ int seterr2(cp, dp) char *cp; char *dp; {
 }
 
 /* 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;
index bf89f4f..f9fc343 100644 (file)
@@ -68,7 +68,7 @@ int   hits, misses;
 /* 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;
@@ -180,7 +180,7 @@ cont:
        pexerr();
 }
 
-int pexerr() {
+void pexerr() {
 
        /* Couldn't find the damn thing */
        setname(expath);
@@ -195,7 +195,7 @@ int pexerr() {
  * 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[];
@@ -250,7 +250,7 @@ int texec(f, t) char *f; register char **t; {
 }
 
 /*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);
@@ -262,7 +262,7 @@ int execash(t, kp) char **t; register struct command *kp; {
        /*NOTREACHED*/
 }
 
-int xechoit(t) char **t; {
+void xechoit(t) char **t; {
 
        if (adrof("echo")) {
                flush();
@@ -272,7 +272,7 @@ int xechoit(t) char **t; {
        }
 }
 
-int dohash() {
+void dohash(t, kp) char **t; struct command *kp; {
        struct stat stb;
        DIR *dirp;
        register struct direct *dp;
@@ -311,13 +311,13 @@ int dohash() {
        }
 }
 
-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",
index 61de5ad..60908f5 100644 (file)
@@ -454,7 +454,7 @@ char *exp6(vp, ignore) register char ***vp; int ignore; {
        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 = &paraml;
        struct command *t;
index b6e8c2f..362164c 100644 (file)
@@ -50,27 +50,27 @@ typedef enum {LIST, RECOGNIZE} COMMAND;
  */
 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 */
 
@@ -97,7 +97,7 @@ static setup_tty(on) int on; {
 /*
  * 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;
 
@@ -114,7 +114,7 @@ static back_to_col_1() {
 /*
  * 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;
@@ -136,7 +136,7 @@ static pushback(string) char *string; {
  * 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++;
@@ -150,7 +150,7 @@ static catn(des, src, count) register char *des; register char *src; register co
  * 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)
@@ -191,7 +191,7 @@ static struct winsize win;
 /*
  * 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)
@@ -254,13 +254,13 @@ static char *tilde(new, old) char *new; char *old; {
 /*
  * 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);
@@ -270,7 +270,7 @@ static beep() {
  * 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)) {
@@ -294,7 +294,7 @@ static print_recognized_stuff(recognized_part) char *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, '/');
@@ -321,7 +321,7 @@ static char *getentry(dir_fd, looking_for_lognames) DIR *dir_fd; int looking_for
        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++)
@@ -424,7 +424,7 @@ again:      /* _search for matches */
                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)
index f963879..632f4c4 100644 (file)
@@ -35,7 +35,7 @@ static char *sccsid = "@(#)sh.func.c  5.3 (Berkeley) 5/13/86";
 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 };
@@ -73,7 +73,7 @@ struct biltins *isbfunc(t) struct command *t; {
        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);
@@ -86,11 +86,11 @@ int func(t, bp) register struct command *t; register struct biltins *bp; {
        (*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];
 
@@ -110,11 +110,11 @@ int doonintr(v) char **v; {
                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");
@@ -126,17 +126,17 @@ int donohup() {
        }
 }
 
-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;
 
@@ -157,18 +157,18 @@ int doalias(v) register char **v; {
        }
 }
 
-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();
@@ -191,7 +191,7 @@ int donewgrp(v) char **v; {
 }
 #endif
 
-int islogin() {
+void islogin() {
 
        if (chkstop == 0 && setintr)
                panystop(0);
@@ -200,7 +200,7 @@ int islogin() {
        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;
 
@@ -241,7 +241,7 @@ int doif(v, kp) char **v; struct command *kp; {
  * 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;
@@ -258,7 +258,7 @@ int reexecute(kp) register struct command *kp; {
 #endif
 }
 
-int doelse() {
+void doelse(v, kp) char **v; struct command *kp; {
 #if defined(__STDC__) || defined(lint)
        search(ZELSE, 0, 0);
 #else
@@ -266,7 +266,7 @@ int doelse() {
 #endif
 }
 
-int dogoto(v) char **v; {
+void dogoto(v, kp) char **v; struct command *kp; {
        register struct whyle *wp;
        char *lp;
 
@@ -293,7 +293,7 @@ int dogoto(v) char **v; {
        wfree();
 }
 
-int doswitch(v) register char **v; {
+void doswitch(v, kp) char **v; struct command *kp; {
        register char *cp, *lp;
 
        v++;
@@ -309,7 +309,7 @@ syntax:
        xfree(lp);
 }
 
-int dobreak() {
+void dobreak(v, kp) char **v; struct command *kp; {
 
        if (whyles)
                toend();
@@ -317,7 +317,7 @@ int dobreak() {
                bferr("Not in while/foreach");
 }
 
-int doexit(v) char **v; {
+void doexit(v, kp) char **v; struct command *kp; {
 
        if (chkstop == 0)
                panystop(0);
@@ -335,7 +335,7 @@ int doexit(v) char **v; {
                (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;
 
@@ -368,7 +368,7 @@ int doforeach(v) register char **v; {
        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;
@@ -406,7 +406,7 @@ int dowhile(v) char **v; {
                toend();
 }
 
-int preread() {
+void preread() {
 
        whyles->w_end = -1;
        if (setintr)
@@ -421,7 +421,7 @@ int preread() {
        whyles->w_end = btell();
 }
 
-int doend() {
+void doend(v, kp) char **v; struct command *kp; {
 
        if (!whyles)
                bferr("Not in while/foreach");
@@ -429,14 +429,14 @@ int doend() {
        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) {
@@ -449,14 +449,18 @@ int doagain() {
         * 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]);
@@ -474,7 +478,7 @@ int dorepeat(v, kp) char **v; struct command *kp; {
                (void) sigsetmask(omask);
 }
 
-int doswbrk() {
+void doswbrk(v, kp) char **v; struct command *kp; {
 #if defined(__STDC__) || defined(lint)
        search(ZBRKSW, 0, 0);
 #else
@@ -508,7 +512,7 @@ char        Stype;
 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;
@@ -660,9 +664,12 @@ past:
                bferr("label not found");
        }
        /*NOTREACHED*/
+#ifdef __GNUC__
+       return 0;
+#endif
 }
 
-int toend() {
+void toend() {
 
        if (whyles->w_end == 0) {
 #if defined(__STDC__) || defined(lint)
@@ -676,7 +683,7 @@ int toend() {
        wfree();
 }
 
-int wfree() {
+void wfree() {
        long o = btell();
 
        while (whyles) {
@@ -694,18 +701,18 @@ int wfree() {
        }
 }
 
-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;
 
@@ -743,7 +750,7 @@ int echo(sep, v) int sep; register char **v; {
 
 char   **environ;
 
-int dosetenv(v) register char **v; {
+void dosetenv(v, kp) char **v; struct command *kp; {
        char *vp, *lp;
 
        v++;
@@ -761,12 +768,16 @@ int dosetenv(v) register char **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
@@ -774,7 +785,7 @@ int dounsetenv(v) register char **v; {
        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;
@@ -797,7 +808,7 @@ int setenv(name, val) char *name; char *val; {
        setenv(name, val);
 }
 
-int unsetenv(name) char *name; {
+void unsetenv(name) char *name; {
        register char **ep = environ;
        register char *cp, *dp;
        char **oep = ep;
@@ -817,7 +828,7 @@ int unsetenv(name) char *name; {
        }
 }
 
-int doumask(v) register char **v; {
+void doumask(v, kp) char **v; struct command *kp; {
        register char *cp = v[1];
        register int i;
 
@@ -841,13 +852,13 @@ struct limits {
        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; {
@@ -866,7 +877,7 @@ 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;
@@ -956,7 +967,7 @@ badscal:
        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)
@@ -965,7 +976,7 @@ int limtail(cp, str0) char *cp; char *str0; {
                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;
 
@@ -981,7 +992,7 @@ int plim(lp, hard) register struct limits *lp; int hard; {
        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;
@@ -1025,9 +1036,9 @@ int setlim(lp, hard, limit) register struct limits *lp; int hard; int limit; {
        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)");
@@ -1056,7 +1067,7 @@ retry:
        }
 }
 
-int doeval(v) char **v; {
+void doeval(v, kp) char **v; struct command *kp; {
        char **oevalvec = evalvec;
        char *oevalp = evalp;
        jmp_buf osetexit;
index e612dfb..473f8d1 100644 (file)
@@ -38,8 +38,12 @@ char *entp;
 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];
@@ -66,13 +70,13 @@ char **glob(v) register char **v; {
                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)) {
@@ -101,7 +105,7 @@ int collect(as) register char *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;
@@ -123,7 +127,7 @@ int sortscmp(a1, a2) char **a1; char **a2; {
         return (strcmp(*a1, *a2));
 }
 
-int expand(as) char *as; {
+void expand(as) char *as; {
        register char *cs;
        register char *sgpathp, *oldcs;
        struct stat stb;
@@ -173,7 +177,7 @@ endit:
        *gpathp = 0;
 }
 
-int matchdir(pattern) char *pattern; {
+void matchdir(pattern) char *pattern; {
        struct stat stb;
        register struct direct *dp;
        register DIR *dirp;
@@ -434,7 +438,7 @@ int Gmatch(s, p) register char *s; register char *p; {
        }
 }
 
-int Gcat(s1, s2) char *s1; char *s2; {
+void Gcat(s1, s2) char *s1; char *s2; {
        register char *p, *q;
        int n;
 
@@ -453,7 +457,7 @@ int Gcat(s1, s2) char *s1; char *s2; {
                ;
 }
 
-int addpath(c) int c; {
+void addpath(c) int c; {
 
        if (gpathp >= lastgpathp)
                error("Pathname too long");
@@ -461,7 +465,7 @@ int addpath(c) int c; {
        *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++)
@@ -469,7 +473,7 @@ int rscan(t, f) register char **t; int (*f)(); {
                        (*f)(*p++);
 }
 
-int trim(t) register char **t; {
+void trim(t) register char **t; {
        register char *p;
 
        while (p = *t++)
@@ -477,7 +481,7 @@ int trim(t) register char **t; {
                        *p++ &= TRIM;
 }
 
-int tglob(t) register char **t; {
+void tglob(t) register char **t; {
        register char *p, c;
 
        while (p = *t++) {
@@ -580,7 +584,7 @@ oops:
        }
 }
 
-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];
@@ -697,14 +701,14 @@ int backeval(cp, literal) char *cp; int literal; {
        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)
index a9c22ce..c320420 100644 (file)
@@ -101,9 +101,19 @@ extern int oldisc;                 /* Initial line discipline or -1 */
  * 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;
@@ -144,8 +154,8 @@ extern jmp_buf      reslab;
 #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.
@@ -400,8 +410,8 @@ extern char HISTSUB;                        /* auto-substitute character */
        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();*/
@@ -484,77 +494,77 @@ extern struct     mesg {
        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 */
@@ -570,7 +580,7 @@ char *exp3a __P((register char ***vp, int ignore));
 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));
@@ -581,97 +591,97 @@ int tenex __P((char *inputline, int inputline_size));
 
 /* 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));
@@ -680,51 +690,51 @@ int matchs __P((register char *str, register char *pat));
 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));
@@ -733,50 +743,53 @@ struct command *syn1a __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
index ff1edba..26d46c2 100644 (file)
@@ -18,7 +18,7 @@ static char *sccsid = "@(#)sh.hist.c  5.2 (Berkeley) 6/6/85";
  * 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;
@@ -64,13 +64,13 @@ struct Hist *enthist(event, lp, docopy) int event; register struct wordent *lp;
        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;
@@ -102,7 +102,7 @@ int dohist(vp) char **vp; {
        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)
@@ -121,7 +121,7 @@ top:
        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);
index a40e65f..51addc8 100644 (file)
@@ -1,4 +1,6 @@
-#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.
@@ -80,76 +82,76 @@ static char *sccsid = "@(#)sh.init.c        5.2 (Berkeley) 6/6/85";
 #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;
 
@@ -174,58 +176,58 @@ 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"}
 };
index 5dd644f..dad7be0 100644 (file)
@@ -110,7 +110,7 @@ int lex(hp) register struct wordent *hp; {
        return (hadhist);
 }
 
-int prlex(sp0) struct wordent *sp0; {
+void prlex(sp0) struct wordent *sp0; {
        register struct wordent *sp = sp0->next;
 
        for (;;) {
@@ -123,7 +123,7 @@ int prlex(sp0) struct wordent *sp0; {
        }
 }
 
-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;
@@ -141,7 +141,7 @@ int copylex(hp, fp) register struct wordent *hp; register struct wordent *fp; {
        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) {
@@ -321,7 +321,7 @@ top:
        return (c);
 }
 
-int getdol() {
+void getdol() {
        register char *np;
        char name[40];
        register int c;
@@ -419,7 +419,7 @@ vsyn:
        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) {
@@ -439,7 +439,7 @@ char        slhs[32];
 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;
@@ -1004,19 +1004,19 @@ struct Hist *findev(cp, anyarg) char *cp; int anyarg; {
        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;
 }
@@ -1214,7 +1214,7 @@ again:
        return (c);
 }
 
-int bfree() {
+void bfree() {
        register int sb, i;
 
 #ifdef TELL
@@ -1234,7 +1234,7 @@ int bfree() {
        }
 }
 
-int bseek(l) off_t l; {
+void bseek(l) off_t l; {
        register struct whyle *wp;
 
        fseekp = l;
@@ -1252,7 +1252,7 @@ int bseek(l) off_t l; {
 #endif
 }
 
-int btoeof() {
+void btoeof() {
 
        (void) lseek(SHIN, (off_t)0, 2);
        fseekp = feobp;
@@ -1261,7 +1261,7 @@ int btoeof() {
 }
 
 #ifdef TELL
-int settell() {
+void settell() {
 
        cantell = 0;
        if (arginp || onelflg || intty)
index afa0386..ae40114 100644 (file)
@@ -37,7 +37,7 @@ int onlyread(cp) char *cp; {
        return (cp < end);
 }
 
-int xfree(cp) char *cp; {
+void xfree(cp) char *cp; {
        extern char end[];
 
        if (cp >= end && cp < (char *) &cp)
@@ -67,7 +67,8 @@ void *calloc(i, j) register unsigned i; unsigned j; {
        return (cp);
 }
 
-int nomem(i) unsigned i; {
+/*ARGSUSED*/
+void *nomem(i) unsigned i; {
 #ifdef debug
        static char *av[2] = {0, 0};
 #endif
@@ -75,16 +76,13 @@ int nomem(i) unsigned i; {
        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; {
@@ -94,7 +92,7 @@ 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);
@@ -125,7 +123,7 @@ char **blkcat(up, vp) char **up; char **vp; {
        return (up);
 }
 
-int blkfree(av0) char **av0; {
+void blkfree(av0) char **av0; {
        register char **av = av0;
 
        for (; *av; av++)
@@ -181,7 +179,7 @@ int lastchr(cp) register char *cp; {
  * 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++)
@@ -190,7 +188,7 @@ int closem() {
                        (void) close(f);
 }
 
-int donefds() {
+void donefds() {
 
        (void) close(0);
        (void) close(1);
@@ -249,7 +247,7 @@ int renum(i, j) register int i; register int j; {
  * 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)
@@ -291,7 +289,7 @@ char *strip(cp) char *cp; {
        return (cp);
 }
 
-int udvar(name) char *name; {
+void udvar(name) char *name; {
 
        setname(name);
        bferr("Undefined variable");
index f16d10f..cd9ebee 100644 (file)
@@ -25,7 +25,7 @@ static char *sccsid = "@(#)sh.parse.c 5.3 (Berkeley) 5/13/86";
  * 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;
 
@@ -41,7 +41,7 @@ int alias(lex) register struct wordent *lex; {
        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"))
@@ -52,7 +52,7 @@ int asyntax(p1, p2) register struct wordent *p1; register struct wordent *p2; {
                }
 }
 
-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;
 
@@ -88,7 +88,7 @@ int asyn0(p1, p2) struct wordent *p1; register struct wordent *p2; {
                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;
@@ -151,7 +151,7 @@ struct wordent *freenod(p1, p2) register struct wordent *p1; register struct wor
 #define        PHERE   1
 #define        PIN     2
 #define        POUT    4
-#define        PDIAG   8
+#define        _PDIAG  8
 
 /*
  * syntax
@@ -371,7 +371,7 @@ struct command *syn2(p1, p2, flags) struct wordent *p1; struct wordent *p2; int
                        f = flags | POUT;
                        pn = p->next;
                        if (pn != p2 && pn->word[0] == '&') {
-                               f |= PDIAG;
+                               f |= _PDIAG;
                                t->t_dflg |= FDIAG;
                        }
                        t->t_dtyp = TFIL;
@@ -499,7 +499,7 @@ again:
                                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, "!"))
@@ -512,7 +512,7 @@ missfile:
                        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
@@ -562,7 +562,7 @@ savep:
        return (t);
 }
 
-int freesyn(t) register struct command *t; {
+void freesyn(t) register struct command *t; {
        register char **v;
 
        if (t == 0)
index 843aef6..837818e 100644 (file)
@@ -19,7 +19,7 @@ static char *sccsid = "@(#)sh.print.c 5.2 (Berkeley) 6/6/85";
  * C Shell
  */
 
-int psecs(l) long l; {
+void psecs(l) long l; {
        register int i;
 
        i = l / 3600;
@@ -37,7 +37,7 @@ minsec:
        p2dig(i);
 }
 
-int p2dig(i) register int i; {
+void p2dig(i) register int i; {
 
        printf("%d%d", i / 10, i % 10);
 }
@@ -45,7 +45,7 @@ int p2dig(i) register int i; {
 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('^');
@@ -60,12 +60,12 @@ int putchar(c) register int c; {
                flush();
 }
 
-int draino() {
+void draino() {
 
        linp = linbuf;
 }
 
-int flush() {
+void flush() {
        register int unit;
        int lmode;
 
index dd7f7d5..9b158a9 100644 (file)
@@ -42,7 +42,7 @@ static char *sccsid = "@(#)sh.proc.c  5.5 (Berkeley) 5/13/86";
  *     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;
@@ -51,7 +51,7 @@ int pchild() {
        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;
@@ -147,7 +147,7 @@ found:
        goto loop;
 }
 
-int pnote() {
+void pnote() {
        register struct process *pp;
        int flags, omask;
 
@@ -168,7 +168,7 @@ int pnote() {
  * 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;
 
@@ -194,7 +194,7 @@ int pwait() {
  * 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;
 
@@ -252,7 +252,7 @@ int pjwait(pp) register struct process *pp; {
 /*
  * dowait - wait for all processes to finish
  */
-int dowait() {
+void dowait(v, kp) char **v; struct command *kp; {
        register struct process *pp;
        int omask;
 
@@ -272,7 +272,7 @@ loop:
 /*
  * 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)
@@ -285,7 +285,7 @@ int pflushall() {
  *     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;
 
@@ -316,7 +316,7 @@ int pflush(pp) register struct process *pp; {
  * 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) {
@@ -338,7 +338,7 @@ char        *cmdp;
  * 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;
 
@@ -399,7 +399,7 @@ int palloc(pid, t) int pid; register struct command *t; {
        (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)
@@ -455,7 +455,7 @@ int padd(t) register struct command *t; {
        }
 }
 
-int pads(cp) char *cp; {
+void pads(cp) char *cp; {
        register int i = strlen(cp);
 
        if (cmdlen >= PMAXLEN)
@@ -476,7 +476,7 @@ int pads(cp) char *cp; {
  *     so another job can be created.  Used for { } in exp6
  *     and `` in globbing.
  */
-int psavejob() {
+void psavejob() {
 
        pholdjob = pcurrjob;
        pcurrjob = PNULL;
@@ -486,7 +486,7 @@ int psavejob() {
  * 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;
@@ -496,7 +496,7 @@ int prestjob() {
  * 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) {
@@ -643,7 +643,7 @@ prcomd:
        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;
@@ -664,7 +664,7 @@ int ptprint(tp) register struct process *tp; {
 /*
  * 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;
@@ -689,7 +689,7 @@ int dojobs(v) char **v; {
 /*
  * 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();
@@ -704,7 +704,7 @@ int dofg(v) char **v; {
 /*
  * %... - 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();
@@ -716,7 +716,7 @@ int dofg1(v) char **v; {
 /*
  * 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();
@@ -730,7 +730,7 @@ int dobg(v) char **v; {
 /*
  * %... & - 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]);
@@ -740,7 +740,7 @@ int dobg1(v) char **v; {
 /*
  * dostop - builtin - stop the job
  */
-int dostop(v) char **v; {
+void dostop(v, kp) char **v; struct command *kp; {
 
        pkill(++v, SIGSTOP);
 }
@@ -748,7 +748,7 @@ int dostop(v) char **v; {
 /*
  * 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;
 
@@ -784,7 +784,7 @@ gotsig:
        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;
@@ -846,7 +846,7 @@ cont:
 /*
  * 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;
 
@@ -873,7 +873,7 @@ int pstart(pp, foregnd) register struct process *pp; int foregnd; {
        (void) sigsetmask(omask);
 }
 
-int panystop(neednl) int neednl; {
+void panystop(neednl) int neednl; {
        register struct process *pp;
 
        chkstop = 2;
@@ -950,7 +950,7 @@ struct process *pgetcurr(pp) register struct process *pp; {
 /*
  * 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);
@@ -1044,7 +1044,7 @@ int pfork(t, wanttty) struct command *t;  /* command we are forking for */ int wa
        return (pid);
 }
 
-int okpcntl() {
+void okpcntl() {
 
        if (tpgrp == -1)
                error("No job control in this shell");
index bff8f22..ecce809 100644 (file)
@@ -99,43 +99,43 @@ short       pmaxindex;                      /* current maximum job index */
 #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
index 6eef10a..f2c34fb 100644 (file)
@@ -28,7 +28,7 @@ static char *sccsid = "@(#)sh.sem.c   5.4 (Berkeley) 5/13/86";
  * 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;
@@ -126,7 +126,7 @@ int execute(t, wanttty, pipein, pipeout) register struct command *t; int wanttty
                        { 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;
@@ -182,7 +182,7 @@ int execute(t, wanttty, pipein, pipeout) register struct command *t; int wanttty
                                        (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) {
@@ -336,7 +336,7 @@ int execute(t, wanttty, pipein, pipeout) register struct command *t; int wanttty
 }
 
 #ifdef VFORK
-int vffree() {
+void vffree() {
        register char **v;
 
        if (v = gargv)
@@ -351,7 +351,7 @@ int vffree() {
  * 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;
 
@@ -402,7 +402,7 @@ int doio(t, pipein, pipeout) register struct command *t; int *pipein; int *pipeo
        didfds = 1;
 }
 
-int mypipe(pv) register int *pv; {
+void mypipe(pv) register int *pv; {
 
        if (pipe(pv) < 0)
                goto oops;
@@ -414,7 +414,7 @@ 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)
index 95e9c7d..8694652 100644 (file)
@@ -20,7 +20,7 @@ static char *sccsid = "@(#)sh.set.c   5.2 (Berkeley) 6/6/85";
  * 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;
@@ -79,7 +79,11 @@ setsyn:
                        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");
 
@@ -109,7 +113,7 @@ char *getinx(cp, ip) register char *cp; register int *ip; {
        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]);
@@ -128,7 +132,7 @@ struct varent *getvx(vp, subscr) char *vp; int subscr; {
 
 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;
@@ -199,7 +203,11 @@ letsyn:
                                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 != '=')
@@ -268,7 +276,7 @@ char *putn(n) register int n; {
        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';
@@ -333,7 +341,7 @@ struct varent *adrof1(name, v) register char *name; register struct varent *v; {
 /*
  * 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;
@@ -341,7 +349,7 @@ int set(var, val) char *var; char *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);
@@ -358,7 +366,7 @@ int set1(var, vec, head) char *var; char **vec; struct varent *head; {
        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;
 
@@ -382,7 +390,7 @@ found:
        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) {
@@ -395,7 +403,7 @@ int unset(v) char *v[]; {
 #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;
 
@@ -408,7 +416,7 @@ int unset1(v, head) register char *v[]; struct varent *head; {
        }
 }
 
-int unsetv(var) char *var; {
+void unsetv(var) char *var; {
        register struct varent *vp;
 
        if ((vp = adrof1(var, &shvhed)) == 0)
@@ -416,7 +424,7 @@ int unsetv(var) char *var; {
        unsetv1(vp);
 }
 
-int unsetv1(p) register struct varent *p; {
+void unsetv1(p) register struct varent *p; {
        register struct varent *c, *pp;
        register f;
 
@@ -457,12 +465,12 @@ int unsetv1(p) register struct varent *p; {
        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;
 
@@ -480,7 +488,7 @@ int shift(v) register char **v; {
        lshift(argv->vec, 1);
 }
 
-int exportpath(val) char **val; {
+void exportpath(val) char **val; {
        char exppath[BUFSIZ];
 
        exppath[0] = 0;
@@ -517,7 +525,7 @@ int exportpath(val) char **val; {
  * 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;
@@ -603,7 +611,7 @@ int balance(p, f, d) register struct varent *p; register f; int d; {
        }
 }
 
-int plist(p) register struct varent *p; {
+void plist(p) register struct varent *p; {
        register struct varent *c;
        register len;
 
index 8852802..ba5983f 100644 (file)
@@ -19,7 +19,7 @@ static char *sccsid = "@(#)sh.time.c  5.4 (Berkeley) 5/13/86";
  * C Shell - routines handling process timing and niceing
  */
 
-int settimes() {
+void settimes() {
        struct rusage ruch;
 
        (void) gettimeofday(&time0, (struct timezone *)0);
@@ -32,7 +32,7 @@ int settimes() {
  * 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;
 
@@ -46,7 +46,7 @@ int dotime() {
 /*
  * 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;
 
@@ -58,7 +58,7 @@ int donice(v) register char **v; {
        (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;
 
@@ -73,7 +73,7 @@ int ruadd(ru, ru2) register struct rusage *ru; register struct rusage *ru2; {
        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+
@@ -152,14 +152,14 @@ int prusage(r0, r1, e, b) register struct rusage *r0; register struct rusage *r1
        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;
@@ -167,7 +167,7 @@ int tvadd(tsum, t0) struct timeval *tsum; struct timeval *t0; {
                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;
diff --git a/bin/csh/uniqify.sed b/bin/csh/uniqify.sed
new file mode 100644 (file)
index 0000000..3db51b3
--- /dev/null
@@ -0,0 +1,9 @@
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+s/[^A-Za-z0-9_]\+/@&@/g
+
+s/@isspace@/@_isspace@/g
+
+s/@//g
+s/ATSIGN/@/g
diff --git a/bin/csh/vprintf.c b/bin/csh/vprintf.c
new file mode 100644 (file)
index 0000000..26e7c5c
--- /dev/null
@@ -0,0 +1,39 @@
+#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);
+}
index f49d116..bb66da3 100644 (file)
@@ -147,7 +147,7 @@ void *malloc(nbytes) unsigned nbytes; {
                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;
@@ -215,7 +215,7 @@ void morecore(bucket) int bucket; {
        }
        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
index 77895ae..29a1eff 100644 (file)
@@ -78,14 +78,13 @@ static cvt __P((double number, register int prec, int flags, char *signp, int fm
 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 */
@@ -107,7 +106,6 @@ int _doprnt(fmt0, argp, fp) u_char *fmt0; va_list argp; register FILE *fp; {
        if ((fp->_flag & _IOWRT) == 0)
                return (EOF);
 
-       fmt = fmt0;
        digs = "0123456789abcdef";
        for (cnt = 0;; ++fmt) {
                n = fp->_cnt;
@@ -212,8 +210,7 @@ rflag:              switch (*++fmt) {
                case 'd':
                case 'i':
                        ARG();
-                       if ((intptr_t)_ulong < 0)
-                       {
+                       if ((intptr_t)_ulong < 0) {
                                _ulong = -_ulong;
                                sign = '-';
                        }