bug-coreutils
[Top][All Lists]
Advanced

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

bug#8565: gzip/bzip2/output-hook support for split


From: Jim Meyering
Subject: bug#8565: gzip/bzip2/output-hook support for split
Date: Fri, 29 Apr 2011 12:33:53 +0200

Karl Heuer wrote:
>>Karl, this is a good time to add the feature.
>>If you don't have time to handle the remaining bits (test,
>>doc and NEWS), let us know and we will take care of the rest.
>
> I'd better let you do it; I've got too many other items in my
> queue at the moment.

Ok.  For starters, I'm squashing this onto your patch.
The type change is required to get past this compilation error:

    split.c: In function 'create':
    split.c:334:42: error: passing argument 2 of 'x2nrealloc' from incompatible 
pointer type [-Werror]
    ../lib/xalloc.h:191:1: note: expected 'size_t *' but argument is of type 
'int *'
    cc1: all warnings being treated as errors

Also, at least initially, I'll remove the short-named (-f)
version of your new --filter option, just to be on the safe side.
People can always abbreviate using "--f".


>From 6b72fcbf896e082cc797b601c0f4e2533a479981 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 29 Apr 2011 12:26:50 +0200
Subject: [PATCH] split: minor adjustments: s/int/size_t/ for new globals,
 and...

rename: open_pipes_size -> open_pipes_alloc
   and  open_pipes_len  -> n_open_pipes
---
 src/split.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/split.c b/src/split.c
index c977ceb..2b9cdfc 100644
--- a/src/split.c
+++ b/src/split.c
@@ -56,8 +56,8 @@ static int filter_pid;

 /* Array of open pipes.  */
 static int *open_pipes;
-static int open_pipes_size;
-static int open_pipes_len;
+static size_t open_pipes_alloc;
+static size_t n_open_pipes;

 /* Blocked signals.  */
 static sigset_t oldblocked;
@@ -307,7 +307,7 @@ create (const char* name)
              earlier call, otherwise this process will be holding a
              write-pipe that will prevent the earlier process from
              reading an EOF on the corresponding read-pipe.  */
-          for (j = 0; j < open_pipes_len; ++j)
+          for (j = 0; j < n_open_pipes; ++j)
             if (close (open_pipes[j]) != 0)
               error (EXIT_FAILURE, errno, _("closing prior pipe"));
           if (close (fd_pair[1]))
@@ -329,10 +329,10 @@ create (const char* name)
       if (close (fd_pair[0]) != 0)
         error (EXIT_FAILURE, errno, _("closing input pipe"));
       filter_pid = child_pid;
-      if (open_pipes_len == open_pipes_size)
-        open_pipes = (int *) x2nrealloc (open_pipes, &open_pipes_size,
+      if (n_open_pipes == open_pipes_alloc)
+        open_pipes = (int *) x2nrealloc (open_pipes, &open_pipes_alloc,
                                          sizeof *open_pipes);
-      open_pipes[open_pipes_len++] = fd_pair[1];
+      open_pipes[n_open_pipes++] = fd_pair[1];
       return fd_pair[1];
     }
 }
@@ -350,9 +350,9 @@ closeout (FILE *fp, int fd, pid_t pid, char const *name)
       if (fp == NULL && close (fd) < 0)
         error (EXIT_FAILURE, errno, "%s", name);
       int j;
-      for (j = 0; j < open_pipes_len; ++j)
+      for (j = 0; j < n_open_pipes; ++j)
         if (open_pipes[j] == fd) {
-          open_pipes[j] = open_pipes[--open_pipes_len];
+          open_pipes[j] = open_pipes[--n_open_pipes];
           break;
         }
     }
--
1.7.5.452.gcf2d0





reply via email to

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