less -> more
[unix-history] / usr / src / usr.bin / more / os.c
index 24528bb..b014e8f 100644 (file)
@@ -3,15 +3,13 @@
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
  *
- * This code is derived from software contributed to Berkeley by
- * Mark Nudleman.
- * 
  * 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
  * 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
+ * by Mark Nudleman and the University of California, Berkeley.  The
+ * name of Mark Nudleman or 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
  * 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
@@ -20,7 +18,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)os.c       5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)os.c       5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -108,7 +106,7 @@ lsystem(cmd)
                        cmd = shell;
                else
                {
                        cmd = shell;
                else
                {
-                       sprintf(cmdbuf, "%s -c \"%s\"", shell, cmd);
+                       (void)sprintf(cmdbuf, "%s -c \"%s\"", shell, cmd);
                        cmd = cmdbuf;
                }
        }
                        cmd = cmdbuf;
                }
        }
@@ -168,30 +166,23 @@ iread(fd, buf, len)
        public void
 intread()
 {
        public void
 intread()
 {
-#if SIGSETMASK
-       sigsetmask(0);
-#endif
+       sigsetmask(0L);
        longjmp(read_label, 1);
 }
 
        longjmp(read_label, 1);
 }
 
-#if GET_TIME
        public long
 get_time()
 {
        public long
 get_time()
 {
-       long t;
+       time_t time();
 
 
-       time(&t);
-       return (t);
+       return(time((long *)NULL));
 }
 }
-#endif
 
 /*
  * Expand a filename, substituting any environment variables, etc.
  * The implementation of this is necessarily very operating system
  * dependent.  This implementation is unabashedly only for Unix systems.
  */
 
 /*
  * Expand a filename, substituting any environment variables, etc.
  * The implementation of this is necessarily very operating system
  * dependent.  This implementation is unabashedly only for Unix systems.
  */
-#if GLOB
-
 FILE *popen();
 
        public char *
 FILE *popen();
 
        public char *
@@ -201,7 +192,7 @@ glob(filename)
        FILE *f;
        char *p;
        int ch;
        FILE *f;
        char *p;
        int ch;
-       char *cmd;
+       char *cmd, *malloc();
        static char buffer[FILENAME];
 
        if (filename[0] == '#')
        static char buffer[FILENAME];
 
        if (filename[0] == '#')
@@ -217,19 +208,19 @@ glob(filename)
                /*
                 * Read the output of <echo filename>.
                 */
                /*
                 * Read the output of <echo filename>.
                 */
-               cmd = calloc(strlen(filename)+8, sizeof(char));
+               cmd = malloc((u_int)(strlen(filename)+8));
                if (cmd == NULL)
                        return (filename);
                if (cmd == NULL)
                        return (filename);
-               sprintf(cmd, "echo \"%s\"", filename);
+               (void)sprintf(cmd, "echo \"%s\"", filename);
        } else
        {
                /*
                 * Read the output of <$SHELL -c "echo filename">.
                 */
        } else
        {
                /*
                 * Read the output of <$SHELL -c "echo filename">.
                 */
-               cmd = calloc(strlen(p)+12);
+               cmd = malloc((u_int)(strlen(p)+12));
                if (cmd == NULL)
                        return (filename);
                if (cmd == NULL)
                        return (filename);
-               sprintf(cmd, "%s -c \"echo %s\"", p, filename);
+               (void)sprintf(cmd, "%s -c \"echo %s\"", p, filename);
        }
 
        if ((f = popen(cmd, "r")) == NULL)
        }
 
        if ((f = popen(cmd, "r")) == NULL)
@@ -247,18 +238,6 @@ glob(filename)
        return (buffer);
 }
 
        return (buffer);
 }
 
-#else
-
-       public char *
-glob(filename)
-       char *filename;
-{
-       return (filename);
-}
-
-#endif
-
-
 /*
  * Returns NULL if the file can be opened and
  * is an ordinary file, otherwise an error message
 /*
  * Returns NULL if the file can be opened and
  * is an ordinary file, otherwise an error message
@@ -275,6 +254,7 @@ bad_file(filename, message, len)
        unsigned int len;
 {
        struct stat statbuf;
        unsigned int len;
 {
        struct stat statbuf;
+       char *strcat();
 
        if (stat(filename, &statbuf) < 0)
                return (errno_message(filename, message, len));
 
        if (stat(filename, &statbuf) < 0)
                return (errno_message(filename, message, len));
@@ -283,14 +263,14 @@ bad_file(filename, message, len)
        {
                static char is_dir[] = " is a directory";
                strtcpy(message, filename, len-sizeof(is_dir)-1);
        {
                static char is_dir[] = " is a directory";
                strtcpy(message, filename, len-sizeof(is_dir)-1);
-               strcat(message, is_dir);
+               (void)strcat(message, is_dir);
                return (message);
        }
        if ((statbuf.st_mode & S_IFMT) != S_IFREG)
        {
                static char not_reg[] = " is not a regular file";
                strtcpy(message, filename, len-sizeof(not_reg)-1);
                return (message);
        }
        if ((statbuf.st_mode & S_IFMT) != S_IFREG)
        {
                static char not_reg[] = " is not a regular file";
                strtcpy(message, filename, len-sizeof(not_reg)-1);
-               strcat(message, not_reg);
+               (void)strcat(message, not_reg);
                return (message);
        }
        return (NULL);
                return (message);
        }
        return (NULL);
@@ -319,11 +299,11 @@ errno_message(filename, message, len)
                p = sys_errlist[errno];
        else
        {
                p = sys_errlist[errno];
        else
        {
-               sprintf(msg, "Error %d", errno);
+               (void)sprintf(msg, "Error %d", errno);
                p = msg;
        }
        strtcpy(message, filename, len-strlen(p)-3);
                p = msg;
        }
        strtcpy(message, filename, len-strlen(p)-3);
-       strcat(message, ": ");
-       strcat(message, p);
+       (void)strcat(message, ": ");
+       (void)strcat(message, p);
        return (message);
 }
        return (message);
 }