Selaa lähdekoodia

dpkg: Refactor file list removal into new remove_file_from_list function

This detangles the two independent actions, removing from the list and
skiping the file from the tarball.
Guillem Jover 16 vuotta sitten
vanhempi
commit
7983e949f7
1 muutettua tiedostoa jossa 15 lisäystä ja 8 poistoa
  1. 15 8
      src/archives.c

+ 15 - 8
src/archives.c

@@ -180,18 +180,12 @@ int tarfileread(void *ud, char *buf, int len) {
 }
 
 static void
-tarfile_skip_one_forward(struct TarInfo *ti,
-                         struct fileinlist **oldnifd,
-                         struct fileinlist *nifd)
+tarfile_skip_one_forward(struct TarInfo *ti)
 {
   struct tarcontext *tc = (struct tarcontext *)ti->UserData;
   size_t r;
   char databuf[TARBLKSZ];
 
-  obstack_free(&tar_obs, nifd);
-  tc->newfilesp = oldnifd;
-  *oldnifd = NULL;
-
   /* We need to advance the tar file to the next object, so read the
    * file data and set it to oblivion.
    */
@@ -343,6 +337,18 @@ struct fileinlist *addfiletolist(struct tarcontext *tc,
   return nifd;
 }
 
+static void
+remove_file_from_list(struct TarInfo *ti,
+                      struct fileinlist **oldnifd,
+                      struct fileinlist *nifd)
+{
+  struct tarcontext *tc = (struct tarcontext *)ti->UserData;
+
+  obstack_free(&tar_obs, nifd);
+  tc->newfilesp = oldnifd;
+  *oldnifd = NULL;
+}
+
 static bool
 linktosameexistingdir(const struct TarInfo *ti, const char *fname,
                       struct varbuf *symlinkfn)
@@ -612,7 +618,8 @@ int tarobject(struct TarInfo *ti) {
        
   if (existingdirectory) return 0;
   if (keepexisting) {
-    tarfile_skip_one_forward(ti, oldnifd, nifd);
+    remove_file_from_list(ti, oldnifd, nifd);
+    tarfile_skip_one_forward(ti);
     return 0;
   }