summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2012-04-10 06:18:35 +0200
committerGuillem Jover <guillem@debian.org>2012-04-14 09:16:03 +0200
commit441f04dcaa91f6e59ff8217f5c98b0e8a116a73c (patch)
tree8127f3f990b332b2254a00cc7cd6d0d16b32acd6
parentc78e21281a15ca218182b18c3c891df901403e89 (diff)
downloaddpkg-441f04dcaa91f6e59ff8217f5c98b0e8a116a73c.tar.gz
u-a: Move alt_map_obj setup logic into alternative_set_selections()
-rw-r--r--utils/update-alternatives.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 542afc831..fc2e928ea 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2078,9 +2078,13 @@ alternative_set_selection(struct alternative_map *all, const char *name,
}
static void
-alternative_set_selections(struct alternative_map *all, FILE *input,
- const char *desc)
+alternative_set_selections(FILE *input, const char *desc)
{
+ struct alternative_map *alt_map_obj;
+
+ alt_map_obj = alternative_map_new(NULL, NULL);
+ alternative_map_load_names(alt_map_obj);
+
for (;;) {
char line[1024], *res, *name, *status, *choice;
size_t len, i;
@@ -2138,8 +2142,10 @@ alternative_set_selections(struct alternative_map *all, FILE *input,
choice = line + i;
printf("[%s %s] ", PROGNAME, "--set-selections");
- alternative_set_selection(all, name, status, choice);
+ alternative_set_selection(alt_map_obj, name, status, choice);
}
+
+ alternative_map_free(alt_map_obj);
}
static void
@@ -2505,13 +2511,8 @@ main(int argc, char **argv)
alternative_get_selections();
exit(0);
} else if (strcmp(action, "set-selections") == 0) {
- struct alternative_map *alt_map_obj;
-
log_msg("run with %s", get_argv_string(argc, argv));
- alt_map_obj = alternative_map_new(NULL, NULL);
- alternative_map_load_names(alt_map_obj);
- alternative_set_selections(alt_map_obj, stdin, _("<standard input>"));
- alternative_map_free(alt_map_obj);
+ alternative_set_selections(stdin, _("<standard input>"));
exit(0);
}