|
7 | 7 | * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group |
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California |
9 | 9 | * |
10 | | - * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.20 2006/03/05 15:58:52 momjian Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.21 2006/09/22 18:50:41 petere Exp $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
@@ -198,18 +198,29 @@ executeCommand(PGconn *conn, const char *query, |
198 | 198 | * Check yes/no answer in a localized way. 1=yes, 0=no, -1=neither. |
199 | 199 | */ |
200 | 200 |
|
201 | | -/* translator: Make sure the (y/n) prompts match the translation of this. */ |
| 201 | +/* translator: abbreviation for "yes" */ |
202 | 202 | #define PG_YESLETTER gettext_noop("y") |
203 | | -/* translator: Make sure the (y/n) prompts match the translation of this. */ |
| 203 | +/* translator: abbreviation for "no" */ |
204 | 204 | #define PG_NOLETTER gettext_noop("n") |
205 | 205 |
|
206 | | -int |
207 | | -check_yesno_response(const char *string) |
| 206 | +bool |
| 207 | +yesno_prompt(const char *question) |
208 | 208 | { |
209 | | - if (strcmp(string, _(PG_YESLETTER)) == 0) |
210 | | - return 1; |
211 | | - else if (strcmp(string, _(PG_NOLETTER)) == 0) |
212 | | - return 0; |
213 | | - else |
214 | | - return -1; |
| 209 | + static char prompt[128]; |
| 210 | + |
| 211 | + for (;;) |
| 212 | + { |
| 213 | + char *resp; |
| 214 | + |
| 215 | + /* translator: This is a question followed by the translated options for "yes" and "no". */ |
| 216 | + snprintf(prompt, sizeof(prompt), _("%s (%s/%s) "), _(question), _(PG_YESLETTER), _(PG_NOLETTER)); |
| 217 | + resp = simple_prompt(prompt, 1, true); |
| 218 | + |
| 219 | + if (strcmp(resp, _(PG_YESLETTER)) == 0) |
| 220 | + return true; |
| 221 | + else if (strcmp(resp, _(PG_NOLETTER)) == 0) |
| 222 | + return false; |
| 223 | + |
| 224 | + printf(_("Please answer \"%s\" or \"%s\".\n"), _(PG_YESLETTER), _(PG_NOLETTER)); |
| 225 | + } |
215 | 226 | } |
0 commit comments