BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / ul / ul.c
index c0f74ee..9cb110f 100644 (file)
@@ -1,18 +1,31 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement:  ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
 char copyright[] =
 "@(#) Copyright (c) 1980 Regents of the University of California.\n\
  All rights reserved.\n";
  */
 
 #ifndef lint
 char copyright[] =
 "@(#) Copyright (c) 1980 Regents of the University of California.\n\
  All rights reserved.\n";
-#endif not lint
+#endif /* not lint */
 
 #ifndef lint
 
 #ifndef lint
-static char sccsid[] = "@(#)ul.c       5.3 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)ul.c       5.6 (Berkeley) 6/1/90";
+#endif /* not lint */
 
 #include <stdio.h>
 
 
 #include <stdio.h>
 
@@ -52,13 +65,13 @@ main(argc, argv)
        int argc;
        char **argv;
 {
        int argc;
        char **argv;
 {
+       extern int optind;
+       extern char *optarg;
        int c;
        int c;
-       char *cp, *termtype;
+       char *termtype;
        FILE *f;
        char termcap[1024];
        FILE *f;
        char termcap[1024];
-       char *getenv();
-       extern int optind;
-       extern char *optarg;
+       char *getenv(), *strcpy();
 
        termtype = getenv("TERM");
        if (termtype == NULL || (argv[0][0] == 'c' && !isatty(1)))
 
        termtype = getenv("TERM");
        if (termtype == NULL || (argv[0][0] == 'c' && !isatty(1)))
@@ -76,7 +89,7 @@ main(argc, argv)
 
                default:
                        fprintf(stderr,
 
                default:
                        fprintf(stderr,
-                               "Usage: %s [ -i ] [ -tTerm ] file...\n",
+                               "usage: %s [ -i ] [ -tTerm ] file...\n",
                                argv[0]);
                        exit(1);
                }
                                argv[0]);
                        exit(1);
                }
@@ -92,7 +105,7 @@ main(argc, argv)
 
        case 0:
                /* No such terminal type - assume dumb */
 
        case 0:
                /* No such terminal type - assume dumb */
-               strcpy(termcap, "dumb:os:col#80:cr=^M:sf=^J:am:");
+               (void)strcpy(termcap, "dumb:os:col#80:cr=^M:sf=^J:am:");
                break;
        }
        initcap();
                break;
        }
        initcap();
@@ -199,6 +212,11 @@ FILE *f;
                flushln();
                continue;
 
                flushln();
                continue;
 
+       case '\f':
+               flushln();
+               putchar('\f');
+               continue;
+
        default:
                if (c < ' ')    /* non printing */
                        continue;
        default:
                if (c < ' ')    /* non printing */
                        continue;
@@ -250,7 +268,7 @@ flushln()
        putchar('\n');
        if (iflag && hadmodes)
                iattr();
        putchar('\n');
        if (iflag && hadmodes)
                iattr();
-       fflush(stdout);
+       (void)fflush(stdout);
        if (upln)
                upln--;
        initbuf();
        if (upln)
                upln--;
        initbuf();
@@ -323,7 +341,7 @@ iattr()
 initbuf()
 {
 
 initbuf()
 {
 
-       bzero(obuf, sizeof (obuf));             /* depends on NORMAL == 0 */
+       bzero((char *)obuf, sizeof (obuf));     /* depends on NORMAL == 0 */
        col = 0;
        maxcol = 0;
        mode &= ALTSET;
        col = 0;
        maxcol = 0;
        mode &= ALTSET;
@@ -352,7 +370,6 @@ reverse()
 initcap()
 {
        static char tcapbuf[512];
 initcap()
 {
        static char tcapbuf[512];
-       char *termtype;
        char *bp = tcapbuf;
        char *getenv(), *tgetstr();
 
        char *bp = tcapbuf;
        char *getenv(), *tgetstr();
 
@@ -479,61 +496,3 @@ int newmode;
        }
        curmode = newmode;
 }
        }
        curmode = newmode;
 }
-/*     @(#)getopt.c    3.2     */
-#define        ERR(s, c)       if(opterr){\
-       fputs(argv[0], stderr);\
-       fputs(s, stderr);\
-       fputc(c, stderr);\
-       fputc('\n', stderr);}
-
-int    opterr = 1;
-int    optind = 1;
-char   *optarg;
-char   *index();
-
-int
-getopt (argc, argv, opts)
-       char **argv, *opts;
-{
-       static int sp = 1;
-       char c;
-       char *cp;
-
-       if (sp == 1)
-               if (optind >= argc ||
-                  argv[optind][0] != '-' || argv[optind][1] == '\0')
-                       return EOF;
-               else if (strcmp(argv[optind], "--") == NULL) {
-                       optind++;
-                       return EOF;
-               }
-               else if (strcmp(argv[optind], "-?") == NULL) {
-                       optind++;
-                       return '?';
-               }
-       c = argv[optind][sp];
-       if (c == ':' || (cp=index(opts, c)) == NULL) {
-               ERR (": illegal option -- ", c);
-               if (argv[optind][++sp] == '\0') {
-                       optind++;
-                       sp = 1;
-               }
-               return '?';
-       }
-       if (*++cp == ':') {
-               if (argv[optind][2] != '\0')
-                       optarg = &argv[optind++][sp+1];
-               else if (++optind >= argc) {
-                       ERR (": option requires an argument -- ", c);
-                       sp = 1;
-                       return '?';
-               } else
-                       optarg = argv[optind++];
-               sp = 1;
-       }
-       else if (argv[optind][++sp] == '\0') {
-               sp = 1;
-               optind++;
-       }
-       return c;
-}