From 441f04dcaa91f6e59ff8217f5c98b0e8a116a73c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 10 Apr 2012 06:18:35 +0200 Subject: u-a: Move alt_map_obj setup logic into alternative_set_selections() --- utils/update-alternatives.c | 19 ++++++++++--------- 1 file 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, _("")); - alternative_map_free(alt_map_obj); + alternative_set_selections(stdin, _("")); exit(0); } -- cgit v1.2.3