commit 18487b02b48a57c5d331bfb417feef451501cb51
parent f5dde44eee092602bee6df746043abc6fcfec38f
Author: tgoodwin <tgoodwin>
Date: Fri, 27 Feb 1998 17:26:03 +0000
next attempt to get readline interaction correct
Diffstat:
5 files changed, 29 insertions(+), 36 deletions(-)
diff --git a/Makefile.am b/Makefile.am
@@ -18,15 +18,19 @@ if N_H_B
EXECVE = execve.o
endif
+if READLINE
+RLO = readline.o
+endif
+
bin_PROGRAMS = rc
noinst_PROGRAMS = $(HISTBIN)
rc_SOURCES = @ADDON@ builtins.c except.c exec.c fn.c footobar.c getopt.c glob.c glom.c hash.c heredoc.c input.c lex.c list.c main.c match.c nalloc.c open.c print.c redir.c sigmsgs.c signal.c status.c tree.c utils.c var.c wait.c walk.c which.c y.tab.c
-EXTRA_rc_SOURCES = execve.c system.c system-bsd.c
+EXTRA_rc_SOURCES = execve.c readline.c system.c system-bsd.c
-rc_DEPENDENCIES = $(SYSTEM) $(EXECVE)
-rc_LDADD = $(SYSTEM) $(EXECVE)
+rc_DEPENDENCIES = $(SYSTEM) $(EXECVE) $(RLO)
+rc_LDADD = $(SYSTEM) $(EXECVE) $(RLO)
history_SOURCES = history.c
diff --git a/configure.ac b/configure.ac
@@ -44,7 +44,7 @@ sort -u |tr '
])
dnl Phew! We now have a list of <signal.h>s. Examine each one to see
-dnl if it contains the signal names we're after. If not, that's a a
+dnl if it contains the signal names we're after. If not, that's a
dnl configure error: bomb out.
AC_CACHE_CHECK(for signal names, rc_cv_signal_h,
@@ -67,6 +67,14 @@ AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE(ssize_t, long)
+dnl Check type of sig_atomic_t.
+AC_CACHE_CHECK(for sig_atomic_t, rc_cv_sig_atomic_t,
+ AC_EGREP_HEADER(sig_atomic_t, signal.h,
+ rc_cv_sig_atomic_t=yes, rc_cv_sig_atomic_t=no))
+case "$rc_cv_sig_atomic_t" in
+no) AC_DEFINE(sig_atomic_t, int) ;;
+esac
+
AC_CHECK_FUNCS(getgroups setpgrp setrlimit)
@@ -316,5 +324,6 @@ AC_ARG_WITH(readline, [ --with-readline Bloated GNU line editing],
AC_DEFINE(READLINE) LIBS="$LIBS -lreadline -ltermcap",
AC_MSG_WARN(readline library not found),
-ltermcap))
+AM_CONDITIONAL(READLINE, test "$ac_cv_lib_readline_readline" = yes || test "$ac_cv_lib_edit_readline" = yes)
AC_OUTPUT(Makefile)
diff --git a/input.c b/input.c
@@ -2,7 +2,6 @@
#include <errno.h>
#include <setjmp.h>
-#include <signal.h>
#include "rc.h"
#include "jbwrap.h"
@@ -22,29 +21,6 @@ typedef struct Input {
#define BUFSIZE ((size_t) 256)
-#if READLINE
-extern void add_history(char *);
-extern char *readline(char *);
-
-static char *rlinebuf, *prompt;
-bool in_readline;
-
-static char *rc_readline(char *prompt) {
- char *r;
- void (*old)(int);
-
- in_readline = TRUE;
- old = signal(SIGINT, sigint);
- r = readline(prompt);
- signal(SIGINT, old);
- in_readline = FALSE;
- sigchk();
-
- return r;
-}
-
-#endif
-
static char *prompt2;
bool rcrc;
@@ -65,6 +41,10 @@ static void (*realugchar)(int);
int last;
+#if READLINE
+static char *rlinebuf, *prompt;
+#endif
+
extern int gchar() {
int c;
@@ -133,8 +113,8 @@ static int fdgchar() {
#endif
/* There is a possible problem here. POSIX allows read() interrupted
-by a signal to return -1 and set errno == EINTR *even if data have
-successfully been read*. (They are also allowed to do the Right Thing,
+by a signal to return -1 and set errno == EINTR *even if some data have
+successfully been read*. (It is also allowed to do the Right Thing,
and return a count of the partial read.) If you have such a broken
system, you lose. */
{
diff --git a/jbwrap.h b/jbwrap.h
@@ -26,6 +26,6 @@ struct Jbwrap {
/* The slowbuf jump buffer is used to prevent "slow" system calls being
restarted on systems like BSD where they are restarted after a signal. */
-#if HAVE_RESTARTABLE_SYSCALLS
+#if HAVE_RESTARTABLE_SYSCALLS || READLINE
extern Jbwrap slowbuf;
#endif
diff --git a/signal.c b/signal.c
@@ -7,14 +7,14 @@
#include "sigmsgs.h"
#include "jbwrap.h"
-#if HAVE_RESTARTABLE_SYSCALLS
+#if HAVE_RESTARTABLE_SYSCALLS || READLINE
Jbwrap slowbuf;
-volatile SIG_ATOMIC_T slow, interrupt_happened;
+volatile sig_atomic_t slow, interrupt_happened;
#endif
void (*sighandlers[NUMOFSIGNALS])(int);
-static volatile SIG_ATOMIC_T sigcount, caught[NUMOFSIGNALS];
+static volatile sig_atomic_t sigcount, caught[NUMOFSIGNALS];
extern void catcher(int s) {
if (caught[s] == 0) {
@@ -28,7 +28,7 @@ extern void catcher(int s) {
in_readline = FALSE;
switch (s) {
default:
- rl_clean_up_for_exit();
+ _rl_clean_up_for_exit();
rl_deprep_terminal();
rl_clear_signals();
rl_pending_input = 0;
@@ -49,7 +49,7 @@ extern void catcher(int s) {
#endif /* READLINE */
-#if HAVE_RESTARTABLE_SYSCALLS
+#if HAVE_RESTARTABLE_SYSCALLS || READLINE
interrupt_happened = TRUE;
if (slow)
siglongjmp(slowbuf.j, 1);