summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-04-25 14:42:17 +0000
committerOlivier Blin <oblin@mandriva.com>2007-04-25 14:42:17 +0000
commitb6edac21ddfd67b4495c58cd5b2e1f31b5fcd1ef (patch)
treec7dfc790463bb5f40c0474d3b0c68b0b5600e8bb
parentb214349247d85764ae1b0b982c09f12ab6fd0bcb (diff)
downloaddrakx-b6edac21ddfd67b4495c58cd5b2e1f31b5fcd1ef.tar
drakx-b6edac21ddfd67b4495c58cd5b2e1f31b5fcd1ef.tar.gz
drakx-b6edac21ddfd67b4495c58cd5b2e1f31b5fcd1ef.tar.bz2
drakx-b6edac21ddfd67b4495c58cd5b2e1f31b5fcd1ef.tar.xz
drakx-b6edac21ddfd67b4495c58cd5b2e1f31b5fcd1ef.zip
implement ask_from_list_index() and drop other ask_from_list() functions
-rw-r--r--mdk-stage1/newt-frontend.c58
-rw-r--r--mdk-stage1/stdio-frontend.c10
2 files changed, 23 insertions, 45 deletions
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index 4bedda82b..731818a0d 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -172,55 +172,39 @@ void end_progression_raw(void)
}
-enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
+enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_comments, int * answer)
{
char * items[500];
- int answer = 0, rc;
- char ** sav_elems = elems;
- int i;
+ int rc;
- i = 0;
- while (elems && *elems) {
- int j = (*elems_comments) ? strlen(*elems_comments) : 0;
- items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4));
- strcpy(items[i], *elems);
- if (*elems_comments) {
- strcat(items[i], " (");
- strcat(items[i], *elems_comments);
- strcat(items[i], ")");
- }
- elems_comments++;
- i++;
- elems++;
+ if (elems_comments) {
+ int i;
+
+ i = 0;
+ while (elems && *elems) {
+ int j = (*elems_comments) ? strlen(*elems_comments) : 0;
+ items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4));
+ strcpy(items[i], *elems);
+ if (*elems_comments) {
+ strcat(items[i], " (");
+ strcat(items[i], *elems_comments);
+ strcat(items[i], ")");
+ }
+ elems_comments++;
+ i++;
+ elems++;
+ }
+ items[i] = NULL;
}
- items[i] = NULL;
- rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, items, &answer, "Ok", "Cancel", NULL);
+ rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems_comments ? items : elems, answer, "Ok", "Cancel", NULL);
if (rc == 2)
return RETURN_BACK;
- *choice = strdup(sav_elems[answer]);
-
return RETURN_OK;
}
-
-enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
-{
- int answer = 0, rc;
-
- rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems, &answer, "Ok", "Cancel", NULL);
-
- if (rc == 2)
- return RETURN_BACK;
-
- *choice = strdup(elems[answer]);
-
- return RETURN_OK;
-}
-
-
enum return_type ask_yes_no(char *msg)
{
int rc;
diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c
index ffa306811..7d3c6f14b 100644
--- a/mdk-stage1/stdio-frontend.c
+++ b/mdk-stage1/stdio-frontend.c
@@ -240,7 +240,7 @@ void end_progression_raw(void)
}
-enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
+enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_comments, int *answer)
{
int justify_number = 1;
void print_choice_number(int i) {
@@ -296,7 +296,7 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
return RETURN_BACK;
if (j >= 1 && j <= i) {
- *choice = strdup(sav_elems[j-1]);
+ *answer = j - 1;
return RETURN_OK;
}
@@ -304,12 +304,6 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
}
-enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
-{
- return ask_from_list_comments(msg, elems, NULL, choice);
-}
-
-
enum return_type ask_yes_no(char *msg)
{
int j;