X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fterminal%2Fterminal-reader.c;fp=src%2Fui%2Fterminal%2Fterminal-reader.c;h=071e435eca6f572809331c84d2cd2fe493c1b8c5;hb=db2d3bd93b133e061510b023a7ade539ab0aad25;hp=c23fad186f86992b164b401792ed3a1300f1706c;hpb=f6c9d54318ada2ae21badf52c9caa73fb0d2c514;p=pspp diff --git a/src/ui/terminal/terminal-reader.c b/src/ui/terminal/terminal-reader.c index c23fad186f..071e435eca 100644 --- a/src/ui/terminal/terminal-reader.c +++ b/src/ui/terminal/terminal-reader.c @@ -413,9 +413,21 @@ command_generator (const char *text, int state) #else /* !HAVE_READLINE */ +static const char * the_prompt; + +static void +handler (int sig) +{ + if (the_prompt) + fputs (the_prompt, stdout); + fflush (stdout); +} + static void readline_init (void) { + if (SIG_ERR == signal (SIGINT, handler)) + perror ("Cannot add signal handler"); } static void @@ -423,19 +435,22 @@ readline_done (void) { } +/* Prompt the user for a line of input and return it in LINE. + Returns true if the LINE should be considered valid, false otherwise. + */ static bool readline_read (struct substring *line, enum prompt_style style) { struct string string; - const char *prompt = readline_prompt (style); + the_prompt = readline_prompt (style); - fputs (prompt, stdout); + fputs (the_prompt, stdout); fflush (stdout); ds_init_empty (&string); ds_read_line (&string, stdin, SIZE_MAX); *line = string.ss; - return false; + return true; } #endif /* !HAVE_READLINE */