Przeglądaj źródła

dpkg: Handle --force-all as any other force option

Add an entry for "all" to forceinfos, so that the code paths are more
clear on what each is doing. This will also make further refactoring
easier.
Guillem Jover 15 lat temu
rodzic
commit
aa18c17889
1 zmienionych plików z 6 dodań i 6 usunięć
  1. 6 6
      src/main.c

+ 6 - 6
src/main.c

@@ -197,6 +197,7 @@ static const struct forceinfo {
   const char *name;
   int *opt;
 } forceinfos[]= {
+  { "all",                 NULL                         },
   { "downgrade",           &fc_downgrade                },
   { "configure-any",       &fc_configureany             },
   { "hold",                &fc_hold                     },
@@ -472,15 +473,14 @@ static void setforce(const struct cmdinfo *cip, const char *value) {
     for (fip=forceinfos; fip->name; fip++)
       if (!strncmp(fip->name,value,l) && strlen(fip->name)==l) break;
     if (!fip->name) {
-      if (strncmp("all", value, l) == 0) {
+      badusage(_("unknown force/refuse option `%.*s'"),
+               (int)min(l, 250), value);
+    } else {
+      if (strcmp("all", fip->name) == 0) {
 	for (fip=forceinfos; fip->name; fip++)
 	  if (fip->opt)
 	    *fip->opt= cip->arg;
-      } else
-	badusage(_("unknown force/refuse option `%.*s'"),
-	         (int)min(l, 250), value);
-    } else {
-      if (fip->opt)
+      } else if (fip->opt)
 	*fip->opt= cip->arg;
       else
 	warning(_("obsolete force/refuse option '%s'\n"), fip->name);