Flush out the last dregs in the terminal before quitting when
[unix-history] / usr / src / usr.bin / fmt / fmt.c
index f8cfd22..cab46b4 100644 (file)
@@ -3,11 +3,16 @@
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at 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'' without express or implied warranty.
+ * 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.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -17,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)fmt.c      5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)fmt.c      5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <stdio.h>
 #endif /* not lint */
 
 #include <stdio.h>
@@ -38,8 +43,10 @@ static char sccsid[] = "@(#)fmt.c    5.5 (Berkeley) %G%";
 #define        NOSTR   ((char *) 0)    /* Null string pointer for lint */
 
 /* LIZ@UOM 6/18/85 --New variables goal_length and max_length */
 #define        NOSTR   ((char *) 0)    /* Null string pointer for lint */
 
 /* LIZ@UOM 6/18/85 --New variables goal_length and max_length */
-int    goal_length = 65;       /* Target or goal line length in output */
-int    max_length = 75;        /* Max line length in output */
+#define GOAL_LENGTH 65
+#define MAX_LENGTH 75
+int    goal_length;            /* Target or goal line length in output */
+int    max_length;             /* Max line length in output */
 int    pfx;                    /* Current leading blank count */
 int    lineno;                 /* Current input line */
 int    mark;                   /* Last place we saw a head line */
 int    pfx;                    /* Current leading blank count */
 int    lineno;                 /* Current input line */
 int    mark;                   /* Last place we saw a head line */
@@ -61,6 +68,8 @@ main(argc, argv)
        register int errs = 0;
        int number;             /* LIZ@UOM 6/18/85 */
 
        register int errs = 0;
        int number;             /* LIZ@UOM 6/18/85 */
 
+       goal_length = GOAL_LENGTH;
+       max_length = MAX_LENGTH;
        setout();
        lineno = 1;
        mark = -10;
        setout();
        lineno = 1;
        mark = -10;
@@ -254,7 +263,7 @@ split(line)
                 */
                if (*cp == '\0') {
                        *cp2++ = ' ';
                 */
                if (*cp == '\0') {
                        *cp2++ = ' ';
-                       if (any(cp[-1], ".:!"))
+                       if (index(".:!", cp[-1]))
                                *cp2++ = ' ';
                }
                while (*cp == ' ')
                                *cp2++ = ' ';
                }
                while (*cp == ' ')
@@ -361,7 +370,7 @@ oflush()
 tabulate(line)
        char line[];
 {
 tabulate(line)
        char line[];
 {
-       register char *cp, *cp2;
+       register char *cp;
        register int b, t;
 
        /*
        register int b, t;
 
        /*