Control: tags -1 + patch Hello,
Samuel Thibault, le Sun 29 Mar 2015 12:17:16 +0200, a écrit : > When using the vocalized installer, the first question (language) is > quite tedious: there are 50 choices, which means that on average the > user will have to listen to 25 choices before hearing what he wants. And > he has to, to know which number he has to type, unless knowing by heart > the number (which is different from release to release since we add > languages). It would be useful that cdebconf-text-udeb accept not only > numbers, but also shortcuts, for instance fr or French. The former will > probably be easier to implement since that's the Choices-C. The attached patch is doing it quite easily indeed. Would it be OK for Jessie? Samuel
diff --git a/src/modules/frontend/text/text.c b/src/modules/frontend/text/text.c index 9bae514..e90b837 100644 --- a/src/modules/frontend/text/text.c +++ b/src/modules/frontend/text/text.c @@ -590,7 +590,7 @@ static int text_handler_multiselect(struct frontend *obj, struct question *q) static int text_handler_select(struct frontend *obj, struct question *q) { struct choices *choices = NULL; - char answer[10]; + char answer[128]; int i, choice, def = -1; const char *defval; int ret = DC_OK; @@ -640,8 +640,19 @@ static int text_handler_select(struct frontend *obj, struct question *q) } if (ISEMPTY(answer)) choice = def; - else + else { choice = atoi(answer) - 1; + if (choice == -1) { + /* Not a number, perhaps the value */ + for (i = 0; i < choices->count; i++) { + if (strcasecmp(choices->choices[choices->tindex[i]], answer) == 0) { + /* Yes */ + choice = i; + break; + } + } + } + } } while (choice < 0 || choice >= choices->count); question_setvalue(q, choices->choices[choices->tindex[choice]]);