mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-29 00:19:51 +02:00
commit bash-20090122 snapshot
This commit is contained in:
@@ -7418,3 +7418,42 @@ builtins/mapfile.def
|
||||
`mapfile -n 5 -c 1 -C 'echo foo' array < file' work right and call
|
||||
the callback after the first line is read. Fixes bug reported by
|
||||
Pierre Gaston <pierre.gaston@gmail.com>
|
||||
|
||||
1/22
|
||||
----
|
||||
lib/readline/complete.c
|
||||
- set _rl_interrupt_immediately non-zero before reading from the file
|
||||
system or calling an application-defined completion function
|
||||
|
||||
lib/readline/signals.c
|
||||
- renamed rl_signal_handler to _rl_handle_signal; new version of
|
||||
rl_signal_handler that just calls _rl_handle_signal (for now)
|
||||
- new function _rl_signal_handler that calls _rl_handle_signal without
|
||||
any checking
|
||||
|
||||
lib/readline/rlprivate.h
|
||||
- new extern declaration for _rl_signal_handler
|
||||
- new define, RL_CHECK_SIGNALS, checks whether or not _rl_caught_signal
|
||||
is set and calls _rl_signal_handler if so
|
||||
|
||||
lib/readline/{bind,input,readline}.c
|
||||
- add RL_CHECK_SIGNALS in appropriate places
|
||||
|
||||
lib/readline/signals.c
|
||||
- change rl_signal_handler to set a flag and return rather than
|
||||
run through the entire signal handling process. If
|
||||
_rl_interrupt_immediately is set, call the signal handling code
|
||||
right away instead of setting the flag. Initial fix for crash
|
||||
bug reported by Roman Rakus <rrakus@redhat.com>
|
||||
|
||||
aclocal.m4
|
||||
- new macro, BASH_TYPE_SIG_ATOMIC_T, tests for sig_atomic_t in
|
||||
<signal.h>, defines as int if not defined
|
||||
|
||||
configure.in
|
||||
- call BASH_TYPE_SIG_ATOMIC_T
|
||||
- call AC_C_VOLATILE
|
||||
|
||||
config.h.in
|
||||
- empty define for sig_atomic_t
|
||||
- empty define for volatile
|
||||
|
||||
@@ -7411,3 +7411,44 @@ builtins/printf.def
|
||||
what the C standard requires. Fixes bug that caused printf -b
|
||||
to `ignore' first % format specifier if it came first in the
|
||||
string. Reported by David Leverton <levertond@googlemail.com>
|
||||
|
||||
builtins/mapfile.def
|
||||
- start the line count at 1, since it doesn't get incremented before
|
||||
(or after) reading the first line, so things like
|
||||
`mapfile -n 5 -c 1 -C 'echo foo' array < file' work right and call
|
||||
the callback after the first line is read. Fixes bug reported by
|
||||
Pierre Gaston <pierre.gaston@gmail.com>
|
||||
|
||||
1/22
|
||||
----
|
||||
lib/readline/complete.c
|
||||
- set _rl_interrupt_immediately non-zero before reading from the file
|
||||
system or calling an application-defined completion function
|
||||
|
||||
lib/readline/signals.c
|
||||
- renamed rl_signal_handler to _rl_handle_signal; new version of
|
||||
rl_signal_handler that just calls _rl_handle_signal (for now)
|
||||
- new function _rl_signal_handler that calls _rl_handle_signal without
|
||||
any checking
|
||||
|
||||
lib/readline/rlprivate.h
|
||||
- new extern declaration for _rl_signal_handler
|
||||
- new define, RL_CHECK_SIGNALS, checks whether or not _rl_caught_signal
|
||||
is set and calls _rl_signal_handler if so
|
||||
|
||||
lib/readline/{bind,input,readline}.c
|
||||
- add RL_CHECK_SIGNALS in appropriate places
|
||||
|
||||
lib/readline/signals.c
|
||||
- change rl_signal_handler to set a flag and return rather than
|
||||
run through the entire signal handling process. If
|
||||
_rl_interrupt_immediately is set, call the signal handling code
|
||||
right away instead of setting the flag. Initial fix for crash
|
||||
bug reported by Roman Rakus <rrakus@redhat.com>
|
||||
|
||||
aclocal.m4
|
||||
- new macro, BASH_TYPE_SIG_ATOMIC_T, tests for sig_atomic_t in
|
||||
<signal.h>, defines as int if not defined
|
||||
|
||||
configure.in
|
||||
- call BASH_TYPE_SIG_ATOMIC_T
|
||||
|
||||
Vendored
+12
@@ -531,6 +531,18 @@ AC_DEFINE(RLIMTYPE, rlim_t)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T,
|
||||
[AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t,
|
||||
[AC_TRY_LINK([
|
||||
#include <signal.h>
|
||||
],[ sig_atomic_t x; ],
|
||||
ac_cv_have_sig_atomic_t=yes, ac_cv_have_sig_atomic_t=no)])
|
||||
if test "$ac_cv_have_sig_atomic_t" = "no"
|
||||
then
|
||||
AC_CHECK_TYPE(sig_atomic_t,int)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(BASH_FUNC_LSTAT,
|
||||
[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
|
||||
dnl inline function in <sys/stat.h>.
|
||||
|
||||
Vendored
+23
-11
@@ -336,18 +336,18 @@ main()
|
||||
{
|
||||
DIR *dir;
|
||||
int fd, err;
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
write(fd, "\n", 1);
|
||||
close(fd);
|
||||
dir = opendir("/tmp/bash-aclocal/not_a_directory");
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
rmdir("/tmp/bash-aclocal");
|
||||
dir = opendir("bash-aclocal/not_a_directory");
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
rmdir("bash-aclocal");
|
||||
exit (dir == 0);
|
||||
}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
|
||||
[AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
|
||||
@@ -531,6 +531,18 @@ AC_DEFINE(RLIMTYPE, rlim_t)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T,
|
||||
[AC_CACHE_CHECK(for sig_atomic_t in signal.h, ac_cv_have_sig_atomic_t,
|
||||
[AC_TRY_LINK([
|
||||
#include <signal.h>
|
||||
],[ sig_atomic_t x; ],
|
||||
ac_cv_have_sig_atomic_t=yes, ac_cv_have_sig_atomic_t=no))
|
||||
if test "$ac_cv_have_sig_atomic_t" = "no"
|
||||
then
|
||||
AC_CHECK_TYPE(sig_atomic_t,int)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(BASH_FUNC_LSTAT,
|
||||
[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
|
||||
dnl inline function in <sys/stat.h>.
|
||||
@@ -1423,19 +1435,19 @@ exit (1);
|
||||
#if defined (NeXT)
|
||||
exit (1);
|
||||
#endif
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror ("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
if (fd == -1) {
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
rmdir ("bash-aclocal");
|
||||
exit (1);
|
||||
}
|
||||
close(fd);
|
||||
unlink ("/tmp/bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
unlink ("bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("bash-aclocal");
|
||||
exit(0);
|
||||
}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
|
||||
[AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
|
||||
|
||||
+603
-463
File diff suppressed because it is too large
Load Diff
+1404
-1402
File diff suppressed because it is too large
Load Diff
@@ -180,6 +180,8 @@
|
||||
|
||||
#undef inline
|
||||
|
||||
#undef volatile
|
||||
|
||||
/* Define if cpp supports the ANSI-C stringizing `#' operator */
|
||||
#undef HAVE_STRINGIZE
|
||||
|
||||
@@ -316,6 +318,9 @@
|
||||
/* Define to `unsigned int' if <sys/socket.h> doesn't define. */
|
||||
#undef socklen_t
|
||||
|
||||
/* Define to `int' if <signal.h> doesn't define. */
|
||||
#undef sig_atomic_t
|
||||
|
||||
#undef HAVE_MBSTATE_T
|
||||
|
||||
/* Define if you have quad_t in <sys/types.h>. */
|
||||
|
||||
+17
-11
@@ -1,22 +1,22 @@
|
||||
/* config.h -- Configuration file for bash. */
|
||||
|
||||
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
Bash is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
@@ -316,6 +316,9 @@
|
||||
/* Define to `unsigned int' if <sys/socket.h> doesn't define. */
|
||||
#undef socklen_t
|
||||
|
||||
/* Define to `int' if <signal.h> doesn't define. */
|
||||
#undef sig_atomic_t
|
||||
|
||||
#undef HAVE_MBSTATE_T
|
||||
|
||||
/* Define if you have quad_t in <sys/types.h>. */
|
||||
@@ -542,6 +545,9 @@
|
||||
/* Define if you have the fcntl function. */
|
||||
#undef HAVE_FCNTL
|
||||
|
||||
/* Define if you have the fdprintf function. */
|
||||
#undef HAVE_FDPRINTF
|
||||
|
||||
/* Define if you have the fpurge/__fpurge function. */
|
||||
#undef HAVE_FPURGE
|
||||
#undef HAVE___FPURGE
|
||||
|
||||
+3
-1
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_REVISION([for Bash 4.0, version 4.009])dnl
|
||||
AC_REVISION([for Bash 4.0, version 4.011])dnl
|
||||
|
||||
define(bashvers, 4.0)
|
||||
define(relstatus, rc1)
|
||||
@@ -637,6 +637,7 @@ AC_C_STRINGIZE
|
||||
AC_C_LONG_DOUBLE
|
||||
AC_C_PROTOTYPES
|
||||
AC_C_CHAR_UNSIGNED
|
||||
AC_C_VOLATILE
|
||||
|
||||
dnl initialize GNU gettext
|
||||
AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
|
||||
@@ -835,6 +836,7 @@ BASH_TYPE_LONG_LONG
|
||||
BASH_TYPE_UNSIGNED_LONG_LONG
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
BASH_TYPE_SIG_ATOMIC_T
|
||||
|
||||
AC_CHECK_SIZEOF(char, 1)
|
||||
AC_CHECK_SIZEOF(short, 2)
|
||||
|
||||
+4
-3
@@ -5,7 +5,7 @@ dnl report bugs to chet@po.cwru.edu
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -21,10 +21,10 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_REVISION([for Bash 4.0, version 4.007])dnl
|
||||
AC_REVISION([for Bash 4.0, version 4.011])dnl
|
||||
|
||||
define(bashvers, 4.0)
|
||||
define(relstatus, beta)
|
||||
define(relstatus, rc1)
|
||||
|
||||
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
|
||||
|
||||
@@ -835,6 +835,7 @@ BASH_TYPE_LONG_LONG
|
||||
BASH_TYPE_UNSIGNED_LONG_LONG
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
BASH_TYPE_SIG_ATOMIC_T
|
||||
|
||||
AC_CHECK_SIZEOF(char, 1)
|
||||
AC_CHECK_SIZEOF(short, 2)
|
||||
|
||||
@@ -796,6 +796,8 @@ _rl_read_file (filename, sizep)
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
buffer[i] = '\0';
|
||||
if (sizep)
|
||||
*sizep = i;
|
||||
@@ -864,6 +866,7 @@ _rl_read_init_file (filename, include_level)
|
||||
buffer = _rl_read_file (openname, &file_size);
|
||||
xfree (openname);
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
if (buffer == 0)
|
||||
return (errno);
|
||||
|
||||
|
||||
+13
-13
@@ -1,24 +1,23 @@
|
||||
/* bind.c -- key binding and startup file support for the readline library. */
|
||||
|
||||
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
@@ -1431,6 +1430,7 @@ static const struct {
|
||||
{ "page-completions", &_rl_page_completions, 0 },
|
||||
{ "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
|
||||
{ "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
|
||||
{ "revert-all-at-newline", &_rl_revert_all_at_newline, 0 },
|
||||
{ "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
|
||||
{ "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 },
|
||||
#if defined (VISIBLE_STATS)
|
||||
|
||||
@@ -87,6 +87,7 @@ _rl_callback_newline ()
|
||||
}
|
||||
|
||||
readline_internal_setup ();
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
|
||||
/* Install a readline handler, set up the terminal, and issue the prompt. */
|
||||
@@ -127,6 +128,7 @@ rl_callback_read_char ()
|
||||
|
||||
do
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
if (RL_ISSTATE (RL_STATE_ISEARCH))
|
||||
{
|
||||
eof = _rl_isearch_callback (_rl_iscxt);
|
||||
@@ -186,6 +188,7 @@ rl_callback_read_char ()
|
||||
else
|
||||
eof = readline_internal_char ();
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
if (rl_done == 0 && _rl_want_redisplay)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
@@ -223,6 +226,7 @@ rl_callback_handler_remove ()
|
||||
{
|
||||
rl_linefunc = NULL;
|
||||
RL_UNSETSTATE (RL_STATE_CALLBACK);
|
||||
RL_CHECK_SIGNALS ();
|
||||
if (in_handler)
|
||||
{
|
||||
in_handler = 0;
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
/* callback.c -- functions to use readline as an X `callback' mechanism. */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "rlconf.h"
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "readline.h"
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Private data for callback registration functions. See comments in
|
||||
rl_callback_read_char for more details. */
|
||||
_rl_callback_func_t *_rl_callback_func = 0;
|
||||
_rl_callback_generic_arg *_rl_callback_data = 0;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Callback Readline Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Allow using readline in situations where a program may have multiple
|
||||
things to handle at once, and dispatches them via select(). Call
|
||||
rl_callback_handler_install() with the prompt and a function to call
|
||||
whenever a complete line of input is ready. The user must then
|
||||
call rl_callback_read_char() every time some input is available, and
|
||||
rl_callback_read_char() will call the user's function with the complete
|
||||
text read in at each end of line. The terminal is kept prepped and
|
||||
signals handled all the time, except during calls to the user's function. */
|
||||
|
||||
rl_vcpfunc_t *rl_linefunc; /* user callback function */
|
||||
static int in_handler; /* terminal_prepped and signals set? */
|
||||
|
||||
/* Make sure the terminal is set up, initialize readline, and prompt. */
|
||||
static void
|
||||
_rl_callback_newline ()
|
||||
{
|
||||
rl_initialize ();
|
||||
|
||||
if (in_handler == 0)
|
||||
{
|
||||
in_handler = 1;
|
||||
|
||||
if (rl_prep_term_function)
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_set_signals ();
|
||||
#endif
|
||||
}
|
||||
|
||||
readline_internal_setup ();
|
||||
}
|
||||
|
||||
/* Install a readline handler, set up the terminal, and issue the prompt. */
|
||||
void
|
||||
rl_callback_handler_install (prompt, linefunc)
|
||||
const char *prompt;
|
||||
rl_vcpfunc_t *linefunc;
|
||||
{
|
||||
rl_set_prompt (prompt);
|
||||
RL_SETSTATE (RL_STATE_CALLBACK);
|
||||
rl_linefunc = linefunc;
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
|
||||
/* Read one character, and dispatch to the handler if it ends the line. */
|
||||
void
|
||||
rl_callback_read_char ()
|
||||
{
|
||||
char *line;
|
||||
int eof, jcode;
|
||||
static procenv_t olevel;
|
||||
|
||||
if (rl_linefunc == NULL)
|
||||
{
|
||||
_rl_errmsg ("readline_callback_read_char() called with no handler!");
|
||||
abort ();
|
||||
}
|
||||
|
||||
memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t));
|
||||
jcode = setjmp (_rl_top_level);
|
||||
if (jcode)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_ISEARCH))
|
||||
{
|
||||
eof = _rl_isearch_callback (_rl_iscxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NSEARCH))
|
||||
{
|
||||
eof = _rl_nsearch_callback (_rl_nscxt);
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG))
|
||||
{
|
||||
eof = _rl_arg_callback (_rl_argcxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
/* XXX - this should handle _rl_last_command_was_kill better */
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
|
||||
_rl_internal_char_cleanup ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_MULTIKEY))
|
||||
{
|
||||
eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
|
||||
while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
|
||||
eof = _rl_dispatch_callback (_rl_kscxt);
|
||||
if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
|
||||
{
|
||||
_rl_internal_char_cleanup ();
|
||||
_rl_want_redisplay = 1;
|
||||
}
|
||||
}
|
||||
else if (_rl_callback_func)
|
||||
{
|
||||
/* This allows functions that simply need to read an additional
|
||||
character (like quoted-insert) to register a function to be
|
||||
called when input is available. _rl_callback_data is simply a
|
||||
pointer to a struct that has the argument count originally
|
||||
passed to the registering function and space for any additional
|
||||
parameters. */
|
||||
eof = (*_rl_callback_func) (_rl_callback_data);
|
||||
/* If the function `deregisters' itself, make sure the data is
|
||||
cleaned up. */
|
||||
if (_rl_callback_func == 0)
|
||||
{
|
||||
if (_rl_callback_data)
|
||||
{
|
||||
_rl_callback_data_dispose (_rl_callback_data);
|
||||
_rl_callback_data = 0;
|
||||
}
|
||||
_rl_internal_char_cleanup ();
|
||||
}
|
||||
}
|
||||
else
|
||||
eof = readline_internal_char ();
|
||||
|
||||
if (rl_done == 0 && _rl_want_redisplay)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
}
|
||||
|
||||
if (rl_done)
|
||||
{
|
||||
line = readline_internal_teardown (eof);
|
||||
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
in_handler = 0;
|
||||
(*rl_linefunc) (line);
|
||||
|
||||
/* If the user did not clear out the line, do it for him. */
|
||||
if (rl_line_buffer[0])
|
||||
_rl_init_line_state ();
|
||||
|
||||
/* Redisplay the prompt if readline_handler_{install,remove}
|
||||
not called. */
|
||||
if (in_handler == 0 && rl_linefunc)
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
}
|
||||
while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT));
|
||||
}
|
||||
|
||||
/* Remove the handler, and make sure the terminal is in its normal state. */
|
||||
void
|
||||
rl_callback_handler_remove ()
|
||||
{
|
||||
rl_linefunc = NULL;
|
||||
RL_UNSETSTATE (RL_STATE_CALLBACK);
|
||||
if (in_handler)
|
||||
{
|
||||
in_handler = 0;
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
_rl_callback_generic_arg *
|
||||
_rl_callback_data_alloc (count)
|
||||
int count;
|
||||
{
|
||||
_rl_callback_generic_arg *arg;
|
||||
|
||||
arg = (_rl_callback_generic_arg *)xmalloc (sizeof (_rl_callback_generic_arg));
|
||||
arg->count = count;
|
||||
|
||||
arg->i1 = arg->i2 = 0;
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
void _rl_callback_data_dispose (arg)
|
||||
_rl_callback_generic_arg *arg;
|
||||
{
|
||||
xfree (arg);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1019,7 +1019,9 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
|
||||
variable rl_attempted_completion_function. */
|
||||
if (rl_attempted_completion_function)
|
||||
{
|
||||
_rl_interrupt_immediately++;
|
||||
matches = (*rl_attempted_completion_function) (text, start, end);
|
||||
_rl_interrupt_immediately--;
|
||||
|
||||
if (matches || rl_attempted_completion_over)
|
||||
{
|
||||
@@ -1881,6 +1883,7 @@ rl_completion_matches (text, entry_function)
|
||||
match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *));
|
||||
match_list[1] = (char *)NULL;
|
||||
|
||||
_rl_interrupt_immediately++;
|
||||
while (string = (*entry_function) (text, matches))
|
||||
{
|
||||
if (matches + 1 == match_list_size)
|
||||
@@ -1890,6 +1893,7 @@ rl_completion_matches (text, entry_function)
|
||||
match_list[++matches] = string;
|
||||
match_list[matches + 1] = (char *)NULL;
|
||||
}
|
||||
_rl_interrupt_immediately--;
|
||||
|
||||
/* If there were any matches, then look through them finding out the
|
||||
lowest common denominator. That then becomes match_list[0]. */
|
||||
|
||||
@@ -252,6 +252,7 @@ rl_gather_tyi ()
|
||||
{
|
||||
while (chars_avail--)
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
k = (*rl_getc_function) (rl_instream);
|
||||
if (rl_stuff_char (k) == 0)
|
||||
break; /* some problem; no more room */
|
||||
@@ -437,6 +438,7 @@ rl_read_key ()
|
||||
while (rl_event_hook && rl_get_char (&c) == 0)
|
||||
{
|
||||
(*rl_event_hook) ();
|
||||
RL_CHECK_SIGNALS ();
|
||||
if (rl_done) /* XXX - experimental */
|
||||
return ('\n');
|
||||
if (rl_gather_tyi () < 0) /* XXX - EIO */
|
||||
@@ -450,6 +452,7 @@ rl_read_key ()
|
||||
{
|
||||
if (rl_get_char (&c) == 0)
|
||||
c = (*rl_getc_function) (rl_instream);
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,6 +468,8 @@ rl_getc (stream)
|
||||
|
||||
while (1)
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
if (isatty (fileno (stream)))
|
||||
return (getch ());
|
||||
|
||||
+17
-14
@@ -1,24 +1,24 @@
|
||||
/* input.c -- character input functions for readline. */
|
||||
|
||||
/* Copyright (C) 1994-2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (__TANDEM)
|
||||
@@ -154,7 +154,7 @@ _rl_unget_char (key)
|
||||
{
|
||||
pop_index--;
|
||||
if (pop_index < 0)
|
||||
pop_index = ibuffer_len - 1;
|
||||
pop_index = ibuffer_len;
|
||||
ibuffer[pop_index] = key;
|
||||
return (1);
|
||||
}
|
||||
@@ -252,6 +252,7 @@ rl_gather_tyi ()
|
||||
{
|
||||
while (chars_avail--)
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
k = (*rl_getc_function) (rl_instream);
|
||||
if (rl_stuff_char (k) == 0)
|
||||
break; /* some problem; no more room */
|
||||
@@ -465,6 +466,8 @@ rl_getc (stream)
|
||||
|
||||
while (1)
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
if (isatty (fileno (stream)))
|
||||
return (getch ());
|
||||
|
||||
@@ -383,7 +383,7 @@ _rl_isearch_dispatch (cxt, c)
|
||||
{
|
||||
if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
|
||||
{
|
||||
/* This sets rl_pending_input to c; it will be picked up the next
|
||||
/* This sets rl_pending_input to LASTC; it will be picked up the next
|
||||
time rl_read_key is called. */
|
||||
rl_execute_next (cxt->lastc);
|
||||
return (0);
|
||||
|
||||
+17
-16
@@ -1,29 +1,30 @@
|
||||
/* isearch.c - incremental searching */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* I-Search and Searching */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
@@ -330,7 +331,7 @@ _rl_isearch_dispatch (cxt, c)
|
||||
|
||||
if (c < 0)
|
||||
{
|
||||
cxt->flags |= SF_FAILED;
|
||||
cxt->sflags |= SF_FAILED;
|
||||
cxt->history_pos = cxt->last_found_line;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -397,6 +397,8 @@ readline_internal_setup ()
|
||||
|
||||
if (rl_pre_input_hook)
|
||||
(*rl_pre_input_hook) ();
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
|
||||
STATIC_CALLBACK char *
|
||||
@@ -406,6 +408,8 @@ readline_internal_teardown (eof)
|
||||
char *temp;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
/* Restore the original of this history line, iff the line that we
|
||||
are editing was originally in the history, AND the line has changed. */
|
||||
entry = current_history ();
|
||||
@@ -542,6 +546,7 @@ readline_internal_charloop ()
|
||||
|
||||
lastc = c;
|
||||
_rl_dispatch ((unsigned char)c, _rl_keymap);
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
/* If there was no change in _rl_last_command_was_kill, then no kill
|
||||
has taken place. Note that if input is pending we are reading
|
||||
@@ -662,7 +667,6 @@ _rl_dispatch_callback (cxt)
|
||||
int nkey, r;
|
||||
|
||||
/* For now */
|
||||
#if 1
|
||||
/* The first time this context is used, we want to read input and dispatch
|
||||
on it. When traversing the chain of contexts back `up', we want to use
|
||||
the value from the next context down. We're simulating recursion using
|
||||
@@ -680,13 +684,11 @@ _rl_dispatch_callback (cxt)
|
||||
}
|
||||
else
|
||||
r = cxt->childval;
|
||||
#else
|
||||
r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
|
||||
#endif
|
||||
|
||||
/* For now */
|
||||
r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
if (r == 0) /* success! */
|
||||
{
|
||||
_rl_keyseq_chain_dispose ();
|
||||
@@ -773,6 +775,8 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
||||
remember the last command executed in this variable. */
|
||||
if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
|
||||
rl_last_func = map[key].function;
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
else if (map[ANYOTHERKEY].function)
|
||||
{
|
||||
|
||||
+25
-20
@@ -1,25 +1,25 @@
|
||||
/* readline.c -- a general facility for reading lines of input
|
||||
with emacs style editing and completion. */
|
||||
|
||||
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
@@ -163,7 +163,7 @@ int rl_done;
|
||||
rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
|
||||
|
||||
/* Top level environment for readline_internal (). */
|
||||
procenv_t readline_top_level;
|
||||
procenv_t _rl_top_level;
|
||||
|
||||
/* The streams we interact with. */
|
||||
FILE *_rl_in_stream, *_rl_out_stream;
|
||||
@@ -176,7 +176,7 @@ FILE *rl_outstream = (FILE *)NULL;
|
||||
set to 1 if there is a controlling terminal, we can get its attributes,
|
||||
and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings
|
||||
for the code that sets it. */
|
||||
int readline_echoing_p = 0;
|
||||
int _rl_echoing_p = 0;
|
||||
|
||||
/* Current prompt. */
|
||||
char *rl_prompt = (char *)NULL;
|
||||
@@ -305,7 +305,9 @@ readline (prompt)
|
||||
const char *prompt;
|
||||
{
|
||||
char *value;
|
||||
#if 0
|
||||
int in_callback;
|
||||
#endif
|
||||
|
||||
/* If we are at EOF return a NULL string. */
|
||||
if (rl_pending_input == EOF)
|
||||
@@ -369,7 +371,7 @@ readline_internal_setup ()
|
||||
/* If we're not echoing, we still want to at least print a prompt, because
|
||||
rl_redisplay will not do it for us. If the calling application has a
|
||||
custom redisplay function, though, let that function handle it. */
|
||||
if (readline_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
|
||||
if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
|
||||
{
|
||||
if (rl_prompt && rl_already_prompted == 0)
|
||||
{
|
||||
@@ -395,6 +397,8 @@ readline_internal_setup ()
|
||||
|
||||
if (rl_pre_input_hook)
|
||||
(*rl_pre_input_hook) ();
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
|
||||
STATIC_CALLBACK char *
|
||||
@@ -404,6 +408,8 @@ readline_internal_teardown (eof)
|
||||
char *temp;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
/* Restore the original of this history line, iff the line that we
|
||||
are editing was originally in the history, AND the line has changed. */
|
||||
entry = current_history ();
|
||||
@@ -482,7 +488,7 @@ readline_internal_charloop ()
|
||||
#endif
|
||||
lk = _rl_last_command_was_kill;
|
||||
|
||||
code = setjmp (readline_top_level);
|
||||
code = setjmp (_rl_top_level);
|
||||
|
||||
if (code)
|
||||
{
|
||||
@@ -490,7 +496,7 @@ readline_internal_charloop ()
|
||||
_rl_want_redisplay = 0;
|
||||
/* If we get here, we're not being called from something dispatched
|
||||
from _rl_callback_read_char(), which sets up its own value of
|
||||
readline_top_level (saving and restoring the old, of course), so
|
||||
_rl_top_level (saving and restoring the old, of course), so
|
||||
we can just return here. */
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
return (0);
|
||||
@@ -540,6 +546,7 @@ readline_internal_charloop ()
|
||||
|
||||
lastc = c;
|
||||
_rl_dispatch ((unsigned char)c, _rl_keymap);
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
/* If there was no change in _rl_last_command_was_kill, then no kill
|
||||
has taken place. Note that if input is pending we are reading
|
||||
@@ -1189,7 +1196,6 @@ rl_save_state (sp)
|
||||
sp->prompt = rl_prompt;
|
||||
|
||||
sp->rlstate = rl_readline_state;
|
||||
sp->in_callback = RL_ISSTATE (RL_STATE_CALLBACK).
|
||||
sp->done = rl_done;
|
||||
sp->kmap = _rl_keymap;
|
||||
|
||||
@@ -1224,7 +1230,6 @@ rl_restore_state (sp)
|
||||
rl_prompt = sp->prompt;
|
||||
|
||||
rl_readline_state = sp->rlstate;
|
||||
/* Don't need to do anything with sp->in_callback */
|
||||
rl_done = sp->done;
|
||||
_rl_keymap = sp->kmap;
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
#define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
|
||||
#define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap)
|
||||
|
||||
#define RL_CHECK_SIGNALS() \
|
||||
do { \
|
||||
if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
|
||||
} while (0)
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global structs undocumented in texinfo manual and not in readline.h *
|
||||
@@ -291,6 +296,8 @@ extern int _rl_restore_tty_signals PARAMS((void));
|
||||
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
|
||||
|
||||
/* signals.c */
|
||||
extern void _rl_signal_handler PARAMS((int));
|
||||
|
||||
extern void _rl_block_sigint PARAMS((void));
|
||||
extern void _rl_release_sigint PARAMS((void));
|
||||
|
||||
@@ -424,6 +431,9 @@ extern _rl_keyseq_cxt *_rl_kscxt;
|
||||
extern _rl_search_cxt *_rl_nscxt;
|
||||
|
||||
/* signals.c */
|
||||
extern int _rl_interrupt_immediately;
|
||||
extern int volatile _rl_caught_signal;
|
||||
|
||||
extern int _rl_echoctl;
|
||||
|
||||
extern int _rl_intr_char;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* rlprivate.h -- functions and variables global to the readline library,
|
||||
but not intended for use by applications. */
|
||||
|
||||
/* Copyright (C) 1999-2008 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
@@ -37,6 +37,11 @@
|
||||
#define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
|
||||
#define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap)
|
||||
|
||||
#define RL_CHECK_SIGNALS() \
|
||||
do { \
|
||||
if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
|
||||
} while (0)
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global structs undocumented in texinfo manual and not in readline.h *
|
||||
@@ -291,11 +296,11 @@ extern int _rl_restore_tty_signals PARAMS((void));
|
||||
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
|
||||
|
||||
/* signals.c */
|
||||
extern void _rl_signal_handler PARAMS((int));
|
||||
|
||||
extern void _rl_block_sigint PARAMS((void));
|
||||
extern void _rl_release_sigint PARAMS((void));
|
||||
|
||||
extern void _rl_echo_signal_char PARAMS((int));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_get_screen_size PARAMS((int, int));
|
||||
extern int _rl_init_terminal_io PARAMS((const char *));
|
||||
@@ -426,11 +431,14 @@ extern _rl_keyseq_cxt *_rl_kscxt;
|
||||
extern _rl_search_cxt *_rl_nscxt;
|
||||
|
||||
/* signals.c */
|
||||
extern int _rl_interrupt_immediately;
|
||||
extern int _rl_caught_signal;
|
||||
|
||||
extern int _rl_echoctl;
|
||||
|
||||
extern _rl_intr_char;
|
||||
extern _rl_quit_char;
|
||||
extern _rl_susp_char;
|
||||
extern int _rl_intr_char;
|
||||
extern int _rl_quit_char;
|
||||
extern int _rl_susp_char;
|
||||
|
||||
/* terminal.c */
|
||||
extern int _rl_enable_keypad;
|
||||
|
||||
@@ -81,6 +81,9 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
|
||||
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
|
||||
static RETSIGTYPE rl_signal_handler PARAMS((int));
|
||||
static RETSIGTYPE _rl_handle_signal PARAMS((int));
|
||||
|
||||
/* Exported variables for use by applications. */
|
||||
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
@@ -95,6 +98,9 @@ int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
|
||||
#endif
|
||||
|
||||
/* Private variables. */
|
||||
int _rl_interrupt_immediately = 0;
|
||||
int volatile _rl_caught_signal = 0; /* should be sig_atomic_t, but that requires including <signal.h> everywhere */
|
||||
|
||||
/* If non-zero, print characters corresponding to received signals. */
|
||||
int _rl_echoctl = 0;
|
||||
|
||||
@@ -121,9 +127,33 @@ static sighandler_cxt old_winch;
|
||||
|
||||
/* Readline signal handler functions. */
|
||||
|
||||
/* Called from RL_CHECK_SIGNALS() macro */
|
||||
RETSIGTYPE
|
||||
_rl_signal_handler (sig)
|
||||
{
|
||||
_rl_caught_signal = 0; /* XXX */
|
||||
|
||||
_rl_handle_signal (sig);
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
rl_signal_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
if (_rl_interrupt_immediately)
|
||||
{
|
||||
_rl_interrupt_immediately = 0;
|
||||
_rl_handle_signal (sig);
|
||||
}
|
||||
|
||||
_rl_caught_signal = sig;
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
_rl_handle_signal (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigset_t set;
|
||||
|
||||
+33
-1
@@ -1,6 +1,6 @@
|
||||
/* signals.c -- signal handling support for readline. */
|
||||
|
||||
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
@@ -81,6 +81,9 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
|
||||
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
|
||||
static RETSIGTYPE rl_signal_handler PARAMS((int));
|
||||
static RETSIGTYPE _rl_handle_signal PARAMS((int));
|
||||
|
||||
/* Exported variables for use by applications. */
|
||||
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
@@ -95,6 +98,9 @@ int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
|
||||
#endif
|
||||
|
||||
/* Private variables. */
|
||||
int _rl_interrupt_immediately = 0;
|
||||
int volatile _rl_caught_signal = 0; /* should be sig_atomic_t, but that requires including <signal.h> everywhere */
|
||||
|
||||
/* If non-zero, print characters corresponding to received signals. */
|
||||
int _rl_echoctl = 0;
|
||||
|
||||
@@ -121,9 +127,34 @@ static sighandler_cxt old_winch;
|
||||
|
||||
/* Readline signal handler functions. */
|
||||
|
||||
/* Called from RL_CHECK_SIGNALS() macro */
|
||||
RETSIGTYPE
|
||||
_rl_signal_handler (sig)
|
||||
{
|
||||
_rl_caught_signal = 0; /* XXX */
|
||||
|
||||
_rl_handle_signal (sig);
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
rl_signal_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
_rl_caught_signal = sig;
|
||||
|
||||
if (_rl_interrupt_immediately)
|
||||
{
|
||||
_rl_interrupt_immediately = 0;
|
||||
_rl_handle_signal (sig);
|
||||
}
|
||||
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
_rl_handle_signal (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigset_t set;
|
||||
@@ -167,6 +198,7 @@ rl_signal_handler (sig)
|
||||
#if defined (SIGQUIT)
|
||||
case SIGQUIT:
|
||||
#endif
|
||||
rl_echo_signal_char (sig);
|
||||
rl_cleanup_after_signal ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
|
||||
+2
-2
@@ -114,7 +114,7 @@ rl_free_undo_list ()
|
||||
rl_undo_list = rl_undo_list->next;
|
||||
|
||||
if (release->what == UNDO_DELETE)
|
||||
free (release->text);
|
||||
xfree (release->text);
|
||||
|
||||
xfree (release);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ rl_do_undo ()
|
||||
case UNDO_DELETE:
|
||||
rl_point = start;
|
||||
rl_insert_text (rl_undo_list->text);
|
||||
free (rl_undo_list->text);
|
||||
xfree (rl_undo_list->text);
|
||||
break;
|
||||
|
||||
/* Undoing inserts means deleting some text. */
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
/* readline.c -- a general facility for reading lines of input
|
||||
with emacs style editing and completion. */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for _POSIX_VERSION */
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
extern void replace_history_data PARAMS((int, histdata_t *, histdata_t *));
|
||||
|
||||
/* Non-zero tells rl_delete_text and rl_insert_text to not add to
|
||||
the undo list. */
|
||||
int _rl_doing_an_undo = 0;
|
||||
|
||||
/* How many unclosed undo groups we currently have. */
|
||||
int _rl_undo_group_level = 0;
|
||||
|
||||
/* The current undo list for THE_LINE. */
|
||||
UNDO_LIST *rl_undo_list = (UNDO_LIST *)NULL;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Undo, and Undoing */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static UNDO_LIST *
|
||||
alloc_undo_entry (what, start, end, text)
|
||||
enum undo_code what;
|
||||
int start, end;
|
||||
char *text;
|
||||
{
|
||||
UNDO_LIST *temp;
|
||||
|
||||
temp = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST));
|
||||
temp->what = what;
|
||||
temp->start = start;
|
||||
temp->end = end;
|
||||
temp->text = text;
|
||||
|
||||
temp->next = (UNDO_LIST *)NULL;
|
||||
return temp;
|
||||
}
|
||||
|
||||
/* Remember how to undo something. Concatenate some undos if that
|
||||
seems right. */
|
||||
void
|
||||
rl_add_undo (what, start, end, text)
|
||||
enum undo_code what;
|
||||
int start, end;
|
||||
char *text;
|
||||
{
|
||||
UNDO_LIST *temp;
|
||||
|
||||
temp = alloc_undo_entry (what, start, end, text);
|
||||
temp->next = rl_undo_list;
|
||||
rl_undo_list = temp;
|
||||
}
|
||||
|
||||
/* Free the existing undo list. */
|
||||
void
|
||||
rl_free_undo_list ()
|
||||
{
|
||||
UNDO_LIST *release, *orig_list;
|
||||
|
||||
orig_list = rl_undo_list;
|
||||
while (rl_undo_list)
|
||||
{
|
||||
release = rl_undo_list;
|
||||
rl_undo_list = rl_undo_list->next;
|
||||
|
||||
if (release->what == UNDO_DELETE)
|
||||
free (release->text);
|
||||
|
||||
xfree (release);
|
||||
}
|
||||
rl_undo_list = (UNDO_LIST *)NULL;
|
||||
replace_history_data (-1, (histdata_t *)orig_list, (histdata_t *)NULL);
|
||||
}
|
||||
|
||||
UNDO_LIST *
|
||||
_rl_copy_undo_entry (entry)
|
||||
UNDO_LIST *entry;
|
||||
{
|
||||
UNDO_LIST *new;
|
||||
|
||||
new = alloc_undo_entry (entry->what, entry->start, entry->end, (char *)NULL);
|
||||
new->text = entry->text ? savestring (entry->text) : 0;
|
||||
return new;
|
||||
}
|
||||
|
||||
UNDO_LIST *
|
||||
_rl_copy_undo_list (head)
|
||||
UNDO_LIST *head;
|
||||
{
|
||||
UNDO_LIST *list, *new, *roving, *c;
|
||||
|
||||
list = head;
|
||||
new = 0;
|
||||
while (list)
|
||||
{
|
||||
c = _rl_copy_undo_entry (list);
|
||||
if (new == 0)
|
||||
roving = new = c;
|
||||
else
|
||||
{
|
||||
roving->next = c;
|
||||
roving = roving->next;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
roving->next = 0;
|
||||
return new;
|
||||
}
|
||||
|
||||
/* Undo the next thing in the list. Return 0 if there
|
||||
is nothing to undo, or non-zero if there was. */
|
||||
int
|
||||
rl_do_undo ()
|
||||
{
|
||||
UNDO_LIST *release;
|
||||
int waiting_for_begin, start, end;
|
||||
|
||||
#define TRANS(i) ((i) == -1 ? rl_point : ((i) == -2 ? rl_end : (i)))
|
||||
|
||||
start = end = waiting_for_begin = 0;
|
||||
do
|
||||
{
|
||||
if (rl_undo_list == 0)
|
||||
return (0);
|
||||
|
||||
_rl_doing_an_undo = 1;
|
||||
RL_SETSTATE(RL_STATE_UNDOING);
|
||||
|
||||
/* To better support vi-mode, a start or end value of -1 means
|
||||
rl_point, and a value of -2 means rl_end. */
|
||||
if (rl_undo_list->what == UNDO_DELETE || rl_undo_list->what == UNDO_INSERT)
|
||||
{
|
||||
start = TRANS (rl_undo_list->start);
|
||||
end = TRANS (rl_undo_list->end);
|
||||
}
|
||||
|
||||
switch (rl_undo_list->what)
|
||||
{
|
||||
/* Undoing deletes means inserting some text. */
|
||||
case UNDO_DELETE:
|
||||
rl_point = start;
|
||||
rl_insert_text (rl_undo_list->text);
|
||||
free (rl_undo_list->text);
|
||||
break;
|
||||
|
||||
/* Undoing inserts means deleting some text. */
|
||||
case UNDO_INSERT:
|
||||
rl_delete_text (start, end);
|
||||
rl_point = start;
|
||||
break;
|
||||
|
||||
/* Undoing an END means undoing everything 'til we get to a BEGIN. */
|
||||
case UNDO_END:
|
||||
waiting_for_begin++;
|
||||
break;
|
||||
|
||||
/* Undoing a BEGIN means that we are done with this group. */
|
||||
case UNDO_BEGIN:
|
||||
if (waiting_for_begin)
|
||||
waiting_for_begin--;
|
||||
else
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
|
||||
_rl_doing_an_undo = 0;
|
||||
RL_UNSETSTATE(RL_STATE_UNDOING);
|
||||
|
||||
release = rl_undo_list;
|
||||
rl_undo_list = rl_undo_list->next;
|
||||
replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list);
|
||||
|
||||
xfree (release);
|
||||
}
|
||||
while (waiting_for_begin);
|
||||
|
||||
return (1);
|
||||
}
|
||||
#undef TRANS
|
||||
|
||||
int
|
||||
_rl_fix_last_undo_of_type (type, start, end)
|
||||
int type, start, end;
|
||||
{
|
||||
UNDO_LIST *rl;
|
||||
|
||||
for (rl = rl_undo_list; rl; rl = rl->next)
|
||||
{
|
||||
if (rl->what == type)
|
||||
{
|
||||
rl->start = start;
|
||||
rl->end = end;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Begin a group. Subsequent undos are undone as an atomic operation. */
|
||||
int
|
||||
rl_begin_undo_group ()
|
||||
{
|
||||
rl_add_undo (UNDO_BEGIN, 0, 0, 0);
|
||||
_rl_undo_group_level++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* End an undo group started with rl_begin_undo_group (). */
|
||||
int
|
||||
rl_end_undo_group ()
|
||||
{
|
||||
rl_add_undo (UNDO_END, 0, 0, 0);
|
||||
_rl_undo_group_level--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Save an undo entry for the text from START to END. */
|
||||
int
|
||||
rl_modifying (start, end)
|
||||
int start, end;
|
||||
{
|
||||
if (start > end)
|
||||
{
|
||||
SWAP (start, end);
|
||||
}
|
||||
|
||||
if (start != end)
|
||||
{
|
||||
char *temp = rl_copy_text (start, end);
|
||||
rl_begin_undo_group ();
|
||||
rl_add_undo (UNDO_DELETE, start, end, temp);
|
||||
rl_add_undo (UNDO_INSERT, start, end, (char *)NULL);
|
||||
rl_end_undo_group ();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Revert the current line to its previous state. */
|
||||
int
|
||||
rl_revert_line (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (rl_undo_list == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
while (rl_undo_list)
|
||||
rl_do_undo ();
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
rl_point = rl_mark = 0; /* rl_end should be set correctly */
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do some undoing of things that were done. */
|
||||
int
|
||||
rl_undo_command (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (count < 0)
|
||||
return 0; /* Nothing to do. */
|
||||
|
||||
while (count)
|
||||
{
|
||||
if (rl_do_undo ())
|
||||
count--;
|
||||
else
|
||||
{
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -35,7 +35,7 @@ Acknowledgement Oenophile
|
||||
ACKNOWLEDGEMENT OENOPHILE
|
||||
BE CONSERVATIVE IN WHAT YOU SEND AND LIBERAL IN WHAT YOU ACCEPT
|
||||
be conservative in what you send and liberal in what you accept
|
||||
Be Conservative in what you send and Liberal in what you accept
|
||||
Be conservative in what you send and liberal in what you accept
|
||||
Be conservative in what you send and liberal in what you accept
|
||||
be Conservative in what you send and Liberal in what you accept
|
||||
be conservative in what you send and liberal in what you accept
|
||||
|
||||
Reference in New Issue
Block a user