projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Deal properly with EOF in the REPL, when built without readline
[pspp]
/
src
/
ui
/
terminal
/
terminal-reader.c
diff --git
a/src/ui/terminal/terminal-reader.c
b/src/ui/terminal/terminal-reader.c
index c23fad186f86992b164b401792ed3a1300f1706c..071e435eca6f572809331c84d2cd2fe493c1b8c5 100644
(file)
--- 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 */
#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)
{
static void
readline_init (void)
{
+ if (SIG_ERR == signal (SIGINT, handler))
+ perror ("Cannot add signal handler");
}
static void
}
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;
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;
fflush (stdout);
ds_init_empty (&string);
ds_read_line (&string, stdin, SIZE_MAX);
*line = string.ss;
- return
fals
e;
+ return
tru
e;
}
#endif /* !HAVE_READLINE */
}
#endif /* !HAVE_READLINE */