don't put anything after the #else or #endif's, unless it's a comment
[unix-history] / usr / src / bin / csh / csh.c
index bdb5f83..5e71778 100644 (file)
@@ -12,12 +12,22 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)csh.c      5.23 (Berkeley) %G%";
+static char sccsid[] = "@(#)csh.c      5.25 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <unistd.h>
 #include "csh.h"
 #include "csh.h"
-#include "dir.h"
 #include "extern.h"
 #include "extern.h"
+#include "pathnames.h"
 
 extern bool MapsAreInited;
 extern bool NLSMapsAreInited;
 
 extern bool MapsAreInited;
 extern bool NLSMapsAreInited;
@@ -52,12 +62,12 @@ bool    tellwhat = 0;
 
 extern char **environ;
 
 
 extern char **environ;
 
-static int srccat();
-static int srcfile();
-static void phup();
-static void srcunit();
-static void mailchk();
-static Char **defaultpath();
+static int     srccat __P((Char *, Char *));
+static int     srcfile __P((char *, bool, bool));
+static void    phup __P((int));
+static void    srcunit __P((int, bool, bool));
+static void    mailchk __P((void));
+static Char   **defaultpath __P((void));
 
 int
 main(argc, argv)
 
 int
 main(argc, argv)
@@ -146,7 +156,7 @@ main(argc, argv)
      */
     set(STRstatus, Strsave(STR0));
 
      */
     set(STRstatus, Strsave(STR0));
 
-    if ((tcp = getenv("HOME")) != (char *) 0)
+    if ((tcp = getenv("HOME")) != NULL)
        cp = SAVE(tcp);
     else
        cp = NULL;
        cp = SAVE(tcp);
     else
        cp = NULL;
@@ -161,16 +171,16 @@ main(argc, argv)
      * Grab other useful things from the environment. Should we grab
      * everything??
      */
      * Grab other useful things from the environment. Should we grab
      * everything??
      */
-    if ((tcp = getenv("LOGNAME")) != (char *) 0 ||
-       (tcp = getenv("USER")) != (char *) 0)
+    if ((tcp = getenv("LOGNAME")) != NULL ||
+       (tcp = getenv("USER")) != NULL)
        set(STRuser, SAVE(tcp));
        set(STRuser, SAVE(tcp));
-    if ((tcp = getenv("TERM")) != (char *) 0)
+    if ((tcp = getenv("TERM")) != NULL)
        set(STRterm, SAVE(tcp));
 
     /*
      * Re-initialize path if set in environment
      */
        set(STRterm, SAVE(tcp));
 
     /*
      * Re-initialize path if set in environment
      */
-    if ((tcp = getenv("PATH")) == (char *) 0)
+    if ((tcp = getenv("PATH")) == NULL)
        set1(STRpath, defaultpath(), &shvhed);
     else
        importpath(SAVE(tcp));
        set1(STRpath, defaultpath(), &shvhed);
     else
        importpath(SAVE(tcp));
@@ -187,9 +197,9 @@ main(argc, argv)
      * only if we are the login shell.
      */
     /* parents interruptibility */
      * only if we are the login shell.
      */
     /* parents interruptibility */
-    (void) sigvec(SIGINT, (struct sigvec *) 0, &osv);
+    (void) sigvec(SIGINT, NULL, &osv);
     parintr = (void (*) ()) osv.sv_handler;
     parintr = (void (*) ()) osv.sv_handler;
-    (void) sigvec(SIGTERM, (struct sigvec *) 0, &osv);
+    (void) sigvec(SIGTERM, NULL, &osv);
     parterm = (void (*) ()) osv.sv_handler;
 
     if (loginsh) {
     parterm = (void (*) ()) osv.sv_handler;
 
     if (loginsh) {
@@ -322,7 +332,7 @@ main(argc, argv)
                stderror(ERR_SYSTEM, tempv[0], strerror(errno));
                break;
            }
                stderror(ERR_SYSTEM, tempv[0], strerror(errno));
                break;
            }
-       (void) ioctl(SHIN, FIOCLEX, (ioctl_t) 0);
+       (void) ioctl(SHIN, FIOCLEX, NULL);
        prompt = 0;
         /* argc not used any more */ tempv++;
     }
        prompt = 0;
         /* argc not used any more */ tempv++;
     }
@@ -413,7 +423,7 @@ main(argc, argv)
                 */
                if (tcsetpgrp(f, shpgrp) == -1)
                    goto notty;
                 */
                if (tcsetpgrp(f, shpgrp) == -1)
                    goto notty;
