Kaynağa Gözat

dpkg-deb: Inline controlextractvextract() into call sites

Although the two call sites are doing almost the same, they need
different argument parsing logic, and inlining the code will allow
to print more meaningful bad usage messages.
Guillem Jover 13 yıl önce
ebeveyn
işleme
44489a5543
1 değiştirilmiş dosya ile 33 ekleme ve 27 silme
  1. 33 27
      dpkg-deb/extract.c

+ 33 - 27
dpkg-deb/extract.c

@@ -367,31 +367,6 @@ extracthalf(const char *debar, const char *dir,
   }
   }
 }
 }
 
 
-static int
-controlextractvextract(int admin, enum dpkg_tar_options taroptions,
-                       const char *const *argv)
-{
-  const char *debar, *dir;
-
-  debar = *argv++;
-  if (debar == NULL)
-    badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
-  dir = *argv++;
-  if (!dir) {
-    if (admin)
-      dir = EXTRACTCONTROLDIR;
-    else
-      badusage(_("--%s needs a target directory.\n"
-                 "Perhaps you should be using dpkg --install ?"),
-               cipaction->olong);
-  } else if (*argv) {
-    badusage(_("--%s takes at most two arguments (.deb and directory)"),cipaction->olong);
-  }
-  extracthalf(debar, dir, taroptions, admin);
-
-  return 0;
-}
-
 int
 int
 do_fsystarfile(const char *const *argv)
 do_fsystarfile(const char *const *argv)
 {
 {
@@ -410,18 +385,49 @@ do_fsystarfile(const char *const *argv)
 int
 int
 do_control(const char *const *argv)
 do_control(const char *const *argv)
 {
 {
-  return controlextractvextract(1, DPKG_TAR_EXTRACT, argv);
+  const char *debar, *dir;
+
+  debar = *argv++;
+  if (debar == NULL)
+    badusage(_("--%s needs a .deb filename argument"), cipaction->olong);
+
+  dir = *argv++;
+  if (dir == NULL)
+    dir = EXTRACTCONTROLDIR;
+  else if (*argv)
+    badusage(_("--%s takes at most two arguments (.deb and directory)"),
+             cipaction->olong);
+
+  extracthalf(debar, dir, DPKG_TAR_EXTRACT, 1);
+
+  return 0;
 }
 }
 
 
 int
 int
 do_extract(const char *const *argv)
 do_extract(const char *const *argv)
 {
 {
+  const char *debar, *dir;
   enum dpkg_tar_options options = DPKG_TAR_EXTRACT | DPKG_TAR_PERMS;
   enum dpkg_tar_options options = DPKG_TAR_EXTRACT | DPKG_TAR_PERMS;
 
 
   if (opt_verbose)
   if (opt_verbose)
     options |= DPKG_TAR_LIST;
     options |= DPKG_TAR_LIST;
 
 
-  return controlextractvextract(0, options, argv);
+  debar = *argv++;
+  if (debar == NULL)
+    badusage(_("--%s needs a .deb filename argument"), cipaction->olong);
+
+  dir = *argv++;
+  if (dir == NULL)
+    badusage(_("--%s needs a target directory.\n"
+               "Perhaps you should be using dpkg --install ?"),
+             cipaction->olong);
+  else if (*argv)
+    badusage(_("--%s takes at most two arguments (.deb and directory)"),
+             cipaction->olong);
+
+  extracthalf(debar, dir, options, 0);
+
+  return 0;
 }
 }
 
 
 int
 int