diff options
| author | Ben Collins <bcollins@ubuntu.com> | 2006-01-08 04:05:13 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-08 23:14:09 -0500 |
| commit | 96e9dd14a3b2aab4098503a5999ee2ef42d82da1 (patch) | |
| tree | 58071e25c9d72b10e12f06788ae9798abb332c22 /scripts | |
| parent | f756d5e256059018d753f0ba79980ebeb87a1bc0 (diff) | |
[PATCH] kconf: Check for eof from input stream.
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/kconfig/conf.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 8ba5d29d3d..10eeae53d8 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
| @@ -63,6 +63,20 @@ static void check_stdin(void) | |||
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static char *fgets_check_stream(char *s, int size, FILE *stream) | ||
| 67 | { | ||
| 68 | char *ret = fgets(s, size, stream); | ||
| 69 | |||
| 70 | if (ret == NULL && feof(stream)) { | ||
| 71 | printf(_("aborted!\n\n")); | ||
| 72 | printf(_("Console input is closed. ")); | ||
| 73 | printf(_("Run 'make oldconfig' to update configuration.\n\n")); | ||
| 74 | exit(1); | ||
| 75 | } | ||
| 76 | |||
| 77 | return ret; | ||
| 78 | } | ||
| 79 | |||
| 66 | static void conf_askvalue(struct symbol *sym, const char *def) | 80 | static void conf_askvalue(struct symbol *sym, const char *def) |
| 67 | { | 81 | { |
| 68 | enum symbol_type type = sym_get_type(sym); | 82 | enum symbol_type type = sym_get_type(sym); |
| @@ -100,7 +114,7 @@ static void conf_askvalue(struct symbol *sym, const char *def) | |||
| 100 | check_stdin(); | 114 | check_stdin(); |
| 101 | case ask_all: | 115 | case ask_all: |
| 102 | fflush(stdout); | 116 | fflush(stdout); |
| 103 | fgets(line, 128, stdin); | 117 | fgets_check_stream(line, 128, stdin); |
| 104 | return; | 118 | return; |
| 105 | case set_default: | 119 | case set_default: |
| 106 | printf("%s\n", def); | 120 | printf("%s\n", def); |
| @@ -356,7 +370,7 @@ static int conf_choice(struct menu *menu) | |||
| 356 | check_stdin(); | 370 | check_stdin(); |
| 357 | case ask_all: | 371 | case ask_all: |
| 358 | fflush(stdout); | 372 | fflush(stdout); |
| 359 | fgets(line, 128, stdin); | 373 | fgets_check_stream(line, 128, stdin); |
| 360 | strip(line); | 374 | strip(line); |
| 361 | if (line[0] == '?') { | 375 | if (line[0] == '?') { |
| 362 | printf("\n%s\n", menu->sym->help ? | 376 | printf("\n%s\n", menu->sym->help ? |
