summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-05-22 05:06:39 +0000
committerJim Meyering <jim@meyering.net>1993-05-22 05:06:39 +0000
commit6587c39b3ad22a17a2525597bc8d4712916d29fe (patch)
tree0e841eb7fb9d97d3e8ae8c26bd4a6b2c337e0ee5
parentd1c5cbfcddaced8d64b23bc3f22bfc4082b58604 (diff)
downloadcoreutils-6587c39b3ad22a17a2525597bc8d4712916d29fe.tar.xz
merge with 1.5.2
-rw-r--r--lib/regex.c1
-rw-r--r--old/textutils/ChangeLog35
-rw-r--r--old/textutils/NEWS6
-rw-r--r--src/cat.c5
-rw-r--r--src/cksum.c5
-rw-r--r--src/comm.c5
-rw-r--r--src/csplit.c5
-rw-r--r--src/cut.c5
-rw-r--r--src/expand.c5
-rw-r--r--src/fold.c21
-rw-r--r--src/head.c5
-rw-r--r--src/join.c5
-rw-r--r--src/nl.c5
-rw-r--r--src/od.c5
-rw-r--r--src/paste.c5
-rw-r--r--src/pr.c116
-rw-r--r--src/sort.c8
-rw-r--r--src/split.c5
-rw-r--r--src/sum.c5
-rw-r--r--src/tac.c5
-rw-r--r--src/tail.c5
-rw-r--r--src/tr.c5
-rw-r--r--src/unexpand.c5
-rw-r--r--src/uniq.c5
-rw-r--r--src/wc.c5
25 files changed, 223 insertions, 59 deletions
diff --git a/lib/regex.c b/lib/regex.c
index 5bd4cf654..e8b588207 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -4784,6 +4784,7 @@ regcomp (preg, pattern, cflags)
/* regex_compile will allocate the space for the compiled pattern. */
preg->buffer = 0;
preg->allocated = 0;
+ preg->used = 0;
/* Don't bother to use a fastmap when searching. This simplifies the
REG_NEWLINE case: if we used a fastmap, we'd have to put all the
diff --git a/old/textutils/ChangeLog b/old/textutils/ChangeLog
index 7a85cf233..d0f54b56c 100644
--- a/old/textutils/ChangeLog
+++ b/old/textutils/ChangeLog
@@ -1,3 +1,38 @@
+Wed May 19 19:12:18 1993 Karl Berry (karl@owl.hq.ileaf.com)
+
+ * sort.c (main): fflush before exit, so a closed stdout doesn't lose.
+
+Tue May 18 23:49:26 1993 Jim Meyering (meyering@comco.com)
+
+ * mkinstalldirs: New file.
+ * Makefile.in (installdirs): Use it.
+
+Fri May 14 23:45:52 1993 Jim Meyering (meyering@comco.com)
+
+ * all source: With --version, print version and exit immediately.
+
+Thu May 13 01:03:16 1993 Jim Meyering (meyering@comco.com)
+
+ * Makefile.in (installdirs): New rules for creating installation
+ directories. (install): depend on it.
+
+ * tail.c (main): Remove --compatible since `+1f' may be used
+ to get the BSD `-0f' behavior portably.
+
+ * fold.c (main): Turn -N arguments, where N is a digit, into -wN.
+ From Ian Lance Taylor (ian@cygnus.com).
+
+Mon May 10 22:33:44 1993 Jim Meyering (meyering@comco.com)
+
+ * tail.c (main): New option -C, --compatible to make `tail -0f'
+ work like `tail +1f' for compatibility with BSD tail.
+
+Thu May 6 23:28:56 1993 Jim Meyering (meyering@comco.com)
+
+ * pr.c (print_page): Decrement cols_ready_to_print even when
+ lines_to_print == 0. The command `echo |pr -2ta' *still* didn't
+ terminate. Add parentheses for clarity.
+
Mon May 3 23:57:47 1993 Jim Meyering (meyering@comco.com)
* Version 1.5.
diff --git a/old/textutils/NEWS b/old/textutils/NEWS
index c63422fe5..0742b700d 100644
--- a/old/textutils/NEWS
+++ b/old/textutils/NEWS
@@ -1,3 +1,9 @@
+Major changes in release 1.6:
+* with the --version option programs print the version and exit immediately
+* --compatible makes `tail -0f' work like `tail +1f' for compatibility
+ with BSD tail.
+* pr -2a really terminates
+
Major changes in release 1.5:
* sort is 8-bit clean
* sort's -n and -M options no longer imply -b
diff --git a/src/cat.c b/src/cat.c
index 98da7c971..724976d83 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -225,7 +225,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/cksum.c b/src/cksum.c
index e629dd8d7..b5e1887e6 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -291,7 +291,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/comm.c b/src/comm.c
index 8b4f87f29..c5f4c39ca 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -92,7 +92,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/csplit.c b/src/csplit.c
index eaea8c314..6eedd39b3 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -1285,7 +1285,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/cut.c b/src/cut.c
index 2e611a9a1..e7997fd58 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -225,7 +225,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/expand.c b/src/expand.c
index f26951013..99ce5c4f7 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -154,7 +154,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/fold.c b/src/fold.c
index ca20a2839..b3cb0988c 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -27,6 +27,7 @@
#include "version.h"
char *xrealloc ();
+char *xmalloc ();
void error ();
/* The name this program was run with. */
@@ -83,6 +84,21 @@ main (argc, argv)
program_name = argv[0];
break_spaces = count_bytes = have_read_stdin = 0;
+ /* Turn any numeric options into -w options. */
+ for (i = 1; i < argc; i++)
+ {
+ if (argv[i][0] == '-' && ISDIGIT (argv[i][1]))
+ {
+ char *s;
+
+ s = xmalloc (strlen (argv[i]) + 2);
+ s[0] = '-';
+ s[1] = 'w';
+ strcpy (s + 2, argv[i] + 1);
+ argv[i] = s;
+ }
+ }
+
while ((optc = getopt_long (argc, argv, "bsw:", longopts, (int *) 0))
!= EOF)
{
@@ -111,7 +127,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/head.c b/src/head.c
index 6d7ac5501..ec4d730d3 100644
--- a/src/head.c
+++ b/src/head.c
@@ -194,7 +194,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/join.c b/src/join.c
index 39599efaf..48e791ac0 100644
--- a/src/join.c
+++ b/src/join.c
@@ -661,7 +661,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/nl.c b/src/nl.c
index 144400223..431c3e91a 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -263,7 +263,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/od.c b/src/od.c
index ea4f12b39..f2f0b3c64 100644
--- a/src/od.c
+++ b/src/od.c
@@ -1790,7 +1790,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/paste.c b/src/paste.c
index bc9b7e5c0..a45b6fe10 100644
--- a/src/paste.c
+++ b/src/paste.c
@@ -133,7 +133,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/pr.c b/src/pr.c
index 876387dff..edf414766 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -441,6 +441,24 @@ static struct option const long_options[] =
{0, 0, 0, 0}
};
+/* Return the number of columns that have either an open file or
+ stored lines. */
+
+static int
+crtp ()
+{
+ COLUMN *q;
+ int i;
+ int n;
+
+ n = 0;
+ for (q = column_vector, i = 0; i < columns; ++q, ++i)
+ if (q->status == OPEN ||
+ (storing_columns && q->lines_stored > 0 && q->lines_to_print > 0))
+ ++n;
+ return n;
+}
+
void
main (argc, argv)
int argc;
@@ -448,28 +466,63 @@ main (argc, argv)
{
int c;
int accum = 0;
+ int n_files;
+ char **file_names;
program_name = argv[0];
- while ((c = getopt_long (argc, argv,
- "0123456789abcde::fFh:i::l:mn::o:rs::tvw:",
- long_options, (int *) 0)) != EOF)
+ n_files = 0;
+ file_names = (char **) xmalloc ((argc - 1) * sizeof (char *));
+
+ while (1)
{
- if (ISDIGIT (c))
+ c = getopt_long (argc, argv,
+ "-0123456789abcde::fFh:i::l:mn::o:rs::tvw:",
+ long_options, (int *) 0);
+ if (c == 1) /* Non-option argument. */
{
- accum = accum * 10 + c - '0';
- continue;
+ char *s;
+ s = optarg;
+ if (*s == '+')
+ {
+ ++s;
+ if (!ISDIGIT (*s))
+ {
+ error (0, 0, "`+' requires a numeric argument");
+ usage ();
+ }
+ /* FIXME: use strtol */
+ first_page_number = atoi (s);
+ }
+ else
+ {
+ file_names[n_files++] = optarg;
+ }
}
else
{
- if (accum > 0)
+ if (ISDIGIT (c))
{
- columns = accum;
- explicit_columns = TRUE;
+ accum = accum * 10 + c - '0';
+ continue;
+ }
+ else
+ {
+ if (accum > 0)
+ {
+ columns = accum;
+ explicit_columns = TRUE;
+ accum = 0;
+ }
}
- accum = 0;
}
+ if (c == 1)
+ continue;
+
+ if (c == EOF)
+ break;
+
switch (c)
{
case 0: /* getopt long option */
@@ -561,7 +614,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
@@ -574,20 +630,12 @@ main (argc, argv)
error (1, 0,
"Cannot specify both printing across and printing in parallel.");
- if (optind >= 2 && strcmp (argv[optind - 1], "--") == 0)
+ for ( ; optind < argc; optind++)
{
- /* We've seen `--', so interpret all remaining arguments as
- filenames. */
- }
- else
- {
- for ( ; optind < argc && argv[optind][0] == '+'; optind++)
- {
- first_page_number = atoi (&argv[optind][1]);
- }
+ file_names[n_files++] = argv[optind];
}
- if (optind >= argc)
+ if (n_files == 0)
{
/* No file arguments specified; read from standard input. */
print_files (0, (char **) 0);
@@ -595,11 +643,12 @@ main (argc, argv)
else
{
if (parallel_files)
- print_files (argc - optind, &argv[optind]);
+ print_files (n_files, file_names);
else
{
- for ( ; optind < argc; optind++)
- print_files (1, &argv[optind]);
+ int i;
+ for (i=0; i<n_files; i++)
+ print_files (1, &file_names[i]);
}
}
@@ -926,8 +975,6 @@ close_file (p)
q->status = CLOSED;
if (q->lines_stored == 0)
{
- if (cols_ready_to_print > 0 && !print_across_flag)
- --cols_ready_to_print;
q->lines_to_print = 0;
}
}
@@ -1078,24 +1125,18 @@ init_page ()
int j;
COLUMN *p;
- cols_ready_to_print = 0;
-
if (storing_columns)
{
store_columns ();
for (j = columns - 1, p = column_vector; j; --j, ++p)
{
p->lines_to_print = p->lines_stored;
- if (p->lines_to_print != 0)
- ++cols_ready_to_print;
}
/* Last column. */
if (balance_columns)
{
p->lines_to_print = p->lines_stored;
- if (p->lines_to_print != 0)
- ++cols_ready_to_print;
}
/* Since we're not balancing columns, we don't need to store
the rightmost column. Read it straight from the file. */
@@ -1104,7 +1145,6 @@ init_page ()
if (p->status == OPEN)
{
p->lines_to_print = lines_per_body;
- ++cols_ready_to_print;
}
else
p->lines_to_print = 0;
@@ -1115,7 +1155,6 @@ init_page ()
if (p->status == OPEN)
{
p->lines_to_print = lines_per_body;
- ++cols_ready_to_print;
}
else
p->lines_to_print = 0;
@@ -1150,7 +1189,7 @@ print_page ()
init_page ();
- if (cols_ready_to_print == 0)
+ if (crtp () == 0)
return FALSE;
if (extremities)
@@ -1164,7 +1203,7 @@ print_page ()
if (double_space)
lines_left_on_page *= 2;
- while (lines_left_on_page > 0 && cols_ready_to_print > 0)
+ while (lines_left_on_page > 0 && crtp () > 0)
{
output_position = 0;
spaces_not_printed = 0;
@@ -1188,8 +1227,7 @@ print_page ()
--p->lines_to_print;
if (p->lines_to_print <= 0)
{
- --cols_ready_to_print;
- if (cols_ready_to_print <= 0)
+ if (crtp () <= 0)
break;
}
}
diff --git a/src/sort.c b/src/sort.c
index 4acc1e5a6..42e0b8e61 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1747,6 +1747,14 @@ main (argc, argv)
sort (files, nfiles, ofp);
cleanup ();
+ /* If we wait for the implicit flush on exit, and the parent process
+ has closed stdout (e.g., exec >&- in a shell), then the output file
+ winds up empty. I don't understand why. This is under SunOS,
+ Solaris, Ultrix, and Irix. This premature fflush makes the output
+ reappear. --karl@cs.umb.edu */
+ if (fflush (ofp) < 0)
+ error (1, errno, "fflush", outfile);
+
if (have_read_stdin && fclose (stdin) == EOF)
error (1, errno, "-");
if (ferror (stdout) || fclose (stdout) == EOF)
diff --git a/src/split.c b/src/split.c
index addddd982..d425b5295 100644
--- a/src/split.c
+++ b/src/split.c
@@ -185,7 +185,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ((char *)0);
diff --git a/src/sum.c b/src/sum.c
index c10f0b866..1283078e7 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -95,7 +95,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/tac.c b/src/tac.c
index 8107823e9..30de5abeb 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -167,7 +167,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/tail.c b/src/tail.c
index d3bc8cd62..8feceb604 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -257,7 +257,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/tr.c b/src/tr.c
index f2a3fac76..f979afb8d 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -1666,7 +1666,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/unexpand.c b/src/unexpand.c
index 6fc5e78f1..27e8d952d 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -157,7 +157,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/uniq.c b/src/uniq.c
index 20fa6d565..aab70db43 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -154,7 +154,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
diff --git a/src/wc.c b/src/wc.c
index 22aa53333..b484911d7 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -111,7 +111,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();