diff --git a/C/errors.c b/C/errors.c index c4edc2033..d0bbec79e 100644 --- a/C/errors.c +++ b/C/errors.c @@ -517,6 +517,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...) error_exit_yap (1); } case PURE_ABORT: + nt[0] = MkAtomTerm(AtomDAbort); fun = FunctorVar; serious = TRUE; break; diff --git a/C/sysbits.c b/C/sysbits.c index 44b4155d0..e12eac683 100755 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1547,6 +1547,8 @@ InteractSIGINT(int ch) { switch (ch) { case 'a': /* abort computation */ + if (Yap_PrologMode &= InReadlineMode) { + } if (Yap_PrologMode & (GCMode|ConsoleGetcMode|GrowStackMode|GrowHeapMode)) { Yap_PrologMode |= AbortMode; } else { @@ -1650,33 +1652,19 @@ HandleSIGINT (int sig, siginfo_t *x, ucontext_t *y) HandleSIGINT (int sig) #endif { - LOCK(SignalLock); my_signal(SIGINT, HandleSIGINT); /* do this before we act */ #if HAVE_ISATTY if (!isatty(0) && !Yap_sockets_io) { - UNLOCK(SignalLock); Yap_Error(INTERRUPT_ERROR,MkIntTerm(SIGINT),NULL); return; } #endif if (Yap_InterruptsDisabled) { - UNLOCK(SignalLock); return; } if (Yap_PrologMode & (CritMode|ConsoleGetcMode)) { Yap_PrologMode |= InterruptMode; -#if HAVE_LIBREADLINE && HAVE_READLINE_READLINE_H - if (Yap_PrologMode & ConsoleGetcMode) { - fprintf(stderr, "Action (h for help): "); - rl_point = rl_end = 0; -#if HAVE_RL_SET_PROMPT - rl_set_prompt("Action (h for help): "); -#endif - } -#endif - UNLOCK(SignalLock); - return; } #ifdef HAVE_SETBUF /* make sure we are not waiting for the end of line */ @@ -1684,11 +1672,9 @@ HandleSIGINT (int sig) #endif if (snoozing) { snoozing = FALSE; - UNLOCK(SignalLock); return; } ProcessSIGINT(); - UNLOCK(SignalLock); } #endif diff --git a/H/Yap.h b/H/Yap.h index a5c917c84..a45157ec9 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -1184,7 +1184,8 @@ typedef enum UserCCallMode = 0x4000, /* In User C-call Code */ MallocMode = 0x8000, /* Doing malloc, realloc, free */ SystemMode = 0x10000, /* in system mode */ - AsyncIntMode = 0x20000 /* YAP has just been interrupted from the outside */ + AsyncIntMode = 0x20000, /* YAP has just been interrupted from the outside */ + InReadlineMode = 0x40000 /* YAP has just been interrupted from the outside */ } prolog_exec_mode; extern Int Yap_PrologMode; diff --git a/Makefile.in b/Makefile.in index 7234dbb71..2fcb3cd01 100755 --- a/Makefile.in +++ b/Makefile.in @@ -825,7 +825,7 @@ clean: clean_docs @INSTALL_DLLS@ (cd packages/semweb; $(MAKE) clean) @INSTALL_DLLS@ (cd packages/sgml; $(MAKE) clean) @USE_MINISAT@ (cd packages/swi-minisat2; $(MAKE) clean) - @USE_MINISAT@ (cd packages/packages/CLPBN/bp; $(MAKE) clean) + @USE_MINISAT@ (cd packages/CLPBN/clpbn/bp; $(MAKE) clean) @INSTALL_DLLS@ (cd packages/tai; $(MAKE) clean) @INSTALL_DLLS@ (cd packages/zlib; $(MAKE) clean) @ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) clean) diff --git a/config.h.in b/config.h.in index 258cfc386..ac0526bdc 100755 --- a/config.h.in +++ b/config.h.in @@ -232,6 +232,7 @@ #undef HAVE_RL_CLEAR_PENDING_INPUT #undef HAVE_RL_COMPLETION_MATCHES #undef HAVE_RL_FILENAME_COMPLETION_FUNCTION +#undef HAVE_RL_FREE_LINE_STATE #undef HAVE_RL_INSERT_CLOSE #undef HAVE_RL_SET_PROMPT #undef HAVE_SBRK diff --git a/configure b/configure index 06fa67f67..e2ac6c59a 100755 --- a/configure +++ b/configure @@ -7988,6 +7988,11 @@ fi ac_fn_c_check_func "$LINENO" "rl_filename_completion_function " "ac_cv_func_rl_filename_completion_function_" if test "x$ac_cv_func_rl_filename_completion_function_" = x""yes; then : +fi + + ac_fn_c_check_func "$LINENO" "rl_free_line_state " "ac_cv_func_rl_free_line_state_" +if test "x$ac_cv_func_rl_free_line_state_" = x""yes; then : + fi ac_fn_c_check_func "$LINENO" "rl_set_prompt " "ac_cv_func_rl_set_prompt_" diff --git a/configure.in b/configure.in index 3737f1d57..dc3d09340 100755 --- a/configure.in +++ b/configure.in @@ -1383,6 +1383,7 @@ then AC_CHECK_FUNC( rl_completion_matches ) AC_CHECK_FUNC( rl_insert_close ) AC_CHECK_FUNC( rl_filename_completion_function ) + AC_CHECK_FUNC( rl_free_line_state ) AC_CHECK_FUNC( rl_set_prompt ) AC_CHECK_FUNC( rl_clear_pending_input ) fi diff --git a/packages/PLStream/pl-rl.c b/packages/PLStream/pl-rl.c index 6eeab6abe..d501f102d 100644 --- a/packages/PLStream/pl-rl.c +++ b/packages/PLStream/pl-rl.c @@ -482,8 +482,9 @@ Sread_readline(void *handle, char *buf, size_t size) rl_prep_terminal(FALSE); rl_readline_state = state; rl_done = 0; - } else + } else { line = pl_readline(prompt); + } in_readline--; if ( my_prompt ) @@ -513,6 +514,12 @@ Sread_readline(void *handle, char *buf, size_t size) PL_clock_wait_ticks(clock() - oldclock); #endif +#if __YAP_PROLOG__ + /* handle abort */ + if (Yap_REGS.P_ == FAILCODE) { + return 0; + } +#endif return rval; } diff --git a/packages/tai/Makefile.in b/packages/tai/Makefile.in index 3e8e4b422..b7dc4c8ce 100755 --- a/packages/tai/Makefile.in +++ b/packages/tai/Makefile.in @@ -20,7 +20,7 @@ YAPLIBDIR=@libdir@/Yap # DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1 CC=@CC@ -CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../PLStream +CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../PLStream -I$(srcdir)/../../H # # # You shouldn't need to change what follows.