Merge 'master' into 'gtk3'.
[pspp] / src / ui / terminal / terminal-reader.c
index 2d72acf39cddbe654555e3525edc582a3f9b00b3..c80a6131dea915afc84b2fc1b2943b55cef0440b 100644 (file)
@@ -26,6 +26,7 @@
 #if HAVE_READLINE
 #include <readline/readline.h>
 #include <readline/history.h>
+#include <termios.h>
 
 static char *history_file;
 
@@ -98,7 +99,7 @@ welcome (void)
         "conditions.\nThere is ABSOLUTELY NO WARRANTY for PSPP; type \"show "
         "warranty.\" for details.\n", stdout);
   puts (stat_version);
-  journal_enable ();
+  journal_init ();
 }
 
 static struct terminal_reader *
@@ -107,14 +108,38 @@ terminal_reader_cast (struct lex_reader *r)
   return UP_CAST (r, struct terminal_reader, reader);
 }
 
-/* 
-   Older libreadline versions do not provide rl_outstream.
-   However, it is almost always going to be the same as stdout.
- */
-#if HAVE_RL_OUTSTREAM
+/* Older libreadline versions do not provide rl_outstream.
+   However, it is almost always going to be the same as stdout. */
+#if ! HAVE_RL_OUTSTREAM
 # define rl_outstream stdout
 #endif
 
+/* Similarly, rl_echo_signal_char is fairly recent.
+   We provide our own crude version if it is not present. */
+#if ! HAVE_RL_ECHO_SIGNAL_CHAR
+static void
+rl_echo_signal_char (int sig)
+{
+#if HAVE_TERMIOS_H
+  struct termios t;
+  if (0 == tcgetattr (0, &t))
+    {
+      cc_t c = t.c_cc[VINTR];
+  
+      if (c >= 0  && c <= 'Z' - 'A')
+       fprintf (rl_outstream, "^%c", 'A' + c - 1);
+      else
+       fprintf (rl_outstream, "%c", c);
+    }
+  else
+#endif
+    fprintf (rl_outstream, "^C");
+
+  fflush (rl_outstream);
+}  
+#endif
+
+
 static size_t
 terminal_reader_read (struct lex_reader *r_, char *buf, size_t n,
                       enum prompt_style prompt_style)