Re: cdebconf http backend and choice/choice-description independence
* (Denis Barbier)
| On Fri, Dec 20, 2002 at 08:49:09PM +0100, Tollef Fog Heen wrote:
| [...]
| > Those aren't checked in yet; I'll send patches here for the
| > Choices-Description so people have a chance to complain ;)
|
| I would like to complain, could you please send your patches ;)
Yeah, and it'll break binary compatibility, so we need to up soname.
Ugh.
Index: debian/changelog
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/debian/changelog,v
retrieving revision 1.79
diff -u -r1.79 changelog
--- debian/changelog 23 Dec 2002 09:51:31 -0000 1.79
+++ debian/changelog 23 Dec 2002 09:52:32 -0000
@@ -18,6 +18,8 @@
* Tollef Fog Heen:
- Move rfc822 functions into libcdebconf from rfc822db module
- Fix getwidth to work properly on serial consoles. Hopefully.
+ - Add support for having Choices' descriptions separate from their
+ values.
-- Randolph Chung <tausq@debian.org> Sun, 8 Dec 2002 11:02:59 -0800
Index: src/template.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/template.c,v
retrieving revision 1.21
diff -u -r1.21 template.c
--- src/template.c 19 Dec 2002 00:38:44 -0000 1.21
+++ src/template.c 23 Dec 2002 09:52:34 -0000
@@ -20,6 +20,7 @@
"type",
"default",
"choices",
+ "choices_description",
"description",
"extended_description",
NULL
@@ -124,6 +125,7 @@
q = p->next;
DELETE(p->defaultval);
DELETE(p->choices);
+ DELETE(p->choices_description);
DELETE(p->description);
DELETE(p->extended_description);
DELETE(p);
@@ -169,6 +171,7 @@
{
to->defaultval = STRDUP(from->defaultval);
to->choices = STRDUP(from->choices);
+ to->choices_description = STRDUP(from->description);
to->description = STRDUP(from->description);
to->extended_description = STRDUP(from->extended_description);
@@ -192,6 +195,8 @@
return p->defaultval;
else if (strcasecmp(field, "choices") == 0)
return p->choices;
+ else if (strcasecmp(field, "choices_description") == 0)
+ return p->choices_description;
else if (strcasecmp(field, "description") == 0)
return p->description;
else if (strcasecmp(field, "extended_description") == 0)
@@ -212,6 +217,11 @@
DELETE(p->choices);
p->choices = STRDUP(value);
}
+ else if (strcasecmp(field, "choices_description") == 0)
+ {
+ DELETE(p->choices_description);
+ p->choices_description = STRDUP(value);
+ }
else if (strcasecmp(field, "description") == 0)
{
DELETE(p->description);
@@ -507,6 +517,25 @@
}
else if (strstr(p, "Choices: ") == p && t != 0)
template_lset(t, NULL, "choices", p+9);
+ else if (strstr(p, "Choices-Description: ") == p && t != 0)
+ template_lset(t, NULL, "choices_description", p+21);
+ else if (strstr(p, "Choices-Description-: ") == p && t != 0)
+ {
+ cp = strstr(p, ".UTF-8: ");
+ if (cp != NULL && cp != p+20)
+ {
+ lang = strndup(p+20, (int) (cp - p - 20));
+ template_lset(t, lang, "choices_description", cp+20);
+ }
+ else
+ {
+#ifndef NODEBUG
+ fprintf(stderr, "Unknown localized field:\n%s\n", p);
+#endif
+ continue;
+ }
+ }
+
else if (strstr(p, "Choices-") == p && t != 0)
{
cp = strstr(p, ".UTF-8: ");
Index: src/template.h
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/template.h,v
retrieving revision 1.7
diff -u -r1.7 template.h
--- src/template.h 7 Dec 2002 23:02:40 -0000 1.7
+++ src/template.h 23 Dec 2002 09:52:34 -0000
@@ -10,6 +10,7 @@
char *language;
char *defaultval;
char *choices;
+ char *choices_description;
char *description;
char *extended_description;
struct template_l10n_fields *next;
Index: src/modules/frontend/text/text.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/modules/frontend/text/text.c,v
retrieving revision 1.29
diff -u -r1.29 text.c
--- src/modules/frontend/text/text.c 23 Dec 2002 09:48:46 -0000 1.29
+++ src/modules/frontend/text/text.c 23 Dec 2002 09:52:35 -0000
@@ -10,7 +10,7 @@
* friendly implementation. I've taken care to make the prompts work well
* with screen readers and the like.
*
- * $Id: text.c,v 1.29 2002/12/23 09:48:46 tfheen Exp $
+ * $Id: text.c,v 1.27 2002/12/18 06:24:04 tausq Exp $
*
* cdebconf is (c) 2000-2001 Randolph Chung and others under the following
* license.
@@ -181,6 +181,7 @@
{
char *choices[100] = {0};
char *choices_translated[100] = {0};
+ char *choices_descriptions[100] = {0};
char *defaults[100] = {0};
char selected[100] = {0};
char answer[1024] = {0};
@@ -190,6 +191,7 @@
if (count <= 0) return DC_NOTOK;
strchoicesplit(question_get_field(q, "", "choices"), choices_translated, DIM(choices_translated));
+ strchoicesplit(question_get_field(q, "", "choices_description"), choices_descriptions, DIM(choices_descriptions));
dcount = strchoicesplit(question_get_field(q, NULL, "value"), defaults, DIM(defaults));
for (j = 0; j < dcount; j++)
@@ -201,7 +203,8 @@
{
for (i = 0; i < count; i++)
{
- printf("%3d. %s%s\n", i+1, choices_translated[i],
+ printf("%3d. %s%s\n", i+1,
+ (choices_descriptions[i] ? choices_descriptions[i] : choices_translated[i] ),
(selected[i] ? _(" (selected)") : ""));
}
@@ -231,6 +234,7 @@
}
free(choices[i]);
free(choices_translated[i]);
+ free(choices_descriptions[i]);
}
for (i = 0; i < dcount; i++)
free(defaults[i]);
@@ -277,10 +281,18 @@
tcsetattr(0, TCSANOW, &newt);
while ((c = fgetc(stdin)) != EOF)
{
- fputc('*', stdout);
- passwd[i++] = (char)c;
if (c == '\r' || c == '\n') break;
-
+ if (c == 127) { /* delete/backspace */
+ if (i > 0) {
+ passwd[i--] = 0;
+ fputc(0x08, stdout);
+ fputc(' ', stdout);
+ fputc(0x08, stdout);
+ }
+ } else {
+ fputc('*', stdout);
+ passwd[i++] = (char)c;
+ }
}
printf("\n");
passwd[i] = 0;
@@ -303,6 +315,7 @@
{
char *choices[100] = {0};
char *choices_translated[100] = {0};
+ char *choices_descriptions[100] = {0};
char answer[10];
int i, count, choice = 1, def = -1;
const char *defval = question_getvalue(q, "");
@@ -313,6 +326,7 @@
defval = choices[0];
strchoicesplit(question_get_field(q, "", "choices"), choices_translated, DIM(choices_translated));
+ strchoicesplit(question_get_field(q, "", "choices_descriptions"), choices_descriptions, DIM(choices_descriptions));
/* fprintf(stderr,"In texthandler_select, count is: %d\n", count);*/
if (defval != NULL)
{
@@ -324,7 +338,8 @@
do
{
for (i = 0; i < count; i++)
- printf("%3d. %s%s\n", i+1, choices_translated[i],
+ printf("%3d. %s%s\n", i+1,
+ (choices_descriptions[i] ? choices_descriptions[i] : choices_translated[i]),
(def == i + 1 ? _(" (default)") : ""));
printf(_("Prompt: 1 - %d> "), count);
@@ -345,6 +360,7 @@
{
free(choices[i]);
free(choices_translated[i]);
+ free(choices_descriptions[i]);
}
return DC_OK;
Index: src/test/test.templates
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/test/test.templates,v
retrieving revision 1.5
diff -u -r1.5 test.templates
--- src/test/test.templates 3 Nov 2002 14:58:19 -0000 1.5
+++ src/test/test.templates 23 Dec 2002 09:52:35 -0000
@@ -8,6 +8,7 @@
Type: multiselect
Default: bar, baz
Choices: foo, bar, baz, quux
+Choices-Description: Meep, Glob, Floppa, Zoot
Description: Select one or more options
This is the prompt for a multiselect-type question
--
Tollef Fog Heen ,''`.
UNIX is user friendly, it's just picky about who its friends are : :' :
`. `'
`-
Reply to: