bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] Get coreutils 6.1 to build on a ANSI 89 compiler


From: Petter Reinholdtsen
Subject: [patch] Get coreutils 6.1 to build on a ANSI 89 compiler
Date: Sun, 17 Sep 2006 10:19:14 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (usg-unix-v)

The ANSI C 89 compilers refuses code that fail to declare variables at
the start of the block.  I found this problem on RHEL 2.1.  The code
refused to compile, and I have to move the variables up to the start
of the block to get it building.

Here is a quick and dirty patch to solve the issue.  Sorry for not
having the time to make it prettier.  For some variables near the end
of its block, I just created a new block covering the new variables
life spam, while for others, I moved the variable up to the nearest
block start.  Please apply this or similar patch to the next relase of
coreutils.

diff -ur /local/store/storeslem/coreutils/src-6.1/src/copy.c 
src-6.1-386linuxlibc62/src/copy.c
--- /local/store/storeslem/coreutils/src-6.1/src/copy.c 2006-08-19 
07:35:24.000000000 +0200
+++ src-6.1-386linuxlibc62/src/copy.c   2006-09-17 10:04:30.000000000 +0200
@@ -1027,6 +1027,7 @@
          bool unlink_src;
          bool ok = same_file_ok (src_name, &src_sb, dst_name, &dst_sb,
                                  x, &return_now, &unlink_src);
+         bool backup_directories = true;
          if (unlink_src)
            {
              if (!abandon_move (x, dst_name, &dst_sb)
@@ -1169,7 +1170,6 @@
                }
            }

-         bool backup_directories = true;
          if (x->backup_type != no_backups
              && (!S_ISDIR (dst_sb.st_mode) || backup_directories))
            {
diff -ur /local/store/storeslem/coreutils/src-6.1/src/ls.c 
src-6.1-386linuxlibc62/src/ls.c
--- /local/store/storeslem/coreutils/src-6.1/src/ls.c   2006-08-17 
17:32:19.000000000 +0200
+++ src-6.1-386linuxlibc62/src/ls.c     2006-09-17 10:05:22.000000000 +0200
@@ -3140,6 +3140,7 @@
       assert (sort_type != sort_version);
     }

+{
   /* When sort_type == sort_time, use time_type as subindex.  */
   int timeoffset = sort_type == sort_time ? time_type : 0;

@@ -3147,6 +3148,7 @@
          sort_functions[sort_type + timeoffset][use_strcmp][sort_reverse]
                        [directories_first]);
 }
+}

 /* List all the files now in the table.  */

diff -ur /local/store/storeslem/coreutils/src-6.1/src/remove.c 
src-6.1-386linuxlibc62/src/remove.c
--- /local/store/storeslem/coreutils/src-6.1/src/remove.c       2006-08-17 
12:03:31.000000000 +0200
+++ src-6.1-386linuxlibc62/src/remove.c 2006-09-17 10:08:38.000000000 +0200
@@ -202,9 +202,10 @@
 {
   size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t);
   size_t *length = obstack_base (&ds->len_stack);
+  size_t top_len;

   assert (n_lengths > 0);
-  size_t top_len = length[n_lengths - 1];
+  top_len = length[n_lengths - 1];
   assert (top_len >= 2);

   /* Pop the specified length of file name.  */
@@ -336,10 +337,11 @@
 static void
 AD_stack_pop (Dirstack_state *ds)
 {
+  struct AD_ent *top;
   assert (0 < AD_stack_height (ds));

   /* operate on Active_dir.  pop and free top entry */
-  struct AD_ent *top = AD_stack_top (ds);
+  top = AD_stack_top (ds);
   if (top->unremovable)
     hash_free (top->unremovable);
   obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent));
@@ -499,6 +501,7 @@
 static void
 AD_mark_helper (Hash_table **ht, char *filename)
 {
+  void *ent;
   if (*ht == NULL)
     {
       *ht = hash_initialize (HT_UNREMOVABLE_INITIAL_CAPACITY, NULL, hash_pjw,
@@ -506,7 +509,7 @@
       if (*ht == NULL)
        xalloc_die ();
     }
-  void *ent = hash_insert (*ht, filename);
+  ent = hash_insert (*ht, filename);
   if (ent == NULL)
     xalloc_die ();
   else
@@ -1058,7 +1061,7 @@
       close_preserve_errno (fd_sub);
       return NULL;
     }
-
+{
   DIR *subdir_dirp = fdopendir (fd_sub);
   if (subdir_dirp == NULL)
     {
@@ -1068,6 +1071,7 @@

   return subdir_dirp;
 }
+}

 /* Remove entries in the directory open on DIRP
    Upon finding a directory that is both non-empty and that can be chdir'd
@@ -1302,9 +1306,10 @@
        /* The name of the directory that we have just processed,
           nominally removing all of its contents.  */
        char *empty_dir;
+       int fd;

        AD_pop_and_chdir (&dirp, ds, &empty_dir);
-       int fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
+       fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
        assert (dirp != NULL || AD_stack_height (ds) == 1);

        /* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded.  */
@@ -1372,6 +1377,8 @@
       struct rm_options const *x, int *cwd_errno)
 {
   char const *base = last_component (filename);
+  int fd_cwd = AT_FDCWD;
+  enum RM_status status;
   if (DOT_OR_DOTDOT (base))
     {
       error (0, 0, _("cannot remove `.' or `..'"));
@@ -1381,8 +1388,7 @@
   AD_push_initial (ds);
   AD_INIT_OTHER_MEMBERS ();

-  int fd_cwd = AT_FDCWD;
-  enum RM_status status = remove_entry (fd_cwd, ds, filename, x, NULL);
+  status = remove_entry (fd_cwd, ds, filename, x, NULL);
   if (status == RM_NONEMPTY_DIR)
     {
       /* In the event that remove_dir->remove_cwd_entries detects
@@ -1413,6 +1419,7 @@

   for (i = 0; i < n_files; i++)
     {
+      enum RM_status s;
       if (cwd_errno && IS_RELATIVE_FILE_NAME (file[i]))
        {
          error (0, 0, _("cannot remove relative-named %s"), quote (file[i]));
@@ -1421,7 +1428,7 @@
        }

       cycle_check_init (&ds->cycle_check_state);
-      enum RM_status s = rm_1 (ds, file[i], x, &cwd_errno);
+      s = rm_1 (ds, file[i], x, &cwd_errno);
       assert (VALID_STATUS (s));
       UPDATE_STATUS (status, s);
     }
diff -ur /local/store/storeslem/coreutils/src-6.1/src/rm.c 
src-6.1-386linuxlibc62/src/rm.c
--- /local/store/storeslem/coreutils/src-6.1/src/rm.c   2006-08-17 
11:51:14.000000000 +0200
+++ src-6.1-386linuxlibc62/src/rm.c     2006-09-17 10:09:07.000000000 +0200
@@ -347,6 +347,7 @@
   {
     size_t n_files = argc - optind;
     char const *const *file = (char const *const *) argv + optind;
+    enum RM_status status;

     if (prompt_once && (x.recursive || 3 < n_files))
       {
@@ -358,7 +359,7 @@
        if (!yesno ())
          exit (EXIT_SUCCESS);
       }
-    enum RM_status status = rm (n_files, file, &x);
+    status = rm (n_files, file, &x);
     assert (VALID_STATUS (status));
     exit (status == RM_ERROR ? EXIT_FAILURE : EXIT_SUCCESS);
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]