make output line buffered if selecting only some of the entries
[unix-history] / usr / src / usr.bin / expand / expand.c
index 17b52e3..08c01d3 100644 (file)
@@ -1,9 +1,34 @@
-static char *sccsid = "@(#)expand.c    4.1 (Berkeley) %G%";
+/*
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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
+ * 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
+char copyright[] =
+"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)expand.c   5.2 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <stdio.h>
 /*
  * expand - expand tabs to equivalent spaces
  */
 #include <stdio.h>
 /*
  * expand - expand tabs to equivalent spaces
  */
-char   obuf[BUFSIZ];
 int    nstops;
 int    tabstops[100];
 
 int    nstops;
 int    tabstops[100];
 
@@ -14,7 +39,6 @@ main(argc, argv)
        register int c, column;
        register int n;
 
        register int c, column;
        register int n;
 
-       setbuf(stdout, obuf);
        argc--, argv++;
        do {
                while (argc > 0 && argv[0][0] == '-') {
        argc--, argv++;
        do {
                while (argc > 0 && argv[0][0] == '-') {
@@ -101,7 +125,7 @@ bad:
                        fprintf(stderr, "Bad tab stop spec\n");
                        exit(1);
                }
                        fprintf(stderr, "Bad tab stop spec\n");
                        exit(1);
                }
-               if (nstops > 0 && i <= tabstops[nstops])
+               if (nstops > 0 && i <= tabstops[nstops-1])
                        goto bad;
                tabstops[nstops++] = i;
                if (*cp == 0)
                        goto bad;
                tabstops[nstops++] = i;
                if (*cp == 0)