]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
merge with 3.8
authorJim Meyering <jim@meyering.net>
Sat, 24 Jul 1993 13:00:24 +0000 (13:00 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 24 Jul 1993 13:00:24 +0000 (13:00 +0000)
lib/backupfile.c
old/fileutils/ChangeLog
old/fileutils/NEWS
src/install.c
src/ls.c

index f15e530bff759a2ca4b2fec698800467dd369b0e..670db0f5d521bd8d822c8edfee702398bd0e78ce 100644 (file)
@@ -216,7 +216,7 @@ concat (str1, str2)
      char *str1, *str2;
 {
   char *newstr;
-  char str1_length = strlen (str1);
+  int str1_length = strlen (str1);
 
   newstr = malloc (str1_length + strlen (str2) + 1);
   if (newstr == 0)
index f59a9cbfa2790ad2e61033f39443d7684759bc01..e8b4215cdc96a012adf0e95092bb753990d25379 100644 (file)
@@ -1,3 +1,28 @@
+Thu May 27 00:03:51 1993  Jim Meyering  (meyering@comco.com)
+
+       * Version 3.8.
+
+       * configure.in (STAT_OSF1): Reference the statfs f_fsize member
+       so that configure defines STAT_OSF1 only if there is such a member.
+       Without such a reference, a Pyramid MIServer running OSx 5.1
+       improperly defined STAT_OSF1 instead of the one it needed:
+       STAT_STATFS2_BSIZE.
+
+Wed May 26 00:57:46 1993  Jim Meyering  (meyering@comco.com)
+
+       * ls.h, ls-ls.c ls-dir.c, ls-vdir.c: New files that define or
+       simply set the new global variable ls_mode.  ls_mode defines whether
+       the executable built from ls.o should act like ls, dir, or vdir.
+       * ls.c (decode_switches): Use the variable instead of #ifdefs.
+       This is modelled after the approach used in GNU binutils 2.x for
+       ar and ranlib.  Here we avoid two rudundant compilations.
+
+       * install.c (change_attributes, copy_file, install_file_in_file):
+       Don't call chown if we can efficiently determine that doing so is
+       unnecessary.  On some systems, calls to chown (even with your own
+       uid and gid) fail unless made by root.  On such systems install
+       got spurious failures.
+
 Sat May 22 02:13:12 1993  Jim Meyering  (meyering@comco.com)
 
        * Version 3.6.
index 487e1d1656feda2eb7bb5873d48ccc93824b2ca1..4b71f42e6cebbfa0038a44b6c9e3ce43a9d4a92d 100644 (file)
@@ -1,3 +1,11 @@
+Major changes in release 3.8:
+* install isn't as likely to produce spurious errors 
+* avoid redundant compilations for `dir' and `vdir';
+* configure properly defines STAT_STATFS2_BSIZE on a Pyramid MIServer
+  running OSx 5.1
+\f
+Major changes in release 3.7:
+* none
 Major changes in release 3.6:
 * `ln -s dir_pathname .' works when the pathname has a trailing slash
 * with the --version option programs print the version and exit immediately
index b2461eefcb9a830ce5f3f5ebd95bf6398237e1f2..c4593602b7ce52fff031e6156b84c40cebdf8aa5 100644 (file)
@@ -263,11 +263,17 @@ install_file_in_file (from, to)
      char *from;
      char *to;
 {
-  if (copy_file (from, to))
+  int to_created;
+  int no_need_to_chown;
+
+  if (copy_file (from, to, &to_created))
     return 1;
   if (strip_files)
     strip (to);
-  return change_attributes (to);
+  no_need_to_chown = (to_created
+                     && owner_name == NULL
+                     && group_name == NULL);
+  return change_attributes (to, no_need_to_chown);
 }
 
 /* Copy file FROM into directory TO_DIR, keeping its same name,
@@ -295,17 +301,22 @@ install_file_in_dir (from, to_dir)
 static char buffer[READ_SIZE];
 
 /* Copy file FROM onto file TO, creating TO if necessary.
-   Return 0 if the copy is successful, 1 if not. */
+   Return 0 if the copy is successful, 1 if not.  If the copy is
+   successful, set *TO_CREATED to non-zero if TO was created (if it did
+   not exist or did, but was unlinked) and to zero otherwise.  If the
+   copy fails, don't modify *TO_CREATED.  */
 
 static int
-copy_file (from, to)
+copy_file (from, to, to_created)
      char *from;
      char *to;
+     int *to_created;
 {
   int fromfd, tofd;
   int bytes;
   int ret = 0;
   struct stat from_stats, to_stats;
+  int target_created = 1;
 
   if (stat (from, &from_stats))
     {
@@ -331,7 +342,8 @@ copy_file (from, to)
          return 1;
        }
       /* If unlink fails, try to proceed anyway.  */
-      unlink (to);
+      if (unlink (to))
+       target_created = 0;
     }
 
   fromfd = open (from, O_RDONLY, 0);
@@ -373,6 +385,8 @@ copy_file (from, to)
       error (0, errno, "%s", to);
       ret = 1;
     }
+  if (ret == 0)
+    *to_created = target_created;
   return ret;
 
  copy_error:
@@ -382,11 +396,13 @@ copy_file (from, to)
 }
 
 /* Set the attributes of file or directory PATH.
+   If NO_NEED_TO_CHOWN is non-zero, don't call chown.
    Return 0 if successful, 1 if not. */
 
 static int
-change_attributes (path)
+change_attributes (path, no_need_to_chown)
      char *path;
+     int no_need_to_chown;
 {
   int err = 0;
 
@@ -406,7 +422,7 @@ change_attributes (path)
      want to know.  But AFS returns EPERM when you try to change a
      file's group; thus the kludge.  */
 
-  if (chown (path, owner_id, group_id)
+  if (!no_need_to_chown && chown (path, owner_id, group_id)
 #ifdef AFS
       && errno != EPERM
 #endif
index 6dd186a3864e2152a874a0a9eca6a2744835b065..e659260e361dae7d6eb40f903d228bc137d13221 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -45,6 +45,8 @@
 #include <getopt.h>
 #include "system.h"
 #include <fnmatch.h>
+
+#include "ls.h"
 #include "version.h"
 
 #ifndef S_IEXEC
@@ -525,29 +527,37 @@ decode_switches (argc, argv)
 
   /* initialize all switches to default settings */
 
-#ifdef MULTI_COL
-  /* This is for the `dir' program.  */
-  format = many_per_line;
-  quote_funny_chars = 1;
-#else
-#ifdef LONG_FORMAT
-  /* This is for the `vdir' program.  */
-  format = long_format;
-  quote_funny_chars = 1;
-#else
-  /* This is for the `ls' program.  */
-  if (isatty (1))
+  switch (ls_mode)
     {
+    case LS_MULTI_COL:
+      /* This is for the `dir' program.  */
       format = many_per_line;
-      qmark_funny_chars = 1;
-    }
-  else
-    {
-      format = one_per_line;
-      qmark_funny_chars = 0;
+      quote_funny_chars = 1;
+      break;
+
+    case LS_LONG_FORMAT:
+      /* This is for the `vdir' program.  */
+      format = long_format;
+      quote_funny_chars = 1;
+      break;
+
+    case LS_LS:
+      /* This is for the `ls' program.  */
+      if (isatty (1))
+       {
+         format = many_per_line;
+         qmark_funny_chars = 1;
+       }
+      else
+       {
+         format = one_per_line;
+         qmark_funny_chars = 0;
+       }
+      break;
+
+    default:
+      abort ();
     }
-#endif
-#endif
 
   time_type = time_mtime;
   full_time = 0;