date and time created 91/03/14 12:01:54 by donn
[unix-history] / usr / src / bin / csh / csh.c
index 8a04c62..787d169 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)csh.c       5.14 (Berkeley) %G%";
+static char *sccsid = "@(#)csh.c       5.17 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -42,20 +42,22 @@ bool        enterhist = 0;
 extern gid_t getegid(), getgid();
 extern uid_t geteuid(), getuid();
 
 extern gid_t getegid(), getgid();
 extern uid_t geteuid(), getuid();
 
-main(c, av)
-       int c;
-       char **av;
+void pintr(), pchild(), srcunit();
+
+main(argc, argv)
+       int argc;
+       char **argv;
 {
        register char **v, *cp;
        register int f;
        struct sigvec osv;
 
        settimes();                     /* Immed. estab. timing base */
 {
        register char **v, *cp;
        register int f;
        struct sigvec osv;
 
        settimes();                     /* Immed. estab. timing base */
-       v = av;
+       v = argv;
        if (eq(v[0], "a.out"))          /* A.out's are quittable */
                quitit = 1;
        uid = getuid();
        if (eq(v[0], "a.out"))          /* A.out's are quittable */
                quitit = 1;
        uid = getuid();
-       loginsh = **v == '-' && c == 1;
+       loginsh = **v == '-' && argc == 1;
        if (loginsh)
                (void) time(&chktim);
 
        if (loginsh)
                (void) time(&chktim);
 
@@ -127,8 +129,8 @@ main(c, av)
         * Note that processing of -v/-x is actually delayed till after
         * script processing.
         */
         * Note that processing of -v/-x is actually delayed till after
         * script processing.
         */
-       c--, v++;
-       while (c > 0 && (cp = v[0])[0] == '-' && *++cp != '\0' && !batch) {
+       argc--, v++;
+       while (argc > 0 && (cp = v[0])[0] == '-' && *++cp != '\0' && !batch) {
                do switch (*cp++) {
 
                case 'b':               /* -b   Next arg is input file */
                do switch (*cp++) {
 
                case 'b':               /* -b   Next arg is input file */
@@ -136,9 +138,9 @@ main(c, av)
                        break;
 
                case 'c':               /* -c   Command input from arg */
                        break;
 
                case 'c':               /* -c   Command input from arg */
-                       if (c == 1)
+                       if (argc == 1)
                                exit(0);
                                exit(0);
-                       c--, v++;
+                       argc--, v++;
                        arginp = v[0];
                        prompt = 0;
                        nofile++;
                        arginp = v[0];
                        prompt = 0;
                        nofile++;
@@ -196,7 +198,7 @@ main(c, av)
                        break;
 
                } while (*cp);
                        break;
 
                } while (*cp);
-               v++, c--;
+               v++, argc--;
        }
 
        if (quitit)                     /* With all due haste, for debugging */
        }
 
        if (quitit)                     /* With all due haste, for debugging */
@@ -207,7 +209,7 @@ main(c, av)
         * are remaining arguments the first of them is the name
         * of a shell file from which to read commands.
         */
         * are remaining arguments the first of them is the name
         * of a shell file from which to read commands.
         */
-       if (nofile == 0 && c > 0) {
+       if (nofile == 0 && argc > 0) {
                nofile = open(v[0], 0);
                if (nofile < 0) {
                        child++;                /* So this ... */
                nofile = open(v[0], 0);
                if (nofile < 0) {
                        child++;                /* So this ... */
@@ -217,7 +219,7 @@ main(c, av)
                SHIN = dmove(nofile, FSHIN);    /* Replace FSHIN */
                (void) ioctl(SHIN, FIOCLEX, (char *)0);
                prompt = 0;
                SHIN = dmove(nofile, FSHIN);    /* Replace FSHIN */
                (void) ioctl(SHIN, FIOCLEX, (char *)0);
                prompt = 0;
-               c--, v++;
+               argc--, v++;
        }
        if (!batch && (uid != geteuid() || getgid() != getegid())) {
                errno = EACCES;
        }
        if (!batch && (uid != geteuid() || getgid() != getegid())) {
                errno = EACCES;
@@ -259,7 +261,7 @@ main(c, av)
        shpgrp = getpgrp(0);
        opgrp = tpgrp = -1;
        if (setintr) {
        shpgrp = getpgrp(0);
        opgrp = tpgrp = -1;
        if (setintr) {
-               **av = '-';
+               **argv = '-';
                if (!quitit)            /* Wary! */
                        (void) signal(SIGQUIT, SIG_IGN);
                (void) signal(SIGINT, pintr);
                if (!quitit)            /* Wary! */
                        (void) signal(SIGQUIT, SIG_IGN);
                (void) signal(SIGINT, pintr);
@@ -436,7 +438,7 @@ srccat(cp, dp)
  * This occurs on ".cshrc"s and the like.
  */
 int    insource;
  * This occurs on ".cshrc"s and the like.
  */
 int    insource;
-static
+static void
 srcunit(unit, onlyown, hflg)
        register int unit;
        bool onlyown, hflg;
 srcunit(unit, onlyown, hflg)
        register int unit;
        bool onlyown, hflg;
@@ -623,6 +625,7 @@ char        *jobargv[2] = { "jobs", 0 };
  * and finally go through the normal error mechanism, which
  * gets a chance to make the shell go away.
  */
  * and finally go through the normal error mechanism, which
  * gets a chance to make the shell go away.
  */
+void
 pintr()
 {
        pintr1(1);
 pintr()
 {
        pintr1(1);