return 0;
}
-static void maybe_exit(int rc)
+static void maybe_exit(int rc, int *asked)
{
char line[LINE_LENGTH];
putchar('\n');
+ if (asked)
+ *asked = 0;
if (is_partition_table_changed() || MBRbuffer_changed) {
fprintf(stderr, _("Do you really want to quit? "));
if (!fgets(line, LINE_LENGTH, stdin) || rpmatch(line) == 1)
exit(rc);
+ if (asked)
+ *asked = 1;
} else
exit(rc);
}
/* read line; return 0 or first char */
int
-read_line(void)
+read_line(int *asked)
{
line_ptr = line_buffer;
if (!fgets(line_buffer, LINE_LENGTH, stdin)) {
- maybe_exit(1);
+ maybe_exit(1, asked);
return 0;
}
+ if (asked)
+ *asked = 0;
while (*line_ptr && !isgraph(*line_ptr))
line_ptr++;
return *line_ptr;
do {
fputs(mesg, stdout);
fflush (stdout); /* requested by niles@scyld.com */
- } while (!read_line());
+ } while (!read_line(NULL));
return *line_ptr;
}
char
read_chars(char *mesg)
{
- fputs(mesg, stdout);
- fflush (stdout); /* niles@scyld.com */
- if (!read_line()) {
+ int rc, asked = 0;
+
+ do {
+ fputs(mesg, stdout);
+ fflush (stdout); /* niles@scyld.com */
+ rc = read_line(&asked);
+ } while (asked);
+
+ if (!rc) {
*line_ptr = '\n';
line_ptr[1] = 0;
}
extern int get_boot(enum action what);
extern int get_partition(int warn, int max);
extern void list_types(struct systypes *sys);
-extern int read_line (void);
+extern int read_line (int *asked);
extern char read_char(char *mesg);
extern int read_hex(struct systypes *sys);
extern void reread_partition_table(int leave);
do {
fputs (mesg, stdout);
printf (" (%d): ", def);
- if (!read_line ())
+ if (!read_line (NULL))
return def;
}
while (!isdigit (*line_ptr));
printf (_("Bootstrap: %sboot -> boot%s (%s): "),
dkbasename, dkbasename, dkbasename);
- if (read_line ()) {
+ if (read_line (NULL)) {
line_ptr[strlen (line_ptr)-1] = '\0';
dkbasename = line_ptr;
}