-               (void) ioctl(dcopy(f, FSHTTY), FIOCLEX, (ioctl_t) 0);
+               (void) ioctl(dcopy(f, FSHTTY), FIOCLEX, NULL);
            }
            if (tpgrp == -1) {
 notty:
            }
            if (tpgrp == -1) {
 notty:
@@ -436,7 +446,7 @@ notty:
        /* Will have value(STRhome) here because set fast if don't */
        {
            int     osetintr = setintr;
        /* Will have value(STRhome) here because set fast if don't */
        {
            int     osetintr = setintr;
-           sigmask_t omask = sigblock(sigmask(SIGINT));
+           sigset_t omask = sigblock(sigmask(SIGINT));
 
            setintr = 0;
 #ifdef _PATH_DOTCSHRC
 
            setintr = 0;
 #ifdef _PATH_DOTCSHRC
@@ -569,7 +579,7 @@ srcfile(f, onlyown, flag)
        return 0;
     unit = dmove(unit, -1);
 
        return 0;
     unit = dmove(unit, -1);
 
-    (void) ioctl(unit, FIOCLEX, (ioctl_t) 0);
+    (void) ioctl(unit, FIOCLEX, NULL);
     srcunit(unit, onlyown, flag);
     return 1;
 }
     srcunit(unit, onlyown, flag);
     return 1;
 }
@@ -596,7 +606,7 @@ srcunit(unit, onlyown, hflg)
     bool    otell = cantell;
 
     struct Bin saveB;
     bool    otell = cantell;
 
     struct Bin saveB;
-    sigmask_t omask;
+    sigset_t omask;
     jmp_buf oldexit;
 
     /* The (few) real local variables */
     jmp_buf oldexit;
 
     /* The (few) real local variables */
@@ -633,7 +643,7 @@ srcunit(unit, onlyown, hflg)
        omask = sigblock(sigmask(SIGINT));
     /* Setup the new values of the state stuff saved above */
     bcopy((char *) &B, (char *) &(saveB), sizeof(B));
        omask = sigblock(sigmask(SIGINT));
     /* Setup the new values of the state stuff saved above */
     bcopy((char *) &B, (char *) &(saveB), sizeof(B));
-    fbuf = (Char **) 0;
+    fbuf = NULL;
     fseekp = feobp = fblocks = 0;
     oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
     intty = isatty(SHIN), whyles = 0, gointr = 0;
     fseekp = feobp = fblocks = 0;
     oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
     intty = isatty(SHIN), whyles = 0, gointr = 0;
@@ -755,10 +765,11 @@ exitstat()
  * in the event of a HUP we want to save the history
  */
 static void
  * in the event of a HUP we want to save the history
  */
 static void
-phup()
+phup(sig)
+int sig;
 {
     rechist();
 {
     rechist();
-    xexit(1);
+    xexit(sig);
 }
 
 Char   *jobargv[2] = {STRjobs, 0};
 }
 
 Char   *jobargv[2] = {STRjobs, 0};
@@ -783,9 +794,9 @@ pintr1(wantnl)
     bool    wantnl;
 {
     register Char **v;
     bool    wantnl;
 {
     register Char **v;
-    sigmask_t omask;
+    sigset_t omask;
 
 
-    omask = sigblock((sigmask_t) 0);
+    omask = sigblock((sigset_t) 0);
     if (setintr) {
        (void) sigsetmask(omask & ~sigmask(SIGINT));
        if (pjobs) {
     if (setintr) {
        (void) sigsetmask(omask & ~sigmask(SIGINT));
        if (pjobs) {
@@ -854,7 +865,7 @@ process(catch)
         * Interruptible during interactive reads
         */
        if (setintr)
         * Interruptible during interactive reads
         */
        if (setintr)
-           (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
+           (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
 
        /*
         * For the sake of reset()
 
        /*
         * For the sake of reset()
@@ -902,7 +913,7 @@ process(catch)
        }
        if (seterr) {
            xfree((ptr_t) seterr);
        }
        if (seterr) {
            xfree((ptr_t) seterr);
-           seterr = (char *) 0;
+           seterr = NULL;
        }
 
        /*
        }
 
        /*
@@ -1074,10 +1085,10 @@ initdesc()
 {
 
     didfds = 0;                        /* 0, 1, 2 aren't set up */
 {
 
     didfds = 0;                        /* 0, 1, 2 aren't set up */
-    (void) ioctl(SHIN = dcopy(0, FSHIN), FIOCLEX, (ioctl_t) 0);
-    (void) ioctl(SHOUT = dcopy(1, FSHOUT), FIOCLEX, (ioctl_t) 0);
-    (void) ioctl(SHDIAG = dcopy(2, FSHDIAG), FIOCLEX, (ioctl_t) 0);
-    (void) ioctl(OLDSTD = dcopy(SHIN, FOLDSTD), FIOCLEX, (ioctl_t) 0);
+    (void) ioctl(SHIN = dcopy(0, FSHIN), FIOCLEX, NULL);
+    (void) ioctl(SHOUT = dcopy(1, FSHOUT), FIOCLEX, NULL);
+    (void) ioctl(SHDIAG = dcopy(2, FSHDIAG), FIOCLEX, NULL);
+    (void) ioctl(OLDSTD = dcopy(SHIN, FOLDSTD), FIOCLEX, NULL);
     closem();
 }
 
     closem();
 }
 
@@ -1113,7 +1124,7 @@ defaultpath()
 #undef DIRAPPEND
 
     *blkp++ = Strsave(STRdot);
 #undef DIRAPPEND
 
     *blkp++ = Strsave(STRdot);
-    *blkp = (Char *) 0;
+    *blkp = NULL;
     return (blk);
 }
 
     return (blk);
 }