]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Merge with pre-release 1.3.6.
authorJim Meyering <jim@meyering.net>
Thu, 10 Dec 1992 19:34:55 +0000 (19:34 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 10 Dec 1992 19:34:55 +0000 (19:34 +0000)
old/textutils/ChangeLog
src/csplit.c
src/od.c
src/sort.c
src/tail.c
src/tr.c

index 598c0906814195453376ad2621a6cf8a9c4fcaa9..a4fa7d7ba69fc32c13b19478183ef6e165d5d1f1 100644 (file)
@@ -1,4 +1,4 @@
-Tue Dec  8 10:31:14 CST 1992
+Tue Dec  8 10:31:14 1992  Jim Meyering  (meyering@idefix.comco.com)
 
        * tr.c (is_char_class_member): Remove unreached return after abort.
 
@@ -18,11 +18,16 @@ Wed Dec  2 12:28:10 1992  Jim Meyering  (meyering@idefix.comco.com)
        struct option to use new macros from getopt.h: no_argument,
        required_argument, and optional_argument.
 
-Wed Nov 25 07:51:55 1992  Jim Meyering  (meyering@idefix.comco.com)
+Tue Dec 01 10:57:24 1992  Jim Meyering  (meyering@idefix.comco.com)
 
-       * pr.c, sort.c, od.c: Make definitions of ISPRINT etc consistent.
+       * od.c, pr.c, sort.c: Make uses of ctype.h macros consistent.
 
-       * tr.c (main): Close stdin and stdout.
+       * tr.c (main): Close stdin and stdout and check return status.
+
+Tue Nov 24 09:26:08 1992  David J. MacKenzie  (djm@goldman.gnu.ai.mit.edu)
+
+       * system.h, csplit.c: Use HAVE_FCNTL_H and HAVE_STRING_H
+       instead of USG.
 
 Tue Nov 24 08:42:30 1992  Jim Meyering  (meyering@idefix.comco.com)
 
@@ -48,6 +53,10 @@ Tue Nov 24 08:42:30 1992  Jim Meyering  (meyering@idefix.comco.com)
        (write_block, dump_strings, dump): Don't test return value from
        functions that operate on streams.  Rely on later ferror tests.
 
+Sat Nov 21 12:41:49 1992  David J. MacKenzie  (djm@goldman.gnu.ai.mit.edu)
+
+       * sort.c (main, usage): Add -T option.
+
 Thu Nov 19 14:33:40 1992  David J. MacKenzie  (djm@goldman.gnu.ai.mit.edu)
 
        * tail.c (tail_forever, sigusr1, kill_kids): New functions to
index 7b2165e5f97a4deb32867d6cc9b6bcea6f0476b1..8d27ce03fc650545f468b9b8fe0d1b5fb86e9fa3 100644 (file)
 #include "regex.h"
 #include "system.h"
 
-#if !defined(USG) && !defined(STDC_HEADERS)
-char *memchr ();
-#endif
-
 #ifdef STDC_HEADERS
 #include <stdlib.h>
 #else
index ae2c3da3b3154c66fae49ea0f07f94429170f10e..0e9161b26f8a55c328e4c7fa16adba5f944ac241 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -1,4 +1,4 @@
-/* od -- dump in octal (and other formats) the contents of files
+/* od -- dump files in octal and other formats
    Copyright (C) 1992 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -1624,13 +1624,13 @@ main (argc, argv)
             specs.  GNU od accepts any combination of old- and
             new-style options.  Format specification options accumulate.  */
 
-#define CASE_OLD_ARG(old_char,new_string)                              \
-       case old_char:                                                  \
-         {                                                             \
-           int tmp;                                                    \
-           tmp = decode_format_string (new_string);                    \
-           assert (tmp == 0);                                          \
-         }                                                             \
+#define CASE_OLD_ARG(old_char,new_string)              \
+       case old_char:                                  \
+         {                                             \
+           int tmp;                                    \
+           tmp = decode_format_string (new_string);    \
+           assert (tmp == 0);                          \
+         }                                             \
          break
 
          CASE_OLD_ARG ('a', "a");
index e514284b8d9995515fce443ca8338f7e2f7cb926..f4f65782f84b0befa2b1cb632340ed01b6a6b129 100644 (file)
@@ -107,7 +107,7 @@ static int linelength = 30;
 #define LINEALLOC 262144
 
 /* Prefix for temporary file names. */
-static char *prefix;
+static char *temp_file_prefix;
 
 /* Flag to reverse the order of all comparisons. */
 static int reverse;
@@ -292,15 +292,15 @@ static char *
 tempname ()
 {
   static int seq;
-  int len = strlen (prefix);
+  int len = strlen (temp_file_prefix);
   char *name = xmalloc (len + 16);
   struct tempnode *node =
   (struct tempnode *) xmalloc (sizeof (struct tempnode));
 
-  if (len && prefix[len - 1] != '/')
-    sprintf (name, "%s/sort%5.5d%5.5d", prefix, getpid (), ++seq);
+  if (len && temp_file_prefix[len - 1] != '/')
+    sprintf (name, "%s/sort%5.5d%5.5d", temp_file_prefix, getpid (), ++seq);
   else
-    sprintf (name, "%ssort%5.5d%5.5d", prefix, getpid (), ++seq);
+    sprintf (name, "%ssort%5.5d%5.5d", temp_file_prefix, getpid (), ++seq);
   node->name = name;
   node->next = temphead.next;
   temphead.next = node;
@@ -1427,9 +1427,9 @@ main (argc, argv)
   have_read_stdin = 0;
   inittables ();
 
-  prefix = getenv ("TMPDIR");
-  if (prefix == NULL)
-    prefix = "/tmp";
+  temp_file_prefix = getenv ("TMPDIR");
+  if (temp_file_prefix == NULL)
+    temp_file_prefix = "/tmp";
 
 #ifdef _POSIX_VERSION
   newact.sa_handler = sighandler;
@@ -1625,6 +1625,17 @@ main (argc, argv)
                    else
                      error (2, 0, "option `-t' requires an argument");
                    break;
+                 case 'T':
+                   if (s[1])
+                     temp_file_prefix = ++s;
+                   else if (i < argc - 1)
+                     {
+                       temp_file_prefix = argv[++i];
+                       goto outer;
+                     }
+                   else
+                     error (2, 0, "option `-T' requires an argument");
+                   break;
                  case 'u':
                    unique = 1;
                    break;
@@ -1725,8 +1736,8 @@ static void
 usage ()
 {
   fprintf (stderr, "\
-Usage: %s [-cmus] [-t separator] [-o output-file] [-bdfiMnr] [+POS1 [-POS2]]\n\
-       [-k POS1[,POS2]] [file...]\n",
+Usage: %s [-cmus] [-t separator] [-o output-file] [-T tempdir] [-bdfiMnr]\n\
+       [+POS1 [-POS2]] [-k POS1[,POS2]] [file...]\n",
           program_name);
   exit (2);
 }
index a94ac9c63912bd5dc11b66bfc4555806abe00669..be0978fe42a0af786c6b1beb0d377dfdb156e679 100644 (file)
@@ -43,7 +43,7 @@
 
    Original version by Paul Rubin <phr@ocf.berkeley.edu>.
    Extensions by David MacKenzie <djm@gnu.ai.mit.edu>.
-   tail -f for multiple files by Ian Lance Taylor <ian@cygnus.com>.  */
+   tail -f for multiple files by Ian Lance Taylor <ian@airs.com>.  */
 
 #include <stdio.h>
 #include <getopt.h>
@@ -907,9 +907,22 @@ tail_forever (names, nfiles)
 
   pids = (int *) xmalloc (nfiles * sizeof (int));
 
-  /* fork once for each file.  If this is too ugly for you, don't use
-     tail -f on multiple files.  Maybe we could use select as an
-     alternative, though it's less portable.  Is it worth the bother?  */
+  /* fork once for each file.  This approach uses one process and
+     one file descriptor for each file we tail.
+     More resource-efficient approaches would be:
+
+     1.  Keep an off_t array of the last-seen sizes of the files,
+     and fstat them each in turn, watching for growth.
+     This would be more portable, but still use the same number of
+     file descriptors, and would probably use more CPU.
+     For pipes, perhaps a separate process would have to be forked to
+     read from the pipe and write to a temporary file.
+
+     2.  Keep an off_t array, but only keep recently changed files open
+     and use stat for the others, opening them only if they change.
+     This would save file descriptors, to allow tail -f on a large number
+     of files.  It's probably not worth the trouble for most uses, though,
+     and GNU won't have arbitrary limits on things like file descriptors.  */
 
   signal (SIGUSR1, sigusr1);
 
@@ -929,11 +942,11 @@ tail_forever (names, nfiles)
          close (pipe_descs[0]);
 
          /* Each child reads continually from a file and writes to
-            the pipe.  Each write to a pipe is the index of the file
+            the pipe.  Each write to the pipe is the index of the file
             being read, followed by the number of bytes read from the
-            file, followed by the actual bytes.  Each child is
+            file, followed by the actual data.  Each child is
             careful to write no more than PIPE_BUF bytes to the pipe,
-            so that the data from the various children does not get
+            so that the data from the various children do not get
             intermixed.  */
 
          /* The file index for this child is always the same.  */
index d0a170dfe423002e1e131e9ab411a23add35d650..873a23520e9504f4c618d68264e9a847e98a2086 100644 (file)
--- a/src/tr.c
+++ b/src/tr.c
@@ -1802,5 +1802,11 @@ deleting and squeezing repeats");
        }
     }
 
+  if (fclose (stdout) == EOF)
+    error (2, errno, "write error");
+
+  if (close (0) != 0)
+    error (2, errno, "standard input");
+
   exit (0);
 }