Added the contents of the "readline" module back. This is
generally unused, as it is incompatible with the Tcl/Tk build of magic. However, I had not intended to remove it, only move the name from "readline-4.3" to "readline". But "readline/readline" was in .gitignore, which caused the contents to be removed from the repository. This commit restores those files, and also prevents the readline directory Makefile from making a symbolic link called "readline" to itself, which was causing compile-time issues. The readline code is only kept for backwards compatibility with ancient versions of magic not using the Tcl/Tk interpreter.
This commit is contained in:
parent
82a1dc98b4
commit
1cec414618
|
|
@ -14,7 +14,6 @@ database/database.h
|
|||
install.log
|
||||
magic/proto.magicrc
|
||||
make.log
|
||||
readline/readline
|
||||
scmos/gdsquery.tech
|
||||
scmos/minimum.tech
|
||||
scmos/scmos-sub.tech
|
||||
|
|
@ -32,4 +31,4 @@ magic/tclmagic.dylib
|
|||
tcltk/magicdnull.dSYM/
|
||||
tcltk/magicexec.dSYM/
|
||||
reconfigure.sh
|
||||
pfx/
|
||||
pfx/
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ module: readline readline/libreadline.a readline/libhistory.a
|
|||
|
||||
depend:
|
||||
|
||||
# NOTE: Previously, source code was in a directory readline-4.3 and
|
||||
# recipe "readline" created a symbolic link to it. This symbolic
|
||||
# link has been removed, and code is now just in real directory
|
||||
# "readline".
|
||||
|
||||
readline:
|
||||
@if ( ! test -f readline/readline ) ; then \
|
||||
ln -s `ls | grep readline` readline ; \
|
||||
fi
|
||||
|
||||
readline/libhistory.a: readline/libreadline.a
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,699 @@
|
|||
[Readline-specific changelog. Descriptions of changes to the source are
|
||||
found in the bash changelog.]
|
||||
|
||||
6/9
|
||||
---
|
||||
Makefile.in
|
||||
- quote value of ${INSTALL_DATA} when passing it to makes in
|
||||
subdirectories
|
||||
|
||||
7/1
|
||||
---
|
||||
Makefile.in
|
||||
- don't pass INSTALL_DATA to a make in the `doc' subdirectory; let
|
||||
autoconf set the value itself in the Makefile
|
||||
- removed a stray `-' before $(RANLIB) in the `install' recipe
|
||||
|
||||
doc/Makefile.in
|
||||
- add a VPATH assignment so the documentation is not remade if it's
|
||||
already up-to-date in the distribution
|
||||
|
||||
configure.in
|
||||
- call AC_SUBST(LOCAL_LDFLAGS), since Makefile.in contains
|
||||
@LOCAL_LDFLAGS@
|
||||
|
||||
7/9
|
||||
---
|
||||
|
||||
config.h.in
|
||||
- add define lines for STRUCT_WINSIZE_IN_SYS_IOCTL and
|
||||
STRUCT_WINSIZE_IN_TERMIOS
|
||||
|
||||
configure.in
|
||||
- call BASH_STRUCT_WINSIZE to look for the definition of
|
||||
`struct winsize'
|
||||
|
||||
7/17
|
||||
----
|
||||
configure.in
|
||||
- call AC_MINIX
|
||||
|
||||
config.h.in
|
||||
- add define line for AC_MINIX
|
||||
|
||||
7/18
|
||||
----
|
||||
Makefile.in
|
||||
- add `install-shared' and `uninstall-shared' targets
|
||||
|
||||
8/4
|
||||
---
|
||||
Makefile.in
|
||||
- install and uninstall libhistory.a in the `install' and
|
||||
`uninstall' targets
|
||||
|
||||
9/4
|
||||
---
|
||||
configure.in
|
||||
- bumped LIBVERSION up to 2.1.1, indicating that this is patch
|
||||
level 1 to release 2.1
|
||||
|
||||
|
||||
9/16
|
||||
----
|
||||
Makefile.in
|
||||
- `make distclean' now descends into the `examples' subdir
|
||||
|
||||
doc/Makefile.in
|
||||
- the `distclean' and `maintainer-clean' targets should remove
|
||||
Makefile
|
||||
|
||||
examples/Makefile.in
|
||||
- added the various clean targets
|
||||
|
||||
4/2
|
||||
---
|
||||
configure.in
|
||||
- bumped LIBVERSION up to 2.2
|
||||
|
||||
4/18
|
||||
----
|
||||
[readline-2.2 released]
|
||||
|
||||
4/20
|
||||
----
|
||||
Makefile.in
|
||||
- make `libhistory.a' a dependency of `install'
|
||||
- fixed a typo in the recipe for `install' that copied libreadline.a
|
||||
to libhistory.old right after installing it
|
||||
|
||||
4/27
|
||||
----
|
||||
doc/Makefile.in
|
||||
- install {readline,history}.info out of the source directory if
|
||||
they are not found in the current (build) directory -- only an
|
||||
issue if the libraries are built in a different directory than
|
||||
the source directory
|
||||
|
||||
5/1
|
||||
---
|
||||
support/shobj-conf
|
||||
- script from the bash distribution to do shared object and library
|
||||
configuration
|
||||
|
||||
shlib/Makefile.in
|
||||
- new directory and makefile to handle building shared versions of
|
||||
libreadline and libhistory, controlled by support/shobj-conf
|
||||
|
||||
5/7
|
||||
---
|
||||
doc/Makefile.in
|
||||
- set SHELL to /bin/sh, rather than relying on make to be correct
|
||||
|
||||
5/14
|
||||
----
|
||||
savestring.c
|
||||
- new file, moved from shell.c, for backwards compatibility
|
||||
|
||||
Makefile.in, shlib/Makefile.in
|
||||
- make sure savestring.c is compiled and added to libreadline and
|
||||
libhistory
|
||||
|
||||
[THERE ARE NO MORE #ifdef SHELL LINES IN THE C SOURCE FILES.]
|
||||
|
||||
5/15
|
||||
----
|
||||
README
|
||||
- updated description of shared library creation for the new scheme
|
||||
|
||||
[THERE ARE NO MORE #ifdef SHELL LINES IN ANY OF THE SOURCE FILES.]
|
||||
|
||||
Makefile.in
|
||||
- bumped SHLIB_MAJOR up to 4 since we've augmented the library
|
||||
API
|
||||
- rlconf.h is now one of the installed headers, so applications can
|
||||
find out whether things like vi-mode are available in the installed
|
||||
libreadline
|
||||
|
||||
5/20
|
||||
----
|
||||
configure.in
|
||||
- changed RL_LIBRARY_VERSION to 4.0 to match the version of the
|
||||
installed shared libraries
|
||||
|
||||
6/5
|
||||
---
|
||||
rlstdc.h
|
||||
- new file
|
||||
|
||||
Makefile.in
|
||||
- rlstdc.h is now one of the installed headers
|
||||
|
||||
8/3
|
||||
---
|
||||
shlib/Makefile.in
|
||||
- made the suffix rule that creates xx.so from xx.c write the
|
||||
compiler output to `a.o', which is then mv'd to xx.so, because
|
||||
some compilers (Sun WSpro 4.2, for example) don't allow any
|
||||
suffixes other than `.o' for `cc -c' (not even `a.out')
|
||||
|
||||
9/15
|
||||
----
|
||||
|
||||
Makefile.in
|
||||
- AR and ARFLAGS are now substituted by configure, used in recipes
|
||||
that build the libraries
|
||||
|
||||
configure.in
|
||||
- use AC_CHECK_PROG to check for ar
|
||||
- set ARFLAGS if it has not already been set in the environment
|
||||
|
||||
10/5
|
||||
----
|
||||
Makefile.in
|
||||
- removed savestring.o from object file list
|
||||
|
||||
10/28
|
||||
-----
|
||||
shlib/Makefile.in
|
||||
- don't use a fixed filename in the .c.so suffix rule to avoid
|
||||
problems with parallel makes
|
||||
|
||||
12/21
|
||||
-----
|
||||
support/shlib-install
|
||||
- new script to install shared readline and history libraries
|
||||
|
||||
shlib/Makefile.in
|
||||
- changed to call shlib-install for install and uninstall targets
|
||||
|
||||
[readline-4.0-beta1 frozen]
|
||||
|
||||
12/22
|
||||
-----
|
||||
configure.in
|
||||
- call AC_SUBST for SHOBJ_XLDFLAGS and SHLIB_LIBS
|
||||
|
||||
shlib/Makefile.in
|
||||
- SHOBJ_XLDFLAGS and SHLIB_LIBS are now substituted by configure
|
||||
- add $(SHLIB_LIBS) at end of command line that builds the shared
|
||||
libraries (currently needed only by AIX 4.2)
|
||||
|
||||
12/31
|
||||
-----
|
||||
MANIFEST, MANIFEST.doc
|
||||
- the TOC html files are no longer generated and no longer part of
|
||||
the distribution
|
||||
|
||||
2/18/1999
|
||||
---------
|
||||
configure.in
|
||||
- set MAKE_SHELL to /bin/sh and substitute into the Makefiles
|
||||
|
||||
Makefile.in,{doc,examples,shlib}/Makefile.in
|
||||
- set SHELL from @MAKE_SHELL@
|
||||
|
||||
[readline-4.0 released]
|
||||
|
||||
3/11
|
||||
----
|
||||
doc/Makefile.in
|
||||
- removed references to HTMLTOC, since separate HTML table-of-contents
|
||||
files are no longer created
|
||||
|
||||
examples/Makefile.in
|
||||
- remove `*.exe' in clean target for MS-DOS
|
||||
|
||||
Makefile.in
|
||||
- make `readline' target depend on ./libreadline.a
|
||||
- configure now substitutes TERMCAP_LIB into Makefile.in
|
||||
- use ${TERMCAP_LIB} instead of -ltermcap in recipe for `readline'
|
||||
- clean target now removes readline and readline.exe in case they
|
||||
get built
|
||||
|
||||
configure.in
|
||||
- use `pwd.exe' to set BUILD_DIR on MS-DOS DJGPP
|
||||
|
||||
3/15
|
||||
----
|
||||
support/shlib-install
|
||||
- Irix 5.x and Irix 6.x should install shared libraries like Solaris 2
|
||||
- changes for installing on hp-ux 1[01].x
|
||||
|
||||
3/23
|
||||
----
|
||||
configure.in
|
||||
- make sure that the $CC argument to shobj-conf is quoted
|
||||
|
||||
4/8
|
||||
---
|
||||
|
||||
xmalloc.h, rlprivate.h, rlshell.h
|
||||
- new files
|
||||
|
||||
Makefile.in,shlib/Makefile.in
|
||||
- add dependencies on xmalloc.h, rlshell.h
|
||||
- add xmalloc.h, rlprivate.h, rlshell.h to list of header files
|
||||
|
||||
MANIFEST
|
||||
- add xmalloc.h, rlprivate.h, rlshell.h
|
||||
|
||||
4/9
|
||||
---
|
||||
Makefile.in,shlib/Makefile.in
|
||||
- add dependencies on rlprivate.h
|
||||
|
||||
4/13
|
||||
----
|
||||
doc/Makefile.in
|
||||
- add variable, PSDVI, which is the desired resolution of the
|
||||
generated postscript files. Set to 300 because I don't have
|
||||
any 600-dpi printers
|
||||
- set LANGUAGE= before calling makeinfo, so messages are in English
|
||||
- add rluserman.{info,dvi,ps,html} to appropriate variables
|
||||
- add rules to create rluserman.{info,dvi,ps,html}
|
||||
- install and uninstall rluserman.info, but don't update the directory
|
||||
file in $(infodir) yet
|
||||
|
||||
MANIFEST
|
||||
- add doc/rluserman.{texinfo,info,dvi,ps,html}
|
||||
|
||||
4/30
|
||||
----
|
||||
configure.in
|
||||
- updated library version to 4.1
|
||||
|
||||
5/3
|
||||
---
|
||||
configure.in
|
||||
- SHLIB_MAJOR and SHLIB_MINOR shared library version numbers are
|
||||
constructed from $LIBRARY_VERSION and substituted into Makefiles
|
||||
|
||||
5/5
|
||||
---
|
||||
support/shlib-install
|
||||
- OSF/1 installs shared libraries like Solaris
|
||||
|
||||
Makefile.in
|
||||
- broke the header file install and uninstall into two new targets:
|
||||
install-headers and uninstall-headers
|
||||
- install and uninstall depend on install-headers and uninstall-headers
|
||||
respectively
|
||||
- changed install-shared and uninstall-shared targets to depend on
|
||||
install-headers and uninstall-headers, respectively, so users may
|
||||
choose to install only the shared libraries. I'm not sure about
|
||||
the uninstall one yet -- maybe it should check whether or not
|
||||
the static libraries are installed and not remove the header files
|
||||
if they are
|
||||
|
||||
9/3
|
||||
---
|
||||
configure.in, config.h.in
|
||||
- added test for memmove (for later use)
|
||||
- changed version to 4.1-beta1
|
||||
|
||||
9/13
|
||||
----
|
||||
examples/rlfe.c
|
||||
- Per Bothner's `rlfe' readline front-end program
|
||||
|
||||
examples/Makefile.in
|
||||
- added rules to build rlfe
|
||||
|
||||
9/21
|
||||
----
|
||||
support/shlib-install
|
||||
- changes to handle FreeBSD-3.x elf or a.out shared libraries, which
|
||||
have different semantics and need different naming conventions
|
||||
|
||||
1/24/2000
|
||||
---------
|
||||
doc/Makefile.in
|
||||
- remove *.bt and *.bts on `make clean'
|
||||
|
||||
2/4
|
||||
---
|
||||
|
||||
|
||||
configure.in
|
||||
- changed LIBVERSION to 4.1-beta5
|
||||
|
||||
3/17/2000
|
||||
---------
|
||||
[readline-4.1 released]
|
||||
|
||||
3/23
|
||||
----
|
||||
Makefile.in
|
||||
- remove the `-t' argument to ranlib in the install recipe; some
|
||||
ranlibs don't have it and attempt to create a file named `-t'
|
||||
|
||||
3/27
|
||||
----
|
||||
support/shlib-install
|
||||
- install shared libraries unwritable by anyone on HP-UX
|
||||
- changed symlinks to relative pathnames on all platforms
|
||||
|
||||
shlib/Makefile.in
|
||||
- added missing `includedir' assignment, substituted by configure
|
||||
|
||||
Makefile.in
|
||||
- added missing @SET_MAKE@ so configure can set $MAKE appropriately
|
||||
|
||||
configure.in
|
||||
- add call to AC_PROG_MAKE_SET
|
||||
|
||||
8/30
|
||||
----
|
||||
shlib/Makefile.in
|
||||
- change the soname bound into the shared libraries, so it includes
|
||||
only the major version number. If it includes the minor version,
|
||||
programs depending on it must be rebuilt (which may or may not be
|
||||
a bad thing)
|
||||
|
||||
9/6
|
||||
---
|
||||
examples/rlfe.c
|
||||
- add -l option to log input and output (-a option appends to logfile)
|
||||
- add -n option to set readline application name
|
||||
- add -v, -h options for version and help information
|
||||
- change a few things because getopt() is now used to parse arguments
|
||||
|
||||
9/12
|
||||
----
|
||||
support/shlib-install
|
||||
- fix up the libname on HPUX 11
|
||||
|
||||
10/18
|
||||
-----
|
||||
configure.in
|
||||
- changed library version to 4.2-alpha
|
||||
|
||||
10/30
|
||||
-----
|
||||
configure.in
|
||||
- add -fsigned-char to LOCAL_CFLAGS for Linux running on the IBM
|
||||
S/390
|
||||
|
||||
Makefile.in
|
||||
- added new file, rltypedefs.h, installed by default with `make install'
|
||||
|
||||
11/2
|
||||
----
|
||||
compat.c
|
||||
- new file, with backwards-compatibility function definitions
|
||||
|
||||
Makefile.in,shlib/Makefile.in
|
||||
- make sure that compat.o/compat.so are built and linked apppropriately
|
||||
|
||||
support/shobj-conf
|
||||
- picked up bash version, which means that shared libs built on
|
||||
linux and BSD/OS 4.x will have an soname that does not include
|
||||
the minor version number
|
||||
|
||||
11/13
|
||||
-----
|
||||
examples/rlfe.c
|
||||
- rlfe can perform filename completion for relative pathnames in the
|
||||
inferior process's context if the OS supports /proc/PID/cwd (linux
|
||||
does it OK, Solaris is slightly warped, none of the BSDs have it)
|
||||
|
||||
11/17/2000
|
||||
----------
|
||||
[readline-4.2-alpha released]
|
||||
|
||||
11/27
|
||||
-----
|
||||
Makefile.in,shlib/Makefile.in
|
||||
- added dependencies for rltypedefs.h
|
||||
|
||||
shlib/Makefile.in
|
||||
- changed dependencies on histlib.h to $(topdir)/histlib.h
|
||||
|
||||
1/22
|
||||
----
|
||||
configure.in
|
||||
- changed release version to 4.2-beta
|
||||
|
||||
2/2
|
||||
---
|
||||
examples/Makefile.in
|
||||
- build histexamp as part of the examples
|
||||
|
||||
2/5
|
||||
---
|
||||
doc/Makefile.in
|
||||
- don't remove the dvi, postscript, html, info, and text `objects'
|
||||
on a `make distclean', only on a `make maintainer-clean'
|
||||
|
||||
3/6
|
||||
---
|
||||
doc/history.{0,3}, doc/history_3.ps
|
||||
- new manual page for history library
|
||||
|
||||
doc/Makefile.in
|
||||
- rules to install and uninstall history.3 in ${man3dir}
|
||||
- rules to build history.0 and history_3.ps
|
||||
|
||||
4/2
|
||||
---
|
||||
configure.in
|
||||
- changed LIBVERSION to `4.2'
|
||||
|
||||
4/5
|
||||
---
|
||||
[readline-4.2 frozen]
|
||||
|
||||
4/9
|
||||
---
|
||||
[readline-4.2 released]
|
||||
|
||||
5/2
|
||||
---
|
||||
Makefile.in,{doc,examples,shlib}/Makefile.in
|
||||
- added support for DESTDIR installation root prefix, to support
|
||||
building packages
|
||||
|
||||
doc/Makefile.in
|
||||
- add an info `dir' file entry for rluserman.info on `make install'
|
||||
- change man1ext to `.1' and man3ext to `.3'
|
||||
- install man pages with a $(man3ext) extension in the target directory
|
||||
- add support for installing html documentation if `htmldir' has a
|
||||
value
|
||||
|
||||
Makefile.in
|
||||
- on `make install', install from the `shlib' directory, too
|
||||
- on `make uninstall', uninstall in the `doc' and `shlib'
|
||||
subdirectories, too
|
||||
|
||||
support/shlib-install
|
||||
- add `freebsdelf*', `freebsdaout*', Hurd, `sysv4*', `sysv5*', `dgux*'
|
||||
targets for symlink creation
|
||||
|
||||
5/7
|
||||
---
|
||||
configure.in, config.h.in
|
||||
- check for <limits.h>, define HAVE_LIMITS_H if found
|
||||
|
||||
5/8
|
||||
---
|
||||
aclocal.m4
|
||||
- pick up change to BASH_CHECK_LIB_TERMCAP that adds check for
|
||||
libtinfo (termcap-specific portion of ncurses-5.2)
|
||||
|
||||
5/9
|
||||
---
|
||||
configure.in
|
||||
- call AC_C_CONST to find out whether or not the compiler supports
|
||||
`const'
|
||||
|
||||
config.h.in
|
||||
- placeholder for `const' define, if any
|
||||
|
||||
5/10
|
||||
----
|
||||
configure.in
|
||||
- fix AC_CHECK_PROG(ar, ...) test to specify right value for the
|
||||
case where ar is not found; should produce a better error message
|
||||
|
||||
5/14
|
||||
----
|
||||
configure.in,config.h.in
|
||||
- check for vsnprintf, define HAVE_VSNPRINTF if found
|
||||
|
||||
5/21
|
||||
----
|
||||
configure.in, config.h.in
|
||||
- add checks for size_t, ssize_t
|
||||
|
||||
5/30
|
||||
----
|
||||
configure.in
|
||||
- update autoconf to version 2.50, use in AC_PREREQ
|
||||
- changed AC_INIT to new flavor
|
||||
- added AC_CONFIG_SRCDIR
|
||||
- AC_CONFIG_HEADER -> AC_CONFIG_HEADERS
|
||||
- call AC_C_PROTOTYPES
|
||||
- AC_RETSIGTYPE -> AC_TYPE_SIGNAL
|
||||
|
||||
8/22
|
||||
----
|
||||
configure.in
|
||||
- updated the version number to 4.2a
|
||||
|
||||
Makefile.in,shlib/Makefile.in
|
||||
- make sure tilde.o is built -DREADLINE_LIBRARY when being built as
|
||||
part of the standalone library, so it picks up the right include
|
||||
files
|
||||
|
||||
8/23
|
||||
----
|
||||
support/shlib-install
|
||||
- support for Darwin/MacOS X shared library installation
|
||||
|
||||
9/24
|
||||
----
|
||||
examples/readlinebuf.h
|
||||
- a new file, a C++ streambuf interface that uses readline for I/O.
|
||||
Donated by Dimitris Vyzovitis <vyzo@media.mit.edu>
|
||||
|
||||
10/9
|
||||
----
|
||||
configure.in
|
||||
- replaced call to BASH_HAVE_TIOCGWINSZ with AC_HEADER_TIOCGWINSZ
|
||||
|
||||
[readline-4.2a-beta1 frozen]
|
||||
|
||||
10/15
|
||||
-----
|
||||
configure.in, config.h.in
|
||||
- check for <memory.h>, define HAVE_MEMORY_H if found
|
||||
- check for <strings.h>, define HAVE_STRINGS_H if found
|
||||
|
||||
10/18
|
||||
-----
|
||||
configure.in, config.h.in
|
||||
- check for isascii, define HAVE_ISASCII if found
|
||||
|
||||
configure.in
|
||||
- changed the macro names from bash as appropriate:
|
||||
BASH_SIGNAL_CHECK -> BASH_SYS_SIGNAL_VINTAGE
|
||||
BASH_REINSTALL_SIGHANDLERS -> BASH_SYS_REINSTALL_SIGHANDLERS
|
||||
BASH_MISC_SPEED_T -> BASH_CHECK_SPEED_T
|
||||
|
||||
10/22
|
||||
-----
|
||||
configure.in
|
||||
- check for isxdigit with AC_CHECK_FUNCS
|
||||
|
||||
config.h.in
|
||||
- new define for HAVE_ISXDIGIT
|
||||
|
||||
10/29
|
||||
-----
|
||||
configure.in, config.h.in
|
||||
- check for strpbrk with AC_CHECK_FUNCS, define HAVE_STRPBRK if found
|
||||
|
||||
11/1
|
||||
----
|
||||
Makefile.in
|
||||
- make sure DESTDIR is passed to install and uninstall makes in
|
||||
subdirectories
|
||||
- when saving old copies of installed libraries, make sure we use
|
||||
DESTDIR for the old installation tree
|
||||
|
||||
[readline-4.2a-rc1 frozen]
|
||||
|
||||
11/2
|
||||
----
|
||||
Makefile.in, shlib/Makefile.in
|
||||
- don't put -I$(includedir) into CFLAGS
|
||||
|
||||
11/15
|
||||
-----
|
||||
[readline-4.2a released]
|
||||
|
||||
11/20
|
||||
-----
|
||||
examples/rlcat.c
|
||||
- new file
|
||||
|
||||
examples/Makefile.in
|
||||
- changes for rlcat
|
||||
|
||||
11/28
|
||||
-----
|
||||
configure.in
|
||||
- default TERMCAP_LIB to -lcurses if $prefer_curses == yes (as when
|
||||
--with-curses is supplied)
|
||||
|
||||
examples/Makefile.in
|
||||
- substitute @LDFLAGS@ in LDFLAGS assignment
|
||||
|
||||
11/29
|
||||
-----
|
||||
config.h.in
|
||||
- add necessary defines for multibyte include files and functions
|
||||
- add code to define HANDLE_MULTIBYTE if prerequisites are met
|
||||
|
||||
configure.in
|
||||
- call BASH_CHECK_MULTIBYTE
|
||||
|
||||
12/14
|
||||
-----
|
||||
config.h.in
|
||||
- add #undef PROTOTYPES, filled in by AC_C_PROTOTYPES
|
||||
|
||||
12/17
|
||||
-----
|
||||
config.h.in
|
||||
- moved HANDLE_MULTIBYTE code to rlmbutil.h
|
||||
|
||||
rlmbutil.h, mbutil.c
|
||||
- new files
|
||||
|
||||
Makefile.in, shlib/Makefile.in
|
||||
- added rules for mbutil.c
|
||||
|
||||
12/20
|
||||
-----
|
||||
configure.in
|
||||
- added --enable-shared, --enable-static options to configure to
|
||||
say which libraries are built by default (both default to yes)
|
||||
- if SHLIB_STATUS == 'unsupported', turn off default shared library
|
||||
building
|
||||
- substitute new STATIC_TARGET, SHARED_TARGET, STATIC_INSTALL_TARGET,
|
||||
and SHARED_INSTALL_TARGET
|
||||
|
||||
Makefile.in
|
||||
- `all' target now depends on (substituted) @STATIC_TARGET@ and
|
||||
@SHARED_TARGET@
|
||||
- `install' target now depends on (substituted) @STATIC_INSTALL_TARGET@
|
||||
and @SHARED_INSTALL_TARGET@
|
||||
|
||||
INSTALL, README
|
||||
- updated with new info about --enable-shared and --enable-static
|
||||
|
||||
1/10/2002
|
||||
---------
|
||||
configure.in
|
||||
- bumped the library version number to 4.3
|
||||
|
||||
1/24
|
||||
----
|
||||
Makefile.in,shlib/Makefile.in
|
||||
- changes for new file, text.c, with character and text handling
|
||||
functions from readline.c
|
||||
|
||||
2/20
|
||||
----
|
||||
{configure.config.h}.in
|
||||
- call AC_C_CHAR_UNSIGNED, define __CHAR_UNSIGNED__ if chars are
|
||||
unsigned by default
|
||||
|
||||
5/20
|
||||
----
|
||||
doc/Makefile.in
|
||||
- new maybe-clean target that removes the generated documentation if
|
||||
the build directory differs from the source directory
|
||||
- distclean target now depends on maybe-clean
|
||||
|
|
@ -0,0 +1,612 @@
|
|||
This document details the changes between this version, readline-4.3,
|
||||
and the previous version, readline-4.2a.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. Fixed output of comment-begin character when listing variable values.
|
||||
|
||||
b. Added some default key bindings for common escape sequences produced by
|
||||
HOME and END keys.
|
||||
|
||||
c. Fixed the mark handling code to be more emacs-compatible.
|
||||
|
||||
d. A bug was fixed in the code that prints possible completions to keep it
|
||||
from printing empty strings in certain circumstances.
|
||||
|
||||
e. Change the key sequence printing code to print ESC as M\- if ESC is a
|
||||
meta-prefix character -- it's easier for users to understand than \e.
|
||||
|
||||
f. Fixed unstifle_history() to return values that match the documentation.
|
||||
|
||||
g. Fixed the event loop (rl_event_hook) to handle the case where the input
|
||||
file descriptor is invalidated.
|
||||
|
||||
h. Fixed the prompt display code to work better when the application has a
|
||||
custom redisplay function.
|
||||
|
||||
i. Changes to make reading and writing the history file a little faster, and
|
||||
to cope with huge history files without calling abort(3) from xmalloc.
|
||||
|
||||
j. The vi-mode `S' and `s' commands are now undone correctly.
|
||||
|
||||
k. Fixed a problem which caused the display to be messed up when the last
|
||||
line of a multi-line prompt (possibly containing invisible characters)
|
||||
was longer than the screen width.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both
|
||||
be bound to readline functions. Now the arrow keys may be used in vi
|
||||
insert mode.
|
||||
|
||||
b. When listing completions, and the number of lines displayed is more than
|
||||
the screen length, readline uses an internal pager to display the results.
|
||||
This is controlled by the `page-completions' variable (default on).
|
||||
|
||||
c. New code to handle editing and displaying multibyte characters.
|
||||
|
||||
d. The behavior introduced in bash-2.05a of deciding whether or not to
|
||||
append a slash to a completed name that is a symlink to a directory has
|
||||
been made optional, controlled by the `mark-symlinked-directories'
|
||||
variable (default is the 2.05a behavior).
|
||||
|
||||
e. The `insert-comment' command now acts as a toggle if given a numeric
|
||||
argument: if the first characters on the line don't specify a
|
||||
comment, insert one; if they do, delete the comment text
|
||||
|
||||
f. New application-settable completion variable:
|
||||
rl_completion_mark_symlink_dirs, allows an application's completion
|
||||
function to temporarily override the user's preference for appending
|
||||
slashes to names which are symlinks to directories.
|
||||
|
||||
g. New function available to application completion functions:
|
||||
rl_completion_mode, to tell how the completion function was invoked
|
||||
and decide which argument to supply to rl_complete_internal (to list
|
||||
completions, etc.).
|
||||
|
||||
h. Readline now has an overwrite mode, toggled by the `overwrite-mode'
|
||||
bindable command, which could be bound to `Insert'.
|
||||
|
||||
i. New application-settable completion variable:
|
||||
rl_completion_suppress_append, inhibits appending of
|
||||
rl_completion_append_character to completed words.
|
||||
|
||||
j. New key bindings when reading an incremental search string: ^W yanks
|
||||
the currently-matched word out of the current line into the search
|
||||
string; ^Y yanks the rest of the current line into the search string,
|
||||
DEL or ^H deletes characters from the search string.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.2a,
|
||||
and the previous version, readline-4.2.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. More `const' and type casting fixes.
|
||||
|
||||
b. Changed rl_message() to use vsnprintf(3) (if available) to fix buffer
|
||||
overflow problems.
|
||||
|
||||
c. The completion code no longer appends a `/' or ` ' to a match when
|
||||
completing a symbolic link that resolves to a directory name, unless
|
||||
the match does not add anything to the word being completed. This
|
||||
means that a tab will complete the word up to the full name, but not
|
||||
add anything, and a subsequent tab will add a slash.
|
||||
|
||||
d. Fixed a trivial typo that made the vi-mode `dT' command not work.
|
||||
|
||||
e. Fixed the tty code so that ^S and ^Q can be inserted with rl_quoted_insert.
|
||||
|
||||
f. Fixed the tty code so that ^V works more than once.
|
||||
|
||||
g. Changed the use of __P((...)) for function prototypes to PARAMS((...))
|
||||
because the use of __P in typedefs conflicted g++ and glibc.
|
||||
|
||||
h. The completion code now attempts to do a better job of preserving the
|
||||
case of the word the user typed if ignoring case in completions.
|
||||
|
||||
i. Readline defaults to not echoing the input and lets the terminal
|
||||
initialization code enable echoing if there is a controlling terminal.
|
||||
|
||||
j. The key binding code now processes only two hex digits after a `\x'
|
||||
escape sequence, and the documentation was changed to note that the
|
||||
octal and hex escape sequences result in an eight-bit value rather
|
||||
than strict ASCII.
|
||||
|
||||
k. Fixed a few places where negative array subscripts could have occurred.
|
||||
|
||||
l. Fixed the vi-mode code to use a better method to determine the bounds of
|
||||
the array used to hold the marks, and to avoid out-of-bounds references.
|
||||
|
||||
m. Fixed the defines in chardefs.h to work better when chars are signed.
|
||||
|
||||
n. Fixed configure.in to use the new names for bash autoconf macros.
|
||||
|
||||
o. Readline no longer attempts to define its own versions of some ctype
|
||||
macros if they are implemented as functions in libc but not as macros in
|
||||
<ctype.h>.
|
||||
|
||||
p. Fixed a problem where rl_backward could possibly set point to before
|
||||
the beginning of the line.
|
||||
|
||||
q. Fixed Makefile to not put -I/usr/include into CFLAGS, since it can cause
|
||||
include file problems.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. Added extern declaration for rl_get_termcap to readline.h, making it a
|
||||
public function (it was always there, just not in readline.h).
|
||||
|
||||
b. New #defines in readline.h: RL_READLINE_VERSION, currently 0x0402,
|
||||
RL_VERSION_MAJOR, currently 4, and RL_VERSION_MINOR, currently 2.
|
||||
|
||||
c. New readline variable: rl_readline_version, mirrors RL_READLINE_VERSION.
|
||||
|
||||
d. New bindable boolean readline variable: match-hidden-files. Controls
|
||||
completion of files beginning with a `.' (on Unix). Enabled by default.
|
||||
|
||||
e. The history expansion code now allows any character to terminate a
|
||||
`:first-' modifier, like csh.
|
||||
|
||||
f. The incremental search code remembers the last search string and uses
|
||||
it if ^R^R is typed without a search string.
|
||||
|
||||
h. New bindable variable `history-preserve-point'. If set, the history
|
||||
code attempts to place the user at the same location on each history
|
||||
line retrived with previous-history or next-history.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.2,
|
||||
and the previous version, readline-4.1.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. When setting the terminal attributes on systems using `struct termio',
|
||||
readline waits for output to drain before changing the attributes.
|
||||
|
||||
b. A fix was made to the history word tokenization code to avoid attempts to
|
||||
dereference a null pointer.
|
||||
|
||||
c. Readline now defaults rl_terminal_name to $TERM if the calling application
|
||||
has left it unset, and tries to initialize with the resultant value.
|
||||
|
||||
d. Instead of calling (*rl_getc_function)() directly to get input in certain
|
||||
places, readline now calls rl_read_key() consistently.
|
||||
|
||||
e. Fixed a bug in the completion code that allowed a backslash to quote a
|
||||
single quote inside a single-quoted string.
|
||||
|
||||
f. rl_prompt is no longer assigned directly from the argument to readline(),
|
||||
but uses memory allocated by readline. This allows constant strings to
|
||||
be passed to readline without problems arising when the prompt processing
|
||||
code wants to modify the string.
|
||||
|
||||
g. Fixed a bug that caused non-interactive history searches to return the
|
||||
wrong line when performing multiple searches backward for the same string.
|
||||
|
||||
h. Many variables, function arguments, and function return values are now
|
||||
declared `const' where appropriate, to improve behavior when linking with
|
||||
C++ code.
|
||||
|
||||
i. The control character detection code now works better on systems where
|
||||
`char' is unsigned by default.
|
||||
|
||||
j. The vi-mode numeric argument is now capped at 999999, just like emacs mode.
|
||||
|
||||
k. The Function, CPFunction, CPPFunction, and VFunction typedefs have been
|
||||
replaced with a set of specific prototyped typedefs, though they are
|
||||
still in the readline header files for backwards compatibility.
|
||||
|
||||
m. Nearly all of the (undocumented) internal global variables in the library
|
||||
now have an _rl_ prefix -- there were a number that did not, like
|
||||
screenheight, screenwidth, alphabetic, etc.
|
||||
|
||||
n. The ding() convenience function has been renamed to rl_ding(), though the
|
||||
old function is still defined for backwards compatibility.
|
||||
|
||||
o. The completion convenience functions filename_completion_function,
|
||||
username_completion_function, and completion_matches now have an rl_
|
||||
prefix, though the old names are still defined for backwards compatibility.
|
||||
|
||||
p. The functions shared by readline and bash (linkage is satisfied from bash
|
||||
when compiling with bash, and internally otherwise) now have an sh_ prefix.
|
||||
|
||||
q. Changed the shared library creation procedure on Linux and BSD/OS 4.x so
|
||||
that the `soname' contains only the major version number rather than the
|
||||
major and minor numbers.
|
||||
|
||||
r. Fixed a redisplay bug that occurred when the prompt spanned more than one
|
||||
physical line and contained invisible characters.
|
||||
|
||||
s. Added a missing `includedir' variable to the Makefile.
|
||||
|
||||
t. When installing the shared libraries, make sure symbolic links are relative.
|
||||
|
||||
u. Added configure test so that it can set `${MAKE}' appropriately.
|
||||
|
||||
v. Fixed a bug in rl_forward that could cause the point to be set to before
|
||||
the beginning of the line in vi mode.
|
||||
|
||||
w. Fixed a bug in the callback read-char interface to make it work when a
|
||||
readline function pushes some input onto the input stream with
|
||||
rl_execute_next (like the incremental search functions).
|
||||
|
||||
x. Fixed a file descriptor leak in the history file manipulation code that
|
||||
was tripped when attempting to truncate a non-regular file (like
|
||||
/dev/null).
|
||||
|
||||
y. Changes to make all of the exported readline functions declared in
|
||||
readline.h have an rl_ prefix (rltty_set_default_bindings is now
|
||||
rl_tty_set_default_bindings, crlf is now rl_crlf, etc.)
|
||||
|
||||
z. The formatted documentation included in the base readline distribution
|
||||
is no longer removed on a `make distclean'.
|
||||
|
||||
aa. Some changes were made to avoid gcc warnings with -Wall.
|
||||
|
||||
bb. rl_get_keymap_by_name now finds keymaps case-insensitively, so
|
||||
`set keymap EMACS' works.
|
||||
|
||||
cc. The history file writing and truncation functions now return a useful
|
||||
status on error.
|
||||
|
||||
dd. Fixed a bug that could cause applications to dereference a NULL pointer
|
||||
if a NULL second argument was passed to history_expand().
|
||||
|
||||
ee. If a hook function assigned to rl_event_hook sets rl_done to a non-zero
|
||||
value, rl_read_key() now immediately returns '\n' (which is assumed to
|
||||
be bound to accept-line).
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. The blink timeout for paren matching is now settable by applications,
|
||||
via the rl_set_paren_blink_timeout() function.
|
||||
|
||||
b. _rl_executing_macro has been renamed to rl_executing_macro, which means
|
||||
it's now part of the public interface.
|
||||
|
||||
c. Readline has a new variable, rl_readline_state, which is a bitmap that
|
||||
encapsulates the current state of the library; intended for use by
|
||||
callbacks and hook functions.
|
||||
|
||||
d. rlfe has a new -l option to log input and output (-a appends to logfile),
|
||||
a new -n option to set the readline application name, and -v and -h
|
||||
options for version and help information.
|
||||
|
||||
e. rlfe can now perform filename completion for the inferior process if the
|
||||
OS has a /proc/<PID>/cwd that can be read with readlink(2) to get the
|
||||
inferior's current working directory.
|
||||
|
||||
f. A new file, rltypedefs.h, contains the new typedefs for function pointers
|
||||
and is installed by `make install'.
|
||||
|
||||
g. New application-callable function rl_set_prompt(const char *prompt):
|
||||
expands its prompt string argument and sets rl_prompt to the result.
|
||||
|
||||
h. New application-callable function rl_set_screen_size(int rows, int cols):
|
||||
public method for applications to set readline's idea of the screen
|
||||
dimensions.
|
||||
|
||||
i. The history example program (examples/histexamp.c) is now built as one
|
||||
of the examples.
|
||||
|
||||
j. The documentation has been updated to cover nearly all of the public
|
||||
functions and variables declared in readline.h.
|
||||
|
||||
k. New function, rl_get_screen_size (int *rows, int *columns), returns
|
||||
readline's idea of the screen dimensions.
|
||||
|
||||
l. The timeout in rl_gather_tyi (readline keyboard input polling function)
|
||||
is now settable via a function (rl_set_keyboard_input_timeout()).
|
||||
|
||||
m. Renamed the max_input_history variable to history_max_entries; the old
|
||||
variable is maintained for backwards compatibility.
|
||||
|
||||
n. The list of characters that separate words for the history tokenizer is
|
||||
now settable with a variable: history_word_delimiters. The default
|
||||
value is as before.
|
||||
|
||||
o. There is a new history.3 manual page documenting the history library.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.1,
|
||||
and the previous version, readline-4.0.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. Changed the HTML documents so that the table-of-contents is no longer
|
||||
a separate file.
|
||||
|
||||
b. Changes to the shared object configuration for: Irix 5.x, Irix 6.x,
|
||||
OSF/1.
|
||||
|
||||
c. The shared library major and minor versions are now constructed
|
||||
automatically by configure and substituted into the makefiles.
|
||||
|
||||
d. It's now possible to install the shared libraries separately from the
|
||||
static libraries.
|
||||
|
||||
e. The history library tries to truncate the history file only if it is a
|
||||
regular file.
|
||||
|
||||
f. A bug that caused _rl_dispatch to address negative array indices on
|
||||
systems with signed chars was fixed.
|
||||
|
||||
g. rl-yank-nth-arg now leaves the history position the same as when it was
|
||||
called.
|
||||
|
||||
h. Changes to the completion code to handle MS-DOS drive-letter:pathname
|
||||
filenames.
|
||||
|
||||
i. Completion is now case-insensitive by default on MS-DOS.
|
||||
|
||||
j. Fixes to the history file manipulation code for MS-DOS.
|
||||
|
||||
k. Readline attempts to bind the arrow keys to appropriate defaults on MS-DOS.
|
||||
|
||||
l. Some fixes were made to the redisplay code for better operation on MS-DOS.
|
||||
|
||||
m. The quoted-insert code will now insert tty special chars like ^C.
|
||||
|
||||
n. A bug was fixed that caused the display code to reference memory before
|
||||
the start of the prompt string.
|
||||
|
||||
o. More support for __EMX__ (OS/2).
|
||||
|
||||
p. A bug was fixed in readline's signal handling that could cause infinite
|
||||
recursion in signal handlers.
|
||||
|
||||
q. A bug was fixed that caused the point to be less than zero when rl_forward
|
||||
was given a very large numeric argument.
|
||||
|
||||
r. The vi-mode code now gets characters via the application-settable value
|
||||
of rl_getc_function rather than calling rl_getc directly.
|
||||
|
||||
s. The history file code now uses O_BINARY mode when reading and writing
|
||||
the history file on cygwin32.
|
||||
|
||||
t. Fixed a bug in the redisplay code for lines with more than 256 line
|
||||
breaks.
|
||||
|
||||
u. A bug was fixed which caused invisible character markers to not be
|
||||
stripped from the prompt string if the terminal was in no-echo mode.
|
||||
|
||||
v. Readline no longer tries to get the variables it needs for redisplay
|
||||
from the termcap entry if the calling application has specified its
|
||||
own redisplay function. Readline treats the terminal as `dumb' in
|
||||
this case.
|
||||
|
||||
w. Fixes to the SIGWINCH code so that a multiple-line prompt with escape
|
||||
sequences is redrawn correctly.
|
||||
|
||||
x. Changes to the install and install-shared targets so that the libraries
|
||||
and header files are installed separately.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. A new Readline `user manual' is in doc/rluserman.texinfo.
|
||||
|
||||
b. Parentheses matching is now always compiled into readline, and enabled
|
||||
or disabled when the value of the `blink-matching-paren' variable is
|
||||
changed.
|
||||
|
||||
c. MS-DOS systems now use ~/_inputrc as the last-ditch inputrc filename.
|
||||
|
||||
d. MS-DOS systems now use ~/_history as the default history file.
|
||||
|
||||
e. history-search-{forward,backward} now leave the point at the end of the
|
||||
line when the string to search for is empty, like
|
||||
{reverse,forward}-search-history.
|
||||
|
||||
f. history-search-{forward,backward} now leave the last history line found
|
||||
in the readline buffer if the second or subsequent search fails.
|
||||
|
||||
g. New function for use by applications: rl_on_new_line_with_prompt, used
|
||||
when an application displays the prompt itself before calling readline().
|
||||
|
||||
h. New variable for use by applications: rl_already_prompted. An application
|
||||
that displays the prompt itself before calling readline() must set this to
|
||||
a non-zero value.
|
||||
|
||||
i. A new variable, rl_gnu_readline_p, always 1. The intent is that an
|
||||
application can verify whether or not it is linked with the `real'
|
||||
readline library or some substitute.
|
||||
|
||||
j. Per Bothner's `rlfe' (pronounced `Ralphie') readline front-end program
|
||||
is included in the examples subdirectory, though it is not built
|
||||
by default.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.0,
|
||||
and the previous version, readline-2.2.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. The version number is now 4.0, to match the major and minor version
|
||||
numbers on the shared readline and history libraries. Future
|
||||
releases will maintain the identical numbering.
|
||||
|
||||
b. Fixed a typo in the `make install' recipe that copied libreadline.a
|
||||
to libhistory.old right after installing it.
|
||||
|
||||
c. The readline and history info files are now installed out of the source
|
||||
directory if they are not found in the build directory.
|
||||
|
||||
d. The library no longer exports a function named `savestring' -- backwards
|
||||
compatibility be damned.
|
||||
|
||||
e. There is no longer any #ifdef SHELL code in the source files.
|
||||
|
||||
f. Some changes were made to the key binding code to fix memory leaks and
|
||||
better support Win32 systems.
|
||||
|
||||
g. Fixed a silly typo in the paren matching code -- it's microseconds, not
|
||||
milliseconds.
|
||||
|
||||
h. The readline library should be compilable by C++ compilers.
|
||||
|
||||
i. The readline.h public header file now includes function prototypes for
|
||||
all readline functions, and some changes were made to fix errors in the
|
||||
source files uncovered by the use of prototypes.
|
||||
|
||||
j. The maximum numeric argument is now clamped at 1000000.
|
||||
|
||||
k. Fixes to rl_yank_last_arg to make it behave better.
|
||||
|
||||
l. Fixed a bug in the display code that caused core dumps if the prompt
|
||||
string length exceeded 1024 characters.
|
||||
|
||||
m. The menu completion code was fixed to properly insert a single completion
|
||||
if there is only one match.
|
||||
|
||||
n. A bug was fixed that caused the display code to improperly display tabs
|
||||
after newlines.
|
||||
|
||||
o. A fix was made to the completion code in which a typo caused the wrong
|
||||
value to be passed to the function that computed the longest common
|
||||
prefix of the list of matches.
|
||||
|
||||
p. The completion code now checks the value of rl_filename_completion_desired,
|
||||
which is set by application-supplied completion functions to indicate
|
||||
that filename completion is being performed, to decide whether or not to
|
||||
call an application-supplied `ignore completions' function.
|
||||
|
||||
q. Code was added to the history library to catch history substitutions
|
||||
using `&' without a previous history substitution or search having been
|
||||
performed.
|
||||
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. There is a new script, support/shobj-conf, to do system-specific shared
|
||||
object and library configuration. It generates variables for configure
|
||||
to substitute into makefiles. The README file provides a detailed
|
||||
explanation of the shared library creation process.
|
||||
|
||||
b. Shared libraries and objects are now built in the `shlib' subdirectory.
|
||||
There is a shlib/Makefile.in to control the build process. `make shared'
|
||||
from the top-level directory is still the right way to build shared
|
||||
versions of the libraries.
|
||||
|
||||
c. rlconf.h is now installed, so applications can find out which features
|
||||
have been compiled into the installed readline and history libraries.
|
||||
|
||||
d. rlstdc.h is now an installed header file.
|
||||
|
||||
e. Many changes to the signal handling:
|
||||
o Readline now catches SIGQUIT and cleans up the tty before returning;
|
||||
o A new variable, rl_catch_signals, is available to application writers
|
||||
to indicate to readline whether or not it should install its own
|
||||
signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP,
|
||||
SIGTTIN, and SIGTTOU;
|
||||
o A new variable, rl_catch_sigwinch, is available to application
|
||||
writers to indicate to readline whether or not it should install its
|
||||
own signal handler for SIGWINCH, which will chain to the calling
|
||||
applications's SIGWINCH handler, if one is installed;
|
||||
o There is a new function, rl_free_line_state, for application signal
|
||||
handlers to call to free up the state associated with the current
|
||||
line after receiving a signal;
|
||||
o There is a new function, rl_cleanup_after_signal, to clean up the
|
||||
display and terminal state after receiving a signal;
|
||||
o There is a new function, rl_reset_after_signal, to reinitialize the
|
||||
terminal and display state after an application signal handler
|
||||
returns and readline continues
|
||||
|
||||
f. There is a new function, rl_resize_terminal, to reset readline's idea of
|
||||
the screen size after a SIGWINCH.
|
||||
|
||||
g. New public functions: rl_save_prompt and rl_restore_prompt. These were
|
||||
previously private functions with a `_' prefix. These functions are
|
||||
used when an application wants to write a message to the `message area'
|
||||
with rl_message and have the prompt restored correctly when the message
|
||||
is erased.
|
||||
|
||||
h. New function hook: rl_pre_input_hook, called just before readline starts
|
||||
reading input, after initialization.
|
||||
|
||||
i. New function hook: rl_display_matches_hook, called when readline would
|
||||
display the list of completion matches. The new function
|
||||
rl_display_match_list is what readline uses internally, and is available
|
||||
for use by application functions called via this hook.
|
||||
|
||||
j. New bindable function, delete-char-or-list, like tcsh.
|
||||
|
||||
k. A new variable, rl_erase_empty_line, which, if set by an application using
|
||||
readline, will cause readline to erase, prompt and all, lines on which the
|
||||
only thing typed was a newline.
|
||||
|
||||
l. There is a new script, support/shlib-install, to install and uninstall
|
||||
the shared readline and history libraries.
|
||||
|
||||
m. A new bindable variable, `isearch-terminators', which is a string
|
||||
containing the set of characters that should terminate an incremental
|
||||
search without being executed as a command.
|
||||
|
||||
n. A new bindable function, forward-backward-delete-char.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-2.2,
|
||||
and the previous version, readline-2.1.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. Added a missing `extern' to a declaration in readline.h that kept
|
||||
readline from compiling cleanly on some systems.
|
||||
|
||||
b. The history file is now opened with mode 0600 when it is written for
|
||||
better security.
|
||||
|
||||
c. Changes were made to the SIGWINCH handling code so that prompt redisplay
|
||||
is done better.
|
||||
|
||||
d. ^G now interrupts incremental searches correctly.
|
||||
|
||||
e. A bug that caused a core dump when the set of characters to be quoted
|
||||
when completing words was empty was fixed.
|
||||
|
||||
f. Fixed a problem in the readline test program rltest.c that caused a core
|
||||
dump.
|
||||
|
||||
g. The code that handles parser directives in inputrc files now displays
|
||||
more error messages.
|
||||
|
||||
h. The history expansion code was fixed so that the appearance of the
|
||||
history comment character at the beginning of a word inhibits history
|
||||
expansion for that word and the rest of the input line.
|
||||
|
||||
i. The code that prints completion listings now behaves better if one or
|
||||
more of the filenames contains non-printable characters.
|
||||
|
||||
j. The time delay when showing matching parentheses is now 0.5 seconds.
|
||||
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. There is now an option for `iterative' yank-last-arg handline, so a user
|
||||
can keep entering `M-.', yanking the last argument of successive history
|
||||
lines.
|
||||
|
||||
b. New variable, `print-completions-horizontally', which causes completion
|
||||
matches to be displayed across the screen (like `ls -x') rather than up
|
||||
and down the screen (like `ls').
|
||||
|
||||
c. New variable, `completion-ignore-case', which causes filename completion
|
||||
and matching to be performed case-insensitively.
|
||||
|
||||
d. There is a new bindable command, `magic-space', which causes history
|
||||
expansion to be performed on the current readline buffer and a space to
|
||||
be inserted into the result.
|
||||
|
||||
e. There is a new bindable command, `menu-complete', which enables tcsh-like
|
||||
menu completion (successive executions of menu-complete insert a single
|
||||
completion match, cycling through the list of possible completions).
|
||||
|
||||
f. There is a new bindable command, `paste-from-clipboard', for use on Win32
|
||||
systems, to insert the text from the Win32 clipboard into the editing
|
||||
buffer.
|
||||
|
||||
g. The key sequence translation code now understands printf-style backslash
|
||||
escape sequences, including \NNN octal escapes. These escape sequences
|
||||
may be used in key sequence definitions or macro values.
|
||||
|
||||
h. An `$include' inputrc file parser directive has been added.
|
||||
|
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program 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 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
Basic Installation
|
||||
==================
|
||||
|
||||
These are installation instructions for Readline-4.3.
|
||||
|
||||
The simplest way to compile readline is:
|
||||
|
||||
1. `cd' to the directory containing the readline source code and type
|
||||
`./configure' to configure readline for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes some time. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile readline and build the static readline
|
||||
and history libraries. If supported, the shared readline and history
|
||||
libraries will be built also. See below for instructions on compiling
|
||||
the other parts of the distribution. Typing `make everything' will
|
||||
cause the static and shared libraries (if supported) and the example
|
||||
programs to be built.
|
||||
|
||||
3. Type `make install' to install the static readline and history
|
||||
libraries, the readline include files, the documentation, and, if
|
||||
supported, the shared readline and history libraries.
|
||||
|
||||
4. You can remove the created libraries and object files from the
|
||||
build directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile readline for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the readline developers, and should be used with care.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It
|
||||
uses those values to create a `Makefile' in the build directory,
|
||||
and Makefiles in the `doc', `shlib', and `examples'
|
||||
subdirectories. It also creates a `config.h' file containing
|
||||
system-dependent definitions. Finally, it creates a shell script
|
||||
`config.status' that you can run in the future to recreate the
|
||||
current configuration, a file `config.cache' that saves the
|
||||
results of its tests to speed up reconfiguring, and a file
|
||||
`config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
If you need to do unusual things to compile readline, please try
|
||||
to figure out how `configure' could check whether to do them, and
|
||||
mail diffs or instructions to <bug-readline@gnu.org> so they can
|
||||
be considered for the next release. If at some point
|
||||
`config.cache' contains results you don't want to keep, you may
|
||||
remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a
|
||||
program called `autoconf'. You only need `configure.in' if you
|
||||
want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'. The readline `configure.in' requires autoconf
|
||||
version 2.50 or newer.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile readline for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not supports the `VPATH'
|
||||
variable, you have to compile readline for one architecture at a
|
||||
time in the source code directory. After you have installed
|
||||
readline for one architecture, use `make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the readline libraries in
|
||||
`/usr/local/lib', the include files in
|
||||
`/usr/local/include/readline', the man pages in `/usr/local/man',
|
||||
and the info files in `/usr/local/info'. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure'
|
||||
the option `--prefix=PATH' or by supplying a value for the
|
||||
DESTDIR variable when running `make install'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files.
|
||||
If you give `configure' the option `--exec-prefix=PATH', the
|
||||
readline Makefiles will use PATH as the prefix for installing the
|
||||
libraries. Documentation and other data files will still use the
|
||||
regular prefix.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but need to determine by the type of host readline
|
||||
will run on. Usually `configure' can figure that out, but if it
|
||||
prints a message saying it can not guess the host type, give it
|
||||
the `--host=TYPE' option. TYPE can either be a short name for
|
||||
the system type, such as `sun4', or a canonical name with three
|
||||
fields: CPU-COMPANY-SYSTEM (e.g., i386-unknown-freebsd4.2).
|
||||
|
||||
See the file `config.sub' for the possible values of each field.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: the readline `configure' looks for a site script, but not
|
||||
all `configure' scripts do.
|
||||
|
||||
Operation Controls
|
||||
==================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Use and save the results of the tests in FILE instead of
|
||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||
debugging `configure'.
|
||||
|
||||
`--help'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made.
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
The readline `configure' recognizes a single `--with-PACKAGE' option:
|
||||
|
||||
`--with-curses'
|
||||
This tells readline that it can find the termcap library functions
|
||||
(tgetent, et al.) in the curses library, rather than a separate
|
||||
termcap library. Readline uses the termcap functions, but does not
|
||||
link with the termcap or curses library itself, allowing applications
|
||||
which link with readline the to choose an appropriate library.
|
||||
This option tells readline to link the example programs with the
|
||||
curses library rather than libtermcap.
|
||||
|
||||
`configure' also recognizes two `--enable-FEATURE' options:
|
||||
|
||||
`--enable-shared'
|
||||
Build the shared libraries by default on supported platforms. The
|
||||
default is `yes'.
|
||||
|
||||
`--enable-static'
|
||||
Build the static libraries by default. The default is `yes'.
|
||||
|
||||
Shared Libraries
|
||||
================
|
||||
|
||||
There is support for building shared versions of the readline and
|
||||
history libraries. The configure script creates a Makefile in
|
||||
the `shlib' subdirectory, and typing `make shared' will cause
|
||||
shared versions of the readline and history libraries to be built
|
||||
on supported platforms.
|
||||
|
||||
If `configure' is given the `--enable-shared' option, it will attempt
|
||||
to build the shared libraries by default on supported platforms.
|
||||
|
||||
Configure calls the script support/shobj-conf to test whether or
|
||||
not shared library creation is supported and to generate the values
|
||||
of variables that are substituted into shlib/Makefile. If you
|
||||
try to build shared libraries on an unsupported platform, `make'
|
||||
will display a message asking you to update support/shobj-conf for
|
||||
your platform.
|
||||
|
||||
If you need to update support/shobj-conf, you will need to create
|
||||
a `stanza' for your operating system and compiler. The script uses
|
||||
the value of host_os and ${CC} as determined by configure. For
|
||||
instance, FreeBSD 4.2 with any version of gcc is identified as
|
||||
`freebsd4.2-gcc*'.
|
||||
|
||||
In the stanza for your operating system-compiler pair, you will need to
|
||||
define several variables. They are:
|
||||
|
||||
SHOBJ_CC The C compiler used to compile source files into shareable
|
||||
object files. This is normally set to the value of ${CC}
|
||||
by configure, and should not need to be changed.
|
||||
|
||||
SHOBJ_CFLAGS Flags to pass to the C compiler ($SHOBJ_CC) to create
|
||||
position-independent code. If you are using gcc, this
|
||||
should probably be set to `-fpic'.
|
||||
|
||||
SHOBJ_LD The link editor to be used to create the shared library from
|
||||
the object files created by $SHOBJ_CC. If you are using
|
||||
gcc, a value of `gcc' will probably work.
|
||||
|
||||
SHOBJ_LDFLAGS Flags to pass to SHOBJ_LD to enable shared object creation.
|
||||
If you are using gcc, `-shared' may be all that is necessary.
|
||||
These should be the flags needed for generic shared object
|
||||
creation.
|
||||
|
||||
SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
|
||||
creation. Many systems use the -R option to the link
|
||||
editor to embed a path within the library for run-time
|
||||
library searches. A reasonable value for such systems would
|
||||
be `-R$(libdir)'.
|
||||
|
||||
SHLIB_LIBS Any additional libraries that shared libraries should be
|
||||
linked against when they are created.
|
||||
|
||||
SHLIB_LIBSUFF The suffix to add to `libreadline' and `libhistory' when
|
||||
generating the filename of the shared library. Many systems
|
||||
use `so'; HP-UX uses `sl'.
|
||||
|
||||
SHLIB_LIBVERSION The string to append to the filename to indicate the version
|
||||
of the shared library. It should begin with $(SHLIB_LIBSUFF),
|
||||
and possibly include version information that allows the
|
||||
run-time loader to load the version of the shared library
|
||||
appropriate for a particular program. Systems using shared
|
||||
libraries similar to SunOS 4.x use major and minor library
|
||||
version numbers; for those systems a value of
|
||||
`$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' is appropriate.
|
||||
Systems based on System V Release 4 don't use minor version
|
||||
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
|
||||
Other Unix versions use different schemes.
|
||||
|
||||
SHLIB_STATUS Set this to `supported' when you have defined the other
|
||||
necessary variables. Make uses this to determine whether
|
||||
or not shared library creation should be attempted. If
|
||||
shared libraries are not supported, this will be set to
|
||||
`unsupported'.
|
||||
|
||||
You should look at the existing stanzas in support/shobj-conf for ideas.
|
||||
|
||||
Once you have updated support/shobj-conf, re-run configure and type
|
||||
`make shared' or `make'. The shared libraries will be created in the
|
||||
shlib subdirectory.
|
||||
|
||||
If shared libraries are created, `make install' will install them.
|
||||
You may install only the shared libraries by running `make
|
||||
install-shared' from the top-level build directory. Running `make
|
||||
install' in the shlib subdirectory will also work. If you don't want
|
||||
to install any created shared libraries, run `make install-static'.
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
#
|
||||
# Master distribution manifest for the standalone readline distribution
|
||||
#
|
||||
doc d
|
||||
examples d
|
||||
support d
|
||||
shlib d
|
||||
COPYING f
|
||||
README f
|
||||
MANIFEST f
|
||||
INSTALL f
|
||||
CHANGELOG f
|
||||
CHANGES f
|
||||
USAGE f
|
||||
aclocal.m4 f
|
||||
config.h.in f
|
||||
configure f
|
||||
configure.in f
|
||||
Makefile.in f
|
||||
ansi_stdlib.h f
|
||||
chardefs.h f
|
||||
history.h f
|
||||
histlib.h f
|
||||
keymaps.h f
|
||||
posixdir.h f
|
||||
posixjmp.h f
|
||||
posixstat.h f
|
||||
readline.h f
|
||||
rlconf.h f
|
||||
rldefs.h f
|
||||
rlmbutil.h f
|
||||
rlprivate.h f
|
||||
rlshell.h f
|
||||
rlstdc.h f
|
||||
rltty.h f
|
||||
rltypedefs.h f
|
||||
rlwinsize.h f
|
||||
tcap.h f
|
||||
tilde.h f
|
||||
xmalloc.h f
|
||||
bind.c f
|
||||
callback.c f
|
||||
compat.c f
|
||||
complete.c f
|
||||
display.c f
|
||||
emacs_keymap.c f
|
||||
funmap.c f
|
||||
input.c f
|
||||
isearch.c f
|
||||
keymaps.c f
|
||||
kill.c f
|
||||
macro.c f
|
||||
mbutil.c f
|
||||
misc.c f
|
||||
nls.c f
|
||||
parens.c f
|
||||
readline.c f
|
||||
rltty.c f
|
||||
savestring.c f
|
||||
search.c f
|
||||
shell.c f
|
||||
signals.c f
|
||||
terminal.c f
|
||||
text.c f
|
||||
tilde.c f
|
||||
undo.c f
|
||||
util.c f
|
||||
vi_keymap.c f
|
||||
vi_mode.c f
|
||||
xmalloc.c f
|
||||
history.c f
|
||||
histexpand.c f
|
||||
histfile.c f
|
||||
histsearch.c f
|
||||
shlib/Makefile.in f
|
||||
support/config.guess f
|
||||
support/config.sub f
|
||||
support/install.sh f
|
||||
support/mkdirs f
|
||||
support/mkdist f
|
||||
support/shobj-conf f
|
||||
support/shlib-install f
|
||||
support/wcwidth.c f
|
||||
doc/Makefile.in f
|
||||
doc/texinfo.tex f
|
||||
doc/manvers.texinfo f
|
||||
doc/rlman.texinfo f
|
||||
doc/rltech.texinfo f
|
||||
doc/rluser.texinfo f
|
||||
doc/rluserman.texinfo f
|
||||
doc/hist.texinfo f
|
||||
doc/hstech.texinfo f
|
||||
doc/hsuser.texinfo f
|
||||
doc/readline.3 f
|
||||
doc/history.3 f
|
||||
doc/texi2dvi f
|
||||
doc/texi2html f
|
||||
examples/Makefile.in f
|
||||
examples/excallback.c f
|
||||
examples/fileman.c f
|
||||
examples/manexamp.c f
|
||||
examples/readlinebuf.h f
|
||||
examples/rlcat.c f
|
||||
examples/rlfe.c f
|
||||
examples/rltest.c f
|
||||
examples/rl.c f
|
||||
examples/rlversion.c f
|
||||
examples/histexamp.c f
|
||||
examples/Inputrc f
|
||||
# formatted documentation, from MANIFEST.doc
|
||||
doc/readline.ps f
|
||||
doc/history.ps f
|
||||
doc/rluserman.ps f
|
||||
doc/readline.dvi f
|
||||
doc/history.dvi f
|
||||
doc/rluserman.dvi f
|
||||
doc/readline.info f
|
||||
doc/history.info f
|
||||
doc/rluserman.info f
|
||||
doc/readline.html f
|
||||
doc/history.html f
|
||||
doc/rluserman.html f
|
||||
doc/readline.0 f
|
||||
doc/history.0 f
|
||||
doc/readline_3.ps f
|
||||
doc/history_3.ps f
|
||||
|
|
@ -0,0 +1,520 @@
|
|||
## -*- text -*- ##
|
||||
# Master Makefile for the GNU readline library.
|
||||
# Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
# This program 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.
|
||||
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
RL_LIBRARY_VERSION = @LIBVERSION@
|
||||
RL_LIBRARY_NAME = readline
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
CC = @CC@
|
||||
RANLIB = @RANLIB@
|
||||
AR = @AR@
|
||||
ARFLAGS = @ARFLAGS@
|
||||
RM = rm -f
|
||||
CP = cp
|
||||
MV = mv
|
||||
|
||||
@SET_MAKE@
|
||||
SHELL = @MAKE_SHELL@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
|
||||
infodir = @infodir@
|
||||
|
||||
man3dir = $(mandir)/man3
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
||||
# Programs to make tags files.
|
||||
ETAGS = etags -tw
|
||||
CTAGS = ctags -tw
|
||||
|
||||
CFLAGS = @CFLAGS@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
DEFS = @DEFS@
|
||||
LOCAL_DEFS = @LOCAL_DEFS@
|
||||
|
||||
TERMCAP_LIB = @TERMCAP_LIB@
|
||||
|
||||
# For libraries which include headers from other libraries.
|
||||
INCLUDES = -I. -I$(srcdir)
|
||||
|
||||
XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES)
|
||||
CCFLAGS = $(XCCFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
|
||||
|
||||
# could add -Werror here
|
||||
GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \
|
||||
-Wwrite-strings -Wstrict-prototypes \
|
||||
-Wmissing-prototypes -Wno-implicit -pedantic
|
||||
GCC_LINT_CFLAGS = $(XCCFLAGS) $(GCC_LINT_FLAGS) @CFLAGS@ @LOCAL_CFLAGS@
|
||||
|
||||
.c.o:
|
||||
${RM} $@
|
||||
$(CC) -c $(CCFLAGS) $<
|
||||
|
||||
# The name of the main library target.
|
||||
LIBRARY_NAME = libreadline.a
|
||||
STATIC_LIBS = libreadline.a libhistory.a
|
||||
|
||||
# The C code source files for this library.
|
||||
CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
|
||||
$(srcdir)/vi_mode.c $(srcdir)/parens.c $(srcdir)/rltty.c \
|
||||
$(srcdir)/complete.c $(srcdir)/bind.c $(srcdir)/isearch.c \
|
||||
$(srcdir)/display.c $(srcdir)/signals.c $(srcdir)/emacs_keymap.c \
|
||||
$(srcdir)/vi_keymap.c $(srcdir)/util.c $(srcdir)/kill.c \
|
||||
$(srcdir)/undo.c $(srcdir)/macro.c $(srcdir)/input.c \
|
||||
$(srcdir)/callback.c $(srcdir)/terminal.c $(srcdir)/xmalloc.c \
|
||||
$(srcdir)/history.c $(srcdir)/histsearch.c $(srcdir)/histexpand.c \
|
||||
$(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
|
||||
$(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
|
||||
$(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \
|
||||
$(srcdir)/mbutil.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
|
||||
posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
|
||||
ansi_stdlib.h tcap.h rlstdc.h xmalloc.h rlprivate.h rlshell.h \
|
||||
rltypedefs.h rlmbutil.h
|
||||
|
||||
HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o mbutil.o
|
||||
TILDEOBJ = tilde.o
|
||||
OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
|
||||
rltty.o complete.o bind.o isearch.o display.o signals.o \
|
||||
util.o kill.o undo.o macro.o input.o callback.o terminal.o \
|
||||
text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)
|
||||
|
||||
# The texinfo files which document this library.
|
||||
DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
|
||||
DOCOBJECT = doc/readline.dvi
|
||||
DOCSUPPORT = doc/Makefile
|
||||
DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT)
|
||||
|
||||
CREATED_MAKEFILES = Makefile doc/Makefile examples/Makefile shlib/Makefile
|
||||
CREATED_CONFIGURE = config.status config.h config.cache config.log \
|
||||
stamp-config stamp-h
|
||||
CREATED_TAGS = TAGS tags
|
||||
|
||||
INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h \
|
||||
rlstdc.h rlconf.h rltypedefs.h
|
||||
|
||||
##########################################################################
|
||||
TARGETS = @STATIC_TARGET@ @SHARED_TARGET@
|
||||
INSTALL_TARGETS = @STATIC_INSTALL_TARGET@ @SHARED_INSTALL_TARGET@
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
everything: all examples
|
||||
|
||||
static: $(STATIC_LIBS)
|
||||
|
||||
libreadline.a: $(OBJECTS)
|
||||
$(RM) $@
|
||||
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
||||
-test -n "$(RANLIB)" && $(RANLIB) $@
|
||||
|
||||
libhistory.a: $(HISTOBJ) xmalloc.o
|
||||
$(RM) $@
|
||||
$(AR) $(ARFLAGS) $@ $(HISTOBJ) xmalloc.o
|
||||
-test -n "$(RANLIB)" && $(RANLIB) $@
|
||||
|
||||
# Since tilde.c is shared between readline and bash, make sure we compile
|
||||
# it with the right flags when it's built as part of readline
|
||||
tilde.o: tilde.c
|
||||
rm -f $@
|
||||
$(CC) $(CCFLAGS) -DREADLINE_LIBRARY -c $(srcdir)/tilde.c
|
||||
|
||||
readline: $(OBJECTS) readline.h rldefs.h chardefs.h ./libreadline.a
|
||||
$(CC) $(CCFLAGS) -o $@ ./examples/rl.c ./libreadline.a ${TERMCAP_LIB}
|
||||
|
||||
lint: force
|
||||
$(MAKE) $(MFLAGS) CCFLAGS='$(GCC_LINT_CFLAGS)' static
|
||||
|
||||
Makefile makefile: config.status $(srcdir)/Makefile.in
|
||||
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
Makefiles makefiles: config.status $(srcdir)/Makefile.in
|
||||
@for mf in $(CREATED_MAKEFILES); do \
|
||||
CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status ; \
|
||||
done
|
||||
|
||||
config.status: configure
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
config.h: stamp-h
|
||||
|
||||
stamp-h: config.status $(srcdir)/config.h.in
|
||||
CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
|
||||
echo > $@
|
||||
|
||||
#$(srcdir)/configure: $(srcdir)/configure.in ## Comment-me-out in distribution
|
||||
# cd $(srcdir) && autoconf ## Comment-me-out in distribution
|
||||
|
||||
|
||||
shared: force
|
||||
-test -d shlib || mkdir shlib
|
||||
-( cd shlib ; ${MAKE} ${MFLAGS} all )
|
||||
|
||||
documentation: force
|
||||
-test -d doc || mkdir doc
|
||||
-( cd doc && $(MAKE) $(MFLAGS) )
|
||||
|
||||
examples: force
|
||||
-test -d examples || mkdir examples
|
||||
-(cd examples && ${MAKE} ${MFLAGS} all )
|
||||
|
||||
force:
|
||||
|
||||
install-headers: installdirs ${INSTALLED_HEADERS}
|
||||
for f in ${INSTALLED_HEADERS}; do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(includedir)/readline ; \
|
||||
done
|
||||
|
||||
uninstall-headers:
|
||||
-test -n "$(includedir)" && cd $(DESTDIR)$(includedir)/readline && \
|
||||
${RM} ${INSTALLED_HEADERS}
|
||||
|
||||
maybe-uninstall-headers: uninstall-headers
|
||||
|
||||
install: $(INSTALL_TARGETS)
|
||||
|
||||
install-static: installdirs $(STATIC_LIBS) install-headers
|
||||
-$(MV) $(DESTDIR)$(libdir)/libreadline.a $(DESTDIR)$(libdir)/libreadline.old
|
||||
$(INSTALL_DATA) libreadline.a $(DESTDIR)$(libdir)/libreadline.a
|
||||
-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libreadline.a
|
||||
-$(MV) $(DESTDIR)$(libdir)/libhistory.a $(DESTDIR)$(libdir)/libhistory.old
|
||||
$(INSTALL_DATA) libhistory.a $(DESTDIR)$(libdir)/libhistory.a
|
||||
-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libhistory.a
|
||||
-( if test -d doc ; then \
|
||||
cd doc && \
|
||||
${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} install; \
|
||||
fi )
|
||||
|
||||
installdirs: $(srcdir)/support/mkdirs
|
||||
-$(SHELL) $(srcdir)/support/mkdirs $(DESTDIR)$(includedir) \
|
||||
$(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
|
||||
|
||||
uninstall: uninstall-headers
|
||||
-test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
|
||||
${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS)
|
||||
-( if test -d doc ; then \
|
||||
cd doc && \
|
||||
${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} $@; \
|
||||
fi )
|
||||
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
|
||||
|
||||
install-shared: installdirs install-headers shared
|
||||
-( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
|
||||
|
||||
uninstall-shared: maybe-uninstall-headers
|
||||
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
|
||||
|
||||
TAGS: force
|
||||
$(ETAGS) $(CSOURCES) $(HSOURCES)
|
||||
|
||||
tags: force
|
||||
$(CTAGS) $(CSOURCES) $(HSOURCES)
|
||||
|
||||
clean: force
|
||||
$(RM) $(OBJECTS) $(STATIC_LIBS)
|
||||
$(RM) readline readline.exe
|
||||
-( cd shlib && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd doc && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd examples && $(MAKE) $(MFLAGS) $@ )
|
||||
|
||||
mostlyclean: clean
|
||||
-( cd shlib && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd doc && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd examples && $(MAKE) $(MFLAGS) $@ )
|
||||
|
||||
distclean maintainer-clean: clean
|
||||
-( cd shlib && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd doc && $(MAKE) $(MFLAGS) $@ )
|
||||
-( cd examples && $(MAKE) $(MFLAGS) $@ )
|
||||
$(RM) Makefile
|
||||
$(RM) $(CREATED_CONFIGURE)
|
||||
$(RM) $(CREATED_TAGS)
|
||||
|
||||
info dvi:
|
||||
-( cd doc && $(MAKE) $(MFLAGS) $@ )
|
||||
|
||||
install-info:
|
||||
check:
|
||||
installcheck:
|
||||
|
||||
dist: force
|
||||
@echo Readline distributions are created using $(srcdir)/support/mkdist.
|
||||
@echo Here is a sample of the necessary commands:
|
||||
@echo bash $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r $(RL_LIBRARY_NAME) $(RL_LIBRARY_VERSION)
|
||||
@echo tar cf $(RL_LIBRARY_NAME)-${RL_LIBRARY_VERSION}.tar ${RL_LIBRARY_NAME}-$(RL_LIBRARY_VERSION)
|
||||
@echo gzip $(RL_LIBRARY_NAME)-$(RL_LIBRARY_VERSION).tar
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
||||
# Dependencies
|
||||
bind.o: ansi_stdlib.h posixstat.h
|
||||
bind.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
bind.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
|
||||
bind.o: history.h
|
||||
callback.o: rlconf.h
|
||||
callback.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
callback.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
|
||||
compat.o: rlstdc.h
|
||||
complete.o: ansi_stdlib.h posixdir.h posixstat.h
|
||||
complete.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
complete.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
|
||||
display.o: ansi_stdlib.h posixstat.h
|
||||
display.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
display.o: tcap.h
|
||||
display.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
display.o: history.h rlstdc.h
|
||||
funmap.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
funmap.o: rlconf.h ansi_stdlib.h rlstdc.h
|
||||
funmap.o: ${BUILD_DIR}/config.h
|
||||
histexpand.o: ansi_stdlib.h
|
||||
histexpand.o: history.h histlib.h rlstdc.h rltypedefs.h
|
||||
histexpand.o: ${BUILD_DIR}/config.h
|
||||
histfile.o: ansi_stdlib.h
|
||||
histfile.o: history.h histlib.h rlstdc.h rltypedefs.h
|
||||
histfile.o: ${BUILD_DIR}/config.h
|
||||
history.o: ansi_stdlib.h
|
||||
history.o: history.h histlib.h rlstdc.h rltypedefs.h
|
||||
history.o: ${BUILD_DIR}/config.h
|
||||
histsearch.o: ansi_stdlib.h
|
||||
histsearch.o: history.h histlib.h rlstdc.h rltypedefs.h
|
||||
histsearch.o: ${BUILD_DIR}/config.h
|
||||
input.o: ansi_stdlib.h
|
||||
input.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
input.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
|
||||
isearch.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
isearch.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
isearch.o: ansi_stdlib.h history.h rlstdc.h
|
||||
keymaps.o: emacs_keymap.c vi_keymap.c
|
||||
keymaps.o: keymaps.h rltypedefs.h chardefs.h rlconf.h ansi_stdlib.h
|
||||
keymaps.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
keymaps.o: ${BUILD_DIR}/config.h rlstdc.h
|
||||
kill.o: ansi_stdlib.h
|
||||
kill.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
kill.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
kill.o: history.h rlstdc.h
|
||||
macro.o: ansi_stdlib.h
|
||||
macro.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
macro.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
macro.o: history.h rlstdc.h
|
||||
mbutil.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
mbutil.o: readline.h keymaps.h rltypedefs.h chardefs.h rlstdc.h
|
||||
misc.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
misc.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
misc.o: history.h rlstdc.h ansi_stdlib.h
|
||||
nls.o: ansi_stdlib.h
|
||||
nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
nls.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
nls.o: history.h rlstdc.h
|
||||
parens.o: rlconf.h
|
||||
parens.o: ${BUILD_DIR}/config.h
|
||||
parens.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
|
||||
readline.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
readline.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
readline.o: history.h rlstdc.h
|
||||
readline.o: posixstat.h ansi_stdlib.h posixjmp.h
|
||||
rltty.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
rltty.o: rltty.h
|
||||
rltty.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
|
||||
search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
search.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
search.o: ansi_stdlib.h history.h rlstdc.h
|
||||
shell.o: ${BUILD_DIR}/config.h
|
||||
shell.o: ansi_stdlib.h
|
||||
signals.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
signals.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
signals.o: history.h rlstdc.h
|
||||
terminal.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
terminal.o: tcap.h
|
||||
terminal.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
terminal.o: history.h rlstdc.h
|
||||
text.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
text.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
text.o: history.h rlstdc.h ansi_stdlib.h
|
||||
tilde.o: ansi_stdlib.h
|
||||
tilde.o: ${BUILD_DIR}/config.h
|
||||
tilde.o: tilde.h
|
||||
undo.o: ansi_stdlib.h
|
||||
undo.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
undo.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
undo.o: history.h rlstdc.h
|
||||
util.o: posixjmp.h ansi_stdlib.h
|
||||
util.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
util.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
|
||||
vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
|
||||
vi_mode.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
|
||||
vi_mode.o: history.h ansi_stdlib.h rlstdc.h
|
||||
xmalloc.o: ${BUILD_DIR}/config.h
|
||||
xmalloc.o: ansi_stdlib.h
|
||||
|
||||
bind.o: rlshell.h
|
||||
histfile.o: rlshell.h
|
||||
nls.o: rlshell.h
|
||||
readline.o: rlshell.h
|
||||
shell.o: rlshell.h
|
||||
terminal.o: rlshell.h
|
||||
histexpand.o: rlshell.h
|
||||
|
||||
bind.o: rlprivate.h
|
||||
callback.o: rlprivate.h
|
||||
complete.o: rlprivate.h
|
||||
display.o: rlprivate.h
|
||||
input.o: rlprivate.h
|
||||
isearch.o: rlprivate.h
|
||||
kill.o: rlprivate.h
|
||||
macro.o: rlprivate.h
|
||||
mbutil.o: rlprivate.h
|
||||
misc.o: rlprivate.h
|
||||
nls.o: rlprivate.h
|
||||
parens.o: rlprivate.h
|
||||
readline.o: rlprivate.h
|
||||
rltty.o: rlprivate.h
|
||||
search.o: rlprivate.h
|
||||
signals.o: rlprivate.h
|
||||
terminal.o: rlprivate.h
|
||||
text.o: rlprivate.h
|
||||
undo.o: rlprivate.h
|
||||
util.o: rlprivate.h
|
||||
vi_mode.o: rlprivate.h
|
||||
|
||||
bind.o: xmalloc.h
|
||||
complete.o: xmalloc.h
|
||||
display.o: xmalloc.h
|
||||
funmap.o: xmalloc.h
|
||||
histexpand.o: xmalloc.h
|
||||
histfile.o: xmalloc.h
|
||||
history.o: xmalloc.h
|
||||
input.o: xmalloc.h
|
||||
isearch.o: xmalloc.h
|
||||
keymaps.o: xmalloc.h
|
||||
kill.o: xmalloc.h
|
||||
macro.o: xmalloc.h
|
||||
mbutil.o: xmalloc.h
|
||||
misc.o: xmalloc.h
|
||||
readline.o: xmalloc.h
|
||||
savestring.o: xmalloc.h
|
||||
search.o: xmalloc.h
|
||||
shell.o: xmalloc.h
|
||||
terminal.o: xmalloc.h
|
||||
text.o: xmalloc.h
|
||||
tilde.o: xmalloc.h
|
||||
undo.o: xmalloc.h
|
||||
util.o: xmalloc.h
|
||||
vi_mode.o: xmalloc.h
|
||||
xmalloc.o: xmalloc.h
|
||||
|
||||
complete.o: rlmbutil.h
|
||||
display.o: rlmbutil.h
|
||||
histexpand.o: rlmbutil.h
|
||||
input.o: rlmbutil.h
|
||||
isearch.o: rlmbutil.h
|
||||
mbutil.o: rlmbutil.h
|
||||
misc.o: rlmbutil.h
|
||||
readline.o: rlmbutil.h
|
||||
search.o: rlmbutil.h
|
||||
text.o: rlmbutil.h
|
||||
vi_mode.o: rlmbutil.h
|
||||
|
||||
bind.o: $(srcdir)/bind.c
|
||||
callback.o: $(srcdir)/callback.c
|
||||
compat.o: $(srcdir)/compat.c
|
||||
complete.o: $(srcdir)/complete.c
|
||||
display.o: $(srcdir)/display.c
|
||||
funmap.o: $(srcdir)/funmap.c
|
||||
input.o: $(srcdir)/input.c
|
||||
isearch.o: $(srcdir)/isearch.c
|
||||
keymaps.o: $(srcdir)/keymaps.c $(srcdir)/emacs_keymap.c $(srcdir)/vi_keymap.c
|
||||
kill.o: $(srcdir)/kill.c
|
||||
macro.o: $(srcdir)/macro.c
|
||||
mbutil.o: $(srcdir)/mbutil.c
|
||||
misc.o: $(srcdir)/misc.c
|
||||
nls.o: $(srcdir)/nls.c
|
||||
parens.o: $(srcdir)/parens.c
|
||||
readline.o: $(srcdir)/readline.c
|
||||
rltty.o: $(srcdir)/rltty.c
|
||||
savestring.o: $(srcdir)/savestring.c
|
||||
search.o: $(srcdir)/search.c
|
||||
shell.o: $(srcdir)/shell.c
|
||||
signals.o: $(srcdir)/signals.c
|
||||
terminal.o: $(srcdir)/terminal.c
|
||||
text.o: $(srcdir)/text.c
|
||||
tilde.o: $(srcdir)/tilde.c
|
||||
undo.o: $(srcdir)/undo.c
|
||||
util.o: $(srcdir)/util.c
|
||||
vi_mode.o: $(srcdir)/vi_mode.c
|
||||
xmalloc.o: $(srcdir)/xmalloc.c
|
||||
|
||||
histexpand.o: $(srcdir)/histexpand.c
|
||||
histfile.o: $(srcdir)/histfile.c
|
||||
history.o: $(srcdir)/history.c
|
||||
histsearch.o: $(srcdir)/histsearch.c
|
||||
|
||||
bind.o: bind.c
|
||||
callback.o: callback.c
|
||||
compat.o: compat.c
|
||||
complete.o: complete.c
|
||||
display.o: display.c
|
||||
funmap.o: funmap.c
|
||||
input.o: input.c
|
||||
isearch.o: isearch.c
|
||||
keymaps.o: keymaps.c emacs_keymap.c vi_keymap.c
|
||||
kill.o: kill.c
|
||||
macro.o: macro.c
|
||||
mbutil.o: mbutil.c
|
||||
misc.o: misc.c
|
||||
nls.o: nls.c
|
||||
parens.o: parens.c
|
||||
readline.o: readline.c
|
||||
rltty.o: rltty.c
|
||||
savestring.o: savestring.c
|
||||
search.o: search.c
|
||||
shell.o: shell.c
|
||||
signals.o: signals.c
|
||||
terminal.o: terminal.c
|
||||
text.o: text.c
|
||||
tilde.o: tilde.c
|
||||
undo.o: undo.c
|
||||
util.o: util.c
|
||||
vi_mode.o: vi_mode.c
|
||||
xmalloc.o: xmalloc.c
|
||||
|
||||
histexpand.o: histexpand.c
|
||||
histfile.o: histfile.c
|
||||
history.o: history.c
|
||||
histsearch.o: histsearch.c
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
This is the Gnu Readline library, version 4.3.
|
||||
|
||||
The Readline library provides a set of functions for use by applications
|
||||
that allow users to edit command lines as they are typed in. Both
|
||||
Emacs and vi editing modes are available. The Readline library includes
|
||||
additional functions to maintain a list of previously-entered command
|
||||
lines, to recall and perhaps reedit those lines, and perform csh-like
|
||||
history expansion on previous commands.
|
||||
|
||||
The history facilites are also placed into a separate library, the
|
||||
History library, as part of the build process. The History library
|
||||
may be used without Readline in applications which desire its
|
||||
capabilities.
|
||||
|
||||
The Readline library is free software, distributed under the terms of
|
||||
the [GNU] General Public License, version 2. For more information, see
|
||||
the file COPYING.
|
||||
|
||||
To build the library, try typing `./configure', then `make'. The
|
||||
configuration process is automated, so no further intervention should
|
||||
be necessary. Readline builds with `gcc' by default if it is
|
||||
available. If you want to use `cc' instead, type
|
||||
|
||||
CC=cc ./configure
|
||||
|
||||
if you are using a Bourne-style shell. If you are not, the following
|
||||
may work:
|
||||
|
||||
env CC=cc ./configure
|
||||
|
||||
Read the file INSTALL in this directory for more information about how
|
||||
to customize and control the build process.
|
||||
|
||||
The file rlconf.h contains C preprocessor defines that enable and disable
|
||||
certain Readline features.
|
||||
|
||||
The special make target `everything' will build the static and shared
|
||||
libraries (if the target platform supports them) and the examples.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
There are several example programs that use Readline features in the
|
||||
examples directory. The `rl' program is of particular interest. It
|
||||
is a command-line interface to Readline, suitable for use in shell
|
||||
scripts in place of `read'.
|
||||
|
||||
Shared Libraries
|
||||
================
|
||||
|
||||
There is skeletal support for building shared versions of the
|
||||
Readline and History libraries. The configure script creates
|
||||
a Makefile in the `shlib' subdirectory, and typing `make shared'
|
||||
will cause shared versions of the Readline and History libraries
|
||||
to be built on supported platforms.
|
||||
|
||||
If `configure' is given the `--enable-shared' option, it will attempt
|
||||
to build the shared libraries by default on supported platforms.
|
||||
|
||||
Configure calls the script support/shobj-conf to test whether or
|
||||
not shared library creation is supported and to generate the values
|
||||
of variables that are substituted into shlib/Makefile. If you
|
||||
try to build shared libraries on an unsupported platform, `make'
|
||||
will display a message asking you to update support/shobj-conf for
|
||||
your platform.
|
||||
|
||||
If you need to update support/shobj-conf, you will need to create
|
||||
a `stanza' for your operating system and compiler. The script uses
|
||||
the value of host_os and ${CC} as determined by configure. For
|
||||
instance, FreeBSD 4.2 with any version of gcc is identified as
|
||||
`freebsd4.2-gcc*'.
|
||||
|
||||
In the stanza for your operating system-compiler pair, you will need to
|
||||
define several variables. They are:
|
||||
|
||||
SHOBJ_CC The C compiler used to compile source files into shareable
|
||||
object files. This is normally set to the value of ${CC}
|
||||
by configure, and should not need to be changed.
|
||||
|
||||
SHOBJ_CFLAGS Flags to pass to the C compiler ($SHOBJ_CC) to create
|
||||
position-independent code. If you are using gcc, this
|
||||
should probably be set to `-fpic'.
|
||||
|
||||
SHOBJ_LD The link editor to be used to create the shared library from
|
||||
the object files created by $SHOBJ_CC. If you are using
|
||||
gcc, a value of `gcc' will probably work.
|
||||
|
||||
SHOBJ_LDFLAGS Flags to pass to SHOBJ_LD to enable shared object creation.
|
||||
If you are using gcc, `-shared' may be all that is necessary.
|
||||
These should be the flags needed for generic shared object
|
||||
creation.
|
||||
|
||||
SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
|
||||
creation. Many systems use the -R option to the link
|
||||
editor to embed a path within the library for run-time
|
||||
library searches. A reasonable value for such systems would
|
||||
be `-R$(libdir)'.
|
||||
|
||||
SHLIB_LIBS Any additional libraries that shared libraries should be
|
||||
linked against when they are created.
|
||||
|
||||
SHLIB_LIBSUFF The suffix to add to `libreadline' and `libhistory' when
|
||||
generating the filename of the shared library. Many systems
|
||||
use `so'; HP-UX uses `sl'.
|
||||
|
||||
SHLIB_LIBVERSION The string to append to the filename to indicate the version
|
||||
of the shared library. It should begin with $(SHLIB_LIBSUFF),
|
||||
and possibly include version information that allows the
|
||||
run-time loader to load the version of the shared library
|
||||
appropriate for a particular program. Systems using shared
|
||||
libraries similar to SunOS 4.x use major and minor library
|
||||
version numbers; for those systems a value of
|
||||
`$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' is appropriate.
|
||||
Systems based on System V Release 4 don't use minor version
|
||||
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
|
||||
Other Unix versions use different schemes.
|
||||
|
||||
SHLIB_STATUS Set this to `supported' when you have defined the other
|
||||
necessary variables. Make uses this to determine whether
|
||||
or not shared library creation should be attempted.
|
||||
|
||||
You should look at the existing stanzas in support/shobj-conf for ideas.
|
||||
|
||||
Once you have updated support/shobj-conf, re-run configure and type
|
||||
`make shared'. The shared libraries will be created in the shlib
|
||||
subdirectory.
|
||||
|
||||
If shared libraries are created, `make install' will install them.
|
||||
You may install only the shared libraries by running `make
|
||||
install-shared' from the top-level build directory. Running `make
|
||||
install' in the shlib subdirectory will also work. If you don't want
|
||||
to install any created shared libraries, run `make install-static'.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
||||
The documentation for the Readline and History libraries appears in
|
||||
the `doc' subdirectory. There are three texinfo files and a
|
||||
Unix-style manual page describing the facilities available in the
|
||||
Readline library. The texinfo files include both user and
|
||||
programmer's manuals. HTML versions of the manuals appear in the
|
||||
`doc' subdirectory as well.
|
||||
|
||||
Reporting Bugs
|
||||
==============
|
||||
|
||||
Bug reports for Readline should be sent to:
|
||||
|
||||
bug-readline@gnu.org
|
||||
|
||||
When reporting a bug, please include the following information:
|
||||
|
||||
* the version number and release status of Readline (e.g., 4.2-release)
|
||||
* the machine and OS that it is running on
|
||||
* a list of the compilation flags or the contents of `config.h', if
|
||||
appropriate
|
||||
* a description of the bug
|
||||
* a recipe for recreating the bug reliably
|
||||
* a fix for the bug if you have one!
|
||||
|
||||
If you would like to contact the Readline maintainer directly, send mail
|
||||
to bash-maintainers@gnu.org.
|
||||
|
||||
Since Readline is developed along with bash, the bug-bash@gnu.org mailing
|
||||
list (mirrored to the Usenet newsgroup gnu.bash.bug) often contains
|
||||
Readline bug reports and fixes.
|
||||
|
||||
Chet Ramey
|
||||
chet@po.cwru.edu
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
From rms@gnu.org Thu Jul 22 20:37:55 1999
|
||||
Flags: 10
|
||||
Return-Path: rms@gnu.org
|
||||
Received: from arthur.INS.CWRU.Edu (root@arthur.INS.CWRU.Edu [129.22.8.215]) by odin.INS.CWRU.Edu with ESMTP (8.8.6+cwru/CWRU-2.4-ins)
|
||||
id UAA25349; Thu, 22 Jul 1999 20:37:54 -0400 (EDT) (from rms@gnu.org for <chet@odin.INS.CWRU.Edu>)
|
||||
Received: from nike.ins.cwru.edu (root@nike.INS.CWRU.Edu [129.22.8.219]) by arthur.INS.CWRU.Edu with ESMTP (8.8.8+cwru/CWRU-3.6)
|
||||
id UAA05311; Thu, 22 Jul 1999 20:37:51 -0400 (EDT) (from rms@gnu.org for <chet@po.cwru.edu>)
|
||||
Received: from pele.santafe.edu (pele.santafe.edu [192.12.12.119]) by nike.ins.cwru.edu with ESMTP (8.8.7/CWRU-2.5-bsdi)
|
||||
id UAA13350; Thu, 22 Jul 1999 20:37:50 -0400 (EDT) (from rms@gnu.org for <chet@nike.ins.cwru.edu>)
|
||||
Received: from wijiji.santafe.edu (wijiji [192.12.12.5])
|
||||
by pele.santafe.edu (8.9.1/8.9.1) with ESMTP id SAA10831
|
||||
for <chet@nike.ins.cwru.edu>; Thu, 22 Jul 1999 18:37:47 -0600 (MDT)
|
||||
Received: (from rms@localhost)
|
||||
by wijiji.santafe.edu (8.9.1b+Sun/8.9.1) id SAA01089;
|
||||
Thu, 22 Jul 1999 18:37:46 -0600 (MDT)
|
||||
Date: Thu, 22 Jul 1999 18:37:46 -0600 (MDT)
|
||||
Message-Id: <199907230037.SAA01089@wijiji.santafe.edu>
|
||||
X-Authentication-Warning: wijiji.santafe.edu: rms set sender to rms@gnu.org using -f
|
||||
From: Richard Stallman <rms@gnu.org>
|
||||
To: chet@nike.ins.cwru.edu
|
||||
Subject: Use of Readline
|
||||
Reply-to: rms@gnu.org
|
||||
|
||||
I think Allbery's suggestion is a good one. So please add this text
|
||||
in a suitable place. Please don't put it in the GPL itself; that
|
||||
should be the same as the GPL everywhere else. Putting it in the
|
||||
README and/or the documentation would be a good idea.
|
||||
|
||||
|
||||
======================================================================
|
||||
Our position on the use of Readline through a shared-library linking
|
||||
mechanism is that there is no legal difference between shared-library
|
||||
linking and static linking--either kind of linking combines various
|
||||
modules into a single larger work. The conditions for using Readline
|
||||
in a larger work are stated in section 3 of the GNU GPL.
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,54 @@
|
|||
/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
|
||||
/* A minimal stdlib.h containing extern declarations for those functions
|
||||
that bash uses. */
|
||||
|
||||
/* Copyright (C) 1993 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 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. */
|
||||
|
||||
#if !defined (_STDLIB_H_)
|
||||
#define _STDLIB_H_ 1
|
||||
|
||||
/* String conversion functions. */
|
||||
extern int atoi ();
|
||||
|
||||
extern double atof ();
|
||||
extern double strtod ();
|
||||
|
||||
/* Memory allocation functions. */
|
||||
/* Generic pointer type. */
|
||||
#ifndef PTR_T
|
||||
|
||||
#if defined (__STDC__)
|
||||
# define PTR_T void *
|
||||
#else
|
||||
# define PTR_T char *
|
||||
#endif
|
||||
|
||||
#endif /* PTR_T */
|
||||
|
||||
extern PTR_T malloc ();
|
||||
extern PTR_T realloc ();
|
||||
extern void free ();
|
||||
|
||||
/* Other miscellaneous functions. */
|
||||
extern void abort ();
|
||||
extern void exit ();
|
||||
extern char *getenv ();
|
||||
extern void qsort ();
|
||||
|
||||
#endif /* _STDLIB_H */
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,156 @@
|
|||
/* callback.c -- functions to use readline as an X `callback' mechanism. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#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"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* 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;
|
||||
|
||||
(*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_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;
|
||||
|
||||
if (rl_linefunc == NULL)
|
||||
{
|
||||
fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
eof = readline_internal_char ();
|
||||
|
||||
/* We loop in case some function has pushed input back with rl_execute_next. */
|
||||
for (;;)
|
||||
{
|
||||
if (rl_done)
|
||||
{
|
||||
line = readline_internal_teardown (eof);
|
||||
|
||||
(*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 ();
|
||||
}
|
||||
if (rl_pending_input)
|
||||
eof = readline_internal_char ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the handler, and make sure the terminal is in its normal state. */
|
||||
void
|
||||
rl_callback_handler_remove ()
|
||||
{
|
||||
rl_linefunc = NULL;
|
||||
if (in_handler)
|
||||
{
|
||||
in_handler = 0;
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
/* chardefs.h -- Character definitions for readline. */
|
||||
|
||||
/* Copyright (C) 1994 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#ifndef _CHARDEFS_H_
|
||||
#define _CHARDEFS_H_
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# if defined (HAVE_STRING_H)
|
||||
# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
# endif /* HAVE_STRING_H */
|
||||
# if defined (HAVE_STRINGS_H)
|
||||
# include <strings.h>
|
||||
# endif /* HAVE_STRINGS_H */
|
||||
#else
|
||||
# include <string.h>
|
||||
#endif /* !HAVE_CONFIG_H */
|
||||
|
||||
#ifndef whitespace
|
||||
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
|
||||
#endif
|
||||
|
||||
#ifdef CTRL
|
||||
# undef CTRL
|
||||
#endif
|
||||
#ifdef UNCTRL
|
||||
# undef UNCTRL
|
||||
#endif
|
||||
|
||||
/* Some character stuff. */
|
||||
#define control_character_threshold 0x020 /* Smaller than this is control. */
|
||||
#define control_character_mask 0x1f /* 0x20 - 1 */
|
||||
#define meta_character_threshold 0x07f /* Larger than this is Meta. */
|
||||
#define control_character_bit 0x40 /* 0x000000, must be off. */
|
||||
#define meta_character_bit 0x080 /* x0000000, must be on. */
|
||||
#define largest_char 255 /* Largest character value. */
|
||||
|
||||
#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
|
||||
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
|
||||
|
||||
#define CTRL(c) ((c) & control_character_mask)
|
||||
#define META(c) ((c) | meta_character_bit)
|
||||
|
||||
#define UNMETA(c) ((c) & (~meta_character_bit))
|
||||
#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
|
||||
|
||||
#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
|
||||
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
|
||||
#endif
|
||||
|
||||
#define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
|
||||
|
||||
/* Some systems define these; we want our definitions. */
|
||||
#undef ISPRINT
|
||||
|
||||
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
|
||||
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
|
||||
#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
|
||||
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
|
||||
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
|
||||
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
|
||||
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
|
||||
|
||||
#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
|
||||
#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
|
||||
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
|
||||
|
||||
#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
|
||||
#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
|
||||
|
||||
#ifndef _rl_to_upper
|
||||
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
|
||||
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
|
||||
#endif
|
||||
|
||||
#ifndef _rl_digit_value
|
||||
# define _rl_digit_value(x) ((x) - '0')
|
||||
#endif
|
||||
|
||||
#ifndef _rl_isident
|
||||
# define _rl_isident(c) (ISALNUM(c) || (c) == '_')
|
||||
#endif
|
||||
|
||||
#ifndef ISOCTAL
|
||||
# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
|
||||
#endif
|
||||
#define OCTVALUE(c) ((c) - '0')
|
||||
|
||||
#define HEXVALUE(c) \
|
||||
(((c) >= 'a' && (c) <= 'f') \
|
||||
? (c)-'a'+10 \
|
||||
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
|
||||
|
||||
#ifndef NEWLINE
|
||||
#define NEWLINE '\n'
|
||||
#endif
|
||||
|
||||
#ifndef RETURN
|
||||
#define RETURN CTRL('M')
|
||||
#endif
|
||||
|
||||
#ifndef RUBOUT
|
||||
#define RUBOUT 0x7f
|
||||
#endif
|
||||
|
||||
#ifndef TAB
|
||||
#define TAB '\t'
|
||||
#endif
|
||||
|
||||
#ifdef ABORT_CHAR
|
||||
#undef ABORT_CHAR
|
||||
#endif
|
||||
#define ABORT_CHAR CTRL('G')
|
||||
|
||||
#ifdef PAGE
|
||||
#undef PAGE
|
||||
#endif
|
||||
#define PAGE CTRL('L')
|
||||
|
||||
#ifdef SPACE
|
||||
#undef SPACE
|
||||
#endif
|
||||
#define SPACE ' ' /* XXX - was 0x20 */
|
||||
|
||||
#ifdef ESC
|
||||
#undef ESC
|
||||
#endif
|
||||
#define ESC CTRL('[')
|
||||
|
||||
#endif /* _CHARDEFS_H_ */
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
/* compat.c -- backwards compatibility functions. */
|
||||
|
||||
/* Copyright (C) 2000 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rlstdc.h"
|
||||
#include "rltypedefs.h"
|
||||
|
||||
extern void rl_free_undo_list PARAMS((void));
|
||||
extern int rl_maybe_save_line PARAMS((void));
|
||||
extern int rl_maybe_unsave_line PARAMS((void));
|
||||
extern int rl_maybe_replace_line PARAMS((void));
|
||||
|
||||
extern int rl_crlf PARAMS((void));
|
||||
extern int rl_ding PARAMS((void));
|
||||
extern int rl_alphabetic PARAMS((int));
|
||||
|
||||
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
|
||||
extern char *rl_username_completion_function PARAMS((const char *, int));
|
||||
extern char *rl_filename_completion_function PARAMS((const char *, int));
|
||||
|
||||
/* Provide backwards-compatible entry points for old function names. */
|
||||
|
||||
void
|
||||
free_undo_list ()
|
||||
{
|
||||
rl_free_undo_list ();
|
||||
}
|
||||
|
||||
int
|
||||
maybe_replace_line ()
|
||||
{
|
||||
return rl_maybe_replace_line ();
|
||||
}
|
||||
|
||||
int
|
||||
maybe_save_line ()
|
||||
{
|
||||
return rl_maybe_save_line ();
|
||||
}
|
||||
|
||||
int
|
||||
maybe_unsave_line ()
|
||||
{
|
||||
return rl_maybe_unsave_line ();
|
||||
}
|
||||
|
||||
int
|
||||
ding ()
|
||||
{
|
||||
return rl_ding ();
|
||||
}
|
||||
|
||||
int
|
||||
crlf ()
|
||||
{
|
||||
return rl_crlf ();
|
||||
}
|
||||
|
||||
int
|
||||
alphabetic (c)
|
||||
int c;
|
||||
{
|
||||
return rl_alphabetic (c);
|
||||
}
|
||||
|
||||
char **
|
||||
completion_matches (s, f)
|
||||
const char *s;
|
||||
rl_compentry_func_t *f;
|
||||
{
|
||||
return rl_completion_matches (s, f);
|
||||
}
|
||||
|
||||
char *
|
||||
username_completion_function (s, i)
|
||||
const char *s;
|
||||
int i;
|
||||
{
|
||||
return rl_username_completion_function (s, i);
|
||||
}
|
||||
|
||||
char *
|
||||
filename_completion_function (s, i)
|
||||
const char *s;
|
||||
int i;
|
||||
{
|
||||
return rl_filename_completion_function (s, i);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,200 @@
|
|||
/* config.h.in. Maintained by hand. */
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Characteristics of the compiler. */
|
||||
#undef const
|
||||
|
||||
#undef size_t
|
||||
|
||||
#undef ssize_t
|
||||
|
||||
#undef PROTOTYPES
|
||||
|
||||
#undef __CHAR_UNSIGNED__
|
||||
|
||||
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
|
||||
#undef STAT_MACROS_BROKEN
|
||||
|
||||
#undef VOID_SIGHANDLER
|
||||
|
||||
/* Define if you have the isascii function. */
|
||||
#undef HAVE_ISASCII
|
||||
|
||||
/* Define if you have the isxdigit function. */
|
||||
#undef HAVE_ISXDIGIT
|
||||
|
||||
/* Define if you have the lstat function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/* Define if you have the mbsrtowcs function. */
|
||||
#undef HAVE_MBSRTOWCS
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define if you have the putenv function. */
|
||||
#undef HAVE_PUTENV
|
||||
|
||||
/* Define if you have the select function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define if you have the setenv function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define if you have the setlocale function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define if you have the strcoll function. */
|
||||
#undef HAVE_STRCOLL
|
||||
|
||||
#undef STRCOLL_BROKEN
|
||||
|
||||
/* Define if you have the strpbrk function. */
|
||||
#undef HAVE_STRPBRK
|
||||
|
||||
/* Define if you have the tcgetattr function. */
|
||||
#undef HAVE_TCGETATTR
|
||||
|
||||
/* Define if you have the vsnprintf function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define if you have the wcwidth function. */
|
||||
#undef HAVE_WCWIDTH
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define if you have the <langinfo.h> header file. */
|
||||
#undef HAVE_LANGINFO_H
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#undef HAVE_STDARG_H
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file. */
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define if you have the <sys/file.h> header file. */
|
||||
#undef HAVE_SYS_FILE_H
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define if you have the <sys/pte.h> header file. */
|
||||
#undef HAVE_SYS_PTE_H
|
||||
|
||||
/* Define if you have the <sys/ptem.h> header file. */
|
||||
#undef HAVE_SYS_PTEM_H
|
||||
|
||||
/* Define if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define if you have the <sys/stream.h> header file. */
|
||||
#undef HAVE_SYS_STREAM_H
|
||||
|
||||
/* Define if you have the <termcap.h> header file. */
|
||||
#undef HAVE_TERMCAP_H
|
||||
|
||||
/* Define if you have the <termio.h> header file. */
|
||||
#undef HAVE_TERMIO_H
|
||||
|
||||
/* Define if you have the <termios.h> header file. */
|
||||
#undef HAVE_TERMIOS_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_VARARGS_H
|
||||
|
||||
/* Define if you have the <wchar.h> header file. */
|
||||
#undef HAVE_WCHAR_H
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_WCTYPE_H
|
||||
|
||||
#undef HAVE_MBSTATE_T
|
||||
|
||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||
#undef HAVE_LANGINFO_CODESET
|
||||
|
||||
/* Definitions pulled in from aclocal.m4. */
|
||||
#undef VOID_SIGHANDLER
|
||||
|
||||
#undef GWINSZ_IN_SYS_IOCTL
|
||||
|
||||
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
|
||||
|
||||
#undef STRUCT_WINSIZE_IN_TERMIOS
|
||||
|
||||
#undef TIOCSTAT_IN_SYS_IOCTL
|
||||
|
||||
#undef FIONREAD_IN_SYS_IOCTL
|
||||
|
||||
#undef SPEED_T_IN_SYS_TYPES
|
||||
|
||||
#undef HAVE_GETPW_DECLS
|
||||
|
||||
#undef STRUCT_DIRENT_HAS_D_INO
|
||||
|
||||
#undef STRUCT_DIRENT_HAS_D_FILENO
|
||||
|
||||
#undef HAVE_BSD_SIGNALS
|
||||
|
||||
#undef HAVE_POSIX_SIGNALS
|
||||
|
||||
#undef HAVE_USG_SIGHOLD
|
||||
|
||||
#undef MUST_REINSTALL_SIGHANDLERS
|
||||
|
||||
#undef HAVE_POSIX_SIGSETJMP
|
||||
|
||||
/* modify settings or make new ones based on what autoconf tells us. */
|
||||
|
||||
/* Ultrix botches type-ahead when switching from canonical to
|
||||
non-canonical mode, at least through version 4.3 */
|
||||
#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix)
|
||||
# define TERMIOS_MISSING
|
||||
#endif
|
||||
|
||||
#if defined (STRCOLL_BROKEN)
|
||||
# undef HAVE_STRCOLL
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && defined (HAVE_STDARG_H)
|
||||
# define PREFER_STDARG
|
||||
# define USE_VARARGS
|
||||
#else
|
||||
# if defined (HAVE_VARARGS_H)
|
||||
# define PREFER_VARARGS
|
||||
# define USE_VARARGS
|
||||
# endif
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,206 @@
|
|||
dnl
|
||||
dnl Configure script for readline library
|
||||
dnl
|
||||
dnl report bugs to chet@po.cwru.edu
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_REVISION([for Readline 4.3, version 2.45, from autoconf version] AC_ACVERSION)
|
||||
|
||||
AC_INIT(readline, 4.3, bug-readline@gnu.org)
|
||||
|
||||
dnl make sure we are using a recent autoconf version
|
||||
AC_PREREQ(2.50)
|
||||
|
||||
AC_CONFIG_SRCDIR(readline.h)
|
||||
AC_CONFIG_AUX_DIR(./support)
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
dnl update the value of RL_READLINE_VERSION in readline.h when this changes
|
||||
LIBVERSION=4.3
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
dnl configure defaults
|
||||
opt_curses=no
|
||||
|
||||
dnl arguments to configure
|
||||
AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
|
||||
|
||||
if test "$opt_curses" = "yes"; then
|
||||
prefer_curses=yes
|
||||
fi
|
||||
|
||||
dnl option parsing for optional features
|
||||
opt_static_libs=yes
|
||||
opt_shared_libs=yes
|
||||
|
||||
AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval)
|
||||
AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval)
|
||||
|
||||
echo ""
|
||||
echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
|
||||
echo ""
|
||||
|
||||
# We want these before the checks, so the checks can modify their values.
|
||||
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
|
||||
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_CC
|
||||
dnl AC_AIX
|
||||
AC_MINIX
|
||||
|
||||
# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
|
||||
test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
|
||||
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_INSTALL
|
||||
AC_CHECK_PROG(AR, ar, , ar)
|
||||
dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
|
||||
dnl This allows people to set it when running configure or make
|
||||
test -n "$ARFLAGS" || ARFLAGS="cr"
|
||||
AC_PROG_RANLIB
|
||||
|
||||
MAKE_SHELL=/bin/sh
|
||||
AC_SUBST(MAKE_SHELL)
|
||||
|
||||
AC_C_CONST
|
||||
AC_C_PROTOTYPES
|
||||
AC_C_CHAR_UNSIGNED
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
|
||||
AC_TYPE_SIZE_T
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
|
||||
AC_HEADER_STAT
|
||||
AC_HEADER_DIRENT
|
||||
|
||||
AC_CHECK_FUNCS(lstat memmove putenv select setenv setlocale \
|
||||
strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit)
|
||||
|
||||
AC_FUNC_STRCOLL
|
||||
|
||||
AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
|
||||
limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
|
||||
termcap.h termios.h termio.h sys/file.h locale.h memory.h )
|
||||
|
||||
BASH_SYS_SIGNAL_VINTAGE
|
||||
BASH_SYS_REINSTALL_SIGHANDLERS
|
||||
|
||||
BASH_FUNC_POSIX_SETJMP
|
||||
BASH_FUNC_LSTAT
|
||||
BASH_FUNC_STRCOLL
|
||||
|
||||
BASH_CHECK_GETPW_FUNCS
|
||||
|
||||
AC_HEADER_TIOCGWINSZ
|
||||
|
||||
BASH_TYPE_SIGHANDLER
|
||||
BASH_HAVE_TIOCSTAT
|
||||
BASH_HAVE_FIONREAD
|
||||
BASH_CHECK_SPEED_T
|
||||
BASH_STRUCT_WINSIZE
|
||||
BASH_STRUCT_DIRENT_D_INO
|
||||
BASH_STRUCT_DIRENT_D_FILENO
|
||||
|
||||
dnl yuck
|
||||
case "$host_os" in
|
||||
aix*) prefer_curses=yes ;;
|
||||
esac
|
||||
BASH_CHECK_LIB_TERMCAP
|
||||
if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
|
||||
if test "$prefer_curses" = yes; then
|
||||
TERMCAP_LIB=-lcurses
|
||||
else
|
||||
TERMCAP_LIB=-ltermcap #default
|
||||
fi
|
||||
fi
|
||||
|
||||
BASH_CHECK_MULTIBYTE
|
||||
|
||||
case "$host_cpu" in
|
||||
*cray*) LOCAL_CFLAGS=-DCRAY ;;
|
||||
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
|
||||
esac
|
||||
|
||||
case "$host_os" in
|
||||
isc*) LOCAL_CFLAGS=-Disc386 ;;
|
||||
esac
|
||||
|
||||
# shared library configuration section
|
||||
#
|
||||
# Shared object configuration section. These values are generated by
|
||||
# ${srcdir}/support/shobj-conf
|
||||
#
|
||||
if test -f ${srcdir}/support/shobj-conf; then
|
||||
AC_MSG_CHECKING(configuration for building shared libraries)
|
||||
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
|
||||
AC_SUBST(SHOBJ_CC)
|
||||
AC_SUBST(SHOBJ_CFLAGS)
|
||||
AC_SUBST(SHOBJ_LD)
|
||||
AC_SUBST(SHOBJ_LDFLAGS)
|
||||
AC_SUBST(SHOBJ_XLDFLAGS)
|
||||
AC_SUBST(SHOBJ_LIBS)
|
||||
AC_SUBST(SHOBJ_STATUS)
|
||||
AC_SUBST(SHLIB_STATUS)
|
||||
AC_SUBST(SHLIB_XLDFLAGS)
|
||||
AC_SUBST(SHLIB_LIBSUFF)
|
||||
AC_SUBST(SHLIB_LIBVERSION)
|
||||
AC_SUBST(SHLIB_LIBS)
|
||||
AC_MSG_RESULT($SHLIB_STATUS)
|
||||
|
||||
# SHLIB_STATUS is either `supported' or `unsupported'. If it's
|
||||
# `unsupported', turn off any default shared library building
|
||||
if test "$SHLIB_STATUS" = 'unsupported'; then
|
||||
opt_shared_libs=no
|
||||
fi
|
||||
|
||||
# shared library versioning
|
||||
# quoted for m4 so I can use character classes
|
||||
SHLIB_MAJOR=[`expr "$LIBVERSION" : '\([0-9]\)\..*'`]
|
||||
SHLIB_MINOR=[`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'`]
|
||||
AC_SUBST(SHLIB_MAJOR)
|
||||
AC_SUBST(SHLIB_MINOR)
|
||||
fi
|
||||
|
||||
if test "$opt_static_libs" = "yes"; then
|
||||
STATIC_TARGET=static
|
||||
STATIC_INSTALL_TARGET=install-static
|
||||
fi
|
||||
if test "$opt_shared_libs" = "yes"; then
|
||||
SHARED_TARGET=shared
|
||||
SHARED_INSTALL_TARGET=install-shared
|
||||
fi
|
||||
|
||||
AC_SUBST(STATIC_TARGET)
|
||||
AC_SUBST(SHARED_TARGET)
|
||||
AC_SUBST(STATIC_INSTALL_TARGET)
|
||||
AC_SUBST(SHARED_INSTALL_TARGET)
|
||||
|
||||
case "$host_os" in
|
||||
msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
|
||||
*) BUILD_DIR=`pwd` ;;
|
||||
esac
|
||||
|
||||
AC_SUBST(BUILD_DIR)
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(LOCAL_CFLAGS)
|
||||
AC_SUBST(LOCAL_LDFLAGS)
|
||||
AC_SUBST(LOCAL_DEFS)
|
||||
|
||||
AC_SUBST(AR)
|
||||
AC_SUBST(ARFLAGS)
|
||||
|
||||
AC_SUBST(host_cpu)
|
||||
AC_SUBST(host_os)
|
||||
|
||||
AC_SUBST(LIBVERSION)
|
||||
|
||||
AC_SUBST(TERMCAP_LIB)
|
||||
|
||||
AC_OUTPUT([Makefile doc/Makefile examples/Makefile shlib/Makefile],
|
||||
[
|
||||
# Makefile uses this timestamp file to record whether config.h is up to date.
|
||||
echo > stamp-h
|
||||
])
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,234 @@
|
|||
# This makefile for Readline library documentation is in -*- text -*- mode.
|
||||
# Emacs likes it that way.
|
||||
|
||||
# Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
# This program 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.
|
||||
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
topdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
|
||||
prefix = @prefix@
|
||||
infodir = @infodir@
|
||||
|
||||
mandir = @mandir@
|
||||
manpfx = man
|
||||
|
||||
man1ext = .1
|
||||
man1dir = $(mandir)/$(manpfx)1
|
||||
man3ext = .3
|
||||
man3dir = $(mandir)/$(manpfx)3
|
||||
|
||||
# set this to a value to have the HTML documentation installed
|
||||
htmldir =
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
||||
SHELL = @MAKE_SHELL@
|
||||
RM = rm -f
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
TEXINPUTDIR = $(srcdir)
|
||||
|
||||
MAKEINFO = LANGUAGE= makeinfo
|
||||
TEXI2DVI = $(srcdir)/texi2dvi
|
||||
TEXI2HTML = $(srcdir)/texi2html
|
||||
QUIETPS = #set this to -q to shut up dvips
|
||||
PAPERSIZE = letter
|
||||
PSDPI = 300 # I don't have any 600-dpi printers
|
||||
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
|
||||
|
||||
RLSRC = $(srcdir)/rlman.texinfo $(srcdir)/rluser.texinfo \
|
||||
$(srcdir)/rltech.texinfo $(srcdir)/manvers.texinfo \
|
||||
$(srcdir)/rluserman.texinfo
|
||||
HISTSRC = $(srcdir)/hist.texinfo $(srcdir)/hsuser.texinfo \
|
||||
$(srcdir)/hstech.texinfo $(srcdir)/manvers.texinfo
|
||||
|
||||
# This should be a program that converts troff to an ascii-readable format
|
||||
NROFF = groff -Tascii
|
||||
|
||||
# This should be a program that converts troff to postscript
|
||||
GROFF = groff
|
||||
|
||||
DVIOBJ = readline.dvi history.dvi rluserman.dvi
|
||||
INFOOBJ = readline.info history.info rluserman.info
|
||||
PSOBJ = readline.ps history.ps rluserman.ps readline_3.ps history_3.ps
|
||||
HTMLOBJ = readline.html history.html rluserman.html
|
||||
TEXTOBJ = readline.0 history.0
|
||||
|
||||
INTERMEDIATE_OBJ = rlman.dvi hist.dvi rluserman.dvi
|
||||
|
||||
DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ) $(INFOOBJ) $(TEXTOBJ)
|
||||
|
||||
.SUFFIXES: .0 .3 .ps .txt .dvi
|
||||
|
||||
.3.0:
|
||||
$(RM) $@
|
||||
-${NROFF} -man $< > $@
|
||||
|
||||
all: info dvi html ps text
|
||||
nodvi: info html text
|
||||
|
||||
readline.dvi: $(RLSRC)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texinfo
|
||||
mv rlman.dvi readline.dvi
|
||||
|
||||
readline.info: $(RLSRC)
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rlman.texinfo
|
||||
|
||||
rluserman.dvi: $(RLSRC)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rluserman.texinfo
|
||||
|
||||
rluserman.info: $(RLSRC)
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rluserman.texinfo
|
||||
|
||||
history.dvi: ${HISTSRC}
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/hist.texinfo
|
||||
mv hist.dvi history.dvi
|
||||
|
||||
history.info: ${HISTSRC}
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/hist.texinfo
|
||||
|
||||
readline.ps: readline.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) readline.dvi
|
||||
|
||||
rluserman.ps: rluserman.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) rluserman.dvi
|
||||
|
||||
history.ps: history.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) history.dvi
|
||||
|
||||
#
|
||||
# This leaves readline.html and rlman.html -- rlman.html is for www.gnu.org
|
||||
#
|
||||
readline.html: ${RLSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rlman.texinfo
|
||||
sed -e 's:rlman.html:readline.html:g' rlman.html > readline.html
|
||||
|
||||
rluserman.html: ${RLSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rluserman.texinfo
|
||||
|
||||
history.html: ${HISTSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/hist.texinfo
|
||||
sed -e 's:hist.html:history.html:g' hist.html > history.html
|
||||
$(RM) hist.html
|
||||
|
||||
info: $(INFOOBJ)
|
||||
dvi: $(DVIOBJ)
|
||||
ps: $(PSOBJ)
|
||||
html: $(HTMLOBJ)
|
||||
text: $(TEXTOBJ)
|
||||
|
||||
readline.0: readline.3
|
||||
|
||||
readline_3.ps: readline.3
|
||||
${RM} $@
|
||||
${GROFF} -man < $(srcdir)/readline.3 > $@
|
||||
|
||||
history.0: history.3
|
||||
|
||||
history_3.ps: history.3
|
||||
${RM} $@
|
||||
${GROFF} -man < $(srcdir)/history.3 > $@
|
||||
|
||||
clean:
|
||||
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
|
||||
*.fns *.kys *.tps *.vrs *.bt *.bts *.o core *.core
|
||||
|
||||
mostlyclean: clean
|
||||
|
||||
distclean: clean maybe-clean
|
||||
$(RM) $(INTERMEDIATE_OBJ)
|
||||
$(RM) Makefile
|
||||
|
||||
maybe-clean:
|
||||
-if test "X$(topdir)" != "X$(BUILD_DIR)"; then \
|
||||
$(RM) $(DIST_DOCS); \
|
||||
fi
|
||||
|
||||
maintainer-clean: clean
|
||||
$(RM) $(DIST_DOCS)
|
||||
$(RM) $(INTERMEDIATE_OBJ)
|
||||
$(RM) Makefile
|
||||
|
||||
installdirs: $(topdir)/support/mkdirs
|
||||
-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
|
||||
-if test -n "${htmldir}" ; then \
|
||||
$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(htmldir) ; \
|
||||
fi
|
||||
|
||||
install: installdirs
|
||||
if test -f readline.info; then \
|
||||
${INSTALL_DATA} readline.info $(DESTDIR)$(infodir)/readline.info; \
|
||||
else \
|
||||
${INSTALL_DATA} $(srcdir)/readline.info $(DESTDIR)$(infodir)/readline.info; \
|
||||
fi
|
||||
if test -f rluserman.info; then \
|
||||
${INSTALL_DATA} rluserman.info $(DESTDIR)$(infodir)/rluserman.info; \
|
||||
else \
|
||||
${INSTALL_DATA} $(srcdir)/rluserman.info $(DESTDIR)$(infodir)/rluserman.info; \
|
||||
fi
|
||||
if test -f history.info; then \
|
||||
${INSTALL_DATA} history.info $(DESTDIR)$(infodir)/history.info; \
|
||||
else \
|
||||
${INSTALL_DATA} $(srcdir)/history.info $(DESTDIR)$(infodir)/history.info; \
|
||||
fi
|
||||
-if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
|
||||
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
|
||||
$(DESTDIR)$(infodir)/readline.info ; \
|
||||
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
|
||||
$(DESTDIR)$(infodir)/history.info ; \
|
||||
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
|
||||
$(DESTDIR)$(infodir)/rluserman.info ; \
|
||||
else true; fi
|
||||
-${INSTALL_DATA} $(srcdir)/readline.3 $(DESTDIR)$(man3dir)/readline$(man3ext)
|
||||
-${INSTALL_DATA} $(srcdir)/history.3 $(DESTDIR)$(man3dir)/history$(man3ext)
|
||||
-if test -n "${htmldir}" ; then \
|
||||
if test -f readline.html; then \
|
||||
${INSTALL_DATA} readline.html $(DESTDIR)$(htmldir)/readline.html; \
|
||||
else \
|
||||
${INSTALL_DATA} $(srcdir)/readline.html $(DESTDIR)$(htmldir)/readline.html; \
|
||||
fi ; \
|
||||
if test -f history.html; then \
|
||||
${INSTALL_DATA} history.html $(DESTDIR)$(htmldir)/history.html; \
|
||||
else \
|
||||
${INSTALL_DATA} $(srcdir)/history.html $(DESTDIR)$(htmldir)/history.html; \
|
||||
fi ; \
|
||||
if test -f rluserman.html; then \
|
||||
${INSTALL_DATA} rluserman.html $(DESTDIR)$(htmldir)/rluserman.html; \
|
||||
else \
|
||||
${INSTALL_DATA} $(srcdir)/rluserman.html $(DESTDIR)$(htmldir)/rluserman.html; \
|
||||
fi ; \
|
||||
fi
|
||||
|
||||
uninstall:
|
||||
$(RM) $(DESTDIR)$(infodir)/readline.info
|
||||
$(RM) $(DESTDIR)$(infodir)/rluserman.info
|
||||
$(RM) $(DESTDIR)$(infodir)/history.info
|
||||
$(RM) $(DESTDIR)$(man3dir)/readline$(man3ext)
|
||||
$(RM) $(DESTDIR)$(man3dir)/history$(man3ext)
|
||||
-if test -n "${htmldir}" ; then \
|
||||
$(RM) $(DESTDIR)$(htmldir)/readline.html ; \
|
||||
$(RM) $(DESTDIR)$(htmldir)/rluserman.html ; \
|
||||
$(RM) $(DESTDIR)$(htmldir)/history.html ; \
|
||||
fi
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename history.info
|
||||
@settitle GNU History Library
|
||||
@c %**end of header (This is for running Texinfo on a region.)
|
||||
|
||||
@setchapternewpage odd
|
||||
|
||||
@include manvers.texinfo
|
||||
|
||||
@ifinfo
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* History: (history). The GNU history library API
|
||||
@end direntry
|
||||
|
||||
This document describes the GNU History library, a programming tool that
|
||||
provides a consistent user interface for recalling lines of previously
|
||||
typed input.
|
||||
|
||||
Copyright (C) 1988-2002 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
pare preserved on all copies.
|
||||
|
||||
@ignore
|
||||
Permission is granted to process this file through TeX and print the
|
||||
results, provided the printed document carries copying permission
|
||||
notice identical to this one except for the removal of this paragraph
|
||||
(this paragraph not being relevant to the printed manual).
|
||||
@end ignore
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Free Software Foundation.
|
||||
@end ifinfo
|
||||
|
||||
@titlepage
|
||||
@title GNU History Library
|
||||
@subtitle Edition @value{EDITION}, for @code{History Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATE-MONTH}
|
||||
@author Brian Fox, Free Software Foundation
|
||||
@author Chet Ramey, Case Western Reserve University
|
||||
|
||||
@page
|
||||
This document describes the GNU History library, a programming tool that
|
||||
provides a consistent user interface for recalling lines of previously
|
||||
typed input.
|
||||
|
||||
Published by the Free Software Foundation @*
|
||||
59 Temple Place, Suite 330, @*
|
||||
Boston, MA 02111 USA
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Free Software Foundation.
|
||||
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1988-2002 Free Software Foundation, Inc.
|
||||
@end titlepage
|
||||
|
||||
@ifinfo
|
||||
@node Top
|
||||
@top GNU History Library
|
||||
|
||||
This document describes the GNU History library, a programming tool that
|
||||
provides a consistent user interface for recalling lines of previously
|
||||
typed input.
|
||||
|
||||
@menu
|
||||
* Using History Interactively:: GNU History User's Manual.
|
||||
* Programming with GNU History:: GNU History Programmer's Manual.
|
||||
* Concept Index:: Index of concepts described in this manual.
|
||||
* Function and Variable Index:: Index of externally visible functions
|
||||
and variables.
|
||||
@end menu
|
||||
@end ifinfo
|
||||
|
||||
@syncodeindex fn vr
|
||||
|
||||
@include hsuser.texinfo
|
||||
@include hstech.texinfo
|
||||
|
||||
@node Concept Index
|
||||
@appendix Concept Index
|
||||
@printindex cp
|
||||
|
||||
@node Function and Variable Index
|
||||
@appendix Function and Variable Index
|
||||
@printindex vr
|
||||
|
||||
@contents
|
||||
@bye
|
||||
|
|
@ -0,0 +1,640 @@
|
|||
.\"
|
||||
.\" MAN PAGE COMMENTS to
|
||||
.\"
|
||||
.\" Chet Ramey
|
||||
.\" Information Network Services
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Thu Jan 31 16:08:07 EST 2002
|
||||
.\"
|
||||
.TH HISTORY 3 "2002 January 31" "GNU History 4.3"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
.\"
|
||||
.de FN
|
||||
\fI\|\\$1\|\fP
|
||||
..
|
||||
.ds lp \fR\|(\fP
|
||||
.ds rp \fR\|)\fP
|
||||
.\" FnN return-value fun-name N arguments
|
||||
.de Fn1
|
||||
\fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3\fP\\*(rp
|
||||
.br
|
||||
..
|
||||
.de Fn2
|
||||
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4\fP\\*(rp
|
||||
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4\fP\\*(rp
|
||||
.br
|
||||
..
|
||||
.de Fn3
|
||||
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4,\|\\$5\fP\|\\*(rp
|
||||
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4, \\$5\fP\\*(rp
|
||||
.br
|
||||
..
|
||||
.de Vb
|
||||
\fI\\$1\fP \fB\\$2\fP
|
||||
.br
|
||||
..
|
||||
.SH NAME
|
||||
history \- GNU History Library
|
||||
.SH COPYRIGHT
|
||||
.if t The GNU History Library is Copyright \(co 1989-2002 by the Free Software Foundation, Inc.
|
||||
.if n The GNU History Library is Copyright (C) 1989-2002 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
Many programs read input from the user a line at a time. The GNU
|
||||
History library is able to keep track of those lines, associate arbitrary
|
||||
data with each line, and utilize information from previous lines in
|
||||
composing new ones.
|
||||
.PP
|
||||
.SH "HISTORY EXPANSION"
|
||||
.PP
|
||||
The history library supports a history expansion feature that
|
||||
is identical to the history expansion in
|
||||
.BR bash.
|
||||
This section describes what syntax features are available.
|
||||
.PP
|
||||
History expansions introduce words from the history list into
|
||||
the input stream, making it easy to repeat commands, insert the
|
||||
arguments to a previous command into the current input line, or
|
||||
fix errors in previous commands quickly.
|
||||
.PP
|
||||
History expansion is usually performed immediately after a complete line
|
||||
is read.
|
||||
It takes place in two parts.
|
||||
The first is to determine which line from the history list
|
||||
to use during substitution.
|
||||
The second is to select portions of that line for inclusion into
|
||||
the current one.
|
||||
The line selected from the history is the \fIevent\fP,
|
||||
and the portions of that line that are acted upon are \fIwords\fP.
|
||||
Various \fImodifiers\fP are available to manipulate the selected words.
|
||||
The line is broken into words in the same fashion as \fBbash\fP
|
||||
does when reading input,
|
||||
so that several words that would otherwise be separated
|
||||
are considered one word when surrounded by quotes (see the
|
||||
description of \fBhistory_tokenize()\fP below).
|
||||
History expansions are introduced by the appearance of the
|
||||
history expansion character, which is \^\fB!\fP\^ by default.
|
||||
Only backslash (\^\fB\e\fP\^) and single quotes can quote
|
||||
the history expansion character.
|
||||
.SS Event Designators
|
||||
.PP
|
||||
An event designator is a reference to a command line entry in the
|
||||
history list.
|
||||
.PP
|
||||
.PD 0
|
||||
.TP
|
||||
.B !
|
||||
Start a history substitution, except when followed by a
|
||||
.BR blank ,
|
||||
newline, = or (.
|
||||
.TP
|
||||
.B !\fIn\fR
|
||||
Refer to command line
|
||||
.IR n .
|
||||
.TP
|
||||
.B !\-\fIn\fR
|
||||
Refer to the current command line minus
|
||||
.IR n .
|
||||
.TP
|
||||
.B !!
|
||||
Refer to the previous command. This is a synonym for `!\-1'.
|
||||
.TP
|
||||
.B !\fIstring\fR
|
||||
Refer to the most recent command starting with
|
||||
.IR string .
|
||||
.TP
|
||||
.B !?\fIstring\fR\fB[?]\fR
|
||||
Refer to the most recent command containing
|
||||
.IR string .
|
||||
The trailing \fB?\fP may be omitted if
|
||||
.I string
|
||||
is followed immediately by a newline.
|
||||
.TP
|
||||
.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
|
||||
Quick substitution. Repeat the last command, replacing
|
||||
.I string1
|
||||
with
|
||||
.IR string2 .
|
||||
Equivalent to
|
||||
``!!:s/\fIstring1\fP/\fIstring2\fP/''
|
||||
(see \fBModifiers\fP below).
|
||||
.TP
|
||||
.B !#
|
||||
The entire command line typed so far.
|
||||
.PD
|
||||
.SS Word Designators
|
||||
.PP
|
||||
Word designators are used to select desired words from the event.
|
||||
A
|
||||
.B :
|
||||
separates the event specification from the word designator.
|
||||
It may be omitted if the word designator begins with a
|
||||
.BR ^ ,
|
||||
.BR $ ,
|
||||
.BR * ,
|
||||
.BR \- ,
|
||||
or
|
||||
.BR % .
|
||||
Words are numbered from the beginning of the line,
|
||||
with the first word being denoted by 0 (zero).
|
||||
Words are inserted into the current line separated by single spaces.
|
||||
.PP
|
||||
.PD 0
|
||||
.TP
|
||||
.B 0 (zero)
|
||||
The zeroth word. For the shell, this is the command
|
||||
word.
|
||||
.TP
|
||||
.I n
|
||||
The \fIn\fRth word.
|
||||
.TP
|
||||
.B ^
|
||||
The first argument. That is, word 1.
|
||||
.TP
|
||||
.B $
|
||||
The last argument.
|
||||
.TP
|
||||
.B %
|
||||
The word matched by the most recent `?\fIstring\fR?' search.
|
||||
.TP
|
||||
.I x\fB\-\fPy
|
||||
A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
|
||||
.TP
|
||||
.B *
|
||||
All of the words but the zeroth. This is a synonym
|
||||
for `\fI1\-$\fP'. It is not an error to use
|
||||
.B *
|
||||
if there is just one
|
||||
word in the event; the empty string is returned in that case.
|
||||
.TP
|
||||
.B x*
|
||||
Abbreviates \fIx\-$\fP.
|
||||
.TP
|
||||
.B x\-
|
||||
Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
|
||||
.PD
|
||||
.PP
|
||||
If a word designator is supplied without an event specification, the
|
||||
previous command is used as the event.
|
||||
.SS Modifiers
|
||||
.PP
|
||||
After the optional word designator, there may appear a sequence of
|
||||
one or more of the following modifiers, each preceded by a `:'.
|
||||
.PP
|
||||
.PD 0
|
||||
.PP
|
||||
.TP
|
||||
.B h
|
||||
Remove a trailing file name component, leaving only the head.
|
||||
.TP
|
||||
.B t
|
||||
Remove all leading file name components, leaving the tail.
|
||||
.TP
|
||||
.B r
|
||||
Remove a trailing suffix of the form \fI.xxx\fP, leaving the
|
||||
basename.
|
||||
.TP
|
||||
.B e
|
||||
Remove all but the trailing suffix.
|
||||
.TP
|
||||
.B p
|
||||
Print the new command but do not execute it.
|
||||
.TP
|
||||
.B q
|
||||
Quote the substituted words, escaping further substitutions.
|
||||
.TP
|
||||
.B x
|
||||
Quote the substituted words as with
|
||||
.BR q ,
|
||||
but break into words at
|
||||
.B blanks
|
||||
and newlines.
|
||||
.TP
|
||||
.B s/\fIold\fP/\fInew\fP/
|
||||
Substitute
|
||||
.I new
|
||||
for the first occurrence of
|
||||
.I old
|
||||
in the event line. Any delimiter can be used in place of /. The
|
||||
final delimiter is optional if it is the last character of the
|
||||
event line. The delimiter may be quoted in
|
||||
.I old
|
||||
and
|
||||
.I new
|
||||
with a single backslash. If & appears in
|
||||
.IR new ,
|
||||
it is replaced by
|
||||
.IR old .
|
||||
A single backslash will quote the &. If
|
||||
.I old
|
||||
is null, it is set to the last
|
||||
.I old
|
||||
substituted, or, if no previous history substitutions took place,
|
||||
the last
|
||||
.I string
|
||||
in a
|
||||
.B !?\fIstring\fR\fB[?]\fR
|
||||
search.
|
||||
.TP
|
||||
.B &
|
||||
Repeat the previous substitution.
|
||||
.TP
|
||||
.B g
|
||||
Cause changes to be applied over the entire event line. This is
|
||||
used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
|
||||
or `\fB:&\fP'. If used with
|
||||
`\fB:s\fP', any delimiter can be used
|
||||
in place of /, and the final delimiter is optional
|
||||
if it is the last character of the event line.
|
||||
.PD
|
||||
.SH "PROGRAMMING WITH HISTORY FUNCTIONS"
|
||||
This section describes how to use the History library in other programs.
|
||||
.SS Introduction to History
|
||||
.PP
|
||||
The programmer using the History library has available functions
|
||||
for remembering lines on a history list, associating arbitrary data
|
||||
with a line, removing lines from the list, searching through the list
|
||||
for a line containing an arbitrary text string, and referencing any line
|
||||
in the list directly. In addition, a history \fIexpansion\fP function
|
||||
is available which provides for a consistent user interface across
|
||||
different programs.
|
||||
.PP
|
||||
The user using programs written with the History library has the
|
||||
benefit of a consistent user interface with a set of well-known
|
||||
commands for manipulating the text of previous lines and using that text
|
||||
in new commands. The basic history manipulation commands are
|
||||
identical to
|
||||
the history substitution provided by \fBbash\fP.
|
||||
.PP
|
||||
If the programmer desires, he can use the Readline library, which
|
||||
includes some history manipulation by default, and has the added
|
||||
advantage of command line editing.
|
||||
.PP
|
||||
Before declaring any functions using any functionality the History
|
||||
library provides in other code, an application writer should include
|
||||
the file
|
||||
.FN <readline/history.h>
|
||||
in any file that uses the
|
||||
History library's features. It supplies extern declarations for all
|
||||
of the library's public functions and variables, and declares all of
|
||||
the public data structures.
|
||||
|
||||
.SS History Storage
|
||||
.PP
|
||||
The history list is an array of history entries. A history entry is
|
||||
declared as follows:
|
||||
.PP
|
||||
.Vb "typedef void *" histdata_t;
|
||||
.PP
|
||||
.nf
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
.fi
|
||||
.PP
|
||||
The history list itself might therefore be declared as
|
||||
.PP
|
||||
.Vb "HIST_ENTRY **" the_history_list;
|
||||
.PP
|
||||
The state of the History library is encapsulated into a single structure:
|
||||
.PP
|
||||
.nf
|
||||
/*
|
||||
* A structure used to pass around the current state of the history.
|
||||
*/
|
||||
typedef struct _hist_state {
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
int offset; /* The location pointer within this array. */
|
||||
int length; /* Number of elements within this array. */
|
||||
int size; /* Number of slots allocated to this array. */
|
||||
int flags;
|
||||
} HISTORY_STATE;
|
||||
.fi
|
||||
.PP
|
||||
If the flags member includes \fBHS_STIFLED\fP, the history has been
|
||||
stifled.
|
||||
.SH "History Functions"
|
||||
.PP
|
||||
This section describes the calling sequence for the various functions
|
||||
exported by the GNU History library.
|
||||
.SS Initializing History and State Management
|
||||
This section describes functions used to initialize and manage
|
||||
the state of the History library when you want to use the history
|
||||
functions in your program.
|
||||
|
||||
.Fn1 void using_history void
|
||||
Begin a session in which the history functions might be used. This
|
||||
initializes the interactive variables.
|
||||
|
||||
.Fn1 "HISTORY_STATE *" history_get_history_state void
|
||||
Return a structure describing the current state of the input history.
|
||||
|
||||
.Fn1 void history_set_history_state "HISTORY_STATE *state"
|
||||
Set the state of the history list according to \fIstate\fP.
|
||||
|
||||
.SS History List Management
|
||||
|
||||
These functions manage individual entries on the history list, or set
|
||||
parameters managing the list itself.
|
||||
|
||||
.Fn1 void add_history "const char *string"
|
||||
Place \fIstring\fP at the end of the history list. The associated data
|
||||
field (if any) is set to \fBNULL\fP.
|
||||
|
||||
.Fn1 "HIST_ENTRY *" remove_history "int which"
|
||||
Remove history entry at offset \fIwhich\fP from the history. The
|
||||
removed element is returned so you can free the line, data,
|
||||
and containing structure.
|
||||
|
||||
.Fn3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" "histdata_t data"
|
||||
Make the history entry at offset \fIwhich\fP have \fIline\fP and \fIdata\fP.
|
||||
This returns the old entry so you can dispose of the data. In the case
|
||||
of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned.
|
||||
|
||||
.Fn1 void clear_history "void"
|
||||
Clear the history list by deleting all the entries.
|
||||
|
||||
.Fn1 void stifle_history "int max"
|
||||
Stifle the history list, remembering only the last \fImax\fP entries.
|
||||
|
||||
.Fn1 int unstifle_history "void"
|
||||
Stop stifling the history. This returns the previously-set
|
||||
maximum number of history entries (as set by \fBstifle_history()\fP).
|
||||
history was stifled. The value is positive if the history was
|
||||
stifled, negative if it wasn't.
|
||||
|
||||
.Fn1 int history_is_stifled "void"
|
||||
Returns non-zero if the history is stifled, zero if it is not.
|
||||
|
||||
.SS Information About the History List
|
||||
|
||||
These functions return information about the entire history list or
|
||||
individual list entries.
|
||||
|
||||
.Fn1 "HIST_ENTRY **" history_list "void"
|
||||
Return a \fBNULL\fP terminated array of \fIHIST_ENTRY *\fP which is the
|
||||
current input history. Element 0 of this list is the beginning of time.
|
||||
If there is no history, return \fBNULL\fP.
|
||||
|
||||
.Fn1 int where_history "void"
|
||||
Returns the offset of the current history element.
|
||||
|
||||
.Fn1 "HIST_ENTRY *" current_history "void"
|
||||
Return the history entry at the current position, as determined by
|
||||
\fBwhere_history()\fP. If there is no entry there, return a \fBNULL\fP
|
||||
pointer.
|
||||
|
||||
.Fn1 "HIST_ENTRY *" history_get "int offset"
|
||||
Return the history entry at position \fIoffset\fP, starting from
|
||||
\fBhistory_base\fP.
|
||||
If there is no entry there, or if \fIoffset\fP
|
||||
is greater than the history length, return a \fBNULL\fP pointer.
|
||||
|
||||
.Fn1 int history_total_bytes "void"
|
||||
Return the number of bytes that the primary history entries are using.
|
||||
This function returns the sum of the lengths of all the lines in the
|
||||
history.
|
||||
|
||||
.SS Moving Around the History List
|
||||
|
||||
These functions allow the current index into the history list to be
|
||||
set or changed.
|
||||
|
||||
.Fn1 int history_set_pos "int pos"
|
||||
Set the current history offset to \fIpos\fP, an absolute index
|
||||
into the list.
|
||||
Returns 1 on success, 0 if \fIpos\fP is less than zero or greater
|
||||
than the number of history entries.
|
||||
|
||||
.Fn1 "HIST_ENTRY *" previous_history "void"
|
||||
Back up the current history offset to the previous history entry, and
|
||||
return a pointer to that entry. If there is no previous entry, return
|
||||
a \fBNULL\fP pointer.
|
||||
|
||||
.Fn1 "HIST_ENTRY *" next_history "void"
|
||||
Move the current history offset forward to the next history entry, and
|
||||
return the a pointer to that entry. If there is no next entry, return
|
||||
a \fBNULL\fP pointer.
|
||||
|
||||
.SS Searching the History List
|
||||
|
||||
These functions allow searching of the history list for entries containing
|
||||
a specific string. Searching may be performed both forward and backward
|
||||
from the current history position. The search may be \fIanchored\fP,
|
||||
meaning that the string must match at the beginning of the history entry.
|
||||
|
||||
.Fn2 int history_search "const char *string" "int direction"
|
||||
Search the history for \fIstring\fP, starting at the current history offset.
|
||||
If \fIdirection\fP is less than 0, then the search is through
|
||||
previous entries, otherwise through subsequent entries.
|
||||
If \fIstring\fP is found, then
|
||||
the current history index is set to that history entry, and the value
|
||||
returned is the offset in the line of the entry where
|
||||
\fIstring\fP was found. Otherwise, nothing is changed, and a -1 is
|
||||
returned.
|
||||
|
||||
.Fn2 int history_search_prefix "const char *string" "int direction"
|
||||
Search the history for \fIstring\fP, starting at the current history
|
||||
offset. The search is anchored: matching lines must begin with
|
||||
\fIstring\fP. If \fIdirection\fP is less than 0, then the search is
|
||||
through previous entries, otherwise through subsequent entries.
|
||||
If \fIstring\fP is found, then the
|
||||
current history index is set to that entry, and the return value is 0.
|
||||
Otherwise, nothing is changed, and a -1 is returned.
|
||||
|
||||
.Fn3 int history_search_pos "const char *string" "int direction" "int pos"
|
||||
Search for \fIstring\fP in the history list, starting at \fIpos\fP, an
|
||||
absolute index into the list. If \fIdirection\fP is negative, the search
|
||||
proceeds backward from \fIpos\fP, otherwise forward. Returns the absolute
|
||||
index of the history element where \fIstring\fP was found, or -1 otherwise.
|
||||
|
||||
.SS Managing the History File
|
||||
The History library can read the history from and write it to a file.
|
||||
This section documents the functions for managing a history file.
|
||||
|
||||
.Fn1 int read_history "const char *filename"
|
||||
Add the contents of \fIfilename\fP to the history list, a line at a time.
|
||||
If \fIfilename\fP is \fBNULL\fP, then read from \fI~/.history\fP.
|
||||
Returns 0 if successful, or \fBerrno\fP if not.
|
||||
|
||||
.Fn3 int read_history_range "const char *filename" "int from" "int to"
|
||||
Read a range of lines from \fIfilename\fP, adding them to the history list.
|
||||
Start reading at line \fIfrom\fP and end at \fIto\fP.
|
||||
If \fIfrom\fP is zero, start at the beginning. If \fIto\fP is less than
|
||||
\fIfrom\fP, then read until the end of the file. If \fIfilename\fP is
|
||||
\fBNULL\fP, then read from \fI~/.history\fP. Returns 0 if successful,
|
||||
or \fBerrno\fP if not.
|
||||
|
||||
.Fn1 int write_history "const char *filename"
|
||||
Write the current history to \fIfilename\fP, overwriting \fIfilename\fP
|
||||
if necessary.
|
||||
If \fIfilename\fP is \fBNULL\fP, then write the history list to \fI~/.history\fP.
|
||||
Returns 0 on success, or \fBerrno\fP on a read or write error.
|
||||
|
||||
|
||||
.Fn2 int append_history "int nelements" "const char *filename"
|
||||
Append the last \fInelements\fP of the history list to \fIfilename\fP.
|
||||
If \fIfilename\fP is \fBNULL\fP, then append to \fI~/.history\fP.
|
||||
Returns 0 on success, or \fBerrno\fP on a read or write error.
|
||||
|
||||
.Fn2 int history_truncate_file "const char *filename" "int nlines"
|
||||
Truncate the history file \fIfilename\fP, leaving only the last
|
||||
\fInlines\fP lines.
|
||||
If \fIfilename\fP is \fBNULL\fP, then \fI~/.history\fP is truncated.
|
||||
Returns 0 on success, or \fBerrno\fP on failure.
|
||||
|
||||
.SS History Expansion
|
||||
|
||||
These functions implement history expansion.
|
||||
|
||||
.Fn2 int history_expand "char *string" "char **output"
|
||||
Expand \fIstring\fP, placing the result into \fIoutput\fP, a pointer
|
||||
to a string. Returns:
|
||||
.RS
|
||||
.PD 0
|
||||
.TP
|
||||
0
|
||||
If no expansions took place (or, if the only change in
|
||||
the text was the removal of escape characters preceding the history expansion
|
||||
character);
|
||||
.TP
|
||||
1
|
||||
if expansions did take place;
|
||||
.TP
|
||||
-1
|
||||
if there was an error in expansion;
|
||||
.TP
|
||||
2
|
||||
if the returned line should be displayed, but not executed,
|
||||
as with the \fB:p\fP modifier.
|
||||
.PD
|
||||
.RE
|
||||
If an error ocurred in expansion, then \fIoutput\fP contains a descriptive
|
||||
error message.
|
||||
|
||||
.Fn3 "char *" get_history_event "const char *string" "int *cindex" "int qchar"
|
||||
Returns the text of the history event beginning at \fIstring\fP +
|
||||
\fI*cindex\fP. \fI*cindex\fP is modified to point to after the event
|
||||
specifier. At function entry, \fIcindex\fP points to the index into
|
||||
\fIstring\fP where the history event specification begins. \fIqchar\fP
|
||||
is a character that is allowed to end the event specification in addition
|
||||
to the ``normal'' terminating characters.
|
||||
|
||||
.Fn1 "char **" history_tokenize "const char *string"
|
||||
Return an array of tokens parsed out of \fIstring\fP, much as the
|
||||
shell might.
|
||||
The tokens are split on the characters in the
|
||||
\fBhistory_word_delimiters\fP variable,
|
||||
and shell quoting conventions are obeyed.
|
||||
|
||||
.Fn3 "char *" history_arg_extract "int first" "int last" "const char *string"
|
||||
Extract a string segment consisting of the \fIfirst\fP through \fIlast\fP
|
||||
arguments present in \fIstring\fP. Arguments are split using
|
||||
\fBhistory_tokenize()\fP.
|
||||
|
||||
.SS History Variables
|
||||
|
||||
This section describes the externally-visible variables exported by
|
||||
the GNU History Library.
|
||||
|
||||
.Vb int history_base
|
||||
The logical offset of the first entry in the history list.
|
||||
|
||||
.Vb int history_length
|
||||
The number of entries currently stored in the history list.
|
||||
|
||||
.Vb int history_max_entries
|
||||
The maximum number of history entries. This must be changed using
|
||||
\fBstifle_history()\fP.
|
||||
|
||||
.Vb char history_expansion_char
|
||||
The character that introduces a history event. The default is \fB!\fP.
|
||||
Setting this to 0 inhibits history expansion.
|
||||
|
||||
.Vb char history_subst_char
|
||||
The character that invokes word substitution if found at the start of
|
||||
a line. The default is \fB^\fP.
|
||||
|
||||
.Vb char history_comment_char
|
||||
During tokenization, if this character is seen as the first character
|
||||
of a word, then it and all subsequent characters up to a newline are
|
||||
ignored, suppressing history expansion for the remainder of the line.
|
||||
This is disabled by default.
|
||||
|
||||
.Vb "char *" history_word_delimiters
|
||||
The characters that separate tokens for \fBhistory_tokenize()\fP.
|
||||
The default value is \fB"\ \et\en()<>;&|"\fP.
|
||||
|
||||
.Vb "char *" history_no_expand_chars
|
||||
The list of characters which inhibit history expansion if found immediately
|
||||
following \fBhistory_expansion_char\fP. The default is space, tab, newline,
|
||||
\fB\er\fP, and \fB=\fP.
|
||||
|
||||
.Vb "char *" history_search_delimiter_chars
|
||||
The list of additional characters which can delimit a history search
|
||||
string, in addition to space, tab, \fI:\fP and \fI?\fP in the case of
|
||||
a substring search. The default is empty.
|
||||
|
||||
.Vb int history_quotes_inhibit_expansion
|
||||
If non-zero, single-quoted words are not scanned for the history expansion
|
||||
character. The default value is 0.
|
||||
|
||||
.Vb "rl_linebuf_func_t *" history_inhibit_expansion_function
|
||||
This should be set to the address of a function that takes two arguments:
|
||||
a \fBchar *\fP (\fIstring\fP)
|
||||
and an \fBint\fP index into that string (\fIi\fP).
|
||||
It should return a non-zero value if the history expansion starting at
|
||||
\fIstring[i]\fP should not be performed; zero if the expansion should
|
||||
be done.
|
||||
It is intended for use by applications like \fBbash\fP that use the history
|
||||
expansion character for additional purposes.
|
||||
By default, this variable is set to \fBNULL\fP.
|
||||
.SH FILES
|
||||
.PD 0
|
||||
.TP
|
||||
.FN ~/.history
|
||||
Default filename for reading and writing saved history
|
||||
.PD
|
||||
.SH "SEE ALSO"
|
||||
.PD 0
|
||||
.TP
|
||||
\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
|
||||
.TP
|
||||
\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
|
||||
.TP
|
||||
\fIbash\fP(1)
|
||||
.TP
|
||||
\fIreadline\fP(3)
|
||||
.PD
|
||||
.SH AUTHORS
|
||||
Brian Fox, Free Software Foundation
|
||||
.br
|
||||
bfox@gnu.org
|
||||
.PP
|
||||
Chet Ramey, Case Western Reserve University
|
||||
.br
|
||||
chet@ins.CWRU.Edu
|
||||
.SH BUG REPORTS
|
||||
If you find a bug in the
|
||||
.B history
|
||||
library, you should report it. But first, you should
|
||||
make sure that it really is a bug, and that it appears in the latest
|
||||
version of the
|
||||
.B history
|
||||
library that you have.
|
||||
.PP
|
||||
Once you have determined that a bug actually exists, mail a
|
||||
bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
|
||||
If you have a fix, you are welcome to mail that
|
||||
as well! Suggestions and `philosophical' bug reports may be mailed
|
||||
to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
|
||||
newsgroup
|
||||
.BR gnu.bash.bug .
|
||||
.PP
|
||||
Comments and bug reports concerning
|
||||
this manual page should be directed to
|
||||
.IR chet@ins.CWRU.Edu .
|
||||
|
|
@ -0,0 +1,550 @@
|
|||
@ignore
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
Copyright (C) 1988-2002 Free Software Foundation, Inc.
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this manual
|
||||
provided the copyright notice and this permission notice are preserved on
|
||||
all copies.
|
||||
|
||||
Permission is granted to process this file through Tex and print the
|
||||
results, provided the printed document carries copying permission notice
|
||||
identical to this one except for the removal of this paragraph (this
|
||||
paragraph not being relevant to the printed manual).
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided also that the
|
||||
GNU Copyright statement is available to the distributee, and provided that
|
||||
the entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions.
|
||||
@end ignore
|
||||
|
||||
@node Programming with GNU History
|
||||
@chapter Programming with GNU History
|
||||
|
||||
This chapter describes how to interface programs that you write
|
||||
with the @sc{gnu} History Library.
|
||||
It should be considered a technical guide.
|
||||
For information on the interactive use of @sc{gnu} History, @pxref{Using
|
||||
History Interactively}.
|
||||
|
||||
@menu
|
||||
* Introduction to History:: What is the GNU History library for?
|
||||
* History Storage:: How information is stored.
|
||||
* History Functions:: Functions that you can use.
|
||||
* History Variables:: Variables that control behaviour.
|
||||
* History Programming Example:: Example of using the GNU History Library.
|
||||
@end menu
|
||||
|
||||
@node Introduction to History
|
||||
@section Introduction to History
|
||||
|
||||
Many programs read input from the user a line at a time. The @sc{gnu}
|
||||
History library is able to keep track of those lines, associate arbitrary
|
||||
data with each line, and utilize information from previous lines in
|
||||
composing new ones.
|
||||
|
||||
The programmer using the History library has available functions
|
||||
for remembering lines on a history list, associating arbitrary data
|
||||
with a line, removing lines from the list, searching through the list
|
||||
for a line containing an arbitrary text string, and referencing any line
|
||||
in the list directly. In addition, a history @dfn{expansion} function
|
||||
is available which provides for a consistent user interface across
|
||||
different programs.
|
||||
|
||||
The user using programs written with the History library has the
|
||||
benefit of a consistent user interface with a set of well-known
|
||||
commands for manipulating the text of previous lines and using that text
|
||||
in new commands. The basic history manipulation commands are similar to
|
||||
the history substitution provided by @code{csh}.
|
||||
|
||||
If the programmer desires, he can use the Readline library, which
|
||||
includes some history manipulation by default, and has the added
|
||||
advantage of command line editing.
|
||||
|
||||
Before declaring any functions using any functionality the History
|
||||
library provides in other code, an application writer should include
|
||||
the file @code{<readline/history.h>} in any file that uses the
|
||||
History library's features. It supplies extern declarations for all
|
||||
of the library's public functions and variables, and declares all of
|
||||
the public data structures.
|
||||
|
||||
@node History Storage
|
||||
@section History Storage
|
||||
|
||||
The history list is an array of history entries. A history entry is
|
||||
declared as follows:
|
||||
|
||||
@example
|
||||
typedef void *histdata_t;
|
||||
|
||||
typedef struct _hist_entry @{
|
||||
char *line;
|
||||
histdata_t data;
|
||||
@} HIST_ENTRY;
|
||||
@end example
|
||||
|
||||
The history list itself might therefore be declared as
|
||||
|
||||
@example
|
||||
HIST_ENTRY **the_history_list;
|
||||
@end example
|
||||
|
||||
The state of the History library is encapsulated into a single structure:
|
||||
|
||||
@example
|
||||
/*
|
||||
* A structure used to pass around the current state of the history.
|
||||
*/
|
||||
typedef struct _hist_state @{
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
int offset; /* The location pointer within this array. */
|
||||
int length; /* Number of elements within this array. */
|
||||
int size; /* Number of slots allocated to this array. */
|
||||
int flags;
|
||||
@} HISTORY_STATE;
|
||||
@end example
|
||||
|
||||
If the flags member includes @code{HS_STIFLED}, the history has been
|
||||
stifled.
|
||||
|
||||
@node History Functions
|
||||
@section History Functions
|
||||
|
||||
This section describes the calling sequence for the various functions
|
||||
exported by the @sc{gnu} History library.
|
||||
|
||||
@menu
|
||||
* Initializing History and State Management:: Functions to call when you
|
||||
want to use history in a
|
||||
program.
|
||||
* History List Management:: Functions used to manage the list
|
||||
of history entries.
|
||||
* Information About the History List:: Functions returning information about
|
||||
the history list.
|
||||
* Moving Around the History List:: Functions used to change the position
|
||||
in the history list.
|
||||
* Searching the History List:: Functions to search the history list
|
||||
for entries containing a string.
|
||||
* Managing the History File:: Functions that read and write a file
|
||||
containing the history list.
|
||||
* History Expansion:: Functions to perform csh-like history
|
||||
expansion.
|
||||
@end menu
|
||||
|
||||
@node Initializing History and State Management
|
||||
@subsection Initializing History and State Management
|
||||
|
||||
This section describes functions used to initialize and manage
|
||||
the state of the History library when you want to use the history
|
||||
functions in your program.
|
||||
|
||||
@deftypefun void using_history (void)
|
||||
Begin a session in which the history functions might be used. This
|
||||
initializes the interactive variables.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HISTORY_STATE *} history_get_history_state (void)
|
||||
Return a structure describing the current state of the input history.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void history_set_history_state (HISTORY_STATE *state)
|
||||
Set the state of the history list according to @var{state}.
|
||||
@end deftypefun
|
||||
|
||||
@node History List Management
|
||||
@subsection History List Management
|
||||
|
||||
These functions manage individual entries on the history list, or set
|
||||
parameters managing the list itself.
|
||||
|
||||
@deftypefun void add_history (const char *string)
|
||||
Place @var{string} at the end of the history list. The associated data
|
||||
field (if any) is set to @code{NULL}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} remove_history (int which)
|
||||
Remove history entry at offset @var{which} from the history. The
|
||||
removed element is returned so you can free the line, data,
|
||||
and containing structure.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} replace_history_entry (int which, const char *line, histdata_t data)
|
||||
Make the history entry at offset @var{which} have @var{line} and @var{data}.
|
||||
This returns the old entry so you can dispose of the data. In the case
|
||||
of an invalid @var{which}, a @code{NULL} pointer is returned.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void clear_history (void)
|
||||
Clear the history list by deleting all the entries.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void stifle_history (int max)
|
||||
Stifle the history list, remembering only the last @var{max} entries.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int unstifle_history (void)
|
||||
Stop stifling the history. This returns the previously-set
|
||||
maximum number of history entries (as set by @code{stifle_history()}).
|
||||
The value is positive if the history was
|
||||
stifled, negative if it wasn't.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int history_is_stifled (void)
|
||||
Returns non-zero if the history is stifled, zero if it is not.
|
||||
@end deftypefun
|
||||
|
||||
@node Information About the History List
|
||||
@subsection Information About the History List
|
||||
|
||||
These functions return information about the entire history list or
|
||||
individual list entries.
|
||||
|
||||
@deftypefun {HIST_ENTRY **} history_list (void)
|
||||
Return a @code{NULL} terminated array of @code{HIST_ENTRY *} which is the
|
||||
current input history. Element 0 of this list is the beginning of time.
|
||||
If there is no history, return @code{NULL}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int where_history (void)
|
||||
Returns the offset of the current history element.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} current_history (void)
|
||||
Return the history entry at the current position, as determined by
|
||||
@code{where_history()}. If there is no entry there, return a @code{NULL}
|
||||
pointer.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} history_get (int offset)
|
||||
Return the history entry at position @var{offset}, starting from
|
||||
@code{history_base} (@pxref{History Variables}).
|
||||
If there is no entry there, or if @var{offset}
|
||||
is greater than the history length, return a @code{NULL} pointer.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int history_total_bytes (void)
|
||||
Return the number of bytes that the primary history entries are using.
|
||||
This function returns the sum of the lengths of all the lines in the
|
||||
history.
|
||||
@end deftypefun
|
||||
|
||||
@node Moving Around the History List
|
||||
@subsection Moving Around the History List
|
||||
|
||||
These functions allow the current index into the history list to be
|
||||
set or changed.
|
||||
|
||||
@deftypefun int history_set_pos (int pos)
|
||||
Set the current history offset to @var{pos}, an absolute index
|
||||
into the list.
|
||||
Returns 1 on success, 0 if @var{pos} is less than zero or greater
|
||||
than the number of history entries.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} previous_history (void)
|
||||
Back up the current history offset to the previous history entry, and
|
||||
return a pointer to that entry. If there is no previous entry, return
|
||||
a @code{NULL} pointer.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} next_history (void)
|
||||
Move the current history offset forward to the next history entry, and
|
||||
return the a pointer to that entry. If there is no next entry, return
|
||||
a @code{NULL} pointer.
|
||||
@end deftypefun
|
||||
|
||||
@node Searching the History List
|
||||
@subsection Searching the History List
|
||||
@cindex History Searching
|
||||
|
||||
These functions allow searching of the history list for entries containing
|
||||
a specific string. Searching may be performed both forward and backward
|
||||
from the current history position. The search may be @dfn{anchored},
|
||||
meaning that the string must match at the beginning of the history entry.
|
||||
@cindex anchored search
|
||||
|
||||
@deftypefun int history_search (const char *string, int direction)
|
||||
Search the history for @var{string}, starting at the current history offset.
|
||||
If @var{direction} is less than 0, then the search is through
|
||||
previous entries, otherwise through subsequent entries.
|
||||
If @var{string} is found, then
|
||||
the current history index is set to that history entry, and the value
|
||||
returned is the offset in the line of the entry where
|
||||
@var{string} was found. Otherwise, nothing is changed, and a -1 is
|
||||
returned.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int history_search_prefix (const char *string, int direction)
|
||||
Search the history for @var{string}, starting at the current history
|
||||
offset. The search is anchored: matching lines must begin with
|
||||
@var{string}. If @var{direction} is less than 0, then the search is
|
||||
through previous entries, otherwise through subsequent entries.
|
||||
If @var{string} is found, then the
|
||||
current history index is set to that entry, and the return value is 0.
|
||||
Otherwise, nothing is changed, and a -1 is returned.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int history_search_pos (const char *string, int direction, int pos)
|
||||
Search for @var{string} in the history list, starting at @var{pos}, an
|
||||
absolute index into the list. If @var{direction} is negative, the search
|
||||
proceeds backward from @var{pos}, otherwise forward. Returns the absolute
|
||||
index of the history element where @var{string} was found, or -1 otherwise.
|
||||
@end deftypefun
|
||||
|
||||
@node Managing the History File
|
||||
@subsection Managing the History File
|
||||
|
||||
The History library can read the history from and write it to a file.
|
||||
This section documents the functions for managing a history file.
|
||||
|
||||
@deftypefun int read_history (const char *filename)
|
||||
Add the contents of @var{filename} to the history list, a line at a time.
|
||||
If @var{filename} is @code{NULL}, then read from @file{~/.history}.
|
||||
Returns 0 if successful, or @code{errno} if not.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int read_history_range (const char *filename, int from, int to)
|
||||
Read a range of lines from @var{filename}, adding them to the history list.
|
||||
Start reading at line @var{from} and end at @var{to}.
|
||||
If @var{from} is zero, start at the beginning. If @var{to} is less than
|
||||
@var{from}, then read until the end of the file. If @var{filename} is
|
||||
@code{NULL}, then read from @file{~/.history}. Returns 0 if successful,
|
||||
or @code{errno} if not.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int write_history (const char *filename)
|
||||
Write the current history to @var{filename}, overwriting @var{filename}
|
||||
if necessary.
|
||||
If @var{filename} is @code{NULL}, then write the history list to
|
||||
@file{~/.history}.
|
||||
Returns 0 on success, or @code{errno} on a read or write error.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int append_history (int nelements, const char *filename)
|
||||
Append the last @var{nelements} of the history list to @var{filename}.
|
||||
If @var{filename} is @code{NULL}, then append to @file{~/.history}.
|
||||
Returns 0 on success, or @code{errno} on a read or write error.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int history_truncate_file (const char *filename, int nlines)
|
||||
Truncate the history file @var{filename}, leaving only the last
|
||||
@var{nlines} lines.
|
||||
If @var{filename} is @code{NULL}, then @file{~/.history} is truncated.
|
||||
Returns 0 on success, or @code{errno} on failure.
|
||||
@end deftypefun
|
||||
|
||||
@node History Expansion
|
||||
@subsection History Expansion
|
||||
|
||||
These functions implement history expansion.
|
||||
|
||||
@deftypefun int history_expand (char *string, char **output)
|
||||
Expand @var{string}, placing the result into @var{output}, a pointer
|
||||
to a string (@pxref{History Interaction}). Returns:
|
||||
@table @code
|
||||
@item 0
|
||||
If no expansions took place (or, if the only change in
|
||||
the text was the removal of escape characters preceding the history expansion
|
||||
character);
|
||||
@item 1
|
||||
if expansions did take place;
|
||||
@item -1
|
||||
if there was an error in expansion;
|
||||
@item 2
|
||||
if the returned line should be displayed, but not executed,
|
||||
as with the @code{:p} modifier (@pxref{Modifiers}).
|
||||
@end table
|
||||
|
||||
If an error ocurred in expansion, then @var{output} contains a descriptive
|
||||
error message.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {char *} get_history_event (const char *string, int *cindex, int qchar)
|
||||
Returns the text of the history event beginning at @var{string} +
|
||||
@var{*cindex}. @var{*cindex} is modified to point to after the event
|
||||
specifier. At function entry, @var{cindex} points to the index into
|
||||
@var{string} where the history event specification begins. @var{qchar}
|
||||
is a character that is allowed to end the event specification in addition
|
||||
to the ``normal'' terminating characters.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {char **} history_tokenize (const char *string)
|
||||
Return an array of tokens parsed out of @var{string}, much as the
|
||||
shell might. The tokens are split on the characters in the
|
||||
@var{history_word_delimiters} variable,
|
||||
and shell quoting conventions are obeyed.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {char *} history_arg_extract (int first, int last, const char *string)
|
||||
Extract a string segment consisting of the @var{first} through @var{last}
|
||||
arguments present in @var{string}. Arguments are split using
|
||||
@code{history_tokenize}.
|
||||
@end deftypefun
|
||||
|
||||
@node History Variables
|
||||
@section History Variables
|
||||
|
||||
This section describes the externally-visible variables exported by
|
||||
the @sc{gnu} History Library.
|
||||
|
||||
@deftypevar int history_base
|
||||
The logical offset of the first entry in the history list.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_length
|
||||
The number of entries currently stored in the history list.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_max_entries
|
||||
The maximum number of history entries. This must be changed using
|
||||
@code{stifle_history()}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar char history_expansion_char
|
||||
The character that introduces a history event. The default is @samp{!}.
|
||||
Setting this to 0 inhibits history expansion.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar char history_subst_char
|
||||
The character that invokes word substitution if found at the start of
|
||||
a line. The default is @samp{^}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar char history_comment_char
|
||||
During tokenization, if this character is seen as the first character
|
||||
of a word, then it and all subsequent characters up to a newline are
|
||||
ignored, suppressing history expansion for the remainder of the line.
|
||||
This is disabled by default.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} history_word_delimiters
|
||||
The characters that separate tokens for @code{history_tokenize()}.
|
||||
The default value is @code{" \t\n()<>;&|"}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} history_no_expand_chars
|
||||
The list of characters which inhibit history expansion if found immediately
|
||||
following @var{history_expansion_char}. The default is space, tab, newline,
|
||||
carriage return, and @samp{=}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} history_search_delimiter_chars
|
||||
The list of additional characters which can delimit a history search
|
||||
string, in addition to space, TAB, @samp{:} and @samp{?} in the case of
|
||||
a substring search. The default is empty.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_quotes_inhibit_expansion
|
||||
If non-zero, single-quoted words are not scanned for the history expansion
|
||||
character. The default value is 0.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {rl_linebuf_func_t *} history_inhibit_expansion_function
|
||||
This should be set to the address of a function that takes two arguments:
|
||||
a @code{char *} (@var{string})
|
||||
and an @code{int} index into that string (@var{i}).
|
||||
It should return a non-zero value if the history expansion starting at
|
||||
@var{string[i]} should not be performed; zero if the expansion should
|
||||
be done.
|
||||
It is intended for use by applications like Bash that use the history
|
||||
expansion character for additional purposes.
|
||||
By default, this variable is set to @code{NULL}.
|
||||
@end deftypevar
|
||||
|
||||
@node History Programming Example
|
||||
@section History Programming Example
|
||||
|
||||
The following program demonstrates simple use of the @sc{gnu} History Library.
|
||||
|
||||
@smallexample
|
||||
#include <stdio.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
@{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
|
||||
line[0] = 0;
|
||||
|
||||
using_history ();
|
||||
while (!done)
|
||||
@{
|
||||
printf ("history$ ");
|
||||
fflush (stdout);
|
||||
t = fgets (line, sizeof (line) - 1, stdin);
|
||||
if (t && *t)
|
||||
@{
|
||||
len = strlen (t);
|
||||
if (t[len - 1] == '\n')
|
||||
t[len - 1] = '\0';
|
||||
@}
|
||||
|
||||
if (!t)
|
||||
strcpy (line, "quit");
|
||||
|
||||
if (line[0])
|
||||
@{
|
||||
char *expansion;
|
||||
int result;
|
||||
|
||||
result = history_expand (line, &expansion);
|
||||
if (result)
|
||||
fprintf (stderr, "%s\n", expansion);
|
||||
|
||||
if (result < 0 || result == 2)
|
||||
@{
|
||||
free (expansion);
|
||||
continue;
|
||||
@}
|
||||
|
||||
add_history (expansion);
|
||||
strncpy (line, expansion, sizeof (line) - 1);
|
||||
free (expansion);
|
||||
@}
|
||||
|
||||
if (strcmp (line, "quit") == 0)
|
||||
done = 1;
|
||||
else if (strcmp (line, "save") == 0)
|
||||
write_history ("history_file");
|
||||
else if (strcmp (line, "read") == 0)
|
||||
read_history ("history_file");
|
||||
else if (strcmp (line, "list") == 0)
|
||||
@{
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
|
||||
the_list = history_list ();
|
||||
if (the_list)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
printf ("%d: %s\n", i + history_base, the_list[i]->line);
|
||||
@}
|
||||
else if (strncmp (line, "delete", 6) == 0)
|
||||
@{
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
@{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
@{
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
@}
|
||||
@}
|
||||
else
|
||||
@{
|
||||
fprintf (stderr, "non-numeric arg given to `delete'\n");
|
||||
@}
|
||||
@}
|
||||
@}
|
||||
@}
|
||||
@end smallexample
|
||||
|
|
@ -0,0 +1,437 @@
|
|||
@ignore
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
Copyright (C) 1988-2002 Free Software Foundation, Inc.
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this manual
|
||||
provided the copyright notice and this permission notice are preserved on
|
||||
all copies.
|
||||
|
||||
Permission is granted to process this file through Tex and print the
|
||||
results, provided the printed document carries copying permission notice
|
||||
identical to this one except for the removal of this paragraph (this
|
||||
paragraph not being relevant to the printed manual).
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided also that the
|
||||
GNU Copyright statement is available to the distributee, and provided that
|
||||
the entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions.
|
||||
@end ignore
|
||||
|
||||
@node Using History Interactively
|
||||
@chapter Using History Interactively
|
||||
|
||||
@ifclear BashFeatures
|
||||
@defcodeindex bt
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
This chapter describes how to use the @sc{gnu} History Library
|
||||
interactively, from a user's standpoint.
|
||||
It should be considered a user's guide.
|
||||
For information on using the @sc{gnu} History Library in other programs,
|
||||
see the @sc{gnu} Readline Library Manual.
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
This chapter describes how to use the @sc{gnu} History Library interactively,
|
||||
from a user's standpoint. It should be considered a user's guide. For
|
||||
information on using the @sc{gnu} History Library in your own programs,
|
||||
@pxref{Programming with GNU History}.
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
@menu
|
||||
* Bash History Facilities:: How Bash lets you manipulate your command
|
||||
history.
|
||||
* Bash History Builtins:: The Bash builtin commands that manipulate
|
||||
the command history.
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
@end menu
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
@menu
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
@end menu
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
@node Bash History Facilities
|
||||
@section Bash History Facilities
|
||||
@cindex command history
|
||||
@cindex history list
|
||||
|
||||
When the @option{-o history} option to the @code{set} builtin
|
||||
is enabled (@pxref{The Set Builtin}),
|
||||
the shell provides access to the @dfn{command history},
|
||||
the list of commands previously typed.
|
||||
The value of the @env{HISTSIZE} shell variable is used as the
|
||||
number of commands to save in a history list.
|
||||
The text of the last @env{$HISTSIZE}
|
||||
commands (default 500) is saved.
|
||||
The shell stores each command in the history list prior to
|
||||
parameter and variable expansion
|
||||
but after history expansion is performed, subject to the
|
||||
values of the shell variables
|
||||
@env{HISTIGNORE} and @env{HISTCONTROL}.
|
||||
|
||||
When the shell starts up, the history is initialized from the
|
||||
file named by the @env{HISTFILE} variable (default @file{~/.bash_history}).
|
||||
The file named by the value of @env{HISTFILE} is truncated, if
|
||||
necessary, to contain no more than the number of lines specified by
|
||||
the value of the @env{HISTFILESIZE} variable.
|
||||
When an interactive shell exits, the last
|
||||
@env{$HISTSIZE} lines are copied from the history list to the file
|
||||
named by @env{$HISTFILE}.
|
||||
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
|
||||
the lines are appended to the history file,
|
||||
otherwise the history file is overwritten.
|
||||
If @env{HISTFILE}
|
||||
is unset, or if the history file is unwritable, the history is
|
||||
not saved. After saving the history, the history file is truncated
|
||||
to contain no more than @env{$HISTFILESIZE}
|
||||
lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
|
||||
|
||||
The builtin command @code{fc} may be used to list or edit and re-execute
|
||||
a portion of the history list.
|
||||
The @code{history} builtin may be used to display or modify the history
|
||||
list and manipulate the history file.
|
||||
When using command-line editing, search commands
|
||||
are available in each editing mode that provide access to the
|
||||
history list (@pxref{Commands For History}).
|
||||
|
||||
The shell allows control over which commands are saved on the history
|
||||
list. The @env{HISTCONTROL} and @env{HISTIGNORE}
|
||||
variables may be set to cause the shell to save only a subset of the
|
||||
commands entered.
|
||||
The @code{cmdhist}
|
||||
shell option, if enabled, causes the shell to attempt to save each
|
||||
line of a multi-line command in the same history entry, adding
|
||||
semicolons where necessary to preserve syntactic correctness.
|
||||
The @code{lithist}
|
||||
shell option causes the shell to save the command with embedded newlines
|
||||
instead of semicolons.
|
||||
The @code{shopt} builtin is used to set these options.
|
||||
@xref{Bash Builtins}, for a description of @code{shopt}.
|
||||
|
||||
@node Bash History Builtins
|
||||
@section Bash History Builtins
|
||||
@cindex history builtins
|
||||
|
||||
Bash provides two builtin commands which manipulate the
|
||||
history list and history file.
|
||||
|
||||
@table @code
|
||||
|
||||
@item fc
|
||||
@btindex fc
|
||||
@example
|
||||
@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
|
||||
@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
|
||||
@end example
|
||||
|
||||
Fix Command. In the first form, a range of commands from @var{first} to
|
||||
@var{last} is selected from the history list. Both @var{first} and
|
||||
@var{last} may be specified as a string (to locate the most recent
|
||||
command beginning with that string) or as a number (an index into the
|
||||
history list, where a negative number is used as an offset from the
|
||||
current command number). If @var{last} is not specified it is set to
|
||||
@var{first}. If @var{first} is not specified it is set to the previous
|
||||
command for editing and @minus{}16 for listing. If the @option{-l} flag is
|
||||
given, the commands are listed on standard output. The @option{-n} flag
|
||||
suppresses the command numbers when listing. The @option{-r} flag
|
||||
reverses the order of the listing. Otherwise, the editor given by
|
||||
@var{ename} is invoked on a file containing those commands. If
|
||||
@var{ename} is not given, the value of the following variable expansion
|
||||
is used: @code{$@{FCEDIT:-$@{EDITOR:-vi@}@}}. This says to use the
|
||||
value of the @env{FCEDIT} variable if set, or the value of the
|
||||
@env{EDITOR} variable if that is set, or @code{vi} if neither is set.
|
||||
When editing is complete, the edited commands are echoed and executed.
|
||||
|
||||
In the second form, @var{command} is re-executed after each instance
|
||||
of @var{pat} in the selected command is replaced by @var{rep}.
|
||||
|
||||
A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so
|
||||
that typing @samp{r cc} runs the last command beginning with @code{cc}
|
||||
and typing @samp{r} re-executes the last command (@pxref{Aliases}).
|
||||
|
||||
@item history
|
||||
@btindex history
|
||||
@example
|
||||
history [@var{n}]
|
||||
history -c
|
||||
history -d @var{offset}
|
||||
history [-anrw] [@var{filename}]
|
||||
history -ps @var{arg}
|
||||
@end example
|
||||
|
||||
With no options, display the history list with line numbers.
|
||||
Lines prefixed with a @samp{*} have been modified.
|
||||
An argument of @var{n} lists only the last @var{n} lines.
|
||||
Options, if supplied, have the following meanings:
|
||||
|
||||
@table @code
|
||||
@item -c
|
||||
Clear the history list. This may be combined
|
||||
with the other options to replace the history list completely.
|
||||
|
||||
@item -d @var{offset}
|
||||
Delete the history entry at position @var{offset}.
|
||||
@var{offset} should be specified as it appears when the history is
|
||||
displayed.
|
||||
|
||||
@item -a
|
||||
Append the new
|
||||
history lines (history lines entered since the beginning of the
|
||||
current Bash session) to the history file.
|
||||
|
||||
@item -n
|
||||
Append the history lines not already read from the history file
|
||||
to the current history list. These are lines appended to the history
|
||||
file since the beginning of the current Bash session.
|
||||
|
||||
@item -r
|
||||
Read the current history file and append its contents to
|
||||
the history list.
|
||||
|
||||
@item -w
|
||||
Write out the current history to the history file.
|
||||
|
||||
@item -p
|
||||
Perform history substitution on the @var{arg}s and display the result
|
||||
on the standard output, without storing the results in the history list.
|
||||
|
||||
@item -s
|
||||
The @var{arg}s are added to the end of
|
||||
the history list as a single entry.
|
||||
|
||||
@end table
|
||||
|
||||
When any of the @option{-w}, @option{-r}, @option{-a}, or @option{-n} options is
|
||||
used, if @var{filename}
|
||||
is given, then it is used as the history file. If not, then
|
||||
the value of the @env{HISTFILE} variable is used.
|
||||
|
||||
@end table
|
||||
@end ifset
|
||||
|
||||
@node History Interaction
|
||||
@section History Expansion
|
||||
@cindex history expansion
|
||||
|
||||
The History library provides a history expansion feature that is similar
|
||||
to the history expansion provided by @code{csh}. This section
|
||||
describes the syntax used to manipulate the history information.
|
||||
|
||||
History expansions introduce words from the history list into
|
||||
the input stream, making it easy to repeat commands, insert the
|
||||
arguments to a previous command into the current input line, or
|
||||
fix errors in previous commands quickly.
|
||||
|
||||
History expansion takes place in two parts. The first is to determine
|
||||
which line from the history list should be used during substitution.
|
||||
The second is to select portions of that line for inclusion into the
|
||||
current one. The line selected from the history is called the
|
||||
@dfn{event}, and the portions of that line that are acted upon are
|
||||
called @dfn{words}. Various @dfn{modifiers} are available to manipulate
|
||||
the selected words. The line is broken into words in the same fashion
|
||||
that Bash does, so that several words
|
||||
surrounded by quotes are considered one word.
|
||||
History expansions are introduced by the appearance of the
|
||||
history expansion character, which is @samp{!} by default.
|
||||
@ifset BashFeatures
|
||||
Only @samp{\} and @samp{'} may be used to escape the history expansion
|
||||
character.
|
||||
@end ifset
|
||||
|
||||
@ifset BashFeatures
|
||||
Several shell options settable with the @code{shopt}
|
||||
builtin (@pxref{Bash Builtins}) may be used to tailor
|
||||
the behavior of history expansion. If the
|
||||
@code{histverify} shell option is enabled, and Readline
|
||||
is being used, history substitutions are not immediately passed to
|
||||
the shell parser.
|
||||
Instead, the expanded line is reloaded into the Readline
|
||||
editing buffer for further modification.
|
||||
If Readline is being used, and the @code{histreedit}
|
||||
shell option is enabled, a failed history expansion will be
|
||||
reloaded into the Readline editing buffer for correction.
|
||||
The @option{-p} option to the @code{history} builtin command
|
||||
may be used to see what a history expansion will do before using it.
|
||||
The @option{-s} option to the @code{history} builtin may be used to
|
||||
add commands to the end of the history list without actually executing
|
||||
them, so that they are available for subsequent recall.
|
||||
This is most useful in conjunction with Readline.
|
||||
|
||||
The shell allows control of the various characters used by the
|
||||
history expansion mechanism with the @code{histchars} variable.
|
||||
@end ifset
|
||||
|
||||
@menu
|
||||
* Event Designators:: How to specify which history line to use.
|
||||
* Word Designators:: Specifying which words are of interest.
|
||||
* Modifiers:: Modifying the results of substitution.
|
||||
@end menu
|
||||
|
||||
@node Event Designators
|
||||
@subsection Event Designators
|
||||
@cindex event designators
|
||||
|
||||
An event designator is a reference to a command line entry in the
|
||||
history list.
|
||||
@cindex history events
|
||||
|
||||
@table @asis
|
||||
|
||||
@item @code{!}
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, @samp{=} or @samp{(}.
|
||||
|
||||
@item @code{!@var{n}}
|
||||
Refer to command line @var{n}.
|
||||
|
||||
@item @code{!-@var{n}}
|
||||
Refer to the command @var{n} lines back.
|
||||
|
||||
@item @code{!!}
|
||||
Refer to the previous command. This is a synonym for @samp{!-1}.
|
||||
|
||||
@item @code{!@var{string}}
|
||||
Refer to the most recent command starting with @var{string}.
|
||||
|
||||
@item @code{!?@var{string}[?]}
|
||||
Refer to the most recent command containing @var{string}. The trailing
|
||||
@samp{?} may be omitted if the @var{string} is followed immediately by
|
||||
a newline.
|
||||
|
||||
@item @code{^@var{string1}^@var{string2}^}
|
||||
Quick Substitution. Repeat the last command, replacing @var{string1}
|
||||
with @var{string2}. Equivalent to
|
||||
@code{!!:s/@var{string1}/@var{string2}/}.
|
||||
|
||||
@item @code{!#}
|
||||
The entire command line typed so far.
|
||||
|
||||
@end table
|
||||
|
||||
@node Word Designators
|
||||
@subsection Word Designators
|
||||
|
||||
Word designators are used to select desired words from the event.
|
||||
A @samp{:} separates the event specification from the word designator. It
|
||||
may be omitted if the word designator begins with a @samp{^}, @samp{$},
|
||||
@samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning
|
||||
of the line, with the first word being denoted by 0 (zero). Words are
|
||||
inserted into the current line separated by single spaces.
|
||||
|
||||
@need 0.75
|
||||
For example,
|
||||
|
||||
@table @code
|
||||
@item !!
|
||||
designates the preceding command. When you type this, the preceding
|
||||
command is repeated in toto.
|
||||
|
||||
@item !!:$
|
||||
designates the last argument of the preceding command. This may be
|
||||
shortened to @code{!$}.
|
||||
|
||||
@item !fi:2
|
||||
designates the second argument of the most recent command starting with
|
||||
the letters @code{fi}.
|
||||
@end table
|
||||
|
||||
@need 0.75
|
||||
Here are the word designators:
|
||||
|
||||
@table @code
|
||||
|
||||
@item 0 (zero)
|
||||
The @code{0}th word. For many applications, this is the command word.
|
||||
|
||||
@item @var{n}
|
||||
The @var{n}th word.
|
||||
|
||||
@item ^
|
||||
The first argument; that is, word 1.
|
||||
|
||||
@item $
|
||||
The last argument.
|
||||
|
||||
@item %
|
||||
The word matched by the most recent @samp{?@var{string}?} search.
|
||||
|
||||
@item @var{x}-@var{y}
|
||||
A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}.
|
||||
|
||||
@item *
|
||||
All of the words, except the @code{0}th. This is a synonym for @samp{1-$}.
|
||||
It is not an error to use @samp{*} if there is just one word in the event;
|
||||
the empty string is returned in that case.
|
||||
|
||||
@item @var{x}*
|
||||
Abbreviates @samp{@var{x}-$}
|
||||
|
||||
@item @var{x}-
|
||||
Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word.
|
||||
|
||||
@end table
|
||||
|
||||
If a word designator is supplied without an event specification, the
|
||||
previous command is used as the event.
|
||||
|
||||
@node Modifiers
|
||||
@subsection Modifiers
|
||||
|
||||
After the optional word designator, you can add a sequence of one or more
|
||||
of the following modifiers, each preceded by a @samp{:}.
|
||||
|
||||
@table @code
|
||||
|
||||
@item h
|
||||
Remove a trailing pathname component, leaving only the head.
|
||||
|
||||
@item t
|
||||
Remove all leading pathname components, leaving the tail.
|
||||
|
||||
@item r
|
||||
Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
|
||||
the basename.
|
||||
|
||||
@item e
|
||||
Remove all but the trailing suffix.
|
||||
|
||||
@item p
|
||||
Print the new command but do not execute it.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item q
|
||||
Quote the substituted words, escaping further substitutions.
|
||||
|
||||
@item x
|
||||
Quote the substituted words as with @samp{q},
|
||||
but break into words at spaces, tabs, and newlines.
|
||||
@end ifset
|
||||
|
||||
@item s/@var{old}/@var{new}/
|
||||
Substitute @var{new} for the first occurrence of @var{old} in the
|
||||
event line. Any delimiter may be used in place of @samp{/}.
|
||||
The delimiter may be quoted in @var{old} and @var{new}
|
||||
with a single backslash. If @samp{&} appears in @var{new},
|
||||
it is replaced by @var{old}. A single backslash will quote
|
||||
the @samp{&}. The final delimiter is optional if it is the last
|
||||
character on the input line.
|
||||
|
||||
@item &
|
||||
Repeat the previous substitution.
|
||||
|
||||
@item g
|
||||
Cause changes to be applied over the entire event line. Used in
|
||||
conjunction with @samp{s}, as in @code{gs/@var{old}/@var{new}/},
|
||||
or with @samp{&}.
|
||||
|
||||
@end table
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
@ignore
|
||||
Copyright (C) 1988-2002 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 4.3
|
||||
@set VERSION 4.3
|
||||
@set UPDATED 2002 March 4
|
||||
@set UPDATE-MONTH March 2002
|
||||
|
||||
@set LASTCHANGE Mon Mar 4 12:00:16 EST 2002
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,108 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@comment %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename readline.info
|
||||
@settitle GNU Readline Library
|
||||
@comment %**end of header (This is for running Texinfo on a region.)
|
||||
@synindex vr fn
|
||||
@setchapternewpage odd
|
||||
|
||||
@include manvers.texinfo
|
||||
|
||||
@ifinfo
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* Readline: (readline). The GNU readline library API
|
||||
@end direntry
|
||||
|
||||
This document describes the GNU Readline Library, a utility which aids
|
||||
in the consistency of user interface across discrete programs that need
|
||||
to provide a command line interface.
|
||||
|
||||
Copyright (C) 1988-2002 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
pare preserved on all copies.
|
||||
|
||||
@ignore
|
||||
Permission is granted to process this file through TeX and print the
|
||||
results, provided the printed document carries copying permission
|
||||
notice identical to this one except for the removal of this paragraph
|
||||
(this paragraph not being relevant to the printed manual).
|
||||
@end ignore
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Free Software Foundation.
|
||||
@end ifinfo
|
||||
|
||||
@titlepage
|
||||
@title GNU Readline Library
|
||||
@subtitle Edition @value{EDITION}, for @code{Readline Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATE-MONTH}
|
||||
@author Brian Fox, Free Software Foundation
|
||||
@author Chet Ramey, Case Western Reserve University
|
||||
|
||||
@page
|
||||
This document describes the GNU Readline Library, a utility which aids
|
||||
in the consistency of user interface across discrete programs that need
|
||||
to provide a command line interface.
|
||||
|
||||
Published by the Free Software Foundation @*
|
||||
59 Temple Place, Suite 330, @*
|
||||
Boston, MA 02111 USA
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Free Software Foundation.
|
||||
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1988-2002 Free Software Foundation, Inc.
|
||||
@end titlepage
|
||||
|
||||
@ifinfo
|
||||
@node Top
|
||||
@top GNU Readline Library
|
||||
|
||||
This document describes the GNU Readline Library, a utility which aids
|
||||
in the consistency of user interface across discrete programs that need
|
||||
to provide a command line interface.
|
||||
|
||||
@menu
|
||||
* Command Line Editing:: GNU Readline User's Manual.
|
||||
* Programming with GNU Readline:: GNU Readline Programmer's Manual.
|
||||
* Concept Index:: Index of concepts described in this manual.
|
||||
* Function and Variable Index:: Index of externally visible functions
|
||||
and variables.
|
||||
@end menu
|
||||
@end ifinfo
|
||||
|
||||
@include rluser.texinfo
|
||||
@include rltech.texinfo
|
||||
|
||||
@node Concept Index
|
||||
@unnumbered Concept Index
|
||||
@printindex cp
|
||||
|
||||
@node Function and Variable Index
|
||||
@unnumbered Function and Variable Index
|
||||
@printindex fn
|
||||
|
||||
@contents
|
||||
@bye
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,94 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@comment %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename rluserman.info
|
||||
@settitle GNU Readline Library
|
||||
@comment %**end of header (This is for running Texinfo on a region.)
|
||||
@setchapternewpage odd
|
||||
|
||||
@include manvers.texinfo
|
||||
|
||||
@ifinfo
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* RLuserman: (rluserman). The GNU readline library User's Manual.
|
||||
@end direntry
|
||||
|
||||
This document describes the end user interface of the GNU Readline Library,
|
||||
a utility which aids in the consistency of user interface across discrete
|
||||
programs that need to provide a command line interface.
|
||||
|
||||
Copyright (C) 1988-2002 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
pare preserved on all copies.
|
||||
|
||||
@ignore
|
||||
Permission is granted to process this file through TeX and print the
|
||||
results, provided the printed document carries copying permission
|
||||
notice identical to this one except for the removal of this paragraph
|
||||
(this paragraph not being relevant to the printed manual).
|
||||
@end ignore
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Free Software Foundation.
|
||||
@end ifinfo
|
||||
|
||||
@titlepage
|
||||
@title GNU Readline Library User Interface
|
||||
@subtitle Edition @value{EDITION}, for @code{Readline Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATE-MONTH}
|
||||
@author Brian Fox, Free Software Foundation
|
||||
@author Chet Ramey, Case Western Reserve University
|
||||
|
||||
@page
|
||||
This document describes the end user interface of the GNU Readline Library,
|
||||
a utility which aids in the consistency of user interface across discrete
|
||||
programs that need to provide a command line interface.
|
||||
|
||||
Published by the Free Software Foundation @*
|
||||
59 Temple Place, Suite 330, @*
|
||||
Boston, MA 02111 USA
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Free Software Foundation.
|
||||
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1988-2002 Free Software Foundation, Inc.
|
||||
@end titlepage
|
||||
|
||||
@ifinfo
|
||||
@node Top
|
||||
@top GNU Readline Library
|
||||
|
||||
This document describes the end user interface of the GNU Readline Library,
|
||||
a utility which aids in the consistency of user interface across discrete
|
||||
programs that need to provide a command line interface.
|
||||
|
||||
@menu
|
||||
* Command Line Editing:: GNU Readline User's Manual.
|
||||
@end menu
|
||||
@end ifinfo
|
||||
|
||||
@include rluser.texinfo
|
||||
|
||||
@contents
|
||||
@bye
|
||||
|
|
@ -0,0 +1,568 @@
|
|||
#! /bin/sh
|
||||
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
|
||||
# $Header$
|
||||
#
|
||||
# Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program; if not, you can either send email to this
|
||||
# program's maintainer or write to: The Free Software Foundation,
|
||||
# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# Original author: Noah Friedman <friedman@gnu.org>.
|
||||
#
|
||||
# Please send bug reports, etc. to bug-texinfo@gnu.org.
|
||||
# If possible, please send a copy of the output of the script called with
|
||||
# the `--debug' option when making a bug report.
|
||||
|
||||
# This string is expanded by rcs automatically when this file is checked out.
|
||||
rcs_revision='$Revision$'
|
||||
rcs_version=`set - $rcs_revision; echo $2`
|
||||
program=`echo $0 | sed -e 's!.*/!!'`
|
||||
version="texi2dvi (GNU Texinfo 4.0) $rcs_version
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
There is NO warranty. You may redistribute this software
|
||||
under the terms of the GNU General Public License.
|
||||
For more information about these matters, see the files named COPYING."
|
||||
|
||||
usage="Usage: $program [OPTION]... FILE...
|
||||
|
||||
Run each Texinfo or LaTeX FILE through TeX in turn until all
|
||||
cross-references are resolved, building all indices. The directory
|
||||
containing each FILE is searched for included files. The suffix of FILE
|
||||
is used to determine its language (LaTeX or Texinfo).
|
||||
|
||||
Makeinfo is used to perform Texinfo macro expansion before running TeX
|
||||
when needed.
|
||||
|
||||
Options:
|
||||
-@ Use @input instead of \input; for preloaded Texinfo.
|
||||
-b, --batch No interaction.
|
||||
-c, --clean Remove all auxiliary files.
|
||||
-D, --debug Turn on shell debugging (set -x).
|
||||
-e, --expand Force macro expansion using makeinfo.
|
||||
-I DIR Search DIR for Texinfo files.
|
||||
-h, --help Display this help and exit successfully.
|
||||
-l, --language=LANG Specify the LANG of FILE: LaTeX or Texinfo.
|
||||
-p, --pdf Use pdftex or pdflatex for processing.
|
||||
-q, --quiet No output unless errors (implies --batch).
|
||||
-s, --silent Same as --quiet.
|
||||
-t, --texinfo=CMD Insert CMD after @setfilename in copy of input file.
|
||||
Multiple values accumulate.
|
||||
-v, --version Display version information and exit successfully.
|
||||
-V, --verbose Report on what is done.
|
||||
|
||||
The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
|
||||
TEX (or PDFTEX), and TEXINDEX environment variables are used to run
|
||||
those commands, if they are set.
|
||||
|
||||
Email bug reports to <bug-texinfo@gnu.org>,
|
||||
general questions and discussion to <help-texinfo@gnu.org>."
|
||||
|
||||
# Initialize variables for option overriding and otherwise.
|
||||
# Don't use `unset' since old bourne shells don't have this command.
|
||||
# Instead, assign them an empty value.
|
||||
escape='\'
|
||||
batch=false # eval for batch mode
|
||||
clean=
|
||||
debug=
|
||||
expand= # t for expansion via makeinfo
|
||||
oformat=dvi
|
||||
set_language=
|
||||
miincludes= # makeinfo include path
|
||||
textra=
|
||||
tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.
|
||||
txincludes= # TEXINPUTS extensions
|
||||
txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
|
||||
quiet= # by default let the tools' message be displayed
|
||||
verbose=false # echo for verbose mode
|
||||
|
||||
orig_pwd=`pwd`
|
||||
|
||||
# Systems which define $COMSPEC or $ComSpec use semicolons to separate
|
||||
# directories in TEXINPUTS.
|
||||
if test -n "$COMSPEC$ComSpec"; then
|
||||
path_sep=";"
|
||||
else
|
||||
path_sep=":"
|
||||
fi
|
||||
|
||||
# Save this so we can construct a new TEXINPUTS path for each file.
|
||||
TEXINPUTS_orig="$TEXINPUTS"
|
||||
# Unfortunately makeindex does not read TEXINPUTS.
|
||||
INDEXSTYLE_orig="$INDEXSTYLE"
|
||||
export TEXINPUTS INDEXSTYLE
|
||||
|
||||
# Push a token among the arguments that will be used to notice when we
|
||||
# ended options/arguments parsing.
|
||||
# Use "set dummy ...; shift" rather than 'set - ..." because on
|
||||
# Solaris set - turns off set -x (but keeps set -e).
|
||||
# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
|
||||
# still expand "$@" to a single argument (the empty string) rather
|
||||
# than nothing at all.
|
||||
arg_sep="$$--$$"
|
||||
set dummy ${1+"$@"} "$arg_sep"; shift
|
||||
|
||||
#
|
||||
# Parse command line arguments.
|
||||
while test x"$1" != x"$arg_sep"; do
|
||||
|
||||
# Handle --option=value by splitting apart and putting back on argv.
|
||||
case "$1" in
|
||||
--*=*)
|
||||
opt=`echo "$1" | sed -e 's/=.*//'`
|
||||
val=`echo "$1" | sed -e 's/[^=]*=//'`
|
||||
shift
|
||||
set dummy "$opt" "$val" ${1+"$@"}; shift
|
||||
;;
|
||||
esac
|
||||
|
||||
# This recognizes --quark as --quiet. So what.
|
||||
case "$1" in
|
||||
-@ ) escape=@;;
|
||||
# Silently and without documentation accept -b and --b[atch] as synonyms.
|
||||
-b | --b*) batch=eval;;
|
||||
-q | -s | --q* | --s*) quiet=t; batch=eval;;
|
||||
-c | --c*) clean=t;;
|
||||
-D | --d*) debug=t;;
|
||||
-e | --e*) expand=t;;
|
||||
-h | --h*) echo "$usage"; exit 0;;
|
||||
-I | --I*)
|
||||
shift
|
||||
miincludes="$miincludes -I $1"
|
||||
txincludes="$txincludes$path_sep$1"
|
||||
;;
|
||||
-l | --l*) shift; set_language=$1;;
|
||||
-p | --p*) oformat=pdf;;
|
||||
-t | --t*) shift; textra="$textra\\
|
||||
$1";;
|
||||
-v | --vers*) echo "$version"; exit 0;;
|
||||
-V | --verb*) verbose=echo;;
|
||||
--) # What remains are not options.
|
||||
shift
|
||||
while test x"$1" != x"$arg_sep"; do
|
||||
set dummy ${1+"$@"} "$1"; shift
|
||||
shift
|
||||
done
|
||||
break;;
|
||||
-*)
|
||||
echo "$0: Unknown or ambiguous option \`$1'." >&2
|
||||
echo "$0: Try \`--help' for more information." >&2
|
||||
exit 1;;
|
||||
*) set dummy ${1+"$@"} "$1"; shift;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
# Pop the token
|
||||
shift
|
||||
|
||||
# Interpret remaining command line args as filenames.
|
||||
if test $# = 0; then
|
||||
echo "$0: Missing file arguments." >&2
|
||||
echo "$0: Try \`--help' for more information." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Prepare the temporary directory. Remove it at exit, unless debugging.
|
||||
if test -z "$debug"; then
|
||||
trap "cd / && rm -rf $tmpdir" 0 1 2 15
|
||||
fi
|
||||
|
||||
# Create the temporary directory with strict rights
|
||||
(umask 077 && mkdir $tmpdir) || exit 1
|
||||
|
||||
# Prepare the tools we might need. This may be extra work in some
|
||||
# cases, but improves the readibility of the script.
|
||||
utildir=$tmpdir/utils
|
||||
mkdir $utildir || exit 1
|
||||
|
||||
# A sed script that preprocesses Texinfo sources in order to keep the
|
||||
# iftex sections only. We want to remove non TeX sections, and
|
||||
# comment (with `@c texi2dvi') TeX sections so that makeinfo does not
|
||||
# try to parse them. Nevertheless, while commenting TeX sections,
|
||||
# don't comment @macro/@end macro so that makeinfo does propagate
|
||||
# them. Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo
|
||||
# doesn't work well enough (yet) to use that, so work around with sed.
|
||||
comment_iftex_sed=$utildir/comment.sed
|
||||
cat <<EOF >$comment_iftex_sed
|
||||
/^@tex/,/^@end tex/{
|
||||
s/^/@c texi2dvi/
|
||||
}
|
||||
/^@iftex/,/^@end iftex/{
|
||||
s/^/@c texi2dvi/
|
||||
/^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
|
||||
s/^@c texi2dvi//
|
||||
}
|
||||
}
|
||||
/^@html/,/^@end html/d
|
||||
/^@ifhtml/,/^@end ifhtml/d
|
||||
/^@ifnottex/,/^@end ifnottex/d
|
||||
/^@ifinfo/,/^@end ifinfo/{
|
||||
/^@node/p
|
||||
/^@menu/,/^@end menu/p
|
||||
d
|
||||
}
|
||||
EOF
|
||||
# Uncommenting is simple: Remove any leading `@c texi2dvi'.
|
||||
uncomment_iftex_sed=$utildir/uncomment.sed
|
||||
cat <<EOF >$uncomment_iftex_sed
|
||||
s/^@c texi2dvi//
|
||||
EOF
|
||||
|
||||
# A shell script that computes the list of xref files.
|
||||
# Takes the filename (without extension) of which we look for xref
|
||||
# files as argument. The index files must be reported last.
|
||||
get_xref_files=$utildir/get_xref.sh
|
||||
cat <<\EOF >$get_xref_files
|
||||
#! /bin/sh
|
||||
|
||||
# Get list of xref files (indexes, tables and lists).
|
||||
# Find all files having root filename with a two-letter extension,
|
||||
# saves the ones that are really Texinfo-related files. .?o? catches
|
||||
# LaTeX tables and lists.
|
||||
for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
|
||||
# If file is empty, skip it.
|
||||
test -s "$this_file" || continue
|
||||
# If the file is not suitable to be an index or xref file, don't
|
||||
# process it. The file can't be if its first character is not a
|
||||
# backslash or single quote.
|
||||
first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
|
||||
if test "x$first_character" = "x\\" \
|
||||
|| test "x$first_character" = "x'"; then
|
||||
xref_files="$xref_files ./$this_file"
|
||||
fi
|
||||
done
|
||||
echo "$xref_files"
|
||||
EOF
|
||||
chmod 500 $get_xref_files
|
||||
|
||||
# File descriptor usage:
|
||||
# 0 standard input
|
||||
# 1 standard output (--verbose messages)
|
||||
# 2 standard error
|
||||
# 3 some systems may open it to /dev/tty
|
||||
# 4 used on the Kubota Titan
|
||||
# 5 tools output (turned off by --quiet)
|
||||
|
||||
# Tools' output. If quiet, discard, else redirect to the message flow.
|
||||
if test "$quiet" = t; then
|
||||
exec 5>/dev/null
|
||||
else
|
||||
exec 5>&1
|
||||
fi
|
||||
|
||||
# Enable tracing
|
||||
test "$debug" = t && set -x
|
||||
|
||||
#
|
||||
# TeXify files.
|
||||
|
||||
for command_line_filename in ${1+"$@"}; do
|
||||
$verbose "Processing $command_line_filename ..."
|
||||
|
||||
# If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
|
||||
# prepend `./' in order to avoid that the tools take it as an option.
|
||||
echo "$command_line_filename" | egrep '^(/|[A-z]:/)' >/dev/null \
|
||||
|| command_line_filename="./$command_line_filename"
|
||||
|
||||
# See if the file exists. If it doesn't we're in trouble since, even
|
||||
# though the user may be able to reenter a valid filename at the tex
|
||||
# prompt (assuming they're attending the terminal), this script won't
|
||||
# be able to find the right xref files and so forth.
|
||||
if test ! -r "$command_line_filename"; then
|
||||
echo "$0: Could not read $command_line_filename, skipping." >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
# Get the name of the current directory. We want the full path
|
||||
# because in clean mode we are in tmp, in which case a relative
|
||||
# path has no meaning.
|
||||
filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
|
||||
filename_dir=`cd "$filename_dir" >/dev/null && pwd`
|
||||
|
||||
# Strip directory part but leave extension.
|
||||
filename_ext=`basename "$command_line_filename"`
|
||||
# Strip extension.
|
||||
filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
|
||||
ext=`echo "$filename_ext" | sed 's/^.*\.//'`
|
||||
|
||||
# _src. Use same basename since we want to generate aux files with
|
||||
# the same basename as the manual. If --expand, then output the
|
||||
# macro-expanded file to here, else copy the original file.
|
||||
tmpdir_src=$tmpdir/src
|
||||
filename_src=$tmpdir_src/$filename_noext.$ext
|
||||
|
||||
# _xtr. The file with the user's extra commands.
|
||||
tmpdir_xtr=$tmpdir/xtr
|
||||
filename_xtr=$tmpdir_xtr/$filename_noext.$ext
|
||||
|
||||
# _bak. Copies of the previous xref files (another round is run if
|
||||
# they differ from the new one).
|
||||
tmpdir_bak=$tmpdir/bak
|
||||
|
||||
# Make all those directories and give up if we can't succeed.
|
||||
mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
|
||||
|
||||
# Source file might include additional sources. Put `.' and
|
||||
# directory where source file(s) reside in TEXINPUTS before anything
|
||||
# else. `.' goes first to ensure that any old .aux, .cps,
|
||||
# etc. files in ${directory} don't get used in preference to fresher
|
||||
# files in `.'. Include orig_pwd in case we are in clean mode, where
|
||||
# we've cd'd to a temp directory.
|
||||
common=".$path_sep$orig_pwd$path_sep$filename_dir$path_sep$txincludes$path_sep"
|
||||
TEXINPUTS="$common$TEXINPUTS_orig"
|
||||
INDEXSTYLE="$common$INDEXSTYLE_orig"
|
||||
|
||||
# If the user explicitly specified the language, use that.
|
||||
# Otherwise, if the first line is \input texinfo, assume it's texinfo.
|
||||
# Otherwise, guess from the file extension.
|
||||
if test -n "$set_language"; then
|
||||
language=$set_language
|
||||
elif sed 1q "$command_line_filename" | fgrep 'input texinfo' >/dev/null; then
|
||||
language=texinfo
|
||||
else
|
||||
language=
|
||||
fi
|
||||
|
||||
# Get the type of the file (latex or texinfo) from the given language
|
||||
# we just guessed, or from the file extension if not set yet.
|
||||
case ${language:-$filename_ext} in
|
||||
[lL]a[tT]e[xX] | *.ltx | *.tex)
|
||||
# Assume a LaTeX file. LaTeX needs bibtex and uses latex for
|
||||
# compilation. No makeinfo.
|
||||
bibtex=${BIBTEX:-bibtex}
|
||||
makeinfo= # no point in running makeinfo on latex source.
|
||||
texindex=${MAKEINDEX:-makeindex}
|
||||
if test $oformat = dvi; then
|
||||
tex=${LATEX:-latex}
|
||||
else
|
||||
tex=${PDFLATEX:-pdflatex}
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
# Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
|
||||
bibtex=
|
||||
texindex=${TEXINDEX:-texindex}
|
||||
if test $oformat = dvi; then
|
||||
tex=${TEX:-tex}
|
||||
else
|
||||
tex=${PDFTEX:-pdftex}
|
||||
fi
|
||||
# Unless required by the user, makeinfo expansion is wanted only
|
||||
# if texinfo.tex is too old.
|
||||
if test "$expand" = t; then
|
||||
makeinfo=${MAKEINFO:-makeinfo}
|
||||
else
|
||||
# Check if texinfo.tex performs macro expansion by looking for
|
||||
# its version. The version is a date of the form YEAR-MO-DA.
|
||||
# We don't need to use [0-9] to match the digits since anyway
|
||||
# the comparison with $txiprereq, a number, will fail with non
|
||||
# digits.
|
||||
txiversion_tex=txiversion.tex
|
||||
echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
|
||||
# Run in the tmpdir to avoid leaving files.
|
||||
eval `cd $tmpdir >/dev/null \
|
||||
&& $tex $txiversion_tex 2>/dev/null \
|
||||
| sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
|
||||
$verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
|
||||
if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
|
||||
makeinfo=
|
||||
else
|
||||
makeinfo=${MAKEINFO:-makeinfo}
|
||||
fi
|
||||
# As long as we had to run TeX, offer the user this convenience
|
||||
if test "$txiformat" = Texinfo; then
|
||||
escape=@
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Expand macro commands in the original source file using Makeinfo.
|
||||
# Always use `end' footnote style, since the `separate' style
|
||||
# generates different output (arguably this is a bug in -E).
|
||||
# Discard main info output, the user asked to run TeX, not makeinfo.
|
||||
if test -n "$makeinfo"; then
|
||||
$verbose "Macro-expanding $command_line_filename to $filename_src ..."
|
||||
sed -f $comment_iftex_sed "$command_line_filename" \
|
||||
| $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
|
||||
-o /dev/null --macro-expand=- \
|
||||
| sed -f $uncomment_iftex_sed >"$filename_src"
|
||||
filename_input=$filename_src
|
||||
fi
|
||||
|
||||
# If makeinfo failed (or was not even run), use the original file as input.
|
||||
if test $? -ne 0 \
|
||||
|| test ! -r "$filename_src"; then
|
||||
$verbose "Reverting to $command_line_filename ..."
|
||||
filename_input=$filename_dir/$filename_ext
|
||||
fi
|
||||
|
||||
# Used most commonly for @finalout, @smallbook, etc.
|
||||
if test -n "$textra"; then
|
||||
$verbose "Inserting extra commands: $textra"
|
||||
sed '/^@setfilename/a\
|
||||
'"$textra" "$filename_input" >$filename_xtr
|
||||
filename_input=$filename_xtr
|
||||
fi
|
||||
|
||||
# If clean mode was specified, then move to the temporary directory.
|
||||
if test "$clean" = t; then
|
||||
$verbose "cd $tmpdir_src"
|
||||
cd "$tmpdir_src" || exit 1
|
||||
fi
|
||||
|
||||
while :; do # will break out of loop below
|
||||
orig_xref_files=`$get_xref_files "$filename_noext"`
|
||||
|
||||
# Save copies of originals for later comparison.
|
||||
if test -n "$orig_xref_files"; then
|
||||
$verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
|
||||
cp $orig_xref_files $tmpdir_bak
|
||||
fi
|
||||
|
||||
# Run bibtex on current file.
|
||||
# - If its input (AUX) exists.
|
||||
# - If AUX contains both `\bibdata' and `\bibstyle'.
|
||||
# - If some citations are missing (LOG contains `Citation').
|
||||
# or the LOG complains of a missing .bbl
|
||||
#
|
||||
# We run bibtex first, because I can see reasons for the indexes
|
||||
# to change after bibtex is run, but I see no reason for the
|
||||
# converse.
|
||||
#
|
||||
# Don't try to be too smart. Running bibtex only if the bbl file
|
||||
# exists and is older than the LaTeX file is wrong, since the
|
||||
# document might include files that have changed. Because there
|
||||
# can be several AUX (if there are \include's), but a single LOG,
|
||||
# looking for missing citations in LOG is easier, though we take
|
||||
# the risk to match false messages.
|
||||
if test -n "$bibtex" \
|
||||
&& test -r "$filename_noext.aux" \
|
||||
&& test -r "$filename_noext.log" \
|
||||
&& (grep '^\\bibdata[{]' "$filename_noext.aux" \
|
||||
&& grep '^\\bibstyle[{]' "$filename_noext.aux" \
|
||||
&& (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
|
||||
|| grep 'No file .*\.bbl\.' "$filename_noext.log")) \
|
||||
>/dev/null 2>&1; \
|
||||
then
|
||||
$verbose "Running $bibtex $filename_noext ..."
|
||||
if $bibtex "$filename_noext" >&5; then :; else
|
||||
echo "$0: $bibtex exited with bad status, quitting." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# What we'll run texindex on -- exclude non-index files.
|
||||
# Since we know index files are last, it is correct to remove everything
|
||||
# before .aux and .?o?.
|
||||
index_files=`echo "$orig_xref_files" \
|
||||
| sed "s!.*\.aux!!g;
|
||||
s!./$filename_noext\..o.!!g;
|
||||
s/^[ ]*//;s/[ ]*$//"`
|
||||
# Run texindex (or makeindex) on current index files. If they
|
||||
# already exist, and after running TeX a first time the index
|
||||
# files don't change, then there's no reason to run TeX again.
|
||||
# But we won't know that if the index files are out of date or
|
||||
# nonexistent.
|
||||
if test -n "$texindex" && test -n "$index_files"; then
|
||||
$verbose "Running $texindex $index_files ..."
|
||||
if $texindex $index_files 2>&5 1>&2; then :; else
|
||||
echo "$0: $texindex exited with bad status, quitting." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Finally, run TeX.
|
||||
# Prevent $ESCAPE from being interpreted by the shell if it happens
|
||||
# to be `/'.
|
||||
$batch tex_args="\\${escape}nonstopmode\ \\${escape}input"
|
||||
$verbose "Running $cmd ..."
|
||||
cmd="$tex $tex_args $filename_input"
|
||||
if $cmd >&5; then :; else
|
||||
echo "$0: $tex exited with bad status, quitting." >&2
|
||||
echo "$0: see $filename_noext.log for errors." >&2
|
||||
test "$clean" = t \
|
||||
&& cp "$filename_noext.log" "$orig_pwd"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Decide if looping again is needed.
|
||||
finished=t
|
||||
|
||||
# LaTeX (and the package changebar) report in the LOG file if it
|
||||
# should be rerun. This is needed for files included from
|
||||
# subdirs, since texi2dvi does not try to compare xref files in
|
||||
# subdirs. Performing xref files test is still good since LaTeX
|
||||
# does not report changes in xref files.
|
||||
if fgrep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
|
||||
finished=
|
||||
fi
|
||||
|
||||
# Check if xref files changed.
|
||||
new_xref_files=`$get_xref_files "$filename_noext"`
|
||||
$verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
|
||||
$verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
|
||||
|
||||
# If old and new lists don't at least have the same file list,
|
||||
# then one file or another has definitely changed.
|
||||
test "x$orig_xref_files" != "x$new_xref_files" && finished=
|
||||
|
||||
# File list is the same. We must compare each file until we find
|
||||
# a difference.
|
||||
if test -n "$finished"; then
|
||||
for this_file in $new_xref_files; do
|
||||
$verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
|
||||
# cmp -s returns nonzero exit status if files differ.
|
||||
if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
|
||||
# We only need to keep comparing until we find one that
|
||||
# differs, because we'll have to run texindex & tex again no
|
||||
# matter how many more there might be.
|
||||
finished=
|
||||
$verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
|
||||
test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# If finished, exit the loop, else rerun the loop.
|
||||
test -n "$finished" && break
|
||||
done
|
||||
|
||||
# If we were in clean mode, compilation was in a tmp directory.
|
||||
# Copy the DVI (or PDF) file into the directory where the compilation
|
||||
# has been done. (The temp dir is about to get removed anyway.)
|
||||
# We also return to the original directory so that
|
||||
# - the next file is processed in correct conditions
|
||||
# - the temporary file can be removed
|
||||
if test -n "$clean"; then
|
||||
$verbose "Copying $oformat file from `pwd` to $orig_pwd"
|
||||
cp -p "./$filename_noext.$oformat" "$orig_pwd"
|
||||
cd / # in case $orig_pwd is on a different drive (for DOS)
|
||||
cd $orig_pwd || exit 1
|
||||
fi
|
||||
|
||||
# Remove temporary files.
|
||||
if test "x$debug" = "x"; then
|
||||
$verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
|
||||
cd /
|
||||
rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
|
||||
fi
|
||||
done
|
||||
|
||||
$verbose "$0 done."
|
||||
exit 0 # exit successfully, not however we ended the loop.
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,873 @@
|
|||
/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if !defined (BUFSIZ)
|
||||
#include <stdio.h>
|
||||
#endif /* !BUFSIZ */
|
||||
|
||||
#include "readline.h"
|
||||
|
||||
/* An array of function pointers, one for each possible key.
|
||||
If the type byte is ISKMAP, then the pointer is the address of
|
||||
a keymap. */
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
|
||||
|
||||
/* Control keys. */
|
||||
{ ISFUNC, rl_set_mark }, /* Control-@ */
|
||||
{ ISFUNC, rl_beg_of_line }, /* Control-a */
|
||||
{ ISFUNC, rl_backward_char }, /* Control-b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-c */
|
||||
{ ISFUNC, rl_delete }, /* Control-d */
|
||||
{ ISFUNC, rl_end_of_line }, /* Control-e */
|
||||
{ ISFUNC, rl_forward_char }, /* Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Control-g */
|
||||
{ ISFUNC, rl_rubout }, /* Control-h */
|
||||
{ ISFUNC, rl_complete }, /* Control-i */
|
||||
{ ISFUNC, rl_newline }, /* Control-j */
|
||||
{ ISFUNC, rl_kill_line }, /* Control-k */
|
||||
{ ISFUNC, rl_clear_screen }, /* Control-l */
|
||||
{ ISFUNC, rl_newline }, /* Control-m */
|
||||
{ ISFUNC, rl_get_next_history }, /* Control-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-o */
|
||||
{ ISFUNC, rl_get_previous_history }, /* Control-p */
|
||||
{ ISFUNC, rl_quoted_insert }, /* Control-q */
|
||||
{ ISFUNC, rl_reverse_search_history }, /* Control-r */
|
||||
{ ISFUNC, rl_forward_search_history }, /* Control-s */
|
||||
{ ISFUNC, rl_transpose_chars }, /* Control-t */
|
||||
{ ISFUNC, rl_unix_line_discard }, /* Control-u */
|
||||
{ ISFUNC, rl_quoted_insert }, /* Control-v */
|
||||
{ ISFUNC, rl_unix_word_rubout }, /* Control-w */
|
||||
{ ISKMAP, (rl_command_func_t *)emacs_ctlx_keymap }, /* Control-x */
|
||||
{ ISFUNC, rl_yank }, /* Control-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-z */
|
||||
{ ISKMAP, (rl_command_func_t *)emacs_meta_keymap }, /* Control-[ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-\ */
|
||||
{ ISFUNC, rl_char_search }, /* Control-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-^ */
|
||||
{ ISFUNC, rl_undo_command }, /* Control-_ */
|
||||
|
||||
/* The start of printing characters. */
|
||||
{ ISFUNC, rl_insert }, /* SPACE */
|
||||
{ ISFUNC, rl_insert }, /* ! */
|
||||
{ ISFUNC, rl_insert }, /* " */
|
||||
{ ISFUNC, rl_insert }, /* # */
|
||||
{ ISFUNC, rl_insert }, /* $ */
|
||||
{ ISFUNC, rl_insert }, /* % */
|
||||
{ ISFUNC, rl_insert }, /* & */
|
||||
{ ISFUNC, rl_insert }, /* ' */
|
||||
{ ISFUNC, rl_insert }, /* ( */
|
||||
{ ISFUNC, rl_insert }, /* ) */
|
||||
{ ISFUNC, rl_insert }, /* * */
|
||||
{ ISFUNC, rl_insert }, /* + */
|
||||
{ ISFUNC, rl_insert }, /* , */
|
||||
{ ISFUNC, rl_insert }, /* - */
|
||||
{ ISFUNC, rl_insert }, /* . */
|
||||
{ ISFUNC, rl_insert }, /* / */
|
||||
|
||||
/* Regular digits. */
|
||||
{ ISFUNC, rl_insert }, /* 0 */
|
||||
{ ISFUNC, rl_insert }, /* 1 */
|
||||
{ ISFUNC, rl_insert }, /* 2 */
|
||||
{ ISFUNC, rl_insert }, /* 3 */
|
||||
{ ISFUNC, rl_insert }, /* 4 */
|
||||
{ ISFUNC, rl_insert }, /* 5 */
|
||||
{ ISFUNC, rl_insert }, /* 6 */
|
||||
{ ISFUNC, rl_insert }, /* 7 */
|
||||
{ ISFUNC, rl_insert }, /* 8 */
|
||||
{ ISFUNC, rl_insert }, /* 9 */
|
||||
|
||||
/* A little more punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* : */
|
||||
{ ISFUNC, rl_insert }, /* ; */
|
||||
{ ISFUNC, rl_insert }, /* < */
|
||||
{ ISFUNC, rl_insert }, /* = */
|
||||
{ ISFUNC, rl_insert }, /* > */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* @ */
|
||||
|
||||
/* Uppercase alphabet. */
|
||||
{ ISFUNC, rl_insert }, /* A */
|
||||
{ ISFUNC, rl_insert }, /* B */
|
||||
{ ISFUNC, rl_insert }, /* C */
|
||||
{ ISFUNC, rl_insert }, /* D */
|
||||
{ ISFUNC, rl_insert }, /* E */
|
||||
{ ISFUNC, rl_insert }, /* F */
|
||||
{ ISFUNC, rl_insert }, /* G */
|
||||
{ ISFUNC, rl_insert }, /* H */
|
||||
{ ISFUNC, rl_insert }, /* I */
|
||||
{ ISFUNC, rl_insert }, /* J */
|
||||
{ ISFUNC, rl_insert }, /* K */
|
||||
{ ISFUNC, rl_insert }, /* L */
|
||||
{ ISFUNC, rl_insert }, /* M */
|
||||
{ ISFUNC, rl_insert }, /* N */
|
||||
{ ISFUNC, rl_insert }, /* O */
|
||||
{ ISFUNC, rl_insert }, /* P */
|
||||
{ ISFUNC, rl_insert }, /* Q */
|
||||
{ ISFUNC, rl_insert }, /* R */
|
||||
{ ISFUNC, rl_insert }, /* S */
|
||||
{ ISFUNC, rl_insert }, /* T */
|
||||
{ ISFUNC, rl_insert }, /* U */
|
||||
{ ISFUNC, rl_insert }, /* V */
|
||||
{ ISFUNC, rl_insert }, /* W */
|
||||
{ ISFUNC, rl_insert }, /* X */
|
||||
{ ISFUNC, rl_insert }, /* Y */
|
||||
{ ISFUNC, rl_insert }, /* Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* [ */
|
||||
{ ISFUNC, rl_insert }, /* \ */
|
||||
{ ISFUNC, rl_insert }, /* ] */
|
||||
{ ISFUNC, rl_insert }, /* ^ */
|
||||
{ ISFUNC, rl_insert }, /* _ */
|
||||
{ ISFUNC, rl_insert }, /* ` */
|
||||
|
||||
/* Lowercase alphabet. */
|
||||
{ ISFUNC, rl_insert }, /* a */
|
||||
{ ISFUNC, rl_insert }, /* b */
|
||||
{ ISFUNC, rl_insert }, /* c */
|
||||
{ ISFUNC, rl_insert }, /* d */
|
||||
{ ISFUNC, rl_insert }, /* e */
|
||||
{ ISFUNC, rl_insert }, /* f */
|
||||
{ ISFUNC, rl_insert }, /* g */
|
||||
{ ISFUNC, rl_insert }, /* h */
|
||||
{ ISFUNC, rl_insert }, /* i */
|
||||
{ ISFUNC, rl_insert }, /* j */
|
||||
{ ISFUNC, rl_insert }, /* k */
|
||||
{ ISFUNC, rl_insert }, /* l */
|
||||
{ ISFUNC, rl_insert }, /* m */
|
||||
{ ISFUNC, rl_insert }, /* n */
|
||||
{ ISFUNC, rl_insert }, /* o */
|
||||
{ ISFUNC, rl_insert }, /* p */
|
||||
{ ISFUNC, rl_insert }, /* q */
|
||||
{ ISFUNC, rl_insert }, /* r */
|
||||
{ ISFUNC, rl_insert }, /* s */
|
||||
{ ISFUNC, rl_insert }, /* t */
|
||||
{ ISFUNC, rl_insert }, /* u */
|
||||
{ ISFUNC, rl_insert }, /* v */
|
||||
{ ISFUNC, rl_insert }, /* w */
|
||||
{ ISFUNC, rl_insert }, /* x */
|
||||
{ ISFUNC, rl_insert }, /* y */
|
||||
{ ISFUNC, rl_insert }, /* z */
|
||||
|
||||
/* Final punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* { */
|
||||
{ ISFUNC, rl_insert }, /* | */
|
||||
{ ISFUNC, rl_insert }, /* } */
|
||||
{ ISFUNC, rl_insert }, /* ~ */
|
||||
{ ISFUNC, rl_rubout }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Pure 8-bit characters (128 - 159).
|
||||
These might be used in some
|
||||
character sets. */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
|
||||
/* ISO Latin-1 characters (160 - 255) */
|
||||
{ ISFUNC, rl_insert }, /* No-break space */
|
||||
{ ISFUNC, rl_insert }, /* Inverted exclamation mark */
|
||||
{ ISFUNC, rl_insert }, /* Cent sign */
|
||||
{ ISFUNC, rl_insert }, /* Pound sign */
|
||||
{ ISFUNC, rl_insert }, /* Currency sign */
|
||||
{ ISFUNC, rl_insert }, /* Yen sign */
|
||||
{ ISFUNC, rl_insert }, /* Broken bar */
|
||||
{ ISFUNC, rl_insert }, /* Section sign */
|
||||
{ ISFUNC, rl_insert }, /* Diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Copyright sign */
|
||||
{ ISFUNC, rl_insert }, /* Feminine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Left pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Not sign */
|
||||
{ ISFUNC, rl_insert }, /* Soft hyphen */
|
||||
{ ISFUNC, rl_insert }, /* Registered sign */
|
||||
{ ISFUNC, rl_insert }, /* Macron */
|
||||
{ ISFUNC, rl_insert }, /* Degree sign */
|
||||
{ ISFUNC, rl_insert }, /* Plus-minus sign */
|
||||
{ ISFUNC, rl_insert }, /* Superscript two */
|
||||
{ ISFUNC, rl_insert }, /* Superscript three */
|
||||
{ ISFUNC, rl_insert }, /* Acute accent */
|
||||
{ ISFUNC, rl_insert }, /* Micro sign */
|
||||
{ ISFUNC, rl_insert }, /* Pilcrow sign */
|
||||
{ ISFUNC, rl_insert }, /* Middle dot */
|
||||
{ ISFUNC, rl_insert }, /* Cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Superscript one */
|
||||
{ ISFUNC, rl_insert }, /* Masculine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Right pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one quarter */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one half */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction three quarters */
|
||||
{ ISFUNC, rl_insert }, /* Inverted questionk mark */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Multiplication sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter Y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter sharp s (German) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Division sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert } /* Latin small letter y with diaeresis */
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
||||
|
||||
/* Meta keys. Just like above, but the high bit is set. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-@ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-a */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-c */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-d */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-e */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Meta-Control-g */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* Meta-Control-h */
|
||||
{ ISFUNC, rl_tab_insert }, /* Meta-Control-i */
|
||||
{ ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-k */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-l */
|
||||
{ ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-o */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-q */
|
||||
{ ISFUNC, rl_revert_line }, /* Meta-Control-r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-s */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-t */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-w */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-x */
|
||||
{ ISFUNC, rl_yank_nth_arg }, /* Meta-Control-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-z */
|
||||
|
||||
{ ISFUNC, rl_complete }, /* Meta-Control-[ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-\ */
|
||||
{ ISFUNC, rl_backward_char_search }, /* Meta-Control-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-^ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-_ */
|
||||
|
||||
/* The start of printing characters. */
|
||||
{ ISFUNC, rl_set_mark }, /* Meta-SPACE */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-! */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-" */
|
||||
{ ISFUNC, rl_insert_comment }, /* Meta-# */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-$ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-% */
|
||||
{ ISFUNC, rl_tilde_expand }, /* Meta-& */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-' */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-( */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-) */
|
||||
{ ISFUNC, rl_insert_completions }, /* Meta-* */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-+ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-, */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-- */
|
||||
{ ISFUNC, rl_yank_last_arg}, /* Meta-. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-/ */
|
||||
|
||||
/* Regular digits. */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-0 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-1 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-2 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-3 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-4 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-5 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-6 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-7 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-8 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-9 */
|
||||
|
||||
/* A little more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-: */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-; */
|
||||
{ ISFUNC, rl_beginning_of_history }, /* Meta-< */
|
||||
{ ISFUNC, rl_possible_completions }, /* Meta-= */
|
||||
{ ISFUNC, rl_end_of_history }, /* Meta-> */
|
||||
{ ISFUNC, rl_possible_completions }, /* Meta-? */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-@ */
|
||||
|
||||
/* Uppercase alphabet. */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-A */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-B */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-C */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-D */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-E */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-F */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-G */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-H */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-I */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-J */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-K */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-L */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-M */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-N */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-O */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-P */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-Q */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-R */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-S */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-T */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-U */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-V */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-W */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-X */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-Y */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-[ */ /* was rl_arrow_keys */
|
||||
{ ISFUNC, rl_delete_horizontal_space }, /* Meta-\ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-^ */
|
||||
{ ISFUNC, rl_yank_last_arg }, /* Meta-_ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-` */
|
||||
|
||||
/* Lowercase alphabet. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-a */
|
||||
{ ISFUNC, rl_backward_word }, /* Meta-b */
|
||||
{ ISFUNC, rl_capitalize_word }, /* Meta-c */
|
||||
{ ISFUNC, rl_kill_word }, /* Meta-d */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-e */
|
||||
{ ISFUNC, rl_forward_word }, /* Meta-f */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-g */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-h */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-i */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-k */
|
||||
{ ISFUNC, rl_downcase_word }, /* Meta-l */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-m */
|
||||
{ ISFUNC, rl_noninc_forward_search }, /* Meta-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-o */ /* was rl_arrow_keys */
|
||||
{ ISFUNC, rl_noninc_reverse_search }, /* Meta-p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-q */
|
||||
{ ISFUNC, rl_revert_line }, /* Meta-r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-s */
|
||||
{ ISFUNC, rl_transpose_words }, /* Meta-t */
|
||||
{ ISFUNC, rl_upcase_word }, /* Meta-u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-w */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-x */
|
||||
{ ISFUNC, rl_yank_pop }, /* Meta-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-z */
|
||||
|
||||
/* Final punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-{ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-| */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-} */
|
||||
{ ISFUNC, rl_tilde_expand }, /* Meta-~ */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* Meta-rubout */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = {
|
||||
|
||||
/* Control keys. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-@ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-a */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-c */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-d */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-e */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Control-g */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-h */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-i */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-k */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-l */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-m */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-o */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-q */
|
||||
{ ISFUNC, rl_re_read_init_file }, /* Control-r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-s */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-t */
|
||||
{ ISFUNC, rl_undo_command }, /* Control-u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-w */
|
||||
{ ISFUNC, rl_exchange_point_and_mark }, /* Control-x */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-z */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-[ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-\ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-^ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-_ */
|
||||
|
||||
/* The start of printing characters. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* SPACE */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ! */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* " */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* # */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* $ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* % */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* & */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ' */
|
||||
{ ISFUNC, rl_start_kbd_macro }, /* ( */
|
||||
{ ISFUNC, rl_end_kbd_macro }, /* ) */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* * */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* + */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* , */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* - */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* . */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* / */
|
||||
|
||||
/* Regular digits. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 0 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 1 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 2 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 3 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 4 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 5 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 6 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 7 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 8 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 9 */
|
||||
|
||||
/* A little more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* : */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ; */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* < */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* = */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* > */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ? */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* @ */
|
||||
|
||||
/* Uppercase alphabet. */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* A */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* B */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* C */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* D */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* E */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* F */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* G */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* H */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* I */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* J */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* K */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* L */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* M */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* N */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* O */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* P */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Q */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* R */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* S */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* T */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* U */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* V */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* W */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* X */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Y */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* [ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* \ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ^ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* _ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ` */
|
||||
|
||||
/* Lowercase alphabet. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* a */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* c */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* d */
|
||||
{ ISFUNC, rl_call_last_kbd_macro }, /* e */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* f */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* g */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* h */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* i */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* k */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* l */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* m */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* o */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* q */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* s */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* t */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* w */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* x */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* z */
|
||||
|
||||
/* Final punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* { */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* | */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* } */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ~ */
|
||||
{ ISFUNC, rl_backward_kill_line }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
# My ~/.inputrc file is in -*- text -*- for easy editing with Emacs.
|
||||
#
|
||||
# Notice the various bindings which are conditionalized depending
|
||||
# on which program is running, or what terminal is active.
|
||||
#
|
||||
|
||||
# Copyright (C) 1989-2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
# In all programs, all terminals, make sure this is bound.
|
||||
"\C-x\C-r": re-read-init-file
|
||||
|
||||
# Hp terminals (and some others) have ugly default behaviour for C-h.
|
||||
"\C-h": backward-delete-char
|
||||
"\e\C-h": backward-kill-word
|
||||
"\C-xd": dump-functions
|
||||
|
||||
# In xterm windows, make the arrow keys do the right thing.
|
||||
$if TERM=xterm
|
||||
"\e[A": previous-history
|
||||
"\e[B": next-history
|
||||
"\e[C": forward-char
|
||||
"\e[D": backward-char
|
||||
|
||||
# alternate arrow key prefix
|
||||
"\eOA": previous-history
|
||||
"\eOB": next-history
|
||||
"\eOC": forward-char
|
||||
"\eOD": backward-char
|
||||
|
||||
# Under Xterm in Bash, we bind local Function keys to do something useful.
|
||||
$if Bash
|
||||
"\e[11~": "Function Key 1"
|
||||
"\e[12~": "Function Key 2"
|
||||
"\e[13~": "Function Key 3"
|
||||
"\e[14~": "Function Key 4"
|
||||
"\e[15~": "Function Key 5"
|
||||
|
||||
# I know the following escape sequence numbers are 1 greater than
|
||||
# the function key. Don't ask me why, I didn't design the xterm terminal.
|
||||
"\e[17~": "Function Key 6"
|
||||
"\e[18~": "Function Key 7"
|
||||
"\e[19~": "Function Key 8"
|
||||
"\e[20~": "Function Key 9"
|
||||
"\e[21~": "Function Key 10"
|
||||
$endif
|
||||
$endif
|
||||
|
||||
# For Bash, all terminals, add some Bash specific hacks.
|
||||
$if Bash
|
||||
"\C-xv": show-bash-version
|
||||
"\C-x\C-e": shell-expand-line
|
||||
|
||||
# Here is one for editing my path.
|
||||
"\C-xp": "$PATH\C-x\C-e\C-e\"\C-aPATH=\":\C-b"
|
||||
|
||||
# Make C-x r read my mail in emacs.
|
||||
# "\C-xr": "emacs -f rmail\C-j"
|
||||
$endif
|
||||
|
||||
# For FTP, different hacks:
|
||||
$if Ftp
|
||||
"\C-xg": "get \M-?"
|
||||
"\C-xt": "put \M-?"
|
||||
"\M-.": yank-last-arg
|
||||
$endif
|
||||
|
||||
" ": self-insert
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
#
|
||||
# This is the Makefile for the readline examples subdirectory.
|
||||
#
|
||||
# Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
# This program 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.
|
||||
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
RL_LIBRARY_VERSION = @LIBVERSION@
|
||||
|
||||
SHELL = @MAKE_SHELL@
|
||||
RM = rm -f
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
BUILD_DIR = .
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
||||
DEFS = @DEFS@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DREADLINE_LIBRARY -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
|
||||
|
||||
CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
|
||||
LDFLAGS = -g -L.. @LDFLAGS@
|
||||
|
||||
READLINE_LIB = ../libreadline.a
|
||||
HISTORY_LIB = ../libhistory.a
|
||||
|
||||
TERMCAP_LIB = @TERMCAP_LIB@
|
||||
|
||||
.c.o:
|
||||
${RM} $@
|
||||
$(CC) $(CCFLAGS) -c $<
|
||||
|
||||
EXECUTABLES = fileman rltest rl rlcat rlversion histexamp
|
||||
OBJECTS = fileman.o rltest.o rl.o rlversion.o histexamp.o
|
||||
|
||||
all: $(EXECUTABLES)
|
||||
everything: all rlfe
|
||||
|
||||
rl: rl.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rl.o -lreadline $(TERMCAP_LIB)
|
||||
|
||||
rlcat: rlcat.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rlcat.o -lreadline $(TERMCAP_LIB)
|
||||
|
||||
fileman: fileman.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ fileman.o -lreadline $(TERMCAP_LIB)
|
||||
|
||||
rltest: rltest.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rltest.o -lreadline $(TERMCAP_LIB)
|
||||
|
||||
rlversion: rlversion.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rlversion.o -lreadline $(TERMCAP_LIB)
|
||||
|
||||
histexamp: histexamp.o $(HISTORY_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
|
||||
|
||||
clean mostlyclean:
|
||||
$(RM) $(OBJECTS)
|
||||
$(RM) $(EXECUTABLES) *.exe
|
||||
$(RM) rlfe.o rlfe
|
||||
|
||||
distclean maintainer-clean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
fileman.o: fileman.c
|
||||
rltest.o: rltest.c
|
||||
rl.o: rl.c
|
||||
rlversion.o: rlversion.c
|
||||
histexamp.o: histexamp.c
|
||||
|
||||
fileman.o: $(top_srcdir)/readline.h
|
||||
rltest.o: $(top_srcdir)/readline.h
|
||||
rl.o: $(top_srcdir)/readline.h
|
||||
rlversion.o: $(top_srcdir)/readline.h
|
||||
histexamp.o: $(top_srcdir)/history.h
|
||||
|
||||
# Stuff for Per Bothner's `rlfe' program
|
||||
|
||||
rlfe: rlfe.o $(READLINE_LIB) $(HISTORY_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rlfe.o -lreadline -lhistory ${TERMCAP_LIB}
|
||||
|
||||
rlfe.o: rlfe.c
|
||||
|
||||
rlfe.o: $(top_srcdir)/readline.h
|
||||
rlfe.o: $(top_srcdir)/history.h
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
From: Jeff Solomon <jsolomon@stanford.edu>
|
||||
Date: Fri, 9 Apr 1999 10:13:27 -0700 (PDT)
|
||||
To: chet@po.cwru.edu
|
||||
Subject: new readline example
|
||||
Message-ID: <14094.12094.527305.199695@mrclean.Stanford.EDU>
|
||||
|
||||
Chet,
|
||||
|
||||
I've been using readline 4.0. Specifically, I've been using the perl
|
||||
version Term::ReadLine::Gnu. It works great.
|
||||
|
||||
Anyway, I've been playing around the alternate interface and I wanted
|
||||
to contribute a little C program, callback.c, to you that you could
|
||||
use as an example of the alternate interface in the /examples
|
||||
directory of the readline distribution.
|
||||
|
||||
My example shows how, using the alternate interface, you can
|
||||
interactively change the prompt (which is very nice imo). Also, I
|
||||
point out that you must roll your own terminal setting when using the
|
||||
alternate interface because readline depreps (using your parlance) the
|
||||
terminal while in the user callback. I try to demostrate what I mean
|
||||
with an example. I've included the program below.
|
||||
|
||||
To compile, I just put the program in the examples directory and made
|
||||
the appropriate changes to the EXECUTABLES and OBJECTS line and added
|
||||
an additional target 'callback'.
|
||||
|
||||
I compiled on my Sun Solaris2.6 box using Sun's cc.
|
||||
|
||||
Let me know what you think.
|
||||
|
||||
Jeff
|
||||
*/
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <termios.h> /* xxx - should make this more general */
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
#endif
|
||||
|
||||
/* This little examples demonstrates the alternate interface to using readline.
|
||||
* In the alternate interface, the user maintains control over program flow and
|
||||
* only calls readline when STDIN is readable. Using the alternate interface,
|
||||
* you can do anything else while still using readline (like talking to a
|
||||
* network or another program) without blocking.
|
||||
*
|
||||
* Specifically, this program highlights two importants features of the
|
||||
* alternate interface. The first is the ability to interactively change the
|
||||
* prompt, which can't be done using the regular interface since rl_prompt is
|
||||
* read-only.
|
||||
*
|
||||
* The second feature really highlights a subtle point when using the alternate
|
||||
* interface. That is, readline will not alter the terminal when inside your
|
||||
* callback handler. So let's so, your callback executes a user command that
|
||||
* takes a non-trivial amount of time to complete (seconds). While your
|
||||
* executing the command, the user continues to type keystrokes and expects them
|
||||
* to be re-echoed on the new prompt when it returns. Unfortunately, the default
|
||||
* terminal configuration doesn't do this. After the prompt returns, the user
|
||||
* must hit one additional keystroke and then will see all of his previous
|
||||
* keystrokes. To illustrate this, compile and run this program. Type "sleep" at
|
||||
* the prompt and then type "bar" before the prompt returns (you have 3
|
||||
* seconds). Notice how "bar" is re-echoed on the prompt after the prompt
|
||||
* returns? This is what you expect to happen. Now comment out the 4 lines below
|
||||
* the line that says COMMENT LINE BELOW. Recompile and rerun the program and do
|
||||
* the same thing. When the prompt returns, you should not see "bar". Now type
|
||||
* "f", see how "barf" magically appears? This behavior is un-expected and not
|
||||
* desired.
|
||||
*/
|
||||
|
||||
void process_line(char *line);
|
||||
int change_prompt(void);
|
||||
char *get_prompt(void);
|
||||
|
||||
int prompt = 1;
|
||||
char prompt_buf[40], line_buf[256];
|
||||
tcflag_t old_lflag;
|
||||
cc_t old_vtime;
|
||||
struct termios term;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
fd_set fds;
|
||||
|
||||
/* Adjust the terminal slightly before the handler is installed. Disable
|
||||
* canonical mode processing and set the input character time flag to be
|
||||
* non-blocking.
|
||||
*/
|
||||
if( tcgetattr(STDIN_FILENO, &term) < 0 ) {
|
||||
perror("tcgetattr");
|
||||
exit(1);
|
||||
}
|
||||
old_lflag = term.c_lflag;
|
||||
old_vtime = term.c_cc[VTIME];
|
||||
term.c_lflag &= ~ICANON;
|
||||
term.c_cc[VTIME] = 1;
|
||||
/* COMMENT LINE BELOW - see above */
|
||||
if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
|
||||
perror("tcsetattr");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rl_add_defun("change-prompt", change_prompt, CTRL('t'));
|
||||
rl_callback_handler_install(get_prompt(), process_line);
|
||||
|
||||
while(1) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(fileno(stdin), &fds);
|
||||
|
||||
if( select(FD_SETSIZE, &fds, NULL, NULL, NULL) < 0) {
|
||||
perror("select");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if( FD_ISSET(fileno(stdin), &fds) ) {
|
||||
rl_callback_read_char();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
process_line(char *line)
|
||||
{
|
||||
if( line == NULL ) {
|
||||
fprintf(stderr, "\n", line);
|
||||
|
||||
/* reset the old terminal setting before exiting */
|
||||
term.c_lflag = old_lflag;
|
||||
term.c_cc[VTIME] = old_vtime;
|
||||
if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
|
||||
perror("tcsetattr");
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if( strcmp(line, "sleep") == 0 ) {
|
||||
sleep(3);
|
||||
} else {
|
||||
fprintf(stderr, "|%s|\n", line);
|
||||
}
|
||||
|
||||
free (line);
|
||||
}
|
||||
|
||||
int
|
||||
change_prompt(void)
|
||||
{
|
||||
/* toggle the prompt variable */
|
||||
prompt = !prompt;
|
||||
|
||||
/* save away the current contents of the line */
|
||||
strcpy(line_buf, rl_line_buffer);
|
||||
|
||||
/* install a new handler which will change the prompt and erase the current line */
|
||||
rl_callback_handler_install(get_prompt(), process_line);
|
||||
|
||||
/* insert the old text on the new line */
|
||||
rl_insert_text(line_buf);
|
||||
|
||||
/* redraw the current line - this is an undocumented function. It invokes the
|
||||
* redraw-current-line command.
|
||||
*/
|
||||
rl_refresh_line(0, 0);
|
||||
}
|
||||
|
||||
char *
|
||||
get_prompt(void)
|
||||
{
|
||||
/* The prompts can even be different lengths! */
|
||||
sprintf(prompt_buf, "%s",
|
||||
prompt ? "Hit ctrl-t to toggle prompt> " : "Pretty cool huh?> ");
|
||||
return prompt_buf;
|
||||
}
|
||||
|
|
@ -0,0 +1,485 @@
|
|||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
/* fileman.c -- A tiny application which demonstrates how to use the
|
||||
GNU Readline library. This application interactively allows users
|
||||
to manipulate files and their modes. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_FILE_H
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
extern char *xmalloc ();
|
||||
|
||||
/* The names of functions that actually do the manipulation. */
|
||||
int com_list PARAMS((char *));
|
||||
int com_view PARAMS((char *));
|
||||
int com_rename PARAMS((char *));
|
||||
int com_stat PARAMS((char *));
|
||||
int com_pwd PARAMS((char *));
|
||||
int com_delete PARAMS((char *));
|
||||
int com_help PARAMS((char *));
|
||||
int com_cd PARAMS((char *));
|
||||
int com_quit PARAMS((char *));
|
||||
|
||||
/* A structure which contains information on the commands this program
|
||||
can understand. */
|
||||
|
||||
typedef struct {
|
||||
char *name; /* User printable name of the function. */
|
||||
rl_icpfunc_t *func; /* Function to call to do the job. */
|
||||
char *doc; /* Documentation for this function. */
|
||||
} COMMAND;
|
||||
|
||||
COMMAND commands[] = {
|
||||
{ "cd", com_cd, "Change to directory DIR" },
|
||||
{ "delete", com_delete, "Delete FILE" },
|
||||
{ "help", com_help, "Display this text" },
|
||||
{ "?", com_help, "Synonym for `help'" },
|
||||
{ "list", com_list, "List files in DIR" },
|
||||
{ "ls", com_list, "Synonym for `list'" },
|
||||
{ "pwd", com_pwd, "Print the current working directory" },
|
||||
{ "quit", com_quit, "Quit using Fileman" },
|
||||
{ "rename", com_rename, "Rename FILE to NEWNAME" },
|
||||
{ "stat", com_stat, "Print out statistics on FILE" },
|
||||
{ "view", com_view, "View the contents of FILE" },
|
||||
{ (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL }
|
||||
};
|
||||
|
||||
/* Forward declarations. */
|
||||
char *stripwhite ();
|
||||
COMMAND *find_command ();
|
||||
|
||||
/* The name of this program, as taken from argv[0]. */
|
||||
char *progname;
|
||||
|
||||
/* When non-zero, this global means the user is done using this program. */
|
||||
int done;
|
||||
|
||||
char *
|
||||
dupstr (s)
|
||||
char *s;
|
||||
{
|
||||
char *r;
|
||||
|
||||
r = xmalloc (strlen (s) + 1);
|
||||
strcpy (r, s);
|
||||
return (r);
|
||||
}
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *line, *s;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
initialize_readline (); /* Bind our completer. */
|
||||
|
||||
/* Loop reading and executing lines until the user quits. */
|
||||
for ( ; done == 0; )
|
||||
{
|
||||
line = readline ("FileMan: ");
|
||||
|
||||
if (!line)
|
||||
break;
|
||||
|
||||
/* Remove leading and trailing whitespace from the line.
|
||||
Then, if there is anything left, add it to the history list
|
||||
and execute it. */
|
||||
s = stripwhite (line);
|
||||
|
||||
if (*s)
|
||||
{
|
||||
add_history (s);
|
||||
execute_line (s);
|
||||
}
|
||||
|
||||
free (line);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/* Execute a command line. */
|
||||
int
|
||||
execute_line (line)
|
||||
char *line;
|
||||
{
|
||||
register int i;
|
||||
COMMAND *command;
|
||||
char *word;
|
||||
|
||||
/* Isolate the command word. */
|
||||
i = 0;
|
||||
while (line[i] && whitespace (line[i]))
|
||||
i++;
|
||||
word = line + i;
|
||||
|
||||
while (line[i] && !whitespace (line[i]))
|
||||
i++;
|
||||
|
||||
if (line[i])
|
||||
line[i++] = '\0';
|
||||
|
||||
command = find_command (word);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
fprintf (stderr, "%s: No such command for FileMan.\n", word);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Get argument to command, if any. */
|
||||
while (whitespace (line[i]))
|
||||
i++;
|
||||
|
||||
word = line + i;
|
||||
|
||||
/* Call the function. */
|
||||
return ((*(command->func)) (word));
|
||||
}
|
||||
|
||||
/* Look up NAME as the name of a command, and return a pointer to that
|
||||
command. Return a NULL pointer if NAME isn't a command name. */
|
||||
COMMAND *
|
||||
find_command (name)
|
||||
char *name;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; commands[i].name; i++)
|
||||
if (strcmp (name, commands[i].name) == 0)
|
||||
return (&commands[i]);
|
||||
|
||||
return ((COMMAND *)NULL);
|
||||
}
|
||||
|
||||
/* Strip whitespace from the start and end of STRING. Return a pointer
|
||||
into STRING. */
|
||||
char *
|
||||
stripwhite (string)
|
||||
char *string;
|
||||
{
|
||||
register char *s, *t;
|
||||
|
||||
for (s = string; whitespace (*s); s++)
|
||||
;
|
||||
|
||||
if (*s == 0)
|
||||
return (s);
|
||||
|
||||
t = s + strlen (s) - 1;
|
||||
while (t > s && whitespace (*t))
|
||||
t--;
|
||||
*++t = '\0';
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Interface to Readline Completion */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
char *command_generator PARAMS((const char *, int));
|
||||
char **fileman_completion PARAMS((const char *, int, int));
|
||||
|
||||
/* Tell the GNU Readline library how to complete. We want to try to complete
|
||||
on command names if this is the first word in the line, or on filenames
|
||||
if not. */
|
||||
initialize_readline ()
|
||||
{
|
||||
/* Allow conditional parsing of the ~/.inputrc file. */
|
||||
rl_readline_name = "FileMan";
|
||||
|
||||
/* Tell the completer that we want a crack first. */
|
||||
rl_attempted_completion_function = fileman_completion;
|
||||
}
|
||||
|
||||
/* Attempt to complete on the contents of TEXT. START and END bound the
|
||||
region of rl_line_buffer that contains the word to complete. TEXT is
|
||||
the word to complete. We can use the entire contents of rl_line_buffer
|
||||
in case we want to do some simple parsing. Return the array of matches,
|
||||
or NULL if there aren't any. */
|
||||
char **
|
||||
fileman_completion (text, start, end)
|
||||
const char *text;
|
||||
int start, end;
|
||||
{
|
||||
char **matches;
|
||||
|
||||
matches = (char **)NULL;
|
||||
|
||||
/* If this word is at the start of the line, then it is a command
|
||||
to complete. Otherwise it is the name of a file in the current
|
||||
directory. */
|
||||
if (start == 0)
|
||||
matches = rl_completion_matches (text, command_generator);
|
||||
|
||||
return (matches);
|
||||
}
|
||||
|
||||
/* Generator function for command completion. STATE lets us know whether
|
||||
to start from scratch; without any state (i.e. STATE == 0), then we
|
||||
start at the top of the list. */
|
||||
char *
|
||||
command_generator (text, state)
|
||||
const char *text;
|
||||
int state;
|
||||
{
|
||||
static int list_index, len;
|
||||
char *name;
|
||||
|
||||
/* If this is a new word to complete, initialize now. This includes
|
||||
saving the length of TEXT for efficiency, and initializing the index
|
||||
variable to 0. */
|
||||
if (!state)
|
||||
{
|
||||
list_index = 0;
|
||||
len = strlen (text);
|
||||
}
|
||||
|
||||
/* Return the next name which partially matches from the command list. */
|
||||
while (name = commands[list_index].name)
|
||||
{
|
||||
list_index++;
|
||||
|
||||
if (strncmp (name, text, len) == 0)
|
||||
return (dupstr(name));
|
||||
}
|
||||
|
||||
/* If no names matched, then return NULL. */
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* FileMan Commands */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* String to pass to system (). This is for the LIST, VIEW and RENAME
|
||||
commands. */
|
||||
static char syscom[1024];
|
||||
|
||||
/* List the file(s) named in arg. */
|
||||
com_list (arg)
|
||||
char *arg;
|
||||
{
|
||||
if (!arg)
|
||||
arg = "";
|
||||
|
||||
sprintf (syscom, "ls -FClg %s", arg);
|
||||
return (system (syscom));
|
||||
}
|
||||
|
||||
com_view (arg)
|
||||
char *arg;
|
||||
{
|
||||
if (!valid_argument ("view", arg))
|
||||
return 1;
|
||||
|
||||
#if defined (__MSDOS__)
|
||||
/* more.com doesn't grok slashes in pathnames */
|
||||
sprintf (syscom, "less %s", arg);
|
||||
#else
|
||||
sprintf (syscom, "more %s", arg);
|
||||
#endif
|
||||
return (system (syscom));
|
||||
}
|
||||
|
||||
com_rename (arg)
|
||||
char *arg;
|
||||
{
|
||||
too_dangerous ("rename");
|
||||
return (1);
|
||||
}
|
||||
|
||||
com_stat (arg)
|
||||
char *arg;
|
||||
{
|
||||
struct stat finfo;
|
||||
|
||||
if (!valid_argument ("stat", arg))
|
||||
return (1);
|
||||
|
||||
if (stat (arg, &finfo) == -1)
|
||||
{
|
||||
perror (arg);
|
||||
return (1);
|
||||
}
|
||||
|
||||
printf ("Statistics for `%s':\n", arg);
|
||||
|
||||
printf ("%s has %d link%s, and is %d byte%s in length.\n",
|
||||
arg,
|
||||
finfo.st_nlink,
|
||||
(finfo.st_nlink == 1) ? "" : "s",
|
||||
finfo.st_size,
|
||||
(finfo.st_size == 1) ? "" : "s");
|
||||
printf ("Inode Last Change at: %s", ctime (&finfo.st_ctime));
|
||||
printf (" Last access at: %s", ctime (&finfo.st_atime));
|
||||
printf (" Last modified at: %s", ctime (&finfo.st_mtime));
|
||||
return (0);
|
||||
}
|
||||
|
||||
com_delete (arg)
|
||||
char *arg;
|
||||
{
|
||||
too_dangerous ("delete");
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Print out help for ARG, or for all of the commands if ARG is
|
||||
not present. */
|
||||
com_help (arg)
|
||||
char *arg;
|
||||
{
|
||||
register int i;
|
||||
int printed = 0;
|
||||
|
||||
for (i = 0; commands[i].name; i++)
|
||||
{
|
||||
if (!*arg || (strcmp (arg, commands[i].name) == 0))
|
||||
{
|
||||
printf ("%s\t\t%s.\n", commands[i].name, commands[i].doc);
|
||||
printed++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!printed)
|
||||
{
|
||||
printf ("No commands match `%s'. Possibilties are:\n", arg);
|
||||
|
||||
for (i = 0; commands[i].name; i++)
|
||||
{
|
||||
/* Print in six columns. */
|
||||
if (printed == 6)
|
||||
{
|
||||
printed = 0;
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
printf ("%s\t", commands[i].name);
|
||||
printed++;
|
||||
}
|
||||
|
||||
if (printed)
|
||||
printf ("\n");
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Change to the directory ARG. */
|
||||
com_cd (arg)
|
||||
char *arg;
|
||||
{
|
||||
if (chdir (arg) == -1)
|
||||
{
|
||||
perror (arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
com_pwd ("");
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Print out the current working directory. */
|
||||
com_pwd (ignore)
|
||||
char *ignore;
|
||||
{
|
||||
char dir[1024], *s;
|
||||
|
||||
s = getcwd (dir, sizeof(dir) - 1);
|
||||
if (s == 0)
|
||||
{
|
||||
printf ("Error getting pwd: %s\n", dir);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf ("Current directory is %s\n", dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The user wishes to quit using this program. Just set DONE non-zero. */
|
||||
com_quit (arg)
|
||||
char *arg;
|
||||
{
|
||||
done = 1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Function which tells you that you can't do this. */
|
||||
too_dangerous (caller)
|
||||
char *caller;
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: Too dangerous for me to distribute. Write it yourself.\n",
|
||||
caller);
|
||||
}
|
||||
|
||||
/* Return non-zero if ARG is a valid argument for CALLER, else print
|
||||
an error message and return zero. */
|
||||
int
|
||||
valid_argument (caller, arg)
|
||||
char *caller, *arg;
|
||||
{
|
||||
if (!arg || !*arg)
|
||||
{
|
||||
fprintf (stderr, "%s: Argument required.\n", caller);
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
|
||||
line[0] = 0;
|
||||
|
||||
using_history ();
|
||||
while (!done)
|
||||
{
|
||||
printf ("history$ ");
|
||||
fflush (stdout);
|
||||
t = fgets (line, sizeof (line) - 1, stdin);
|
||||
if (t && *t)
|
||||
{
|
||||
len = strlen (t);
|
||||
if (t[len - 1] == '\n')
|
||||
t[len - 1] = '\0';
|
||||
}
|
||||
|
||||
if (!t)
|
||||
strcpy (line, "quit");
|
||||
|
||||
if (line[0])
|
||||
{
|
||||
char *expansion;
|
||||
int result;
|
||||
|
||||
using_history ();
|
||||
|
||||
result = history_expand (line, &expansion);
|
||||
if (result)
|
||||
fprintf (stderr, "%s\n", expansion);
|
||||
|
||||
if (result < 0 || result == 2)
|
||||
{
|
||||
free (expansion);
|
||||
continue;
|
||||
}
|
||||
|
||||
add_history (expansion);
|
||||
strncpy (line, expansion, sizeof (line) - 1);
|
||||
free (expansion);
|
||||
}
|
||||
|
||||
if (strcmp (line, "quit") == 0)
|
||||
done = 1;
|
||||
else if (strcmp (line, "save") == 0)
|
||||
write_history ("history_file");
|
||||
else if (strcmp (line, "read") == 0)
|
||||
read_history ("history_file");
|
||||
else if (strcmp (line, "list") == 0)
|
||||
{
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
|
||||
the_list = history_list ();
|
||||
if (the_list)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
printf ("%d: %s\n", i + history_base, the_list[i]->line);
|
||||
}
|
||||
else if (strncmp (line, "delete", 6) == 0)
|
||||
{
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
{
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "non-numeric arg given to `delete'\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/* manexamp.c -- The examples which appear in the documentation are here. */
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <readline/readline.h>
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* How to Emulate gets () */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* A static variable for holding the line. */
|
||||
static char *line_read = (char *)NULL;
|
||||
|
||||
/* Read a string, and return a pointer to it. Returns NULL on EOF. */
|
||||
char *
|
||||
rl_gets ()
|
||||
{
|
||||
/* If the buffer has already been allocated, return the memory
|
||||
to the free pool. */
|
||||
if (line_read)
|
||||
{
|
||||
free (line_read);
|
||||
line_read = (char *)NULL;
|
||||
}
|
||||
|
||||
/* Get a line from the user. */
|
||||
line_read = readline ("");
|
||||
|
||||
/* If the line has any text in it, save it on the history. */
|
||||
if (line_read && *line_read)
|
||||
add_history (line_read);
|
||||
|
||||
return (line_read);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Writing a Function to be Called by Readline. */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Invert the case of the COUNT following characters. */
|
||||
invert_case_line (count, key)
|
||||
int count, key;
|
||||
{
|
||||
register int start, end;
|
||||
|
||||
start = rl_point;
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
direction = -1;
|
||||
count = -count;
|
||||
}
|
||||
else
|
||||
direction = 1;
|
||||
|
||||
/* Find the end of the range to modify. */
|
||||
end = start + (count * direction);
|
||||
|
||||
/* Force it to be within range. */
|
||||
if (end > rl_end)
|
||||
end = rl_end;
|
||||
else if (end < 0)
|
||||
end = -1;
|
||||
|
||||
if (start > end)
|
||||
{
|
||||
int temp = start;
|
||||
start = end;
|
||||
end = temp;
|
||||
}
|
||||
|
||||
if (start == end)
|
||||
return;
|
||||
|
||||
/* Tell readline that we are modifying the line, so save the undo
|
||||
information. */
|
||||
rl_modifying (start, end);
|
||||
|
||||
for (; start != end; start += direction)
|
||||
{
|
||||
if (_rl_uppercase_p (rl_line_buffer[start]))
|
||||
rl_line_buffer[start] = _rl_to_lower (rl_line_buffer[start]);
|
||||
else if (_rl_lowercase_p (rl_line_buffer[start]))
|
||||
rl_line_buffer[start] = _rl_to_upper (rl_line_buffer[start]);
|
||||
}
|
||||
|
||||
/* Move point to on top of the last character changed. */
|
||||
rl_point = end - direction;
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*******************************************************************************
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
*
|
||||
* Contents: A streambuf which uses the GNU readline library for line I/O
|
||||
* (c) 2001 by Dimitris Vyzovitis [vyzo@media.mit.edu]
|
||||
*
|
||||
* This program 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free
|
||||
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _READLINEBUF_H_
|
||||
#define _READLINEBUF_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#if (defined __GNUC__) && (__GNUC__ < 3)
|
||||
#include <streambuf.h>
|
||||
#else
|
||||
#include <streambuf>
|
||||
using std::streamsize;
|
||||
using std::streambuf;
|
||||
#endif
|
||||
|
||||
class readlinebuf : public streambuf {
|
||||
public:
|
||||
#if (defined __GNUC__) && (__GNUC__ < 3)
|
||||
typedef char char_type;
|
||||
typedef int int_type;
|
||||
typedef streampos pos_type;
|
||||
typedef streamoff off_type;
|
||||
#endif
|
||||
static const int_type eof = EOF; // this is -1
|
||||
static const int_type not_eof = 0;
|
||||
|
||||
private:
|
||||
const char* prompt_;
|
||||
bool history_;
|
||||
char* line_;
|
||||
int low_;
|
||||
int high_;
|
||||
|
||||
protected:
|
||||
|
||||
virtual int_type showmanyc() const { return high_ - low_; }
|
||||
|
||||
virtual streamsize xsgetn( char_type* buf, streamsize n ) {
|
||||
int rd = n > (high_ - low_)? (high_ - low_) : n;
|
||||
memcpy( buf, line_, rd );
|
||||
low_ += rd;
|
||||
|
||||
if ( rd < n ) {
|
||||
low_ = high_ = 0;
|
||||
free( line_ ); // free( NULL ) is a noop
|
||||
line_ = readline( prompt_ );
|
||||
if ( line_ ) {
|
||||
high_ = strlen( line_ );
|
||||
if ( history_ && high_ ) add_history( line_ );
|
||||
rd += xsgetn( buf + rd, n - rd );
|
||||
}
|
||||
}
|
||||
|
||||
return rd;
|
||||
}
|
||||
|
||||
virtual int_type underflow() {
|
||||
if ( high_ == low_ ) {
|
||||
low_ = high_ = 0;
|
||||
free( line_ ); // free( NULL ) is a noop
|
||||
line_ = readline( prompt_ );
|
||||
if ( line_ ) {
|
||||
high_ = strlen( line_ );
|
||||
if ( history_ && high_ ) add_history( line_ );
|
||||
}
|
||||
}
|
||||
|
||||
if ( low_ < high_ ) return line_[low_];
|
||||
else return eof;
|
||||
}
|
||||
|
||||
virtual int_type uflow() {
|
||||
int_type c = underflow();
|
||||
if ( c != eof ) ++low_;
|
||||
return c;
|
||||
}
|
||||
|
||||
virtual int_type pbackfail( int_type c = eof ) {
|
||||
if ( low_ > 0 ) --low_;
|
||||
else if ( c != eof ) {
|
||||
if ( high_ > 0 ) {
|
||||
char* nl = (char*)realloc( line_, high_ + 1 );
|
||||
if ( nl ) {
|
||||
line_ = (char*)memcpy( nl + 1, line_, high_ );
|
||||
high_ += 1;
|
||||
line_[0] = char( c );
|
||||
} else return eof;
|
||||
} else {
|
||||
assert( !line_ );
|
||||
line_ = (char*)malloc( sizeof( char ) );
|
||||
*line_ = char( c );
|
||||
high_ = 1;
|
||||
}
|
||||
} else return eof;
|
||||
|
||||
return not_eof;
|
||||
}
|
||||
|
||||
public:
|
||||
readlinebuf( const char* prompt = NULL, bool history = true )
|
||||
: prompt_( prompt ), history_( history ),
|
||||
line_( NULL ), low_( 0 ), high_( 0 ) {
|
||||
setbuf( 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* rl - command-line interface to read a line from the standard input
|
||||
* (or another fd) using readline.
|
||||
*
|
||||
* usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "posixstat.h"
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strrchr();
|
||||
#endif
|
||||
|
||||
static char *progname;
|
||||
static char *deftext;
|
||||
|
||||
static int
|
||||
set_deftext ()
|
||||
{
|
||||
if (deftext)
|
||||
{
|
||||
rl_insert_text (deftext);
|
||||
deftext = (char *)NULL;
|
||||
rl_startup_hook = (rl_hook_func_t *)NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
|
||||
progname, progname);
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *temp, *prompt;
|
||||
struct stat sb;
|
||||
int opt, fd, nch;
|
||||
FILE *ifp;
|
||||
|
||||
progname = strrchr(argv[0], '/');
|
||||
if (progname == 0)
|
||||
progname = argv[0];
|
||||
else
|
||||
progname++;
|
||||
|
||||
/* defaults */
|
||||
prompt = "readline$ ";
|
||||
fd = nch = 0;
|
||||
deftext = (char *)0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "p:u:d:n:")) != EOF)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'p':
|
||||
prompt = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
fd = atoi(optarg);
|
||||
if (fd < 0)
|
||||
{
|
||||
fprintf (stderr, "%s: bad file descriptor `%s'\n", progname, optarg);
|
||||
exit (2);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
deftext = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
nch = atoi(optarg);
|
||||
if (nch < 0)
|
||||
{
|
||||
fprintf (stderr, "%s: bad value for -n: `%s'\n", progname, optarg);
|
||||
exit (2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
exit (2);
|
||||
}
|
||||
}
|
||||
|
||||
if (fd != 0)
|
||||
{
|
||||
if (fstat (fd, &sb) < 0)
|
||||
{
|
||||
fprintf (stderr, "%s: %d: bad file descriptor\n", progname, fd);
|
||||
exit (1);
|
||||
}
|
||||
ifp = fdopen (fd, "r");
|
||||
rl_instream = ifp;
|
||||
}
|
||||
|
||||
if (deftext && *deftext)
|
||||
rl_startup_hook = set_deftext;
|
||||
|
||||
if (nch > 0)
|
||||
rl_num_chars_to_read = nch;
|
||||
|
||||
temp = readline (prompt);
|
||||
|
||||
/* Test for EOF. */
|
||||
if (temp == 0)
|
||||
exit (1);
|
||||
|
||||
printf ("%s\n", temp);
|
||||
exit (0);
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* rlcat - cat(1) using readline
|
||||
*
|
||||
* usage: rlcat
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "posixstat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
static int stdcat();
|
||||
|
||||
static char *progname;
|
||||
static int vflag;
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf (stderr, "%s: usage: %s [-vEVN] [filename]\n", progname, progname);
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *temp;
|
||||
int opt, Vflag, Nflag;
|
||||
|
||||
progname = strrchr(argv[0], '/');
|
||||
if (progname == 0)
|
||||
progname = argv[0];
|
||||
else
|
||||
progname++;
|
||||
|
||||
vflag = Vflag = Nflag = 0;
|
||||
while ((opt = getopt(argc, argv, "vEVN")) != EOF)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
case 'V':
|
||||
Vflag = 1;
|
||||
break;
|
||||
case 'E':
|
||||
Vflag = 0;
|
||||
break;
|
||||
case 'N':
|
||||
Nflag = 1;
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
exit (2);
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (isatty(0) == 0 || argc || Nflag)
|
||||
return stdcat(argc, argv);
|
||||
|
||||
rl_variable_bind ("editing-mode", Vflag ? "vi" : "emacs");
|
||||
while (temp = readline (""))
|
||||
{
|
||||
if (*temp)
|
||||
add_history (temp);
|
||||
printf ("%s\n", temp);
|
||||
}
|
||||
|
||||
return (ferror (stdout));
|
||||
}
|
||||
|
||||
static int
|
||||
fcopy(fp)
|
||||
FILE *fp;
|
||||
{
|
||||
int c;
|
||||
char *x;
|
||||
|
||||
while ((c = getc(fp)) != EOF)
|
||||
{
|
||||
if (vflag && isascii ((unsigned char)c) && isprint((unsigned char)c) == 0)
|
||||
{
|
||||
x = rl_untranslate_keyseq (c);
|
||||
if (fputs (x, stdout) != 0)
|
||||
return 1;
|
||||
}
|
||||
else if (putchar (c) == EOF)
|
||||
return 1;
|
||||
}
|
||||
return (ferror (stdout));
|
||||
}
|
||||
|
||||
int
|
||||
stdcat (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i, fd, r;
|
||||
char *s;
|
||||
FILE *fp;
|
||||
|
||||
if (argc == 0)
|
||||
return (fcopy(stdin));
|
||||
|
||||
for (i = 0, r = 1; i < argc; i++)
|
||||
{
|
||||
if (*argv[i] == '-' && argv[i][1] == 0)
|
||||
fp = stdin;
|
||||
else
|
||||
{
|
||||
fp = fopen (argv[i], "r");
|
||||
if (fp == 0)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: cannot open: %s\n", progname, argv[i], strerror(errno));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
r = fcopy (fp);
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,87 @@
|
|||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Testing Readline */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
extern HIST_ENTRY **history_list ();
|
||||
|
||||
main ()
|
||||
{
|
||||
char *temp, *prompt;
|
||||
int done;
|
||||
|
||||
temp = (char *)NULL;
|
||||
prompt = "readline$ ";
|
||||
done = 0;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
temp = readline (prompt);
|
||||
|
||||
/* Test for EOF. */
|
||||
if (!temp)
|
||||
exit (1);
|
||||
|
||||
/* If there is anything on the line, print it and remember it. */
|
||||
if (*temp)
|
||||
{
|
||||
fprintf (stderr, "%s\r\n", temp);
|
||||
add_history (temp);
|
||||
}
|
||||
|
||||
/* Check for `command' that we handle. */
|
||||
if (strcmp (temp, "quit") == 0)
|
||||
done = 1;
|
||||
|
||||
if (strcmp (temp, "list") == 0)
|
||||
{
|
||||
HIST_ENTRY **list;
|
||||
register int i;
|
||||
|
||||
list = history_list ();
|
||||
if (list)
|
||||
{
|
||||
for (i = 0; list[i]; i++)
|
||||
fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
|
||||
}
|
||||
}
|
||||
free (temp);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* rlversion -- print out readline's version number
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "posixstat.h"
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
#endif
|
||||
|
||||
main()
|
||||
{
|
||||
printf ("%s\n", rl_library_version ? rl_library_version : "unknown");
|
||||
exit (0);
|
||||
}
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
/* funmap.c -- attach names to functions. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined (BUFSIZ)
|
||||
#include <stdio.h>
|
||||
#endif /* BUFSIZ */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include "rlconf.h"
|
||||
#include "readline.h"
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef int QSFUNC (const void *, const void *);
|
||||
#else
|
||||
typedef int QSFUNC ();
|
||||
#endif
|
||||
|
||||
extern int _rl_qsort_string_compare PARAMS((char **, char **));
|
||||
|
||||
FUNMAP **funmap;
|
||||
static int funmap_size;
|
||||
static int funmap_entry;
|
||||
|
||||
/* After initializing the function map, this is the index of the first
|
||||
program specific function. */
|
||||
int funmap_program_specific_entry_start;
|
||||
|
||||
static FUNMAP default_funmap[] = {
|
||||
{ "abort", rl_abort },
|
||||
{ "accept-line", rl_newline },
|
||||
{ "arrow-key-prefix", rl_arrow_keys },
|
||||
{ "backward-byte", rl_backward_byte },
|
||||
{ "backward-char", rl_backward_char },
|
||||
{ "backward-delete-char", rl_rubout },
|
||||
{ "backward-kill-line", rl_backward_kill_line },
|
||||
{ "backward-kill-word", rl_backward_kill_word },
|
||||
{ "backward-word", rl_backward_word },
|
||||
{ "beginning-of-history", rl_beginning_of_history },
|
||||
{ "beginning-of-line", rl_beg_of_line },
|
||||
{ "call-last-kbd-macro", rl_call_last_kbd_macro },
|
||||
{ "capitalize-word", rl_capitalize_word },
|
||||
{ "character-search", rl_char_search },
|
||||
{ "character-search-backward", rl_backward_char_search },
|
||||
{ "clear-screen", rl_clear_screen },
|
||||
{ "complete", rl_complete },
|
||||
{ "copy-backward-word", rl_copy_backward_word },
|
||||
{ "copy-forward-word", rl_copy_forward_word },
|
||||
{ "copy-region-as-kill", rl_copy_region_to_kill },
|
||||
{ "delete-char", rl_delete },
|
||||
{ "delete-char-or-list", rl_delete_or_show_completions },
|
||||
{ "delete-horizontal-space", rl_delete_horizontal_space },
|
||||
{ "digit-argument", rl_digit_argument },
|
||||
{ "do-lowercase-version", rl_do_lowercase_version },
|
||||
{ "downcase-word", rl_downcase_word },
|
||||
{ "dump-functions", rl_dump_functions },
|
||||
{ "dump-macros", rl_dump_macros },
|
||||
{ "dump-variables", rl_dump_variables },
|
||||
{ "emacs-editing-mode", rl_emacs_editing_mode },
|
||||
{ "end-kbd-macro", rl_end_kbd_macro },
|
||||
{ "end-of-history", rl_end_of_history },
|
||||
{ "end-of-line", rl_end_of_line },
|
||||
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
|
||||
{ "forward-backward-delete-char", rl_rubout_or_delete },
|
||||
{ "forward-byte", rl_forward_byte },
|
||||
{ "forward-char", rl_forward_char },
|
||||
{ "forward-search-history", rl_forward_search_history },
|
||||
{ "forward-word", rl_forward_word },
|
||||
{ "history-search-backward", rl_history_search_backward },
|
||||
{ "history-search-forward", rl_history_search_forward },
|
||||
{ "insert-comment", rl_insert_comment },
|
||||
{ "insert-completions", rl_insert_completions },
|
||||
{ "kill-whole-line", rl_kill_full_line },
|
||||
{ "kill-line", rl_kill_line },
|
||||
{ "kill-region", rl_kill_region },
|
||||
{ "kill-word", rl_kill_word },
|
||||
{ "menu-complete", rl_menu_complete },
|
||||
{ "next-history", rl_get_next_history },
|
||||
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
|
||||
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
|
||||
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
|
||||
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
|
||||
{ "overwrite-mode", rl_overwrite_mode },
|
||||
#ifdef __CYGWIN__
|
||||
{ "paste-from-clipboard", rl_paste_from_clipboard },
|
||||
#endif
|
||||
{ "possible-completions", rl_possible_completions },
|
||||
{ "previous-history", rl_get_previous_history },
|
||||
{ "quoted-insert", rl_quoted_insert },
|
||||
{ "re-read-init-file", rl_re_read_init_file },
|
||||
{ "redraw-current-line", rl_refresh_line},
|
||||
{ "reverse-search-history", rl_reverse_search_history },
|
||||
{ "revert-line", rl_revert_line },
|
||||
{ "self-insert", rl_insert },
|
||||
{ "set-mark", rl_set_mark },
|
||||
{ "start-kbd-macro", rl_start_kbd_macro },
|
||||
{ "tab-insert", rl_tab_insert },
|
||||
{ "tilde-expand", rl_tilde_expand },
|
||||
{ "transpose-chars", rl_transpose_chars },
|
||||
{ "transpose-words", rl_transpose_words },
|
||||
{ "tty-status", rl_tty_status },
|
||||
{ "undo", rl_undo_command },
|
||||
{ "universal-argument", rl_universal_argument },
|
||||
{ "unix-line-discard", rl_unix_line_discard },
|
||||
{ "unix-word-rubout", rl_unix_word_rubout },
|
||||
{ "upcase-word", rl_upcase_word },
|
||||
{ "yank", rl_yank },
|
||||
{ "yank-last-arg", rl_yank_last_arg },
|
||||
{ "yank-nth-arg", rl_yank_nth_arg },
|
||||
{ "yank-pop", rl_yank_pop },
|
||||
|
||||
#if defined (VI_MODE)
|
||||
{ "vi-append-eol", rl_vi_append_eol },
|
||||
{ "vi-append-mode", rl_vi_append_mode },
|
||||
{ "vi-arg-digit", rl_vi_arg_digit },
|
||||
{ "vi-back-to-indent", rl_vi_back_to_indent },
|
||||
{ "vi-bWord", rl_vi_bWord },
|
||||
{ "vi-bword", rl_vi_bword },
|
||||
{ "vi-change-case", rl_vi_change_case },
|
||||
{ "vi-change-char", rl_vi_change_char },
|
||||
{ "vi-change-to", rl_vi_change_to },
|
||||
{ "vi-char-search", rl_vi_char_search },
|
||||
{ "vi-column", rl_vi_column },
|
||||
{ "vi-complete", rl_vi_complete },
|
||||
{ "vi-delete", rl_vi_delete },
|
||||
{ "vi-delete-to", rl_vi_delete_to },
|
||||
{ "vi-eWord", rl_vi_eWord },
|
||||
{ "vi-editing-mode", rl_vi_editing_mode },
|
||||
{ "vi-end-word", rl_vi_end_word },
|
||||
{ "vi-eof-maybe", rl_vi_eof_maybe },
|
||||
{ "vi-eword", rl_vi_eword },
|
||||
{ "vi-fWord", rl_vi_fWord },
|
||||
{ "vi-fetch-history", rl_vi_fetch_history },
|
||||
{ "vi-first-print", rl_vi_first_print },
|
||||
{ "vi-fword", rl_vi_fword },
|
||||
{ "vi-goto-mark", rl_vi_goto_mark },
|
||||
{ "vi-insert-beg", rl_vi_insert_beg },
|
||||
{ "vi-insertion-mode", rl_vi_insertion_mode },
|
||||
{ "vi-match", rl_vi_match },
|
||||
{ "vi-movement-mode", rl_vi_movement_mode },
|
||||
{ "vi-next-word", rl_vi_next_word },
|
||||
{ "vi-overstrike", rl_vi_overstrike },
|
||||
{ "vi-overstrike-delete", rl_vi_overstrike_delete },
|
||||
{ "vi-prev-word", rl_vi_prev_word },
|
||||
{ "vi-put", rl_vi_put },
|
||||
{ "vi-redo", rl_vi_redo },
|
||||
{ "vi-replace", rl_vi_replace },
|
||||
{ "vi-search", rl_vi_search },
|
||||
{ "vi-search-again", rl_vi_search_again },
|
||||
{ "vi-set-mark", rl_vi_set_mark },
|
||||
{ "vi-subst", rl_vi_subst },
|
||||
{ "vi-tilde-expand", rl_vi_tilde_expand },
|
||||
{ "vi-yank-arg", rl_vi_yank_arg },
|
||||
{ "vi-yank-to", rl_vi_yank_to },
|
||||
#endif /* VI_MODE */
|
||||
|
||||
{(char *)NULL, (rl_command_func_t *)NULL }
|
||||
};
|
||||
|
||||
int
|
||||
rl_add_funmap_entry (name, function)
|
||||
const char *name;
|
||||
rl_command_func_t *function;
|
||||
{
|
||||
if (funmap_entry + 2 >= funmap_size)
|
||||
{
|
||||
funmap_size += 64;
|
||||
funmap = (FUNMAP **)xrealloc (funmap, funmap_size * sizeof (FUNMAP *));
|
||||
}
|
||||
|
||||
funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
|
||||
funmap[funmap_entry]->name = name;
|
||||
funmap[funmap_entry]->function = function;
|
||||
|
||||
funmap[++funmap_entry] = (FUNMAP *)NULL;
|
||||
return funmap_entry;
|
||||
}
|
||||
|
||||
static int funmap_initialized;
|
||||
|
||||
/* Make the funmap contain all of the default entries. */
|
||||
void
|
||||
rl_initialize_funmap ()
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (funmap_initialized)
|
||||
return;
|
||||
|
||||
for (i = 0; default_funmap[i].name; i++)
|
||||
rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
|
||||
|
||||
funmap_initialized = 1;
|
||||
funmap_program_specific_entry_start = i;
|
||||
}
|
||||
|
||||
/* Produce a NULL terminated array of known function names. The array
|
||||
is sorted. The array itself is allocated, but not the strings inside.
|
||||
You should free () the array when you done, but not the pointrs. */
|
||||
const char **
|
||||
rl_funmap_names ()
|
||||
{
|
||||
const char **result;
|
||||
int result_size, result_index;
|
||||
|
||||
/* Make sure that the function map has been initialized. */
|
||||
rl_initialize_funmap ();
|
||||
|
||||
for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
|
||||
{
|
||||
if (result_index + 2 > result_size)
|
||||
{
|
||||
result_size += 20;
|
||||
result = (const char **)xrealloc (result, result_size * sizeof (char *));
|
||||
}
|
||||
|
||||
result[result_index] = funmap[result_index]->name;
|
||||
result[result_index + 1] = (char *)NULL;
|
||||
}
|
||||
|
||||
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
return (result);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,479 @@
|
|||
/* histfile.c - functions to manipulate the history file. */
|
||||
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
/* The goal is to make the implementation transparent, so that you
|
||||
don't have to know what data types are used, just what functions
|
||||
you can call. I think I have done that. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef _MINIX
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include "posixstat.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (__EMX__) || defined (__CYGWIN__)
|
||||
# undef HAVE_MMAP
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
# include <sys/mman.h>
|
||||
|
||||
# ifdef MAP_FILE
|
||||
# define MAP_RFLAGS (MAP_FILE|MAP_PRIVATE)
|
||||
# define MAP_WFLAGS (MAP_FILE|MAP_SHARED)
|
||||
# else
|
||||
# define MAP_RFLAGS MAP_PRIVATE
|
||||
# define MAP_WFLAGS MAP_SHARED
|
||||
# endif
|
||||
|
||||
# ifndef MAP_FAILED
|
||||
# define MAP_FAILED ((void *)-1)
|
||||
# endif
|
||||
|
||||
#endif /* HAVE_MMAP */
|
||||
|
||||
/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
|
||||
on win 95/98/nt), we want to open files with O_BINARY mode so that there
|
||||
is no \n -> \r\n conversion performed. On other systems, we don't want to
|
||||
mess around with O_BINARY at all, so we ensure that it's defined to 0. */
|
||||
#if defined (__EMX__) || defined (__CYGWIN__)
|
||||
# ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
# endif
|
||||
#else /* !__EMX__ && !__CYGWIN__ */
|
||||
# undef O_BINARY
|
||||
# define O_BINARY 0
|
||||
#endif /* !__EMX__ && !__CYGWIN__ */
|
||||
|
||||
#include <errno.h>
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Return the string that should be used in the place of this
|
||||
filename. This only matters when you don't specify the
|
||||
filename to read_history (), or write_history (). */
|
||||
static char *
|
||||
history_filename (filename)
|
||||
const char *filename;
|
||||
{
|
||||
char *return_val;
|
||||
const char *home;
|
||||
int home_len;
|
||||
|
||||
return_val = filename ? savestring (filename) : (char *)NULL;
|
||||
|
||||
if (return_val)
|
||||
return (return_val);
|
||||
|
||||
home = sh_get_env_value ("HOME");
|
||||
|
||||
if (home == 0)
|
||||
{
|
||||
home = ".";
|
||||
home_len = 1;
|
||||
}
|
||||
else
|
||||
home_len = strlen (home);
|
||||
|
||||
return_val = (char *)xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
|
||||
strcpy (return_val, home);
|
||||
return_val[home_len] = '/';
|
||||
#if defined (__MSDOS__)
|
||||
strcpy (return_val + home_len + 1, "_history");
|
||||
#else
|
||||
strcpy (return_val + home_len + 1, ".history");
|
||||
#endif
|
||||
|
||||
return (return_val);
|
||||
}
|
||||
|
||||
/* Add the contents of FILENAME to the history list, a line at a time.
|
||||
If FILENAME is NULL, then read from ~/.history. Returns 0 if
|
||||
successful, or errno if not. */
|
||||
int
|
||||
read_history (filename)
|
||||
const char *filename;
|
||||
{
|
||||
return (read_history_range (filename, 0, -1));
|
||||
}
|
||||
|
||||
/* Read a range of lines from FILENAME, adding them to the history list.
|
||||
Start reading at the FROM'th line and end at the TO'th. If FROM
|
||||
is zero, start at the beginning. If TO is less than FROM, read
|
||||
until the end of the file. If FILENAME is NULL, then read from
|
||||
~/.history. Returns 0 if successful, or errno if not. */
|
||||
int
|
||||
read_history_range (filename, from, to)
|
||||
const char *filename;
|
||||
int from, to;
|
||||
{
|
||||
register char *line_start, *line_end;
|
||||
char *input, *buffer, *bufend;
|
||||
int file, current_line, chars_read;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
|
||||
buffer = (char *)NULL;
|
||||
input = history_filename (filename);
|
||||
file = open (input, O_RDONLY|O_BINARY, 0666);
|
||||
|
||||
if ((file < 0) || (fstat (file, &finfo) == -1))
|
||||
goto error_and_exit;
|
||||
|
||||
file_size = (size_t)finfo.st_size;
|
||||
|
||||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
#if defined (EFBIG)
|
||||
errno = EFBIG;
|
||||
#elif defined (EOVERFLOW)
|
||||
errno = EOVERFLOW;
|
||||
#endif
|
||||
goto error_and_exit;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
/* We map read/write and private so we can change newlines to NULs without
|
||||
affecting the underlying object. */
|
||||
buffer = (char *)mmap (0, file_size, PROT_READ|PROT_WRITE, MAP_RFLAGS, file, 0);
|
||||
if ((void *)buffer == MAP_FAILED)
|
||||
goto error_and_exit;
|
||||
chars_read = file_size;
|
||||
#else
|
||||
buffer = (char *)malloc (file_size + 1);
|
||||
if (buffer == 0)
|
||||
goto error_and_exit;
|
||||
|
||||
chars_read = read (file, buffer, file_size);
|
||||
#endif
|
||||
if (chars_read < 0)
|
||||
{
|
||||
error_and_exit:
|
||||
chars_read = errno;
|
||||
if (file >= 0)
|
||||
close (file);
|
||||
|
||||
FREE (input);
|
||||
#ifndef HAVE_MMAP
|
||||
FREE (buffer);
|
||||
#endif
|
||||
|
||||
return (chars_read);
|
||||
}
|
||||
|
||||
close (file);
|
||||
|
||||
/* Set TO to larger than end of file if negative. */
|
||||
if (to < 0)
|
||||
to = chars_read;
|
||||
|
||||
/* Start at beginning of file, work to end. */
|
||||
bufend = buffer + chars_read;
|
||||
current_line = 0;
|
||||
|
||||
/* Skip lines until we are at FROM. */
|
||||
for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
|
||||
if (*line_end == '\n')
|
||||
{
|
||||
current_line++;
|
||||
line_start = line_end + 1;
|
||||
}
|
||||
|
||||
/* If there are lines left to gobble, then gobble them now. */
|
||||
for (line_end = line_start; line_end < bufend; line_end++)
|
||||
if (*line_end == '\n')
|
||||
{
|
||||
*line_end = '\0';
|
||||
|
||||
if (*line_start)
|
||||
add_history (line_start);
|
||||
|
||||
current_line++;
|
||||
|
||||
if (current_line >= to)
|
||||
break;
|
||||
|
||||
line_start = line_end + 1;
|
||||
}
|
||||
|
||||
FREE (input);
|
||||
#ifndef HAVE_MMAP
|
||||
FREE (buffer);
|
||||
#else
|
||||
munmap (buffer, file_size);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Truncate the history file FNAME, leaving only LINES trailing lines.
|
||||
If FNAME is NULL, then use ~/.history. Returns 0 on success, errno
|
||||
on failure. */
|
||||
int
|
||||
history_truncate_file (fname, lines)
|
||||
const char *fname;
|
||||
int lines;
|
||||
{
|
||||
char *buffer, *filename, *bp;
|
||||
int file, chars_read, rv;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
|
||||
buffer = (char *)NULL;
|
||||
filename = history_filename (fname);
|
||||
file = open (filename, O_RDONLY|O_BINARY, 0666);
|
||||
rv = 0;
|
||||
|
||||
/* Don't try to truncate non-regular files. */
|
||||
if (file == -1 || fstat (file, &finfo) == -1)
|
||||
{
|
||||
rv = errno;
|
||||
if (file != -1)
|
||||
close (file);
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
if (S_ISREG (finfo.st_mode) == 0)
|
||||
{
|
||||
close (file);
|
||||
#ifdef EFTYPE
|
||||
rv = EFTYPE;
|
||||
#else
|
||||
rv = EINVAL;
|
||||
#endif
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
file_size = (size_t)finfo.st_size;
|
||||
|
||||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
close (file);
|
||||
#if defined (EFBIG)
|
||||
rv = errno = EFBIG;
|
||||
#elif defined (EOVERFLOW)
|
||||
rv = errno = EOVERFLOW;
|
||||
#else
|
||||
rv = errno = EINVAL;
|
||||
#endif
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
buffer = (char *)malloc (file_size + 1);
|
||||
if (buffer == 0)
|
||||
{
|
||||
close (file);
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
chars_read = read (file, buffer, file_size);
|
||||
close (file);
|
||||
|
||||
if (chars_read <= 0)
|
||||
{
|
||||
rv = (chars_read < 0) ? errno : 0;
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
/* Count backwards from the end of buffer until we have passed
|
||||
LINES lines. */
|
||||
for (bp = buffer + chars_read - 1; lines && bp > buffer; bp--)
|
||||
{
|
||||
if (*bp == '\n')
|
||||
lines--;
|
||||
}
|
||||
|
||||
/* If this is the first line, then the file contains exactly the
|
||||
number of lines we want to truncate to, so we don't need to do
|
||||
anything. It's the first line if we don't find a newline between
|
||||
the current value of i and 0. Otherwise, write from the start of
|
||||
this line until the end of the buffer. */
|
||||
for ( ; bp > buffer; bp--)
|
||||
if (*bp == '\n')
|
||||
{
|
||||
bp++;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Write only if there are more lines in the file than we want to
|
||||
truncate to. */
|
||||
if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
|
||||
{
|
||||
write (file, bp, chars_read - (bp - buffer));
|
||||
|
||||
#if defined (__BEOS__)
|
||||
/* BeOS ignores O_TRUNC. */
|
||||
ftruncate (file, chars_read - (bp - buffer));
|
||||
#endif
|
||||
|
||||
close (file);
|
||||
}
|
||||
|
||||
truncate_exit:
|
||||
|
||||
FREE (buffer);
|
||||
|
||||
free (filename);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Workhorse function for writing history. Writes NELEMENT entries
|
||||
from the history list to FILENAME. OVERWRITE is non-zero if you
|
||||
wish to replace FILENAME with the entries. */
|
||||
static int
|
||||
history_do_write (filename, nelements, overwrite)
|
||||
const char *filename;
|
||||
int nelements, overwrite;
|
||||
{
|
||||
register int i;
|
||||
char *output;
|
||||
int file, mode, rv;
|
||||
size_t cursize;
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
mode = overwrite ? O_RDWR|O_CREAT|O_TRUNC|O_BINARY : O_RDWR|O_APPEND|O_BINARY;
|
||||
#else
|
||||
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
|
||||
#endif
|
||||
output = history_filename (filename);
|
||||
rv = 0;
|
||||
|
||||
if ((file = open (output, mode, 0600)) == -1)
|
||||
{
|
||||
FREE (output);
|
||||
return (errno);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
cursize = overwrite ? 0 : lseek (file, 0, SEEK_END);
|
||||
#endif
|
||||
|
||||
if (nelements > history_length)
|
||||
nelements = history_length;
|
||||
|
||||
/* Build a buffer of all the lines to write, and write them in one syscall.
|
||||
Suggested by Peter Ho (peter@robosts.oxford.ac.uk). */
|
||||
{
|
||||
HIST_ENTRY **the_history; /* local */
|
||||
register int j;
|
||||
int buffer_size;
|
||||
char *buffer;
|
||||
|
||||
the_history = history_list ();
|
||||
/* Calculate the total number of bytes to write. */
|
||||
for (buffer_size = 0, i = history_length - nelements; i < history_length; i++)
|
||||
buffer_size += 1 + strlen (the_history[i]->line);
|
||||
|
||||
/* Allocate the buffer, and fill it. */
|
||||
#ifdef HAVE_MMAP
|
||||
if (ftruncate (file, buffer_size+cursize) == -1)
|
||||
goto mmap_error;
|
||||
buffer = (char *)mmap (0, buffer_size, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, cursize);
|
||||
if ((void *)buffer == MAP_FAILED)
|
||||
{
|
||||
mmap_error:
|
||||
rv = errno;
|
||||
FREE (output);
|
||||
close (file);
|
||||
return rv;
|
||||
}
|
||||
#else
|
||||
buffer = (char *)malloc (buffer_size);
|
||||
if (buffer == 0)
|
||||
{
|
||||
rv = errno;
|
||||
FREE (output);
|
||||
close (file);
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (j = 0, i = history_length - nelements; i < history_length; i++)
|
||||
{
|
||||
strcpy (buffer + j, the_history[i]->line);
|
||||
j += strlen (the_history[i]->line);
|
||||
buffer[j++] = '\n';
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
if (msync (buffer, buffer_size, 0) != 0 || munmap (buffer, buffer_size) != 0)
|
||||
rv = errno;
|
||||
#else
|
||||
if (write (file, buffer, buffer_size) < 0)
|
||||
rv = errno;
|
||||
free (buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
close (file);
|
||||
|
||||
FREE (output);
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/* Append NELEMENT entries to FILENAME. The entries appended are from
|
||||
the end of the list minus NELEMENTs up to the end of the list. */
|
||||
int
|
||||
append_history (nelements, filename)
|
||||
int nelements;
|
||||
const char *filename;
|
||||
{
|
||||
return (history_do_write (filename, nelements, HISTORY_APPEND));
|
||||
}
|
||||
|
||||
/* Overwrite FILENAME with the current history. If FILENAME is NULL,
|
||||
then write the history list to ~/.history. Values returned
|
||||
are as in read_history ().*/
|
||||
int
|
||||
write_history (filename)
|
||||
const char *filename;
|
||||
{
|
||||
return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/* histlib.h -- internal definitions for the history library. */
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#if !defined (_HISTLIB_H_)
|
||||
#define _HISTLIB_H_
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if !defined (STREQ)
|
||||
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
|
||||
#define STREQN(a, b, n) (((n) == 0) ? (1) \
|
||||
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
|
||||
#endif
|
||||
|
||||
#ifndef savestring
|
||||
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
|
||||
#endif
|
||||
|
||||
#ifndef whitespace
|
||||
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
|
||||
#endif
|
||||
|
||||
#ifndef _rl_digit_p
|
||||
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
|
||||
#endif
|
||||
|
||||
#ifndef _rl_digit_value
|
||||
#define _rl_digit_value(c) ((c) - '0')
|
||||
#endif
|
||||
|
||||
#ifndef member
|
||||
# ifndef strchr
|
||||
extern char *strchr ();
|
||||
# endif
|
||||
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
|
||||
#endif
|
||||
|
||||
#ifndef FREE
|
||||
# define FREE(x) if (x) free (x)
|
||||
#endif
|
||||
|
||||
/* Possible history errors passed to hist_error. */
|
||||
#define EVENT_NOT_FOUND 0
|
||||
#define BAD_WORD_SPEC 1
|
||||
#define SUBST_FAILED 2
|
||||
#define BAD_MODIFIER 3
|
||||
#define NO_PREV_SUBST 4
|
||||
|
||||
/* Possible definitions for history starting point specification. */
|
||||
#define ANCHORED_SEARCH 1
|
||||
#define NON_ANCHORED_SEARCH 0
|
||||
|
||||
/* Possible definitions for what style of writing the history file we want. */
|
||||
#define HISTORY_APPEND 0
|
||||
#define HISTORY_OVERWRITE 1
|
||||
|
||||
/* Some variable definitions shared across history source files. */
|
||||
extern int history_offset;
|
||||
|
||||
#endif /* !_HISTLIB_H_ */
|
||||
|
|
@ -0,0 +1,381 @@
|
|||
/* History.c -- standalone history library */
|
||||
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
/* The goal is to make the implementation transparent, so that you
|
||||
don't have to know what data types are used, just what functions
|
||||
you can call. I think I have done that. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* The number of slots to increase the_history by. */
|
||||
#define DEFAULT_HISTORY_GROW_SIZE 50
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* An array of HIST_ENTRY. This is where we store the history. */
|
||||
static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
|
||||
|
||||
/* Non-zero means that we have enforced a limit on the amount of
|
||||
history that we save. */
|
||||
static int history_stifled;
|
||||
|
||||
/* The current number of slots allocated to the input_history. */
|
||||
static int history_size;
|
||||
|
||||
/* If HISTORY_STIFLED is non-zero, then this is the maximum number of
|
||||
entries to remember. */
|
||||
int history_max_entries;
|
||||
int max_input_history; /* backwards compatibility */
|
||||
|
||||
/* The current location of the interactive history pointer. Just makes
|
||||
life easier for outside callers. */
|
||||
int history_offset;
|
||||
|
||||
/* The number of strings currently stored in the history list. */
|
||||
int history_length;
|
||||
|
||||
/* The logical `base' of the history array. It defaults to 1. */
|
||||
int history_base = 1;
|
||||
|
||||
/* Return the current HISTORY_STATE of the history. */
|
||||
HISTORY_STATE *
|
||||
history_get_history_state ()
|
||||
{
|
||||
HISTORY_STATE *state;
|
||||
|
||||
state = (HISTORY_STATE *)xmalloc (sizeof (HISTORY_STATE));
|
||||
state->entries = the_history;
|
||||
state->offset = history_offset;
|
||||
state->length = history_length;
|
||||
state->size = history_size;
|
||||
state->flags = 0;
|
||||
if (history_stifled)
|
||||
state->flags |= HS_STIFLED;
|
||||
|
||||
return (state);
|
||||
}
|
||||
|
||||
/* Set the state of the current history array to STATE. */
|
||||
void
|
||||
history_set_history_state (state)
|
||||
HISTORY_STATE *state;
|
||||
{
|
||||
the_history = state->entries;
|
||||
history_offset = state->offset;
|
||||
history_length = state->length;
|
||||
history_size = state->size;
|
||||
if (state->flags & HS_STIFLED)
|
||||
history_stifled = 1;
|
||||
}
|
||||
|
||||
/* Begin a session in which the history functions might be used. This
|
||||
initializes interactive variables. */
|
||||
void
|
||||
using_history ()
|
||||
{
|
||||
history_offset = history_length;
|
||||
}
|
||||
|
||||
/* Return the number of bytes that the primary history entries are using.
|
||||
This just adds up the lengths of the_history->lines. */
|
||||
int
|
||||
history_total_bytes ()
|
||||
{
|
||||
register int i, result;
|
||||
|
||||
for (i = result = 0; the_history && the_history[i]; i++)
|
||||
result += strlen (the_history[i]->line);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Returns the magic number which says what history element we are
|
||||
looking at now. In this implementation, it returns history_offset. */
|
||||
int
|
||||
where_history ()
|
||||
{
|
||||
return (history_offset);
|
||||
}
|
||||
|
||||
/* Make the current history item be the one at POS, an absolute index.
|
||||
Returns zero if POS is out of range, else non-zero. */
|
||||
int
|
||||
history_set_pos (pos)
|
||||
int pos;
|
||||
{
|
||||
if (pos > history_length || pos < 0 || !the_history)
|
||||
return (0);
|
||||
history_offset = pos;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Return the current history array. The caller has to be carefull, since this
|
||||
is the actual array of data, and could be bashed or made corrupt easily.
|
||||
The array is terminated with a NULL pointer. */
|
||||
HIST_ENTRY **
|
||||
history_list ()
|
||||
{
|
||||
return (the_history);
|
||||
}
|
||||
|
||||
/* Return the history entry at the current position, as determined by
|
||||
history_offset. If there is no entry there, return a NULL pointer. */
|
||||
HIST_ENTRY *
|
||||
current_history ()
|
||||
{
|
||||
return ((history_offset == history_length) || the_history == 0)
|
||||
? (HIST_ENTRY *)NULL
|
||||
: the_history[history_offset];
|
||||
}
|
||||
|
||||
/* Back up history_offset to the previous history entry, and return
|
||||
a pointer to that entry. If there is no previous entry then return
|
||||
a NULL pointer. */
|
||||
HIST_ENTRY *
|
||||
previous_history ()
|
||||
{
|
||||
return history_offset ? the_history[--history_offset] : (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Move history_offset forward to the next history entry, and return
|
||||
a pointer to that entry. If there is no next entry then return a
|
||||
NULL pointer. */
|
||||
HIST_ENTRY *
|
||||
next_history ()
|
||||
{
|
||||
return (history_offset == history_length) ? (HIST_ENTRY *)NULL : the_history[++history_offset];
|
||||
}
|
||||
|
||||
/* Return the history entry which is logically at OFFSET in the history array.
|
||||
OFFSET is relative to history_base. */
|
||||
HIST_ENTRY *
|
||||
history_get (offset)
|
||||
int offset;
|
||||
{
|
||||
int local_index;
|
||||
|
||||
local_index = offset - history_base;
|
||||
return (local_index >= history_length || local_index < 0 || !the_history)
|
||||
? (HIST_ENTRY *)NULL
|
||||
: the_history[local_index];
|
||||
}
|
||||
|
||||
/* Place STRING at the end of the history list. The data field
|
||||
is set to NULL. */
|
||||
void
|
||||
add_history (string)
|
||||
const char *string;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
|
||||
if (history_stifled && (history_length == history_max_entries))
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* If the history is stifled, and history_length is zero,
|
||||
and it equals history_max_entries, we don't save items. */
|
||||
if (history_length == 0)
|
||||
return;
|
||||
|
||||
/* If there is something in the slot, then remove it. */
|
||||
if (the_history[0])
|
||||
{
|
||||
free (the_history[0]->line);
|
||||
free (the_history[0]);
|
||||
}
|
||||
|
||||
/* Copy the rest of the entries, moving down one slot. */
|
||||
for (i = 0; i < history_length; i++)
|
||||
the_history[i] = the_history[i + 1];
|
||||
|
||||
history_base++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (history_size == 0)
|
||||
{
|
||||
history_size = DEFAULT_HISTORY_GROW_SIZE;
|
||||
the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *));
|
||||
history_length = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (history_length == (history_size - 1))
|
||||
{
|
||||
history_size += DEFAULT_HISTORY_GROW_SIZE;
|
||||
the_history = (HIST_ENTRY **)
|
||||
xrealloc (the_history, history_size * sizeof (HIST_ENTRY *));
|
||||
}
|
||||
history_length++;
|
||||
}
|
||||
}
|
||||
|
||||
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
|
||||
temp->line = savestring (string);
|
||||
temp->data = (char *)NULL;
|
||||
|
||||
the_history[history_length] = (HIST_ENTRY *)NULL;
|
||||
the_history[history_length - 1] = temp;
|
||||
}
|
||||
|
||||
/* Make the history entry at WHICH have LINE and DATA. This returns
|
||||
the old entry so you can dispose of the data. In the case of an
|
||||
invalid WHICH, a NULL pointer is returned. */
|
||||
HIST_ENTRY *
|
||||
replace_history_entry (which, line, data)
|
||||
int which;
|
||||
const char *line;
|
||||
histdata_t data;
|
||||
{
|
||||
HIST_ENTRY *temp, *old_value;
|
||||
|
||||
if (which >= history_length)
|
||||
return ((HIST_ENTRY *)NULL);
|
||||
|
||||
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
|
||||
old_value = the_history[which];
|
||||
|
||||
temp->line = savestring (line);
|
||||
temp->data = data;
|
||||
the_history[which] = temp;
|
||||
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
/* Remove history element WHICH from the history. The removed
|
||||
element is returned to you so you can free the line, data,
|
||||
and containing structure. */
|
||||
HIST_ENTRY *
|
||||
remove_history (which)
|
||||
int which;
|
||||
{
|
||||
HIST_ENTRY *return_value;
|
||||
register int i;
|
||||
|
||||
if (which >= history_length || !history_length)
|
||||
return_value = (HIST_ENTRY *)NULL;
|
||||
else
|
||||
{
|
||||
return_value = the_history[which];
|
||||
|
||||
for (i = which; i < history_length; i++)
|
||||
the_history[i] = the_history[i + 1];
|
||||
|
||||
history_length--;
|
||||
}
|
||||
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
/* Stifle the history list, remembering only MAX number of lines. */
|
||||
void
|
||||
stifle_history (max)
|
||||
int max;
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
|
||||
if (history_length > max)
|
||||
{
|
||||
/* This loses because we cannot free the data. */
|
||||
for (i = 0, j = history_length - max; i < j; i++)
|
||||
{
|
||||
free (the_history[i]->line);
|
||||
free (the_history[i]);
|
||||
}
|
||||
|
||||
history_base = i;
|
||||
for (j = 0, i = history_length - max; j < max; i++, j++)
|
||||
the_history[j] = the_history[i];
|
||||
the_history[j] = (HIST_ENTRY *)NULL;
|
||||
history_length = j;
|
||||
}
|
||||
|
||||
history_stifled = 1;
|
||||
max_input_history = history_max_entries = max;
|
||||
}
|
||||
|
||||
/* Stop stifling the history. This returns the previous maximum
|
||||
number of history entries. The value is positive if the history
|
||||
was stifled, negative if it wasn't. */
|
||||
int
|
||||
unstifle_history ()
|
||||
{
|
||||
if (history_stifled)
|
||||
{
|
||||
history_stifled = 0;
|
||||
return (history_max_entries);
|
||||
}
|
||||
else
|
||||
return (-history_max_entries);
|
||||
}
|
||||
|
||||
int
|
||||
history_is_stifled ()
|
||||
{
|
||||
return (history_stifled);
|
||||
}
|
||||
|
||||
void
|
||||
clear_history ()
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* This loses because we cannot free the data. */
|
||||
for (i = 0; i < history_length; i++)
|
||||
{
|
||||
free (the_history[i]->line);
|
||||
free (the_history[i]);
|
||||
the_history[i] = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
history_offset = history_length = 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,246 @@
|
|||
/* History.h -- the names of functions that you can call in history. */
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#ifndef _HISTORY_H_
|
||||
#define _HISTORY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined READLINE_LIBRARY
|
||||
# include "rlstdc.h"
|
||||
# include "rltypedefs.h"
|
||||
#else
|
||||
# include <readline/rlstdc.h>
|
||||
# include <readline/rltypedefs.h>
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef void *histdata_t;
|
||||
#else
|
||||
typedef char *histdata_t;
|
||||
#endif
|
||||
|
||||
/* The structure used to store a history entry. */
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
/* A structure used to pass the current state of the history stuff around. */
|
||||
typedef struct _hist_state {
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
int offset; /* The location pointer within this array. */
|
||||
int length; /* Number of elements within this array. */
|
||||
int size; /* Number of slots allocated to this array. */
|
||||
int flags;
|
||||
} HISTORY_STATE;
|
||||
|
||||
/* Flag values for the `flags' member of HISTORY_STATE. */
|
||||
#define HS_STIFLED 0x01
|
||||
|
||||
/* Initialization and state management. */
|
||||
|
||||
/* Begin a session in which the history functions might be used. This
|
||||
just initializes the interactive variables. */
|
||||
extern void using_history PARAMS((void));
|
||||
|
||||
/* Return the current HISTORY_STATE of the history. */
|
||||
extern HISTORY_STATE *history_get_history_state PARAMS((void));
|
||||
|
||||
/* Set the state of the current history array to STATE. */
|
||||
extern void history_set_history_state PARAMS((HISTORY_STATE *));
|
||||
|
||||
/* Manage the history list. */
|
||||
|
||||
/* Place STRING at the end of the history list.
|
||||
The associated data field (if any) is set to NULL. */
|
||||
extern void add_history PARAMS((const char *));
|
||||
|
||||
/* A reasonably useless function, only here for completeness. WHICH
|
||||
is the magic number that tells us which element to delete. The
|
||||
elements are numbered from 0. */
|
||||
extern HIST_ENTRY *remove_history PARAMS((int));
|
||||
|
||||
/* Make the history entry at WHICH have LINE and DATA. This returns
|
||||
the old entry so you can dispose of the data. In the case of an
|
||||
invalid WHICH, a NULL pointer is returned. */
|
||||
extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
|
||||
|
||||
/* Clear the history list and start over. */
|
||||
extern void clear_history PARAMS((void));
|
||||
|
||||
/* Stifle the history list, remembering only MAX number of entries. */
|
||||
extern void stifle_history PARAMS((int));
|
||||
|
||||
/* Stop stifling the history. This returns the previous amount the
|
||||
history was stifled by. The value is positive if the history was
|
||||
stifled, negative if it wasn't. */
|
||||
extern int unstifle_history PARAMS((void));
|
||||
|
||||
/* Return 1 if the history is stifled, 0 if it is not. */
|
||||
extern int history_is_stifled PARAMS((void));
|
||||
|
||||
/* Information about the history list. */
|
||||
|
||||
/* Return a NULL terminated array of HIST_ENTRY which is the current input
|
||||
history. Element 0 of this list is the beginning of time. If there
|
||||
is no history, return NULL. */
|
||||
extern HIST_ENTRY **history_list PARAMS((void));
|
||||
|
||||
/* Returns the number which says what history element we are now
|
||||
looking at. */
|
||||
extern int where_history PARAMS((void));
|
||||
|
||||
/* Return the history entry at the current position, as determined by
|
||||
history_offset. If there is no entry there, return a NULL pointer. */
|
||||
extern HIST_ENTRY *current_history PARAMS((void));
|
||||
|
||||
/* Return the history entry which is logically at OFFSET in the history
|
||||
array. OFFSET is relative to history_base. */
|
||||
extern HIST_ENTRY *history_get PARAMS((int));
|
||||
|
||||
/* Return the number of bytes that the primary history entries are using.
|
||||
This just adds up the lengths of the_history->lines. */
|
||||
extern int history_total_bytes PARAMS((void));
|
||||
|
||||
/* Moving around the history list. */
|
||||
|
||||
/* Set the position in the history list to POS. */
|
||||
extern int history_set_pos PARAMS((int));
|
||||
|
||||
/* Back up history_offset to the previous history entry, and return
|
||||
a pointer to that entry. If there is no previous entry, return
|
||||
a NULL pointer. */
|
||||
extern HIST_ENTRY *previous_history PARAMS((void));
|
||||
|
||||
/* Move history_offset forward to the next item in the input_history,
|
||||
and return the a pointer to that entry. If there is no next entry,
|
||||
return a NULL pointer. */
|
||||
extern HIST_ENTRY *next_history PARAMS((void));
|
||||
|
||||
/* Searching the history list. */
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
If DIRECTION < 0, then the search is through previous entries,
|
||||
else through subsequent. If the string is found, then
|
||||
current_history () is the history entry, and the value of this function
|
||||
is the offset in the line of that history entry that the string was
|
||||
found in. Otherwise, nothing is changed, and a -1 is returned. */
|
||||
extern int history_search PARAMS((const char *, int));
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
The search is anchored: matching lines must begin with string.
|
||||
DIRECTION is as in history_search(). */
|
||||
extern int history_search_prefix PARAMS((const char *, int));
|
||||
|
||||
/* Search for STRING in the history list, starting at POS, an
|
||||
absolute index into the list. DIR, if negative, says to search
|
||||
backwards from POS, else forwards.
|
||||
Returns the absolute index of the history element where STRING
|
||||
was found, or -1 otherwise. */
|
||||
extern int history_search_pos PARAMS((const char *, int, int));
|
||||
|
||||
/* Managing the history file. */
|
||||
|
||||
/* Add the contents of FILENAME to the history list, a line at a time.
|
||||
If FILENAME is NULL, then read from ~/.history. Returns 0 if
|
||||
successful, or errno if not. */
|
||||
extern int read_history PARAMS((const char *));
|
||||
|
||||
/* Read a range of lines from FILENAME, adding them to the history list.
|
||||
Start reading at the FROM'th line and end at the TO'th. If FROM
|
||||
is zero, start at the beginning. If TO is less than FROM, read
|
||||
until the end of the file. If FILENAME is NULL, then read from
|
||||
~/.history. Returns 0 if successful, or errno if not. */
|
||||
extern int read_history_range PARAMS((const char *, int, int));
|
||||
|
||||
/* Write the current history to FILENAME. If FILENAME is NULL,
|
||||
then write the history list to ~/.history. Values returned
|
||||
are as in read_history (). */
|
||||
extern int write_history PARAMS((const char *));
|
||||
|
||||
/* Append NELEMENT entries to FILENAME. The entries appended are from
|
||||
the end of the list minus NELEMENTs up to the end of the list. */
|
||||
extern int append_history PARAMS((int, const char *));
|
||||
|
||||
/* Truncate the history file, leaving only the last NLINES lines. */
|
||||
extern int history_truncate_file PARAMS((const char *, int));
|
||||
|
||||
/* History expansion. */
|
||||
|
||||
/* Expand the string STRING, placing the result into OUTPUT, a pointer
|
||||
to a string. Returns:
|
||||
|
||||
0) If no expansions took place (or, if the only change in
|
||||
the text was the de-slashifying of the history expansion
|
||||
character)
|
||||
1) If expansions did take place
|
||||
-1) If there was an error in expansion.
|
||||
2) If the returned line should just be printed.
|
||||
|
||||
If an error ocurred in expansion, then OUTPUT contains a descriptive
|
||||
error message. */
|
||||
extern int history_expand PARAMS((char *, char **));
|
||||
|
||||
/* Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are broken up as in
|
||||
the shell. */
|
||||
extern char *history_arg_extract PARAMS((int, int, const char *));
|
||||
|
||||
/* Return the text of the history event beginning at the current
|
||||
offset into STRING. Pass STRING with *INDEX equal to the
|
||||
history_expansion_char that begins this specification.
|
||||
DELIMITING_QUOTE is a character that is allowed to end the string
|
||||
specification for what to search for in addition to the normal
|
||||
characters `:', ` ', `\t', `\n', and sometimes `?'. */
|
||||
extern char *get_history_event PARAMS((const char *, int *, int));
|
||||
|
||||
/* Return an array of tokens, much as the shell might. The tokens are
|
||||
parsed out of STRING. */
|
||||
extern char **history_tokenize PARAMS((const char *));
|
||||
|
||||
/* Exported history variables. */
|
||||
extern int history_base;
|
||||
extern int history_length;
|
||||
extern int history_max_entries;
|
||||
extern char history_expansion_char;
|
||||
extern char history_subst_char;
|
||||
extern char *history_word_delimiters;
|
||||
extern char history_comment_char;
|
||||
extern char *history_no_expand_chars;
|
||||
extern char *history_search_delimiter_chars;
|
||||
extern int history_quotes_inhibit_expansion;
|
||||
|
||||
/* Backwards compatibility */
|
||||
extern int max_input_history;
|
||||
|
||||
/* If set, this function is called to decide whether or not a particular
|
||||
history expansion should be treated as a special case for the calling
|
||||
application and not expanded. */
|
||||
extern rl_linebuf_func_t *history_inhibit_expansion_function;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_HISTORY_H_ */
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
/* histsearch.c -- searching the history list. */
|
||||
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
/* The list of alternate characters that can delimit a history search
|
||||
string. */
|
||||
char *history_search_delimiter_chars = (char *)NULL;
|
||||
|
||||
static int history_search_internal PARAMS((const char *, int, int));
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
If DIRECTION < 0, then the search is through previous entries, else
|
||||
through subsequent. If ANCHORED is non-zero, the string must
|
||||
appear at the beginning of a history line, otherwise, the string
|
||||
may appear anywhere in the line. If the string is found, then
|
||||
current_history () is the history entry, and the value of this
|
||||
function is the offset in the line of that history entry that the
|
||||
string was found in. Otherwise, nothing is changed, and a -1 is
|
||||
returned. */
|
||||
|
||||
static int
|
||||
history_search_internal (string, direction, anchored)
|
||||
const char *string;
|
||||
int direction, anchored;
|
||||
{
|
||||
register int i, reverse;
|
||||
register char *line;
|
||||
register int line_index;
|
||||
int string_len;
|
||||
HIST_ENTRY **the_history; /* local */
|
||||
|
||||
i = history_offset;
|
||||
reverse = (direction < 0);
|
||||
|
||||
/* Take care of trivial cases first. */
|
||||
if (string == 0 || *string == '\0')
|
||||
return (-1);
|
||||
|
||||
if (!history_length || ((i == history_length) && !reverse))
|
||||
return (-1);
|
||||
|
||||
if (reverse && (i == history_length))
|
||||
i--;
|
||||
|
||||
#define NEXT_LINE() do { if (reverse) i--; else i++; } while (0)
|
||||
|
||||
the_history = history_list ();
|
||||
string_len = strlen (string);
|
||||
while (1)
|
||||
{
|
||||
/* Search each line in the history list for STRING. */
|
||||
|
||||
/* At limit for direction? */
|
||||
if ((reverse && i < 0) || (!reverse && i == history_length))
|
||||
return (-1);
|
||||
|
||||
line = the_history[i]->line;
|
||||
line_index = strlen (line);
|
||||
|
||||
/* If STRING is longer than line, no match. */
|
||||
if (string_len > line_index)
|
||||
{
|
||||
NEXT_LINE ();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Handle anchored searches first. */
|
||||
if (anchored == ANCHORED_SEARCH)
|
||||
{
|
||||
if (STREQN (string, line, string_len))
|
||||
{
|
||||
history_offset = i;
|
||||
return (0);
|
||||
}
|
||||
|
||||
NEXT_LINE ();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Do substring search. */
|
||||
if (reverse)
|
||||
{
|
||||
line_index -= string_len;
|
||||
|
||||
while (line_index >= 0)
|
||||
{
|
||||
if (STREQN (string, line + line_index, string_len))
|
||||
{
|
||||
history_offset = i;
|
||||
return (line_index);
|
||||
}
|
||||
line_index--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
register int limit;
|
||||
|
||||
limit = line_index - string_len + 1;
|
||||
line_index = 0;
|
||||
|
||||
while (line_index < limit)
|
||||
{
|
||||
if (STREQN (string, line + line_index, string_len))
|
||||
{
|
||||
history_offset = i;
|
||||
return (line_index);
|
||||
}
|
||||
line_index++;
|
||||
}
|
||||
}
|
||||
NEXT_LINE ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Do a non-anchored search for STRING through the history in DIRECTION. */
|
||||
int
|
||||
history_search (string, direction)
|
||||
const char *string;
|
||||
int direction;
|
||||
{
|
||||
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
|
||||
}
|
||||
|
||||
/* Do an anchored search for string through the history in DIRECTION. */
|
||||
int
|
||||
history_search_prefix (string, direction)
|
||||
const char *string;
|
||||
int direction;
|
||||
{
|
||||
return (history_search_internal (string, direction, ANCHORED_SEARCH));
|
||||
}
|
||||
|
||||
/* Search for STRING in the history list. DIR is < 0 for searching
|
||||
backwards. POS is an absolute index into the history list at
|
||||
which point to begin searching. */
|
||||
int
|
||||
history_search_pos (string, dir, pos)
|
||||
const char *string;
|
||||
int dir, pos;
|
||||
{
|
||||
int ret, old;
|
||||
|
||||
old = where_history ();
|
||||
history_set_pos (pos);
|
||||
if (history_search (string, dir) == -1)
|
||||
{
|
||||
history_set_pos (old);
|
||||
return (-1);
|
||||
}
|
||||
ret = where_history ();
|
||||
history_set_pos (old);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,540 @@
|
|||
/* input.c -- character input functions for readline. */
|
||||
|
||||
/* Copyright (C) 1994 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif /* HAVE_SYS_FILE_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
#endif /* HAVE_SELECT */
|
||||
#if defined (HAVE_SYS_SELECT_H)
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if defined (FIONREAD_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* What kind of non-blocking I/O do we have? */
|
||||
#if !defined (O_NDELAY) && defined (O_NONBLOCK)
|
||||
# define O_NDELAY O_NONBLOCK /* Posix style */
|
||||
#endif
|
||||
|
||||
/* Non-null means it is a pointer to a function to run while waiting for
|
||||
character input. */
|
||||
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
|
||||
|
||||
rl_getc_func_t *rl_getc_function = rl_getc;
|
||||
|
||||
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
|
||||
|
||||
static int ibuffer_space PARAMS((void));
|
||||
static int rl_get_char PARAMS((int *));
|
||||
static int rl_gather_tyi PARAMS((void));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Character Input Buffering */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static int pop_index, push_index;
|
||||
static unsigned char ibuffer[512];
|
||||
static int ibuffer_len = sizeof (ibuffer) - 1;
|
||||
|
||||
#define any_typein (push_index != pop_index)
|
||||
|
||||
int
|
||||
_rl_any_typein ()
|
||||
{
|
||||
return any_typein;
|
||||
}
|
||||
|
||||
/* Return the amount of space available in the buffer for stuffing
|
||||
characters. */
|
||||
static int
|
||||
ibuffer_space ()
|
||||
{
|
||||
if (pop_index > push_index)
|
||||
return (pop_index - push_index - 1);
|
||||
else
|
||||
return (ibuffer_len - (push_index - pop_index));
|
||||
}
|
||||
|
||||
/* Get a key from the buffer of characters to be read.
|
||||
Return the key in KEY.
|
||||
Result is KEY if there was a key, or 0 if there wasn't. */
|
||||
static int
|
||||
rl_get_char (key)
|
||||
int *key;
|
||||
{
|
||||
if (push_index == pop_index)
|
||||
return (0);
|
||||
|
||||
*key = ibuffer[pop_index++];
|
||||
|
||||
if (pop_index >= ibuffer_len)
|
||||
pop_index = 0;
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Stuff KEY into the *front* of the input buffer.
|
||||
Returns non-zero if successful, zero if there is
|
||||
no space left in the buffer. */
|
||||
int
|
||||
_rl_unget_char (key)
|
||||
int key;
|
||||
{
|
||||
if (ibuffer_space ())
|
||||
{
|
||||
pop_index--;
|
||||
if (pop_index < 0)
|
||||
pop_index = ibuffer_len - 1;
|
||||
ibuffer[pop_index] = key;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* If a character is available to be read, then read it and stuff it into
|
||||
IBUFFER. Otherwise, just return. Returns number of characters read
|
||||
(0 if none available) and -1 on error (EIO). */
|
||||
static int
|
||||
rl_gather_tyi ()
|
||||
{
|
||||
int tty;
|
||||
register int tem, result;
|
||||
int chars_avail;
|
||||
char input;
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (tty, &readfds);
|
||||
FD_SET (tty, &exceptfds);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = _keyboard_input_timeout;
|
||||
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
|
||||
if (result <= 0)
|
||||
return 0; /* Nothing to read. */
|
||||
#endif
|
||||
|
||||
result = -1;
|
||||
#if defined (FIONREAD)
|
||||
errno = 0;
|
||||
result = ioctl (tty, FIONREAD, &chars_avail);
|
||||
if (result == -1 && errno == EIO)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
#if defined (O_NDELAY)
|
||||
if (result == -1)
|
||||
{
|
||||
tem = fcntl (tty, F_GETFL, 0);
|
||||
|
||||
fcntl (tty, F_SETFL, (tem | O_NDELAY));
|
||||
chars_avail = read (tty, &input, 1);
|
||||
|
||||
fcntl (tty, F_SETFL, tem);
|
||||
if (chars_avail == -1 && errno == EAGAIN)
|
||||
return 0;
|
||||
}
|
||||
#endif /* O_NDELAY */
|
||||
|
||||
/* If there's nothing available, don't waste time trying to read
|
||||
something. */
|
||||
if (chars_avail <= 0)
|
||||
return 0;
|
||||
|
||||
tem = ibuffer_space ();
|
||||
|
||||
if (chars_avail > tem)
|
||||
chars_avail = tem;
|
||||
|
||||
/* One cannot read all of the available input. I can only read a single
|
||||
character at a time, or else programs which require input can be
|
||||
thwarted. If the buffer is larger than one character, I lose.
|
||||
Damn! */
|
||||
if (tem < ibuffer_len)
|
||||
chars_avail = 0;
|
||||
|
||||
if (result != -1)
|
||||
{
|
||||
while (chars_avail--)
|
||||
rl_stuff_char ((*rl_getc_function) (rl_instream));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chars_avail)
|
||||
rl_stuff_char (input);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
rl_set_keyboard_input_timeout (u)
|
||||
int u;
|
||||
{
|
||||
int o;
|
||||
|
||||
o = _keyboard_input_timeout;
|
||||
if (u > 0)
|
||||
_keyboard_input_timeout = u;
|
||||
return (o);
|
||||
}
|
||||
|
||||
/* Is there input available to be read on the readline input file
|
||||
descriptor? Only works if the system has select(2) or FIONREAD.
|
||||
Uses the value of _keyboard_input_timeout as the timeout; if another
|
||||
readline function wants to specify a timeout and not leave it up to
|
||||
the user, it should use _rl_input_queued(timeout_value_in_microseconds)
|
||||
instead. */
|
||||
int
|
||||
_rl_input_available ()
|
||||
{
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
#if !defined (HAVE_SELECT) && defined(FIONREAD)
|
||||
int chars_avail;
|
||||
#endif
|
||||
int tty;
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (tty, &readfds);
|
||||
FD_SET (tty, &exceptfds);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = _keyboard_input_timeout;
|
||||
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
|
||||
#else
|
||||
|
||||
#if defined (FIONREAD)
|
||||
if (ioctl (tty, FIONREAD, &chars_avail) == 0)
|
||||
return (chars_avail);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_input_queued (t)
|
||||
int t;
|
||||
{
|
||||
int old_timeout, r;
|
||||
|
||||
old_timeout = rl_set_keyboard_input_timeout (t);
|
||||
r = _rl_input_available ();
|
||||
rl_set_keyboard_input_timeout (old_timeout);
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_insert_typein (c)
|
||||
int c;
|
||||
{
|
||||
int key, t, i;
|
||||
char *string;
|
||||
|
||||
i = key = 0;
|
||||
string = (char *)xmalloc (ibuffer_len + 1);
|
||||
string[i++] = (char) c;
|
||||
|
||||
while ((t = rl_get_char (&key)) &&
|
||||
_rl_keymap[key].type == ISFUNC &&
|
||||
_rl_keymap[key].function == rl_insert)
|
||||
string[i++] = key;
|
||||
|
||||
if (t)
|
||||
_rl_unget_char (key);
|
||||
|
||||
string[i] = '\0';
|
||||
rl_insert_text (string);
|
||||
free (string);
|
||||
}
|
||||
|
||||
/* Add KEY to the buffer of characters to be read. Returns 1 if the
|
||||
character was stuffed correctly; 0 otherwise. */
|
||||
int
|
||||
rl_stuff_char (key)
|
||||
int key;
|
||||
{
|
||||
if (ibuffer_space () == 0)
|
||||
return 0;
|
||||
|
||||
if (key == EOF)
|
||||
{
|
||||
key = NEWLINE;
|
||||
rl_pending_input = EOF;
|
||||
RL_SETSTATE (RL_STATE_INPUTPENDING);
|
||||
}
|
||||
ibuffer[push_index++] = key;
|
||||
if (push_index >= ibuffer_len)
|
||||
push_index = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Make C be the next command to be executed. */
|
||||
int
|
||||
rl_execute_next (c)
|
||||
int c;
|
||||
{
|
||||
rl_pending_input = c;
|
||||
RL_SETSTATE (RL_STATE_INPUTPENDING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Clear any pending input pushed with rl_execute_next() */
|
||||
int
|
||||
rl_clear_pending_input ()
|
||||
{
|
||||
rl_pending_input = 0;
|
||||
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Character Input */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Read a key, including pending input. */
|
||||
int
|
||||
rl_read_key ()
|
||||
{
|
||||
int c;
|
||||
|
||||
rl_key_sequence_length++;
|
||||
|
||||
if (rl_pending_input)
|
||||
{
|
||||
c = rl_pending_input;
|
||||
rl_clear_pending_input ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If input is coming from a macro, then use that. */
|
||||
if (c = _rl_next_macro_key ())
|
||||
return (c);
|
||||
|
||||
/* If the user has an event function, then call it periodically. */
|
||||
if (rl_event_hook)
|
||||
{
|
||||
while (rl_event_hook && rl_get_char (&c) == 0)
|
||||
{
|
||||
(*rl_event_hook) ();
|
||||
if (rl_done) /* XXX - experimental */
|
||||
return ('\n');
|
||||
if (rl_gather_tyi () < 0) /* XXX - EIO */
|
||||
{
|
||||
rl_done = 1;
|
||||
return ('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rl_get_char (&c) == 0)
|
||||
c = (*rl_getc_function) (rl_instream);
|
||||
}
|
||||
}
|
||||
|
||||
return (c);
|
||||
}
|
||||
|
||||
int
|
||||
rl_getc (stream)
|
||||
FILE *stream;
|
||||
{
|
||||
int result;
|
||||
unsigned char c;
|
||||
|
||||
while (1)
|
||||
{
|
||||
result = read (fileno (stream), &c, sizeof (unsigned char));
|
||||
|
||||
if (result == sizeof (unsigned char))
|
||||
return (c);
|
||||
|
||||
/* If zero characters are returned, then the file that we are
|
||||
reading from is empty! Return EOF in that case. */
|
||||
if (result == 0)
|
||||
return (EOF);
|
||||
|
||||
#if defined (__BEOS__)
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
#if defined (EWOULDBLOCK)
|
||||
# define X_EWOULDBLOCK EWOULDBLOCK
|
||||
#else
|
||||
# define X_EWOULDBLOCK -99
|
||||
#endif
|
||||
|
||||
#if defined (EAGAIN)
|
||||
# define X_EAGAIN EAGAIN
|
||||
#else
|
||||
# define X_EAGAIN -99
|
||||
#endif
|
||||
|
||||
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
|
||||
{
|
||||
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
|
||||
return (EOF);
|
||||
continue;
|
||||
}
|
||||
|
||||
#undef X_EWOULDBLOCK
|
||||
#undef X_EAGAIN
|
||||
|
||||
/* If the error that we received was SIGINT, then try again,
|
||||
this is simply an interrupted system call to read ().
|
||||
Otherwise, some error ocurred, also signifying EOF. */
|
||||
if (errno != EINTR)
|
||||
return (EOF);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* read multibyte char */
|
||||
int
|
||||
_rl_read_mbchar (mbchar, size)
|
||||
char *mbchar;
|
||||
int size;
|
||||
{
|
||||
int mb_len = 0;
|
||||
size_t mbchar_bytes_length;
|
||||
wchar_t wc;
|
||||
mbstate_t ps, ps_back;
|
||||
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
memset(&ps_back, 0, sizeof (mbstate_t));
|
||||
|
||||
while (mb_len < size)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
mbchar[mb_len++] = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
|
||||
if (mbchar_bytes_length == (size_t)(-1))
|
||||
break; /* invalid byte sequence for the current locale */
|
||||
else if (mbchar_bytes_length == (size_t)(-2))
|
||||
{
|
||||
/* shorted bytes */
|
||||
ps = ps_back;
|
||||
continue;
|
||||
}
|
||||
else if (mbchar_bytes_length > (size_t)(0))
|
||||
break;
|
||||
}
|
||||
|
||||
return mb_len;
|
||||
}
|
||||
|
||||
/* Read a multibyte-character string whose first character is FIRST into
|
||||
the buffer MB of length MBLEN. Returns the last character read, which
|
||||
may be FIRST. Used by the search functions, among others. Very similar
|
||||
to _rl_read_mbchar. */
|
||||
int
|
||||
_rl_read_mbstring (first, mb, mblen)
|
||||
int first;
|
||||
char *mb;
|
||||
int mblen;
|
||||
{
|
||||
int i, c;
|
||||
mbstate_t ps;
|
||||
|
||||
c = first;
|
||||
memset (mb, 0, mblen);
|
||||
for (i = 0; i < mblen; i++)
|
||||
{
|
||||
mb[i] = (char)c;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
if (_rl_get_char_len (mb, &ps) == -2)
|
||||
{
|
||||
/* Read more for multibyte character */
|
||||
RL_SETSTATE (RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE (RL_STATE_MOREINPUT);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
#endif /* HANDLE_MULTIBYTE */
|
||||
|
|
@ -0,0 +1,560 @@
|
|||
/* **************************************************************** */
|
||||
/* */
|
||||
/* I-Search and Searching */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Variables exported to other files in the readline library. */
|
||||
char *_rl_isearch_terminators = (char *)NULL;
|
||||
|
||||
/* Variables imported from other files in the readline library. */
|
||||
extern HIST_ENTRY *_rl_saved_line_for_history;
|
||||
|
||||
/* Forward declarations */
|
||||
static int rl_search_history PARAMS((int, int));
|
||||
|
||||
/* Last line found by the current incremental search, so we don't `find'
|
||||
identical lines many times in a row. */
|
||||
static char *prev_line_found;
|
||||
|
||||
/* Last search string and its length. */
|
||||
static char *last_isearch_string;
|
||||
static int last_isearch_string_len;
|
||||
|
||||
static char *default_isearch_terminators = "\033\012";
|
||||
|
||||
/* Search backwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
int
|
||||
rl_reverse_search_history (sign, key)
|
||||
int sign, key;
|
||||
{
|
||||
return (rl_search_history (-sign, key));
|
||||
}
|
||||
|
||||
/* Search forwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
int
|
||||
rl_forward_search_history (sign, key)
|
||||
int sign, key;
|
||||
{
|
||||
return (rl_search_history (sign, key));
|
||||
}
|
||||
|
||||
/* Display the current state of the search in the echo-area.
|
||||
SEARCH_STRING contains the string that is being searched for,
|
||||
DIRECTION is zero for forward, or 1 for reverse,
|
||||
WHERE is the history list number of the current line. If it is
|
||||
-1, then this line is the starting one. */
|
||||
static void
|
||||
rl_display_search (search_string, reverse_p, where)
|
||||
char *search_string;
|
||||
int reverse_p, where;
|
||||
{
|
||||
char *message;
|
||||
int msglen, searchlen;
|
||||
|
||||
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
|
||||
|
||||
message = (char *)xmalloc (searchlen + 33);
|
||||
msglen = 0;
|
||||
|
||||
#if defined (NOTDEF)
|
||||
if (where != -1)
|
||||
{
|
||||
sprintf (message, "[%d]", where + history_base);
|
||||
msglen = strlen (message);
|
||||
}
|
||||
#endif /* NOTDEF */
|
||||
|
||||
message[msglen++] = '(';
|
||||
|
||||
if (reverse_p)
|
||||
{
|
||||
strcpy (message + msglen, "reverse-");
|
||||
msglen += 8;
|
||||
}
|
||||
|
||||
strcpy (message + msglen, "i-search)`");
|
||||
msglen += 10;
|
||||
|
||||
if (search_string)
|
||||
{
|
||||
strcpy (message + msglen, search_string);
|
||||
msglen += searchlen;
|
||||
}
|
||||
|
||||
strcpy (message + msglen, "': ");
|
||||
|
||||
rl_message ("%s", message);
|
||||
free (message);
|
||||
(*rl_redisplay_function) ();
|
||||
}
|
||||
|
||||
/* Search through the history looking for an interactively typed string.
|
||||
This is analogous to i-search. We start the search in the current line.
|
||||
DIRECTION is which direction to search; >= 0 means forward, < 0 means
|
||||
backwards. */
|
||||
static int
|
||||
rl_search_history (direction, invoking_key)
|
||||
int direction, invoking_key;
|
||||
{
|
||||
/* The string that the user types in to search for. */
|
||||
char *search_string;
|
||||
|
||||
/* The current length of SEARCH_STRING. */
|
||||
int search_string_index;
|
||||
|
||||
/* The amount of space that SEARCH_STRING has allocated to it. */
|
||||
int search_string_size;
|
||||
|
||||
/* The list of lines to search through. */
|
||||
char **lines, *allocated_line;
|
||||
|
||||
/* The length of LINES. */
|
||||
int hlen;
|
||||
|
||||
/* Where we get LINES from. */
|
||||
HIST_ENTRY **hlist;
|
||||
|
||||
register int i;
|
||||
int orig_point, orig_mark, orig_line, last_found_line;
|
||||
int c, found, failed, sline_len;
|
||||
int n, wstart, wlen;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
char mb[MB_LEN_MAX];
|
||||
#endif
|
||||
|
||||
/* The line currently being searched. */
|
||||
char *sline;
|
||||
|
||||
/* Offset in that line. */
|
||||
int line_index;
|
||||
|
||||
/* Non-zero if we are doing a reverse search. */
|
||||
int reverse;
|
||||
|
||||
/* The list of characters which terminate the search, but are not
|
||||
subsequently executed. If the variable isearch-terminators has
|
||||
been set, we use that value, otherwise we use ESC and C-J. */
|
||||
char *isearch_terminators;
|
||||
|
||||
RL_SETSTATE(RL_STATE_ISEARCH);
|
||||
orig_point = rl_point;
|
||||
orig_mark = rl_mark;
|
||||
last_found_line = orig_line = where_history ();
|
||||
reverse = direction < 0;
|
||||
hlist = history_list ();
|
||||
allocated_line = (char *)NULL;
|
||||
|
||||
isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
|
||||
: default_isearch_terminators;
|
||||
|
||||
/* Create an arrary of pointers to the lines that we want to search. */
|
||||
rl_maybe_replace_line ();
|
||||
i = 0;
|
||||
if (hlist)
|
||||
for (i = 0; hlist[i]; i++);
|
||||
|
||||
/* Allocate space for this many lines, +1 for the current input line,
|
||||
and remember those lines. */
|
||||
lines = (char **)xmalloc ((1 + (hlen = i)) * sizeof (char *));
|
||||
for (i = 0; i < hlen; i++)
|
||||
lines[i] = hlist[i]->line;
|
||||
|
||||
if (_rl_saved_line_for_history)
|
||||
lines[i] = _rl_saved_line_for_history->line;
|
||||
else
|
||||
{
|
||||
/* Keep track of this so we can free it. */
|
||||
allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));
|
||||
strcpy (allocated_line, &rl_line_buffer[0]);
|
||||
lines[i] = allocated_line;
|
||||
}
|
||||
|
||||
hlen++;
|
||||
|
||||
/* The line where we start the search. */
|
||||
i = orig_line;
|
||||
|
||||
rl_save_prompt ();
|
||||
|
||||
/* Initialize search parameters. */
|
||||
search_string = (char *)xmalloc (search_string_size = 128);
|
||||
*search_string = '\0';
|
||||
search_string_index = 0;
|
||||
prev_line_found = (char *)0; /* XXX */
|
||||
|
||||
/* Normalize DIRECTION into 1 or -1. */
|
||||
direction = (direction >= 0) ? 1 : -1;
|
||||
|
||||
rl_display_search (search_string, reverse, -1);
|
||||
|
||||
sline = rl_line_buffer;
|
||||
sline_len = strlen (sline);
|
||||
line_index = rl_point;
|
||||
|
||||
found = failed = 0;
|
||||
for (;;)
|
||||
{
|
||||
rl_command_func_t *f = (rl_command_func_t *)NULL;
|
||||
|
||||
/* Read a key and decide how to proceed. */
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
|
||||
#endif
|
||||
|
||||
/* Translate the keys we do something with to opcodes. */
|
||||
if (c >= 0 && _rl_keymap[c].type == ISFUNC)
|
||||
{
|
||||
f = _rl_keymap[c].function;
|
||||
|
||||
if (f == rl_reverse_search_history)
|
||||
c = reverse ? -1 : -2;
|
||||
else if (f == rl_forward_search_history)
|
||||
c = !reverse ? -1 : -2;
|
||||
else if (f == rl_rubout)
|
||||
c = -3;
|
||||
else if (c == CTRL ('G'))
|
||||
c = -4;
|
||||
else if (c == CTRL ('W')) /* XXX */
|
||||
c = -5;
|
||||
else if (c == CTRL ('Y')) /* XXX */
|
||||
c = -6;
|
||||
}
|
||||
|
||||
/* The characters in isearch_terminators (set from the user-settable
|
||||
variable isearch-terminators) are used to terminate the search but
|
||||
not subsequently execute the character as a command. The default
|
||||
value is "\033\012" (ESC and C-J). */
|
||||
if (strchr (isearch_terminators, c))
|
||||
{
|
||||
/* ESC still terminates the search, but if there is pending
|
||||
input or if input arrives within 0.1 seconds (on systems
|
||||
with select(2)) it is used as a prefix character
|
||||
with rl_execute_next. WATCH OUT FOR THIS! This is intended
|
||||
to allow the arrow keys to be used like ^F and ^B are used
|
||||
to terminate the search and execute the movement command.
|
||||
XXX - since _rl_input_available depends on the application-
|
||||
settable keyboard timeout value, this could alternatively
|
||||
use _rl_input_queued(100000) */
|
||||
if (c == ESC && _rl_input_available ())
|
||||
rl_execute_next (ESC);
|
||||
break;
|
||||
}
|
||||
|
||||
#define ENDSRCH_CHAR(c) \
|
||||
((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G')))
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
if (c >= 0 && strlen (mb) == 1 && ENDSRCH_CHAR (c))
|
||||
{
|
||||
/* This sets rl_pending_input to c; it will be picked up the next
|
||||
time rl_read_key is called. */
|
||||
rl_execute_next (c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (c >= 0 && ENDSRCH_CHAR (c))
|
||||
{
|
||||
/* This sets rl_pending_input to c; it will be picked up the next
|
||||
time rl_read_key is called. */
|
||||
rl_execute_next (c);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case -1:
|
||||
if (search_string_index == 0)
|
||||
{
|
||||
if (last_isearch_string)
|
||||
{
|
||||
search_string_size = 64 + last_isearch_string_len;
|
||||
search_string = (char *)xrealloc (search_string, search_string_size);
|
||||
strcpy (search_string, last_isearch_string);
|
||||
search_string_index = last_isearch_string_len;
|
||||
rl_display_search (search_string, reverse, -1);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (reverse)
|
||||
--line_index;
|
||||
else if (line_index != sline_len)
|
||||
++line_index;
|
||||
else
|
||||
rl_ding ();
|
||||
break;
|
||||
|
||||
/* switch directions */
|
||||
case -2:
|
||||
direction = -direction;
|
||||
reverse = direction < 0;
|
||||
break;
|
||||
|
||||
/* delete character from search string. */
|
||||
case -3: /* C-H, DEL */
|
||||
/* This is tricky. To do this right, we need to keep a
|
||||
stack of search positions for the current search, with
|
||||
sentinels marking the beginning and end. But this will
|
||||
do until we have a real isearch-undo. */
|
||||
if (search_string_index == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
search_string[--search_string_index] = '\0';
|
||||
|
||||
break;
|
||||
|
||||
case -4: /* C-G */
|
||||
rl_replace_line (lines[orig_line], 0);
|
||||
rl_point = orig_point;
|
||||
rl_mark = orig_mark;
|
||||
rl_restore_prompt();
|
||||
rl_clear_message ();
|
||||
if (allocated_line)
|
||||
free (allocated_line);
|
||||
free (lines);
|
||||
RL_UNSETSTATE(RL_STATE_ISEARCH);
|
||||
return 0;
|
||||
|
||||
case -5: /* C-W */
|
||||
/* skip over portion of line we already matched */
|
||||
wstart = rl_point + search_string_index;
|
||||
if (wstart >= rl_end)
|
||||
{
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
|
||||
/* if not in a word, move to one. */
|
||||
if (rl_alphabetic(rl_line_buffer[wstart]) == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
n = wstart;
|
||||
while (n < rl_end && rl_alphabetic(rl_line_buffer[n]))
|
||||
n++;
|
||||
wlen = n - wstart + 1;
|
||||
if (search_string_index + wlen + 1 >= search_string_size)
|
||||
{
|
||||
search_string_size += wlen + 1;
|
||||
search_string = (char *)xrealloc (search_string, search_string_size);
|
||||
}
|
||||
for (; wstart < n; wstart++)
|
||||
search_string[search_string_index++] = rl_line_buffer[wstart];
|
||||
search_string[search_string_index] = '\0';
|
||||
break;
|
||||
|
||||
case -6: /* C-Y */
|
||||
/* skip over portion of line we already matched */
|
||||
wstart = rl_point + search_string_index;
|
||||
if (wstart >= rl_end)
|
||||
{
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
n = rl_end - wstart + 1;
|
||||
if (search_string_index + n + 1 >= search_string_size)
|
||||
{
|
||||
search_string_size += n + 1;
|
||||
search_string = (char *)xrealloc (search_string, search_string_size);
|
||||
}
|
||||
for (n = wstart; n < rl_end; n++)
|
||||
search_string[search_string_index++] = rl_line_buffer[n];
|
||||
search_string[search_string_index] = '\0';
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Add character to search string and continue search. */
|
||||
if (search_string_index + 2 >= search_string_size)
|
||||
{
|
||||
search_string_size += 128;
|
||||
search_string = (char *)xrealloc (search_string, search_string_size);
|
||||
}
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
int j, l;
|
||||
for (j = 0, l = strlen (mb); j < l; )
|
||||
search_string[search_string_index++] = mb[j++];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
search_string[search_string_index++] = c;
|
||||
search_string[search_string_index] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
for (found = failed = 0;;)
|
||||
{
|
||||
int limit = sline_len - search_string_index + 1;
|
||||
|
||||
/* Search the current line. */
|
||||
while (reverse ? (line_index >= 0) : (line_index < limit))
|
||||
{
|
||||
if (STREQN (search_string, sline + line_index, search_string_index))
|
||||
{
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
line_index += direction;
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
|
||||
/* Move to the next line, but skip new copies of the line
|
||||
we just found and lines shorter than the string we're
|
||||
searching for. */
|
||||
do
|
||||
{
|
||||
/* Move to the next line. */
|
||||
i += direction;
|
||||
|
||||
/* At limit for direction? */
|
||||
if (reverse ? (i < 0) : (i == hlen))
|
||||
{
|
||||
failed++;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We will need these later. */
|
||||
sline = lines[i];
|
||||
sline_len = strlen (sline);
|
||||
}
|
||||
while ((prev_line_found && STREQ (prev_line_found, lines[i])) ||
|
||||
(search_string_index > sline_len));
|
||||
|
||||
if (failed)
|
||||
break;
|
||||
|
||||
/* Now set up the line for searching... */
|
||||
line_index = reverse ? sline_len - search_string_index : 0;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
/* We cannot find the search string. Ding the bell. */
|
||||
rl_ding ();
|
||||
i = last_found_line;
|
||||
continue; /* XXX - was break */
|
||||
}
|
||||
|
||||
/* We have found the search string. Just display it. But don't
|
||||
actually move there in the history list until the user accepts
|
||||
the location. */
|
||||
if (found)
|
||||
{
|
||||
prev_line_found = lines[i];
|
||||
rl_replace_line (lines[i], 0);
|
||||
rl_point = line_index;
|
||||
last_found_line = i;
|
||||
rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i);
|
||||
}
|
||||
}
|
||||
|
||||
/* The searching is over. The user may have found the string that she
|
||||
was looking for, or else she may have exited a failing search. If
|
||||
LINE_INDEX is -1, then that shows that the string searched for was
|
||||
not found. We use this to determine where to place rl_point. */
|
||||
|
||||
/* First put back the original state. */
|
||||
strcpy (rl_line_buffer, lines[orig_line]);
|
||||
|
||||
rl_restore_prompt ();
|
||||
|
||||
/* Save the search string for possible later use. */
|
||||
FREE (last_isearch_string);
|
||||
last_isearch_string = search_string;
|
||||
last_isearch_string_len = search_string_index;
|
||||
|
||||
if (last_found_line < orig_line)
|
||||
rl_get_previous_history (orig_line - last_found_line, 0);
|
||||
else
|
||||
rl_get_next_history (last_found_line - orig_line, 0);
|
||||
|
||||
/* If the string was not found, put point at the end of the last matching
|
||||
line. If last_found_line == orig_line, we didn't find any matching
|
||||
history lines at all, so put point back in its original position. */
|
||||
if (line_index < 0)
|
||||
{
|
||||
if (last_found_line == orig_line)
|
||||
line_index = orig_point;
|
||||
else
|
||||
line_index = strlen (rl_line_buffer);
|
||||
rl_mark = orig_mark;
|
||||
}
|
||||
|
||||
rl_point = line_index;
|
||||
/* Don't worry about where to put the mark here; rl_get_previous_history
|
||||
and rl_get_next_history take care of it. */
|
||||
|
||||
rl_clear_message ();
|
||||
|
||||
FREE (allocated_line);
|
||||
free (lines);
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_ISEARCH);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
|
||||
|
||||
/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU 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 2, 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; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <stdio.h> /* for FILE * definition for readline.h */
|
||||
|
||||
#include "readline.h"
|
||||
#include "rlconf.h"
|
||||
|
||||
#include "emacs_keymap.c"
|
||||
|
||||
#if defined (VI_MODE)
|
||||
#include "vi_keymap.c"
|
||||
#endif
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions for manipulating Keymaps. */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
|
||||
/* Return a new, empty keymap.
|
||||
Free it with free() when you are done. */
|
||||
Keymap
|
||||
rl_make_bare_keymap ()
|
||||
{
|
||||
register int i;
|
||||
Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
|
||||
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
keymap[i].type = ISFUNC;
|
||||
keymap[i].function = (rl_command_func_t *)NULL;
|
||||
}
|
||||
|
||||
for (i = 'A'; i < ('Z' + 1); i++)
|
||||
{
|
||||
keymap[i].type = ISFUNC;
|
||||
keymap[i].function = rl_do_lowercase_version;
|
||||
}
|
||||
|
||||
return (keymap);
|
||||
}
|
||||
|
||||
/* Return a new keymap which is a copy of MAP. */
|
||||
Keymap
|
||||
rl_copy_keymap (map)
|
||||
Keymap map;
|
||||
{
|
||||
register int i;
|
||||
Keymap temp = rl_make_bare_keymap ();
|
||||
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
temp[i].type = map[i].type;
|
||||
temp[i].function = map[i].function;
|
||||
}
|
||||
return (temp);
|
||||
}
|
||||
|
||||
/* Return a new keymap with the printing characters bound to rl_insert,
|
||||
the uppercase Meta characters bound to run their lowercase equivalents,
|
||||
and the Meta digits bound to produce numeric arguments. */
|
||||
Keymap
|
||||
rl_make_keymap ()
|
||||
{
|
||||
register int i;
|
||||
Keymap newmap;
|
||||
|
||||
newmap = rl_make_bare_keymap ();
|
||||
|
||||
/* All ASCII printing characters are self-inserting. */
|
||||
for (i = ' '; i < 127; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
|
||||
newmap[TAB].function = rl_insert;
|
||||
newmap[RUBOUT].function = rl_rubout; /* RUBOUT == 127 */
|
||||
newmap[CTRL('H')].function = rl_rubout;
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Printing characters in some 8-bit character sets. */
|
||||
for (i = 128; i < 160; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
|
||||
/* ISO Latin-1 printing characters should self-insert. */
|
||||
for (i = 160; i < 256; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
|
||||
return (newmap);
|
||||
}
|
||||
|
||||
/* Free the storage associated with MAP. */
|
||||
void
|
||||
rl_discard_keymap (map)
|
||||
Keymap map;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!map)
|
||||
return;
|
||||
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
switch (map[i].type)
|
||||
{
|
||||
case ISFUNC:
|
||||
break;
|
||||
|
||||
case ISKMAP:
|
||||
rl_discard_keymap ((Keymap)map[i].function);
|
||||
break;
|
||||
|
||||
case ISMACR:
|
||||
free ((char *)map[i].function);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/* keymaps.h -- Manipulation of readline keymaps. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#ifndef _KEYMAPS_H_
|
||||
#define _KEYMAPS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "rlstdc.h"
|
||||
# include "chardefs.h"
|
||||
# include "rltypedefs.h"
|
||||
#else
|
||||
# include <readline/rlstdc.h>
|
||||
# include <readline/chardefs.h>
|
||||
# include <readline/rltypedefs.h>
|
||||
#endif
|
||||
|
||||
/* A keymap contains one entry for each key in the ASCII set.
|
||||
Each entry consists of a type and a pointer.
|
||||
FUNCTION is the address of a function to run, or the
|
||||
address of a keymap to indirect through.
|
||||
TYPE says which kind of thing FUNCTION is. */
|
||||
typedef struct _keymap_entry {
|
||||
char type;
|
||||
rl_command_func_t *function;
|
||||
} KEYMAP_ENTRY;
|
||||
|
||||
/* This must be large enough to hold bindings for all of the characters
|
||||
in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
|
||||
and so on) plus one for subsequence matching. */
|
||||
#define KEYMAP_SIZE 257
|
||||
#define ANYOTHERKEY KEYMAP_SIZE-1
|
||||
|
||||
/* I wanted to make the above structure contain a union of:
|
||||
union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
|
||||
but this made it impossible for me to create a static array.
|
||||
Maybe I need C lessons. */
|
||||
|
||||
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
|
||||
typedef KEYMAP_ENTRY *Keymap;
|
||||
|
||||
/* The values that TYPE can have in a keymap entry. */
|
||||
#define ISFUNC 0
|
||||
#define ISKMAP 1
|
||||
#define ISMACR 2
|
||||
|
||||
extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
|
||||
extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
|
||||
|
||||
/* Return a new, empty keymap.
|
||||
Free it with free() when you are done. */
|
||||
extern Keymap rl_make_bare_keymap PARAMS((void));
|
||||
|
||||
/* Return a new keymap which is a copy of MAP. */
|
||||
extern Keymap rl_copy_keymap PARAMS((Keymap));
|
||||
|
||||
/* Return a new keymap with the printing characters bound to rl_insert,
|
||||
the lowercase Meta characters bound to run their equivalents, and
|
||||
the Meta digits bound to produce numeric arguments. */
|
||||
extern Keymap rl_make_keymap PARAMS((void));
|
||||
|
||||
/* Free the storage associated with a keymap. */
|
||||
extern void rl_discard_keymap PARAMS((Keymap));
|
||||
|
||||
/* These functions actually appear in bind.c */
|
||||
|
||||
/* Return the keymap corresponding to a given name. Names look like
|
||||
`emacs' or `emacs-meta' or `vi-insert'. */
|
||||
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
|
||||
|
||||
/* Return the current keymap. */
|
||||
extern Keymap rl_get_keymap PARAMS((void));
|
||||
|
||||
/* Set the current keymap to MAP. */
|
||||
extern void rl_set_keymap PARAMS((Keymap));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _KEYMAPS_H_ */
|
||||
|
|
@ -0,0 +1,652 @@
|
|||
/* kill.c -- kill ring management. */
|
||||
|
||||
/* Copyright (C) 1994 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#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"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Killing Mechanism */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* What we assume for a max number of kills. */
|
||||
#define DEFAULT_MAX_KILLS 10
|
||||
|
||||
/* The real variable to look at to find out when to flush kills. */
|
||||
static int rl_max_kills = DEFAULT_MAX_KILLS;
|
||||
|
||||
/* Where to store killed text. */
|
||||
static char **rl_kill_ring = (char **)NULL;
|
||||
|
||||
/* Where we are in the kill ring. */
|
||||
static int rl_kill_index;
|
||||
|
||||
/* How many slots we have in the kill ring. */
|
||||
static int rl_kill_ring_length;
|
||||
|
||||
static int _rl_copy_to_kill_ring PARAMS((char *, int));
|
||||
static int region_kill_internal PARAMS((int));
|
||||
static int _rl_copy_word_as_kill PARAMS((int, int));
|
||||
static int rl_yank_nth_arg_internal PARAMS((int, int, int));
|
||||
|
||||
/* How to say that you only want to save a certain amount
|
||||
of kill material. */
|
||||
int
|
||||
rl_set_retained_kills (num)
|
||||
int num;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add TEXT to the kill ring, allocating a new kill ring slot as necessary.
|
||||
This uses TEXT directly, so the caller must not free it. If APPEND is
|
||||
non-zero, and the last command was a kill, the text is appended to the
|
||||
current kill ring slot, otherwise prepended. */
|
||||
static int
|
||||
_rl_copy_to_kill_ring (text, append)
|
||||
char *text;
|
||||
int append;
|
||||
{
|
||||
char *old, *new;
|
||||
int slot;
|
||||
|
||||
/* First, find the slot to work with. */
|
||||
if (_rl_last_command_was_kill == 0)
|
||||
{
|
||||
/* Get a new slot. */
|
||||
if (rl_kill_ring == 0)
|
||||
{
|
||||
/* If we don't have any defined, then make one. */
|
||||
rl_kill_ring = (char **)
|
||||
xmalloc (((rl_kill_ring_length = 1) + 1) * sizeof (char *));
|
||||
rl_kill_ring[slot = 0] = (char *)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We have to add a new slot on the end, unless we have
|
||||
exceeded the max limit for remembering kills. */
|
||||
slot = rl_kill_ring_length;
|
||||
if (slot == rl_max_kills)
|
||||
{
|
||||
register int i;
|
||||
free (rl_kill_ring[0]);
|
||||
for (i = 0; i < slot; i++)
|
||||
rl_kill_ring[i] = rl_kill_ring[i + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
slot = rl_kill_ring_length += 1;
|
||||
rl_kill_ring = (char **)xrealloc (rl_kill_ring, slot * sizeof (char *));
|
||||
}
|
||||
rl_kill_ring[--slot] = (char *)NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
slot = rl_kill_ring_length - 1;
|
||||
|
||||
/* If the last command was a kill, prepend or append. */
|
||||
if (_rl_last_command_was_kill && rl_editing_mode != vi_mode)
|
||||
{
|
||||
old = rl_kill_ring[slot];
|
||||
new = (char *)xmalloc (1 + strlen (old) + strlen (text));
|
||||
|
||||
if (append)
|
||||
{
|
||||
strcpy (new, old);
|
||||
strcat (new, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy (new, text);
|
||||
strcat (new, old);
|
||||
}
|
||||
free (old);
|
||||
free (text);
|
||||
rl_kill_ring[slot] = new;
|
||||
}
|
||||
else
|
||||
rl_kill_ring[slot] = text;
|
||||
|
||||
rl_kill_index = slot;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The way to kill something. This appends or prepends to the last
|
||||
kill, if the last command was a kill command. if FROM is less
|
||||
than TO, then the text is appended, otherwise prepended. If the
|
||||
last command was not a kill command, then a new slot is made for
|
||||
this kill. */
|
||||
int
|
||||
rl_kill_text (from, to)
|
||||
int from, to;
|
||||
{
|
||||
char *text;
|
||||
|
||||
/* Is there anything to kill? */
|
||||
if (from == to)
|
||||
{
|
||||
_rl_last_command_was_kill++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
text = rl_copy_text (from, to);
|
||||
|
||||
/* Delete the copied text from the line. */
|
||||
rl_delete_text (from, to);
|
||||
|
||||
_rl_copy_to_kill_ring (text, from < to);
|
||||
|
||||
_rl_last_command_was_kill++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Now REMEMBER! In order to do prepending or appending correctly, kill
|
||||
commands always make rl_point's original position be the FROM argument,
|
||||
and rl_point's extent be the TO argument. */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Killing Commands */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Delete the word at point, saving the text in the kill ring. */
|
||||
int
|
||||
rl_kill_word (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_backward_kill_word (-count, key));
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_forward_word (count, key);
|
||||
|
||||
if (rl_point != orig_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
|
||||
rl_point = orig_point;
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Rubout the word before point, placing it on the kill ring. */
|
||||
int
|
||||
rl_backward_kill_word (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_kill_word (-count, ignore));
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_backward_word (count, ignore);
|
||||
|
||||
if (rl_point != orig_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Kill from here to the end of the line. If DIRECTION is negative, kill
|
||||
back to the line start instead. */
|
||||
int
|
||||
rl_kill_line (direction, ignore)
|
||||
int direction, ignore;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (direction < 0)
|
||||
return (rl_backward_kill_line (1, ignore));
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_end_of_line (1, ignore);
|
||||
if (orig_point != rl_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
rl_point = orig_point;
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Kill backwards to the start of the line. If DIRECTION is negative, kill
|
||||
forwards to the line end instead. */
|
||||
int
|
||||
rl_backward_kill_line (direction, ignore)
|
||||
int direction, ignore;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (direction < 0)
|
||||
return (rl_kill_line (1, ignore));
|
||||
else
|
||||
{
|
||||
if (!rl_point)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_beg_of_line (1, ignore);
|
||||
if (rl_point != orig_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Kill the whole line, no matter where point is. */
|
||||
int
|
||||
rl_kill_full_line (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
rl_begin_undo_group ();
|
||||
rl_point = 0;
|
||||
rl_kill_text (rl_point, rl_end);
|
||||
rl_mark = 0;
|
||||
rl_end_undo_group ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The next two functions mimic unix line editing behaviour, except they
|
||||
save the deleted text on the kill ring. This is safer than not saving
|
||||
it, and since we have a ring, nobody should get screwed. */
|
||||
|
||||
/* This does what C-w does in Unix. We can't prevent people from
|
||||
using behaviour that they expect. */
|
||||
int
|
||||
rl_unix_word_rubout (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (rl_point == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
if (count <= 0)
|
||||
count = 1;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
while (rl_point && whitespace (rl_line_buffer[rl_point - 1]))
|
||||
rl_point--;
|
||||
|
||||
while (rl_point && (whitespace (rl_line_buffer[rl_point - 1]) == 0))
|
||||
rl_point--;
|
||||
}
|
||||
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Here is C-u doing what Unix does. You don't *have* to use these
|
||||
key-bindings. We have a choice of killing the entire line, or
|
||||
killing from where we are to the start of the line. We choose the
|
||||
latter, because if you are a Unix weenie, then you haven't backspaced
|
||||
into the line at all, and if you aren't, then you know what you are
|
||||
doing. */
|
||||
int
|
||||
rl_unix_line_discard (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (rl_point == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
rl_kill_text (rl_point, 0);
|
||||
rl_point = 0;
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the text in the `region' to the kill ring. If DELETE is non-zero,
|
||||
delete the text from the line as well. */
|
||||
static int
|
||||
region_kill_internal (delete)
|
||||
int delete;
|
||||
{
|
||||
char *text;
|
||||
|
||||
if (rl_mark != rl_point)
|
||||
{
|
||||
text = rl_copy_text (rl_point, rl_mark);
|
||||
if (delete)
|
||||
rl_delete_text (rl_point, rl_mark);
|
||||
_rl_copy_to_kill_ring (text, rl_point < rl_mark);
|
||||
}
|
||||
|
||||
_rl_last_command_was_kill++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the text in the region to the kill ring. */
|
||||
int
|
||||
rl_copy_region_to_kill (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
return (region_kill_internal (0));
|
||||
}
|
||||
|
||||
/* Kill the text between the point and mark. */
|
||||
int
|
||||
rl_kill_region (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
int r, npoint;
|
||||
|
||||
npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
|
||||
r = region_kill_internal (1);
|
||||
_rl_fix_point (1);
|
||||
rl_point = npoint;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Copy COUNT words to the kill ring. DIR says which direction we look
|
||||
to find the words. */
|
||||
static int
|
||||
_rl_copy_word_as_kill (count, dir)
|
||||
int count, dir;
|
||||
{
|
||||
int om, op, r;
|
||||
|
||||
om = rl_mark;
|
||||
op = rl_point;
|
||||
|
||||
if (dir > 0)
|
||||
rl_forward_word (count, 0);
|
||||
else
|
||||
rl_backward_word (count, 0);
|
||||
|
||||
rl_mark = rl_point;
|
||||
|
||||
if (dir > 0)
|
||||
rl_backward_word (count, 0);
|
||||
else
|
||||
rl_forward_word (count, 0);
|
||||
|
||||
r = region_kill_internal (0);
|
||||
|
||||
rl_mark = om;
|
||||
rl_point = op;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
rl_copy_forward_word (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (count < 0)
|
||||
return (rl_copy_backward_word (-count, key));
|
||||
|
||||
return (_rl_copy_word_as_kill (count, 1));
|
||||
}
|
||||
|
||||
int
|
||||
rl_copy_backward_word (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (count < 0)
|
||||
return (rl_copy_forward_word (-count, key));
|
||||
|
||||
return (_rl_copy_word_as_kill (count, -1));
|
||||
}
|
||||
|
||||
/* Yank back the last killed text. This ignores arguments. */
|
||||
int
|
||||
rl_yank (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (rl_kill_ring == 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
_rl_set_mark_at_pos (rl_point);
|
||||
rl_insert_text (rl_kill_ring[rl_kill_index]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If the last command was yank, or yank_pop, and the text just
|
||||
before point is identical to the current kill item, then
|
||||
delete that text from the line, rotate the index down, and
|
||||
yank back some other text. */
|
||||
int
|
||||
rl_yank_pop (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int l, n;
|
||||
|
||||
if (((rl_last_func != rl_yank_pop) && (rl_last_func != rl_yank)) ||
|
||||
!rl_kill_ring)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
l = strlen (rl_kill_ring[rl_kill_index]);
|
||||
n = rl_point - l;
|
||||
if (n >= 0 && STREQN (rl_line_buffer + n, rl_kill_ring[rl_kill_index], l))
|
||||
{
|
||||
rl_delete_text (n, rl_point);
|
||||
rl_point = n;
|
||||
rl_kill_index--;
|
||||
if (rl_kill_index < 0)
|
||||
rl_kill_index = rl_kill_ring_length - 1;
|
||||
rl_yank (1, 0);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Yank the COUNTh argument from the previous history line, skipping
|
||||
HISTORY_SKIP lines before looking for the `previous line'. */
|
||||
static int
|
||||
rl_yank_nth_arg_internal (count, ignore, history_skip)
|
||||
int count, ignore, history_skip;
|
||||
{
|
||||
register HIST_ENTRY *entry;
|
||||
char *arg;
|
||||
int i, pos;
|
||||
|
||||
pos = where_history ();
|
||||
|
||||
if (history_skip)
|
||||
{
|
||||
for (i = 0; i < history_skip; i++)
|
||||
entry = previous_history ();
|
||||
}
|
||||
|
||||
entry = previous_history ();
|
||||
|
||||
history_set_pos (pos);
|
||||
|
||||
if (entry == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
arg = history_arg_extract (count, count, entry->line);
|
||||
if (!arg || !*arg)
|
||||
{
|
||||
rl_ding ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
rl_begin_undo_group ();
|
||||
|
||||
_rl_set_mark_at_pos (rl_point);
|
||||
|
||||
#if defined (VI_MODE)
|
||||
/* Vi mode always inserts a space before yanking the argument, and it
|
||||
inserts it right *after* rl_point. */
|
||||
if (rl_editing_mode == vi_mode)
|
||||
{
|
||||
rl_vi_append_mode (1, ignore);
|
||||
rl_insert_text (" ");
|
||||
}
|
||||
#endif /* VI_MODE */
|
||||
|
||||
rl_insert_text (arg);
|
||||
free (arg);
|
||||
|
||||
rl_end_undo_group ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Yank the COUNTth argument from the previous history line. */
|
||||
int
|
||||
rl_yank_nth_arg (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
return (rl_yank_nth_arg_internal (count, ignore, 0));
|
||||
}
|
||||
|
||||
/* Yank the last argument from the previous history line. This `knows'
|
||||
how rl_yank_nth_arg treats a count of `$'. With an argument, this
|
||||
behaves the same as rl_yank_nth_arg. */
|
||||
int
|
||||
rl_yank_last_arg (count, key)
|
||||
int count, key;
|
||||
{
|
||||
static int history_skip = 0;
|
||||
static int explicit_arg_p = 0;
|
||||
static int count_passed = 1;
|
||||
static int direction = 1;
|
||||
static int undo_needed = 0;
|
||||
int retval;
|
||||
|
||||
if (rl_last_func != rl_yank_last_arg)
|
||||
{
|
||||
history_skip = 0;
|
||||
explicit_arg_p = rl_explicit_arg;
|
||||
count_passed = count;
|
||||
direction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (undo_needed)
|
||||
rl_do_undo ();
|
||||
if (count < 1)
|
||||
direction = -direction;
|
||||
history_skip += direction;
|
||||
if (history_skip < 0)
|
||||
history_skip = 0;
|
||||
}
|
||||
|
||||
if (explicit_arg_p)
|
||||
retval = rl_yank_nth_arg_internal (count_passed, key, history_skip);
|
||||
else
|
||||
retval = rl_yank_nth_arg_internal ('$', key, history_skip);
|
||||
|
||||
undo_needed = retval == 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* A special paste command for users of Cygnus's cygwin32. */
|
||||
#if defined (__CYGWIN__)
|
||||
#include <windows.h>
|
||||
|
||||
int
|
||||
rl_paste_from_clipboard (count, key)
|
||||
int count, key;
|
||||
{
|
||||
char *data, *ptr;
|
||||
int len;
|
||||
|
||||
if (OpenClipboard (NULL) == 0)
|
||||
return (0);
|
||||
|
||||
data = (char *)GetClipboardData (CF_TEXT);
|
||||
if (data)
|
||||
{
|
||||
ptr = strchr (data, '\r');
|
||||
if (ptr)
|
||||
{
|
||||
len = ptr - data;
|
||||
ptr = (char *)xmalloc (len + 1);
|
||||
ptr[len] = '\0';
|
||||
strncpy (ptr, data, len);
|
||||
}
|
||||
else
|
||||
ptr = data;
|
||||
_rl_set_mark_at_pos (rl_point);
|
||||
rl_insert_text (ptr);
|
||||
if (ptr != data)
|
||||
free (ptr);
|
||||
CloseClipboard ();
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif /* __CYGWIN__ */
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
/* macro.c -- keyboard macros for readline. */
|
||||
|
||||
/* Copyright (C) 1994 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#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"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Hacking Keyboard Macros */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* The currently executing macro string. If this is non-zero,
|
||||
then it is a malloc ()'ed string where input is coming from. */
|
||||
char *rl_executing_macro = (char *)NULL;
|
||||
|
||||
/* The offset in the above string to the next character to be read. */
|
||||
static int executing_macro_index;
|
||||
|
||||
/* The current macro string being built. Characters get stuffed
|
||||
in here by add_macro_char (). */
|
||||
static char *current_macro = (char *)NULL;
|
||||
|
||||
/* The size of the buffer allocated to current_macro. */
|
||||
static int current_macro_size;
|
||||
|
||||
/* The index at which characters are being added to current_macro. */
|
||||
static int current_macro_index;
|
||||
|
||||
/* A structure used to save nested macro strings.
|
||||
It is a linked list of string/index for each saved macro. */
|
||||
struct saved_macro {
|
||||
struct saved_macro *next;
|
||||
char *string;
|
||||
int sindex;
|
||||
};
|
||||
|
||||
/* The list of saved macros. */
|
||||
static struct saved_macro *macro_list = (struct saved_macro *)NULL;
|
||||
|
||||
/* Set up to read subsequent input from STRING.
|
||||
STRING is free ()'ed when we are done with it. */
|
||||
void
|
||||
_rl_with_macro_input (string)
|
||||
char *string;
|
||||
{
|
||||
_rl_push_executing_macro ();
|
||||
rl_executing_macro = string;
|
||||
executing_macro_index = 0;
|
||||
RL_SETSTATE(RL_STATE_MACROINPUT);
|
||||
}
|
||||
|
||||
/* Return the next character available from a macro, or 0 if
|
||||
there are no macro characters. */
|
||||
int
|
||||
_rl_next_macro_key ()
|
||||
{
|
||||
if (rl_executing_macro == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_executing_macro[executing_macro_index] == 0)
|
||||
{
|
||||
_rl_pop_executing_macro ();
|
||||
return (_rl_next_macro_key ());
|
||||
}
|
||||
|
||||
return (rl_executing_macro[executing_macro_index++]);
|
||||
}
|
||||
|
||||
/* Save the currently executing macro on a stack of saved macros. */
|
||||
void
|
||||
_rl_push_executing_macro ()
|
||||
{
|
||||
struct saved_macro *saver;
|
||||
|
||||
saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
|
||||
saver->next = macro_list;
|
||||
saver->sindex = executing_macro_index;
|
||||
saver->string = rl_executing_macro;
|
||||
|
||||
macro_list = saver;
|
||||
}
|
||||
|
||||
/* Discard the current macro, replacing it with the one
|
||||
on the top of the stack of saved macros. */
|
||||
void
|
||||
_rl_pop_executing_macro ()
|
||||
{
|
||||
struct saved_macro *macro;
|
||||
|
||||
FREE (rl_executing_macro);
|
||||
rl_executing_macro = (char *)NULL;
|
||||
executing_macro_index = 0;
|
||||
|
||||
if (macro_list)
|
||||
{
|
||||
macro = macro_list;
|
||||
rl_executing_macro = macro_list->string;
|
||||
executing_macro_index = macro_list->sindex;
|
||||
macro_list = macro_list->next;
|
||||
free (macro);
|
||||
}
|
||||
|
||||
if (rl_executing_macro == 0)
|
||||
RL_UNSETSTATE(RL_STATE_MACROINPUT);
|
||||
}
|
||||
|
||||
/* Add a character to the macro being built. */
|
||||
void
|
||||
_rl_add_macro_char (c)
|
||||
int c;
|
||||
{
|
||||
if (current_macro_index + 1 >= current_macro_size)
|
||||
{
|
||||
if (current_macro == 0)
|
||||
current_macro = (char *)xmalloc (current_macro_size = 25);
|
||||
else
|
||||
current_macro = (char *)xrealloc (current_macro, current_macro_size += 25);
|
||||
}
|
||||
|
||||
current_macro[current_macro_index++] = c;
|
||||
current_macro[current_macro_index] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
_rl_kill_kbd_macro ()
|
||||
{
|
||||
if (current_macro)
|
||||
{
|
||||
free (current_macro);
|
||||
current_macro = (char *) NULL;
|
||||
}
|
||||
current_macro_size = current_macro_index = 0;
|
||||
|
||||
FREE (rl_executing_macro);
|
||||
rl_executing_macro = (char *) NULL;
|
||||
executing_macro_index = 0;
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_MACRODEF);
|
||||
}
|
||||
|
||||
/* Begin defining a keyboard macro.
|
||||
Keystrokes are recorded as they are executed.
|
||||
End the definition with rl_end_kbd_macro ().
|
||||
If a numeric argument was explicitly typed, then append this
|
||||
definition to the end of the existing macro, and start by
|
||||
re-executing the existing macro. */
|
||||
int
|
||||
rl_start_kbd_macro (ignore1, ignore2)
|
||||
int ignore1, ignore2;
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF))
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rl_explicit_arg)
|
||||
{
|
||||
if (current_macro)
|
||||
_rl_with_macro_input (savestring (current_macro));
|
||||
}
|
||||
else
|
||||
current_macro_index = 0;
|
||||
|
||||
RL_SETSTATE(RL_STATE_MACRODEF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Stop defining a keyboard macro.
|
||||
A numeric argument says to execute the macro right now,
|
||||
that many times, counting the definition as the first time. */
|
||||
int
|
||||
rl_end_kbd_macro (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
current_macro_index -= rl_key_sequence_length - 1;
|
||||
current_macro[current_macro_index] = '\0';
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_MACRODEF);
|
||||
|
||||
return (rl_call_last_kbd_macro (--count, 0));
|
||||
}
|
||||
|
||||
/* Execute the most recently defined keyboard macro.
|
||||
COUNT says how many times to execute it. */
|
||||
int
|
||||
rl_call_last_kbd_macro (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (current_macro == 0)
|
||||
_rl_abort_internal ();
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF))
|
||||
{
|
||||
rl_ding (); /* no recursive macros */
|
||||
current_macro[--current_macro_index] = '\0'; /* erase this char */
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (count--)
|
||||
_rl_with_macro_input (savestring (current_macro));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rl_push_macro_input (macro)
|
||||
char *macro;
|
||||
{
|
||||
_rl_with_macro_input (macro);
|
||||
}
|
||||
|
|
@ -0,0 +1,348 @@
|
|||
/* mbutil.c -- readline multibyte character utility functions */
|
||||
|
||||
/* Copyright (C) 2001 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#define _XOPEN_SOURCE /* See feature_test_macros(7) */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <wchar.h>
|
||||
#include "posixjmp.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>
|
||||
#include <ctype.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#if defined (TIOCSTAT_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* TIOCSTAT_IN_SYS_IOCTL */
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Declared here so it can be shared between the readline and history
|
||||
libraries. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
int rl_byte_oriented = 0;
|
||||
#else
|
||||
int rl_byte_oriented = 1;
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Multibyte Character Utility Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined(HANDLE_MULTIBYTE)
|
||||
|
||||
static int
|
||||
_rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
|
||||
char *string;
|
||||
int seed, count, find_non_zero;
|
||||
{
|
||||
size_t tmp = 0;
|
||||
mbstate_t ps;
|
||||
int point = 0;
|
||||
wchar_t wc;
|
||||
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
if (seed < 0)
|
||||
seed = 0;
|
||||
if (count <= 0)
|
||||
return seed;
|
||||
|
||||
point = seed + _rl_adjust_point(string, seed, &ps);
|
||||
/* if this is true, means that seed was not pointed character
|
||||
started byte. So correct the point and consume count */
|
||||
if (seed < point)
|
||||
count --;
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
|
||||
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
|
||||
{
|
||||
/* invalid bytes. asume a byte represents a character */
|
||||
point++;
|
||||
count--;
|
||||
/* reset states. */
|
||||
memset(&ps, 0, sizeof(mbstate_t));
|
||||
}
|
||||
else if (tmp == (size_t)0)
|
||||
/* found '\0' char */
|
||||
break;
|
||||
else
|
||||
{
|
||||
/* valid bytes */
|
||||
point += tmp;
|
||||
if (find_non_zero)
|
||||
{
|
||||
if (wcwidth (wc) == 0)
|
||||
continue;
|
||||
else
|
||||
count--;
|
||||
}
|
||||
else
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
if (find_non_zero)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
|
||||
while (wcwidth (wc) == 0)
|
||||
{
|
||||
point += tmp;
|
||||
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
|
||||
if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_find_prev_mbchar_internal (string, seed, find_non_zero)
|
||||
char *string;
|
||||
int seed, find_non_zero;
|
||||
{
|
||||
mbstate_t ps;
|
||||
int prev, non_zero_prev, point, length;
|
||||
size_t tmp;
|
||||
wchar_t wc;
|
||||
|
||||
memset(&ps, 0, sizeof(mbstate_t));
|
||||
length = strlen(string);
|
||||
|
||||
if (seed < 0)
|
||||
return 0;
|
||||
else if (length < seed)
|
||||
return length;
|
||||
|
||||
prev = non_zero_prev = point = 0;
|
||||
while (point < seed)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string + point, length - point, &ps);
|
||||
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
|
||||
{
|
||||
/* in this case, bytes are invalid or shorted to compose
|
||||
multibyte char, so assume that the first byte represents
|
||||
a single character anyway. */
|
||||
tmp = 1;
|
||||
/* clear the state of the byte sequence, because
|
||||
in this case effect of mbstate is undefined */
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (tmp == 0)
|
||||
break; /* Found '\0' char. Can this happen? */
|
||||
else
|
||||
{
|
||||
if (find_non_zero)
|
||||
{
|
||||
if (wcwidth (wc) != 0)
|
||||
prev = point;
|
||||
}
|
||||
else
|
||||
prev = point;
|
||||
}
|
||||
|
||||
point += tmp;
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
/* return the number of bytes parsed from the multibyte sequence starting
|
||||
at src, if a non-L'\0' wide character was recognized. It returns 0,
|
||||
if a L'\0' wide character was recognized. It returns (size_t)(-1),
|
||||
if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
|
||||
if it couldn't parse a complete multibyte character. */
|
||||
int
|
||||
_rl_get_char_len (src, ps)
|
||||
char *src;
|
||||
mbstate_t *ps;
|
||||
{
|
||||
size_t tmp;
|
||||
|
||||
tmp = mbrlen((const char *)src, (size_t)strlen (src), ps);
|
||||
if (tmp == (size_t)(-2))
|
||||
{
|
||||
/* shorted to compose multibyte char */
|
||||
if (ps)
|
||||
memset (ps, 0, sizeof(mbstate_t));
|
||||
return -2;
|
||||
}
|
||||
else if (tmp == (size_t)(-1))
|
||||
{
|
||||
/* invalid to compose multibyte char */
|
||||
/* initialize the conversion state */
|
||||
if (ps)
|
||||
memset (ps, 0, sizeof(mbstate_t));
|
||||
return -1;
|
||||
}
|
||||
else if (tmp == (size_t)0)
|
||||
return 0;
|
||||
else
|
||||
return (int)tmp;
|
||||
}
|
||||
|
||||
/* compare the specified two characters. If the characters matched,
|
||||
return 1. Otherwise return 0. */
|
||||
int
|
||||
_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
|
||||
char *buf1;
|
||||
int pos1;
|
||||
mbstate_t *ps1;
|
||||
char *buf2;
|
||||
int pos2;
|
||||
mbstate_t *ps2;
|
||||
{
|
||||
int i, w1, w2;
|
||||
|
||||
if ((w1 = _rl_get_char_len (&buf1[pos1], ps1)) <= 0 ||
|
||||
(w2 = _rl_get_char_len (&buf2[pos2], ps2)) <= 0 ||
|
||||
(w1 != w2) ||
|
||||
(buf1[pos1] != buf2[pos2]))
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < w1; i++)
|
||||
if (buf1[pos1+i] != buf2[pos2+i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* adjust pointed byte and find mbstate of the point of string.
|
||||
adjusted point will be point <= adjusted_point, and returns
|
||||
differences of the byte(adjusted_point - point).
|
||||
if point is invalied (point < 0 || more than string length),
|
||||
it returns -1 */
|
||||
int
|
||||
_rl_adjust_point(string, point, ps)
|
||||
char *string;
|
||||
int point;
|
||||
mbstate_t *ps;
|
||||
{
|
||||
size_t tmp = 0;
|
||||
int length;
|
||||
int pos = 0;
|
||||
|
||||
length = strlen(string);
|
||||
if (point < 0)
|
||||
return -1;
|
||||
if (length < point)
|
||||
return -1;
|
||||
|
||||
while (pos < point)
|
||||
{
|
||||
tmp = mbrlen (string + pos, length - pos, ps);
|
||||
if((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
|
||||
{
|
||||
/* in this case, bytes are invalid or shorted to compose
|
||||
multibyte char, so assume that the first byte represents
|
||||
a single character anyway. */
|
||||
pos++;
|
||||
/* clear the state of the byte sequence, because
|
||||
in this case effect of mbstate is undefined */
|
||||
if (ps)
|
||||
memset (ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (tmp == 0)
|
||||
pos++;
|
||||
else
|
||||
pos += tmp;
|
||||
}
|
||||
|
||||
return (pos - point);
|
||||
}
|
||||
|
||||
int
|
||||
_rl_is_mbchar_matched (string, seed, end, mbchar, length)
|
||||
char *string;
|
||||
int seed, end;
|
||||
char *mbchar;
|
||||
int length;
|
||||
{
|
||||
int i;
|
||||
|
||||
if ((end - seed) < length)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
if (string[seed + i] != mbchar[i])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
#endif /* HANDLE_MULTIBYTE */
|
||||
|
||||
/* Find next `count' characters started byte point of the specified seed.
|
||||
If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte
|
||||
characters. */
|
||||
#undef _rl_find_next_mbchar
|
||||
int
|
||||
_rl_find_next_mbchar (string, seed, count, flags)
|
||||
char *string;
|
||||
int seed, count, flags;
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
return _rl_find_next_mbchar_internal (string, seed, count, flags);
|
||||
#else
|
||||
return (seed + count);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Find previous character started byte point of the specified seed.
|
||||
Returned point will be point <= seed. If flags is MB_FIND_NONZERO,
|
||||
we look for non-zero-width multibyte characters. */
|
||||
#undef _rl_find_prev_mbchar
|
||||
int
|
||||
_rl_find_prev_mbchar (string, seed, flags)
|
||||
char *string;
|
||||
int seed, flags;
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
return _rl_find_prev_mbchar_internal (string, seed, flags);
|
||||
#else
|
||||
return ((seed == 0) ? seed : seed - 1);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,496 @@
|
|||
/* misc.c -- miscellaneous bindable readline functions. */
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_LOCALE_H)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
static int rl_digit_loop PARAMS((void));
|
||||
static void _rl_history_set_point PARAMS((void));
|
||||
|
||||
/* Forward declarations used in this file */
|
||||
void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
|
||||
to preserve the value of rl_point from line to line. */
|
||||
int _rl_history_preserve_point = 0;
|
||||
|
||||
/* Saved target point for when _rl_history_preserve_point is set. Special
|
||||
value of -1 means that point is at the end of the line. */
|
||||
int _rl_history_saved_point = -1;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Numeric Arguments */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Handle C-u style numeric args, as well as M--, and M-digits. */
|
||||
static int
|
||||
rl_digit_loop ()
|
||||
{
|
||||
int key, c, sawminus, sawdigits;
|
||||
|
||||
rl_save_prompt ();
|
||||
|
||||
RL_SETSTATE(RL_STATE_NUMERICARG);
|
||||
sawminus = sawdigits = 0;
|
||||
while (1)
|
||||
{
|
||||
if (rl_numeric_arg > 1000000)
|
||||
{
|
||||
sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
|
||||
rl_ding ();
|
||||
rl_restore_prompt ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
return 1;
|
||||
}
|
||||
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
key = c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
if (c < 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we see a key bound to `universal-argument' after seeing digits,
|
||||
it ends the argument but is otherwise ignored. */
|
||||
if (_rl_keymap[c].type == ISFUNC &&
|
||||
_rl_keymap[c].function == rl_universal_argument)
|
||||
{
|
||||
if (sawdigits == 0)
|
||||
{
|
||||
rl_numeric_arg *= 4;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
key = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
rl_restore_prompt ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
return (_rl_dispatch (key, _rl_keymap));
|
||||
}
|
||||
}
|
||||
|
||||
c = UNMETA (c);
|
||||
|
||||
if (_rl_digit_p (c))
|
||||
{
|
||||
rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0';
|
||||
sawdigits = rl_explicit_arg = 1;
|
||||
}
|
||||
else if (c == '-' && rl_explicit_arg == 0)
|
||||
{
|
||||
rl_numeric_arg = sawminus = 1;
|
||||
rl_arg_sign = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make M-- command equivalent to M--1 command. */
|
||||
if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
|
||||
rl_explicit_arg = 1;
|
||||
rl_restore_prompt ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
return (_rl_dispatch (key, _rl_keymap));
|
||||
}
|
||||
}
|
||||
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/* Add the current digit to the argument in progress. */
|
||||
int
|
||||
rl_digit_argument (ignore, key)
|
||||
int ignore, key;
|
||||
{
|
||||
rl_execute_next (key);
|
||||
return (rl_digit_loop ());
|
||||
}
|
||||
|
||||
/* What to do when you abort reading an argument. */
|
||||
int
|
||||
rl_discard_argument ()
|
||||
{
|
||||
rl_ding ();
|
||||
rl_clear_message ();
|
||||
_rl_init_argument ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create a default argument. */
|
||||
int
|
||||
_rl_init_argument ()
|
||||
{
|
||||
rl_numeric_arg = rl_arg_sign = 1;
|
||||
rl_explicit_arg = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* C-u, universal argument. Multiply the current argument by 4.
|
||||
Read a key. If the key has nothing to do with arguments, then
|
||||
dispatch on it. If the key is the abort character then abort. */
|
||||
int
|
||||
rl_universal_argument (count, key)
|
||||
int count, key;
|
||||
{
|
||||
rl_numeric_arg *= 4;
|
||||
return (rl_digit_loop ());
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Utilities */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* We already have a history library, and that is what we use to control
|
||||
the history features of readline. This is our local interface to
|
||||
the history mechanism. */
|
||||
|
||||
/* While we are editing the history, this is the saved
|
||||
version of the original line. */
|
||||
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
|
||||
/* Set the history pointer back to the last entry in the history. */
|
||||
void
|
||||
_rl_start_using_history ()
|
||||
{
|
||||
using_history ();
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Free the contents (and containing structure) of a HIST_ENTRY. */
|
||||
void
|
||||
_rl_free_history_entry (entry)
|
||||
HIST_ENTRY *entry;
|
||||
{
|
||||
if (entry == 0)
|
||||
return;
|
||||
if (entry->line)
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
}
|
||||
|
||||
/* Perhaps put back the current line if it has changed. */
|
||||
int
|
||||
rl_maybe_replace_line ()
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
|
||||
temp = current_history ();
|
||||
/* If the current line has changed, save the changes. */
|
||||
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
|
||||
{
|
||||
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
|
||||
free (temp->line);
|
||||
free (temp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Restore the _rl_saved_line_for_history if there is one. */
|
||||
int
|
||||
rl_maybe_unsave_line ()
|
||||
{
|
||||
if (_rl_saved_line_for_history)
|
||||
{
|
||||
rl_replace_line (_rl_saved_line_for_history->line, 0);
|
||||
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
rl_point = rl_end; /* rl_replace_line sets rl_end */
|
||||
}
|
||||
else
|
||||
rl_ding ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Save the current line in _rl_saved_line_for_history. */
|
||||
int
|
||||
rl_maybe_save_line ()
|
||||
{
|
||||
if (_rl_saved_line_for_history == 0)
|
||||
{
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
|
||||
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
|
||||
_rl_saved_line_for_history->data = (char *)rl_undo_list;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_free_saved_history_line ()
|
||||
{
|
||||
if (_rl_saved_line_for_history)
|
||||
{
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_rl_history_set_point ()
|
||||
{
|
||||
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
|
||||
? _rl_history_saved_point
|
||||
: rl_end;
|
||||
if (rl_point > rl_end)
|
||||
rl_point = rl_end;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
rl_point = 0;
|
||||
#endif /* VI_MODE */
|
||||
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = (rl_point == rl_end ? 0 : rl_end);
|
||||
}
|
||||
|
||||
void
|
||||
rl_replace_from_history (entry, flags)
|
||||
HIST_ENTRY *entry;
|
||||
int flags; /* currently unused */
|
||||
{
|
||||
rl_replace_line (entry->line, 0);
|
||||
rl_undo_list = (UNDO_LIST *)entry->data;
|
||||
rl_point = rl_end;
|
||||
rl_mark = 0;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
{
|
||||
rl_point = 0;
|
||||
rl_mark = rl_end;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Commands */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Meta-< goes to the start of the history. */
|
||||
int
|
||||
rl_beginning_of_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
return (rl_get_previous_history (1 + where_history (), key));
|
||||
}
|
||||
|
||||
/* Meta-> goes to the end of the history. (The current line). */
|
||||
int
|
||||
rl_end_of_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
rl_maybe_replace_line ();
|
||||
using_history ();
|
||||
rl_maybe_unsave_line ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Move down to the next history line. */
|
||||
int
|
||||
rl_get_next_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_get_previous_history (-count, key));
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
rl_maybe_replace_line ();
|
||||
|
||||
/* either not saved by rl_newline or at end of line, so set appropriately. */
|
||||
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
|
||||
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
|
||||
|
||||
temp = (HIST_ENTRY *)NULL;
|
||||
while (count)
|
||||
{
|
||||
temp = next_history ();
|
||||
if (!temp)
|
||||
break;
|
||||
--count;
|
||||
}
|
||||
|
||||
if (temp == 0)
|
||||
rl_maybe_unsave_line ();
|
||||
else
|
||||
{
|
||||
rl_replace_from_history (temp, 0);
|
||||
_rl_history_set_point ();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the previous item out of our interactive history, making it the current
|
||||
line. If there is no previous history, just ding. */
|
||||
int
|
||||
rl_get_previous_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
HIST_ENTRY *old_temp, *temp;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_get_next_history (-count, key));
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
/* either not saved by rl_newline or at end of line, so set appropriately. */
|
||||
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
|
||||
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
|
||||
|
||||
/* If we don't have a line saved, then save this one. */
|
||||
rl_maybe_save_line ();
|
||||
|
||||
/* If the current line has changed, save the changes. */
|
||||
rl_maybe_replace_line ();
|
||||
|
||||
temp = old_temp = (HIST_ENTRY *)NULL;
|
||||
while (count)
|
||||
{
|
||||
temp = previous_history ();
|
||||
if (temp == 0)
|
||||
break;
|
||||
|
||||
old_temp = temp;
|
||||
--count;
|
||||
}
|
||||
|
||||
/* If there was a large argument, and we moved back to the start of the
|
||||
history, that is not an error. So use the last value found. */
|
||||
if (!temp && old_temp)
|
||||
temp = old_temp;
|
||||
|
||||
if (temp == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
rl_replace_from_history (temp, 0);
|
||||
_rl_history_set_point ();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Editing Modes */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
/* How to toggle back and forth between editing modes. */
|
||||
int
|
||||
rl_vi_editing_mode (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
|
||||
rl_editing_mode = vi_mode;
|
||||
rl_vi_insertion_mode (1, key);
|
||||
#endif /* VI_MODE */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rl_emacs_editing_mode (count, key)
|
||||
int count, key;
|
||||
{
|
||||
rl_editing_mode = emacs_mode;
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
|
||||
_rl_keymap = emacs_standard_keymap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function for the rest of the library to use to set insert/overwrite mode. */
|
||||
void
|
||||
_rl_set_insert_mode (im, force)
|
||||
int im, force;
|
||||
{
|
||||
#ifdef CURSOR_MODE
|
||||
_rl_set_cursor (im, force);
|
||||
#endif
|
||||
|
||||
rl_insert_mode = im;
|
||||
}
|
||||
|
||||
/* Toggle overwrite mode. A positive explicit argument selects overwrite
|
||||
mode. A negative or zero explicit argument selects insert mode. */
|
||||
int
|
||||
rl_overwrite_mode (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (rl_explicit_arg == 0)
|
||||
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
|
||||
else if (count > 0)
|
||||
_rl_set_insert_mode (RL_IM_OVERWRITE, 0);
|
||||
else
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
/* nls.c -- skeletal internationalization code. */
|
||||
|
||||
/* Copyright (C) 1996 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_LOCALE_H)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "readline.h"
|
||||
#include "rlshell.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
#if !defined (HAVE_SETLOCALE)
|
||||
/* A list of legal values for the LANG or LC_CTYPE environment variables.
|
||||
If a locale name in this list is the value for the LC_ALL, LC_CTYPE,
|
||||
or LANG environment variable (using the first of those with a value),
|
||||
readline eight-bit mode is enabled. */
|
||||
static char *legal_lang_values[] =
|
||||
{
|
||||
"iso88591",
|
||||
"iso88592",
|
||||
"iso88593",
|
||||
"iso88594",
|
||||
"iso88595",
|
||||
"iso88596",
|
||||
"iso88597",
|
||||
"iso88598",
|
||||
"iso88599",
|
||||
"iso885910",
|
||||
"koi8r",
|
||||
0
|
||||
};
|
||||
|
||||
static char *normalize_codeset PARAMS((char *));
|
||||
static char *find_codeset PARAMS((char *, size_t *));
|
||||
#endif /* !HAVE_SETLOCALE */
|
||||
|
||||
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
|
||||
to decide the defaults for 8-bit character input and output. Returns
|
||||
1 if we set eight-bit mode. */
|
||||
int
|
||||
_rl_init_eightbit ()
|
||||
{
|
||||
/* If we have setlocale(3), just check the current LC_CTYPE category
|
||||
value, and go into eight-bit mode if it's not C or POSIX. */
|
||||
#if defined (HAVE_SETLOCALE)
|
||||
char *t;
|
||||
|
||||
/* Set the LC_CTYPE locale category from environment variables. */
|
||||
t = setlocale (LC_CTYPE, "");
|
||||
if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0))
|
||||
{
|
||||
_rl_meta_flag = 1;
|
||||
_rl_convert_meta_chars_to_ascii = 0;
|
||||
_rl_output_meta_chars = 1;
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
|
||||
#else /* !HAVE_SETLOCALE */
|
||||
char *lspec, *t;
|
||||
int i;
|
||||
|
||||
/* We don't have setlocale. Finesse it. Check the environment for the
|
||||
appropriate variables and set eight-bit mode if they have the right
|
||||
values. */
|
||||
lspec = sh_get_env_value ("LC_ALL");
|
||||
if (lspec == 0) lspec = sh_get_env_value ("LC_CTYPE");
|
||||
if (lspec == 0) lspec = sh_get_env_value ("LANG");
|
||||
if (lspec == 0 || (t = normalize_codeset (lspec)) == 0)
|
||||
return (0);
|
||||
for (i = 0; t && legal_lang_values[i]; i++)
|
||||
if (STREQ (t, legal_lang_values[i]))
|
||||
{
|
||||
_rl_meta_flag = 1;
|
||||
_rl_convert_meta_chars_to_ascii = 0;
|
||||
_rl_output_meta_chars = 1;
|
||||
break;
|
||||
}
|
||||
free (t);
|
||||
return (legal_lang_values[i] ? 1 : 0);
|
||||
|
||||
#endif /* !HAVE_SETLOCALE */
|
||||
}
|
||||
|
||||
#if !defined (HAVE_SETLOCALE)
|
||||
static char *
|
||||
normalize_codeset (codeset)
|
||||
char *codeset;
|
||||
{
|
||||
size_t namelen, i;
|
||||
int len, all_digits;
|
||||
char *wp, *retval;
|
||||
|
||||
codeset = find_codeset (codeset, &namelen);
|
||||
|
||||
if (codeset == 0)
|
||||
return (codeset);
|
||||
|
||||
all_digits = 1;
|
||||
for (len = 0, i = 0; i < namelen; i++)
|
||||
{
|
||||
if (ISALNUM ((unsigned char)codeset[i]))
|
||||
{
|
||||
len++;
|
||||
all_digits &= _rl_digit_p (codeset[i]);
|
||||
}
|
||||
}
|
||||
|
||||
retval = (char *)malloc ((all_digits ? 3 : 0) + len + 1);
|
||||
if (retval == 0)
|
||||
return ((char *)0);
|
||||
|
||||
wp = retval;
|
||||
/* Add `iso' to beginning of an all-digit codeset */
|
||||
if (all_digits)
|
||||
{
|
||||
*wp++ = 'i';
|
||||
*wp++ = 's';
|
||||
*wp++ = 'o';
|
||||
}
|
||||
|
||||
for (i = 0; i < namelen; i++)
|
||||
if (ISALPHA ((unsigned char)codeset[i]))
|
||||
*wp++ = _rl_to_lower (codeset[i]);
|
||||
else if (_rl_digit_p (codeset[i]))
|
||||
*wp++ = codeset[i];
|
||||
*wp = '\0';
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Isolate codeset portion of locale specification. */
|
||||
static char *
|
||||
find_codeset (name, lenp)
|
||||
char *name;
|
||||
size_t *lenp;
|
||||
{
|
||||
char *cp, *language, *result;
|
||||
|
||||
cp = language = name;
|
||||
result = (char *)0;
|
||||
|
||||
while (*cp && *cp != '_' && *cp != '@' && *cp != '+' && *cp != ',')
|
||||
cp++;
|
||||
|
||||
/* This does not make sense: language has to be specified. As
|
||||
an exception we allow the variable to contain only the codeset
|
||||
name. Perhaps there are funny codeset names. */
|
||||
if (language == cp)
|
||||
{
|
||||
*lenp = strlen (language);
|
||||
result = language;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Next is the territory. */
|
||||
if (*cp == '_')
|
||||
do
|
||||
++cp;
|
||||
while (*cp && *cp != '.' && *cp != '@' && *cp != '+' && *cp != ',' && *cp != '_');
|
||||
|
||||
/* Now, finally, is the codeset. */
|
||||
result = cp;
|
||||
if (*cp == '.')
|
||||
do
|
||||
++cp;
|
||||
while (*cp && *cp != '@');
|
||||
|
||||
if (cp - result > 2)
|
||||
{
|
||||
result++;
|
||||
*lenp = cp - result;
|
||||
}
|
||||
else
|
||||
{
|
||||
*lenp = strlen (language);
|
||||
result = language;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* !HAVE_SETLOCALE */
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
/* parens.c -- Implementation of matching parentheses feature. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#include "rlconf.h"
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (FD_SET) && !defined (HAVE_SELECT)
|
||||
# define HAVE_SELECT
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
# include <sys/time.h>
|
||||
#endif /* HAVE_SELECT */
|
||||
#if defined (HAVE_SYS_SELECT_H)
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
#include "readline.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
static int find_matching_open PARAMS((char *, int, int));
|
||||
|
||||
/* Non-zero means try to blink the matching open parenthesis when the
|
||||
close parenthesis is inserted. */
|
||||
#if defined (HAVE_SELECT)
|
||||
int rl_blink_matching_paren = 1;
|
||||
#else /* !HAVE_SELECT */
|
||||
int rl_blink_matching_paren = 0;
|
||||
#endif /* !HAVE_SELECT */
|
||||
|
||||
static int _paren_blink_usec = 500000;
|
||||
|
||||
/* Change emacs_standard_keymap to have bindings for paren matching when
|
||||
ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
|
||||
void
|
||||
_rl_enable_paren_matching (on_or_off)
|
||||
int on_or_off;
|
||||
{
|
||||
if (on_or_off)
|
||||
{ /* ([{ */
|
||||
rl_bind_key_in_map (')', rl_insert_close, emacs_standard_keymap);
|
||||
rl_bind_key_in_map (']', rl_insert_close, emacs_standard_keymap);
|
||||
rl_bind_key_in_map ('}', rl_insert_close, emacs_standard_keymap);
|
||||
}
|
||||
else
|
||||
{ /* ([{ */
|
||||
rl_bind_key_in_map (')', rl_insert, emacs_standard_keymap);
|
||||
rl_bind_key_in_map (']', rl_insert, emacs_standard_keymap);
|
||||
rl_bind_key_in_map ('}', rl_insert, emacs_standard_keymap);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rl_set_paren_blink_timeout (u)
|
||||
int u;
|
||||
{
|
||||
int o;
|
||||
|
||||
o = _paren_blink_usec;
|
||||
if (u > 0)
|
||||
_paren_blink_usec = u;
|
||||
return (o);
|
||||
}
|
||||
|
||||
int
|
||||
rl_insert_close (count, invoking_key)
|
||||
int count, invoking_key;
|
||||
{
|
||||
if (rl_explicit_arg || !rl_blink_matching_paren)
|
||||
_rl_insert_char (count, invoking_key);
|
||||
else
|
||||
{
|
||||
#if defined (HAVE_SELECT)
|
||||
int orig_point, match_point, ready;
|
||||
struct timeval timer;
|
||||
fd_set readfds;
|
||||
|
||||
_rl_insert_char (1, invoking_key);
|
||||
(*rl_redisplay_function) ();
|
||||
match_point =
|
||||
find_matching_open (rl_line_buffer, rl_point - 2, invoking_key);
|
||||
|
||||
/* Emacs might message or ring the bell here, but I don't. */
|
||||
if (match_point < 0)
|
||||
return -1;
|
||||
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (fileno (rl_instream), &readfds);
|
||||
timer.tv_sec = 0;
|
||||
timer.tv_usec = _paren_blink_usec;
|
||||
|
||||
orig_point = rl_point;
|
||||
rl_point = match_point;
|
||||
(*rl_redisplay_function) ();
|
||||
ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer);
|
||||
rl_point = orig_point;
|
||||
#else /* !HAVE_SELECT */
|
||||
_rl_insert_char (count, invoking_key);
|
||||
#endif /* !HAVE_SELECT */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find_matching_open (string, from, closer)
|
||||
char *string;
|
||||
int from, closer;
|
||||
{
|
||||
register int i;
|
||||
int opener, level, delimiter;
|
||||
|
||||
switch (closer)
|
||||
{
|
||||
case ']': opener = '['; break;
|
||||
case '}': opener = '{'; break;
|
||||
case ')': opener = '('; break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
|
||||
level = 1; /* The closer passed in counts as 1. */
|
||||
delimiter = 0; /* Delimited state unknown. */
|
||||
|
||||
for (i = from; i > -1; i--)
|
||||
{
|
||||
if (delimiter && (string[i] == delimiter))
|
||||
delimiter = 0;
|
||||
else if (rl_basic_quote_characters && strchr (rl_basic_quote_characters, string[i]))
|
||||
delimiter = string[i];
|
||||
else if (!delimiter && (string[i] == closer))
|
||||
level++;
|
||||
else if (!delimiter && (string[i] == opener))
|
||||
level--;
|
||||
|
||||
if (!level)
|
||||
break;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/* posixdir.h -- Posix directory reading includes and defines. */
|
||||
|
||||
/* Copyright (C) 1987,1991 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 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. */
|
||||
|
||||
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
|
||||
|
||||
#if !defined (_POSIXDIR_H_)
|
||||
#define _POSIXDIR_H_
|
||||
|
||||
#if defined (HAVE_DIRENT_H)
|
||||
# include <dirent.h>
|
||||
# define D_NAMLEN(d) (strlen ((d)->d_name))
|
||||
#else
|
||||
# if defined (HAVE_SYS_NDIR_H)
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if defined (HAVE_SYS_DIR_H)
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if defined (HAVE_NDIR_H)
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
# if !defined (dirent)
|
||||
# define dirent direct
|
||||
# endif /* !dirent */
|
||||
# define D_NAMLEN(d) ((d)->d_namlen)
|
||||
#endif /* !HAVE_DIRENT_H */
|
||||
|
||||
#if defined (STRUCT_DIRENT_HAS_D_INO) && !defined (STRUCT_DIRENT_HAS_D_FILENO)
|
||||
# define d_fileno d_ino
|
||||
#endif
|
||||
|
||||
#if defined (_POSIX_SOURCE) && (!defined (STRUCT_DIRENT_HAS_D_INO) || defined (BROKEN_DIRENT_D_INO))
|
||||
/* Posix does not require that the d_ino field be present, and some
|
||||
systems do not provide it. */
|
||||
# define REAL_DIR_ENTRY(dp) 1
|
||||
#else
|
||||
# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
|
||||
#endif /* _POSIX_SOURCE */
|
||||
|
||||
#endif /* !_POSIXDIR_H_ */
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
|
||||
|
||||
/* Copyright (C) 1987,1991 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 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. */
|
||||
|
||||
#ifndef _POSIXJMP_H_
|
||||
#define _POSIXJMP_H_
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
/* This *must* be included *after* config.h */
|
||||
|
||||
#if defined (HAVE_POSIX_SIGSETJMP)
|
||||
# define procenv_t sigjmp_buf
|
||||
# if !defined (__OPENNT)
|
||||
# undef setjmp
|
||||
# define setjmp(x) sigsetjmp((x), 1)
|
||||
# undef longjmp
|
||||
# define longjmp(x, n) siglongjmp((x), (n))
|
||||
# endif /* !__OPENNT */
|
||||
#else
|
||||
# define procenv_t jmp_buf
|
||||
#endif
|
||||
|
||||
#endif /* _POSIXJMP_H_ */
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
/* posixstat.h -- Posix stat(2) definitions for systems that
|
||||
don't have them. */
|
||||
|
||||
/* Copyright (C) 1987,1991 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 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. */
|
||||
|
||||
/* This file should be included instead of <sys/stat.h>.
|
||||
It relies on the local sys/stat.h to work though. */
|
||||
#if !defined (_POSIXSTAT_H_)
|
||||
#define _POSIXSTAT_H_
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined (STAT_MACROS_BROKEN)
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
# undef S_ISDIR
|
||||
# undef S_ISFIFO
|
||||
# undef S_ISREG
|
||||
# undef S_ISLNK
|
||||
#endif /* STAT_MACROS_BROKEN */
|
||||
|
||||
/* These are guaranteed to work only on isc386 */
|
||||
#if !defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
# define S_IFDIR 0040000
|
||||
#endif /* !S_IFDIR && !S_ISDIR */
|
||||
#if !defined (S_IFMT)
|
||||
# define S_IFMT 0170000
|
||||
#endif /* !S_IFMT */
|
||||
|
||||
/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
|
||||
|
||||
/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
|
||||
do not provide the S_IS* macros that Posix requires. */
|
||||
|
||||
#if defined (_S_IFMT) && !defined (S_IFMT)
|
||||
#define S_IFMT _S_IFMT
|
||||
#endif
|
||||
#if defined (_S_IFIFO) && !defined (S_IFIFO)
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#endif
|
||||
#if defined (_S_IFCHR) && !defined (S_IFCHR)
|
||||
#define S_IFCHR _S_IFCHR
|
||||
#endif
|
||||
#if defined (_S_IFDIR) && !defined (S_IFDIR)
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#endif
|
||||
#if defined (_S_IFBLK) && !defined (S_IFBLK)
|
||||
#define S_IFBLK _S_IFBLK
|
||||
#endif
|
||||
#if defined (_S_IFREG) && !defined (S_IFREG)
|
||||
#define S_IFREG _S_IFREG
|
||||
#endif
|
||||
#if defined (_S_IFLNK) && !defined (S_IFLNK)
|
||||
#define S_IFLNK _S_IFLNK
|
||||
#endif
|
||||
#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
|
||||
#define S_IFSOCK _S_IFSOCK
|
||||
#endif
|
||||
|
||||
/* Test for each symbol individually and define the ones necessary (some
|
||||
systems claiming Posix compatibility define some but not all). */
|
||||
|
||||
#if defined (S_IFBLK) && !defined (S_ISBLK)
|
||||
#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFCHR) && !defined (S_ISCHR)
|
||||
#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFREG) && !defined (S_ISREG)
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFIFO) && !defined (S_ISFIFO)
|
||||
#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFLNK) && !defined (S_ISLNK)
|
||||
#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFSOCK) && !defined (S_ISSOCK)
|
||||
#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
|
||||
*/
|
||||
|
||||
#if !defined (S_IRWXU)
|
||||
# if !defined (S_IREAD)
|
||||
# define S_IREAD 00400
|
||||
# define S_IWRITE 00200
|
||||
# define S_IEXEC 00100
|
||||
# endif /* S_IREAD */
|
||||
|
||||
# if !defined (S_IRUSR)
|
||||
# define S_IRUSR S_IREAD /* read, owner */
|
||||
# define S_IWUSR S_IWRITE /* write, owner */
|
||||
# define S_IXUSR S_IEXEC /* execute, owner */
|
||||
|
||||
# define S_IRGRP (S_IREAD >> 3) /* read, group */
|
||||
# define S_IWGRP (S_IWRITE >> 3) /* write, group */
|
||||
# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
|
||||
|
||||
# define S_IROTH (S_IREAD >> 6) /* read, other */
|
||||
# define S_IWOTH (S_IWRITE >> 6) /* write, other */
|
||||
# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
|
||||
# endif /* !S_IRUSR */
|
||||
|
||||
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
||||
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
||||
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
||||
#endif /* !S_IRWXU */
|
||||
|
||||
/* These are non-standard, but are used in builtins.c$symbolic_umask() */
|
||||
#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
|
||||
#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
|
||||
#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
|
||||
|
||||
#endif /* _POSIXSTAT_H_ */
|
||||
|
|
@ -0,0 +1,974 @@
|
|||
/* readline.c -- a general facility for reading lines of input
|
||||
with emacs style editing and completion. */
|
||||
|
||||
/* Copyright (C) 1987-2002 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "posixstat.h"
|
||||
#include <fcntl.h>
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif /* HAVE_SYS_FILE_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_LOCALE_H)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "posixjmp.h"
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#if defined (__EMX__)
|
||||
# define INCL_DOSPROCESS
|
||||
# include <os2.h>
|
||||
#endif /* __EMX__ */
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#ifndef RL_LIBRARY_VERSION
|
||||
# define RL_LIBRARY_VERSION "4.3"
|
||||
#endif
|
||||
|
||||
#ifndef RL_READLINE_VERSION
|
||||
# define RL_READLINE_VERSION 0x0403
|
||||
#endif
|
||||
|
||||
extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
/* Forward declarations used in this file. */
|
||||
static char *readline_internal PARAMS((void));
|
||||
static void readline_initialize_everything PARAMS((void));
|
||||
|
||||
static void bind_arrow_keys_internal PARAMS((Keymap));
|
||||
static void bind_arrow_keys PARAMS((void));
|
||||
|
||||
static void readline_default_bindings PARAMS((void));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Line editing input utility */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
const char *rl_library_version = RL_LIBRARY_VERSION;
|
||||
|
||||
int rl_readline_version = RL_READLINE_VERSION;
|
||||
|
||||
/* True if this is `real' readline as opposed to some stub substitute. */
|
||||
int rl_gnu_readline_p = 1;
|
||||
|
||||
/* A pointer to the keymap that is currently in use.
|
||||
By default, it is the standard emacs keymap. */
|
||||
Keymap _rl_keymap = emacs_standard_keymap;
|
||||
|
||||
/* The current style of editing. */
|
||||
int rl_editing_mode = emacs_mode;
|
||||
|
||||
/* The current insert mode: input (the default) or overwrite */
|
||||
int rl_insert_mode = RL_IM_DEFAULT;
|
||||
|
||||
/* Non-zero if we called this function from _rl_dispatch(). It's present
|
||||
so functions can find out whether they were called from a key binding
|
||||
or directly from an application. */
|
||||
int rl_dispatching;
|
||||
|
||||
/* Non-zero if the previous command was a kill command. */
|
||||
int _rl_last_command_was_kill = 0;
|
||||
|
||||
/* The current value of the numeric argument specified by the user. */
|
||||
int rl_numeric_arg = 1;
|
||||
|
||||
/* Non-zero if an argument was typed. */
|
||||
int rl_explicit_arg = 0;
|
||||
|
||||
/* Temporary value used while generating the argument. */
|
||||
int rl_arg_sign = 1;
|
||||
|
||||
/* Non-zero means we have been called at least once before. */
|
||||
static int rl_initialized;
|
||||
|
||||
#if 0
|
||||
/* If non-zero, this program is running in an EMACS buffer. */
|
||||
static int running_in_emacs;
|
||||
#endif
|
||||
|
||||
/* Flags word encapsulating the current readline state. */
|
||||
int rl_readline_state = RL_STATE_NONE;
|
||||
|
||||
/* The current offset in the current input line. */
|
||||
int rl_point;
|
||||
|
||||
/* Mark in the current input line. */
|
||||
int rl_mark;
|
||||
|
||||
/* Length of the current input line. */
|
||||
int rl_end;
|
||||
|
||||
/* Make this non-zero to return the current input_line. */
|
||||
int rl_done;
|
||||
|
||||
/* The last function executed by readline. */
|
||||
rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
|
||||
|
||||
/* Top level environment for readline_internal (). */
|
||||
procenv_t readline_top_level;
|
||||
|
||||
/* The streams we interact with. */
|
||||
FILE *_rl_in_stream, *_rl_out_stream;
|
||||
|
||||
/* The names of the streams that we do input and output to. */
|
||||
FILE *rl_instream = (FILE *)NULL;
|
||||
FILE *rl_outstream = (FILE *)NULL;
|
||||
|
||||
/* Non-zero means echo characters as they are read. Defaults to no echo;
|
||||
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;
|
||||
|
||||
/* Current prompt. */
|
||||
char *rl_prompt = (char *)NULL;
|
||||
int rl_visible_prompt_length = 0;
|
||||
|
||||
/* Set to non-zero by calling application if it has already printed rl_prompt
|
||||
and does not want readline to do it the first time. */
|
||||
int rl_already_prompted = 0;
|
||||
|
||||
/* The number of characters read in order to type this complete command. */
|
||||
int rl_key_sequence_length = 0;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal_setup () prints the first prompt. */
|
||||
rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
|
||||
|
||||
/* If non-zero, this is the address of a function to call just before
|
||||
readline_internal_setup () returns and readline_internal starts
|
||||
reading input characters. */
|
||||
rl_hook_func_t *rl_pre_input_hook = (rl_hook_func_t *)NULL;
|
||||
|
||||
/* What we use internally. You should always refer to RL_LINE_BUFFER. */
|
||||
static char *the_line;
|
||||
|
||||
/* The character that can generate an EOF. Really read from
|
||||
the terminal driver... just defaulted here. */
|
||||
int _rl_eof_char = CTRL ('D');
|
||||
|
||||
/* Non-zero makes this the next keystroke to read. */
|
||||
int rl_pending_input = 0;
|
||||
|
||||
/* Pointer to a useful terminal name. */
|
||||
const char *rl_terminal_name = (const char *)NULL;
|
||||
|
||||
/* Non-zero means to always use horizontal scrolling in line display. */
|
||||
int _rl_horizontal_scroll_mode = 0;
|
||||
|
||||
/* Non-zero means to display an asterisk at the starts of history lines
|
||||
which have been modified. */
|
||||
int _rl_mark_modified_lines = 0;
|
||||
|
||||
/* The style of `bell' notification preferred. This can be set to NO_BELL,
|
||||
AUDIBLE_BELL, or VISIBLE_BELL. */
|
||||
int _rl_bell_preference = AUDIBLE_BELL;
|
||||
|
||||
/* String inserted into the line by rl_insert_comment (). */
|
||||
char *_rl_comment_begin;
|
||||
|
||||
/* Keymap holding the function currently being executed. */
|
||||
Keymap rl_executing_keymap;
|
||||
|
||||
/* Non-zero means to erase entire line, including prompt, on empty input lines. */
|
||||
int rl_erase_empty_line = 0;
|
||||
|
||||
/* Non-zero means to read only this many characters rather than up to a
|
||||
character bound to accept-line. */
|
||||
int rl_num_chars_to_read;
|
||||
|
||||
/* Line buffer and maintenence. */
|
||||
char *rl_line_buffer = (char *)NULL;
|
||||
int rl_line_buffer_len = 0;
|
||||
|
||||
/* Forward declarations used by the display, termcap, and history code. */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* `Forward' declarations */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Non-zero means do not parse any lines other than comments and
|
||||
parser directives. */
|
||||
unsigned char _rl_parsing_conditionalized_out = 0;
|
||||
|
||||
/* Non-zero means to convert characters with the meta bit set to
|
||||
escape-prefixed characters so we can indirect through
|
||||
emacs_meta_keymap or vi_escape_keymap. */
|
||||
int _rl_convert_meta_chars_to_ascii = 1;
|
||||
|
||||
/* Non-zero means to output characters with the meta bit set directly
|
||||
rather than as a meta-prefixed escape sequence. */
|
||||
int _rl_output_meta_chars = 0;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Top Level Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Non-zero means treat 0200 bit in terminal input as Meta bit. */
|
||||
int _rl_meta_flag = 0; /* Forward declaration */
|
||||
|
||||
/* Set up the prompt and expand it. Called from readline() and
|
||||
rl_callback_handler_install (). */
|
||||
int
|
||||
rl_set_prompt (prompt)
|
||||
const char *prompt;
|
||||
{
|
||||
FREE (rl_prompt);
|
||||
rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
|
||||
|
||||
rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read a line of input. Prompt with PROMPT. An empty PROMPT means
|
||||
none. A return value of NULL means that EOF was encountered. */
|
||||
char *
|
||||
readline (prompt)
|
||||
const char *prompt;
|
||||
{
|
||||
char *value;
|
||||
|
||||
/* If we are at EOF return a NULL string. */
|
||||
if (rl_pending_input == EOF)
|
||||
{
|
||||
rl_clear_pending_input ();
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
rl_set_prompt (prompt);
|
||||
|
||||
rl_initialize ();
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_set_signals ();
|
||||
#endif
|
||||
|
||||
value = readline_internal ();
|
||||
(*rl_deprep_term_function) ();
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
# define STATIC_CALLBACK
|
||||
#else
|
||||
# define STATIC_CALLBACK static
|
||||
#endif
|
||||
|
||||
STATIC_CALLBACK void
|
||||
readline_internal_setup ()
|
||||
{
|
||||
char *nprompt;
|
||||
|
||||
_rl_in_stream = rl_instream;
|
||||
_rl_out_stream = rl_outstream;
|
||||
|
||||
if (rl_startup_hook)
|
||||
(*rl_startup_hook) ();
|
||||
|
||||
/* 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_prompt && rl_already_prompted == 0)
|
||||
{
|
||||
nprompt = _rl_strip_prompt (rl_prompt);
|
||||
fprintf (_rl_out_stream, "%s", nprompt);
|
||||
fflush (_rl_out_stream);
|
||||
free (nprompt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rl_prompt && rl_already_prompted)
|
||||
rl_on_new_line_with_prompt ();
|
||||
else
|
||||
rl_on_new_line ();
|
||||
(*rl_redisplay_function) ();
|
||||
}
|
||||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
rl_vi_insertion_mode (1, 0);
|
||||
#endif /* VI_MODE */
|
||||
|
||||
if (rl_pre_input_hook)
|
||||
(*rl_pre_input_hook) ();
|
||||
}
|
||||
|
||||
STATIC_CALLBACK char *
|
||||
readline_internal_teardown (eof)
|
||||
int eof;
|
||||
{
|
||||
char *temp;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
/* 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 ();
|
||||
|
||||
if (entry && rl_undo_list)
|
||||
{
|
||||
temp = savestring (the_line);
|
||||
rl_revert_line (1, 0);
|
||||
entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
|
||||
_rl_free_history_entry (entry);
|
||||
|
||||
strcpy (the_line, temp);
|
||||
free (temp);
|
||||
}
|
||||
|
||||
/* At any rate, it is highly likely that this line has an undo list. Get
|
||||
rid of it now. */
|
||||
if (rl_undo_list)
|
||||
rl_free_undo_list ();
|
||||
|
||||
/* Restore normal cursor, if available. */
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 0);
|
||||
|
||||
return (eof ? (char *)NULL : savestring (the_line));
|
||||
}
|
||||
|
||||
STATIC_CALLBACK int
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
readline_internal_char ()
|
||||
#else
|
||||
readline_internal_charloop ()
|
||||
#endif
|
||||
{
|
||||
static int lastc, eof_found;
|
||||
int c, code, lk;
|
||||
|
||||
lastc = -1;
|
||||
eof_found = 0;
|
||||
|
||||
#if !defined (READLINE_CALLBACKS)
|
||||
while (rl_done == 0)
|
||||
{
|
||||
#endif
|
||||
lk = _rl_last_command_was_kill;
|
||||
|
||||
code = setjmp (readline_top_level);
|
||||
|
||||
if (code)
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
if (rl_pending_input == 0)
|
||||
{
|
||||
/* Then initialize the argument and number of keys read. */
|
||||
_rl_init_argument ();
|
||||
rl_key_sequence_length = 0;
|
||||
}
|
||||
|
||||
RL_SETSTATE(RL_STATE_READCMD);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_READCMD);
|
||||
|
||||
/* EOF typed to a non-blank line is a <NL>. */
|
||||
if (c == EOF && rl_end)
|
||||
c = NEWLINE;
|
||||
|
||||
/* The character _rl_eof_char typed to blank line, and not as the
|
||||
previous character is interpreted as EOF. */
|
||||
if (((c == _rl_eof_char && lastc != c) || c == EOF) && !rl_end)
|
||||
{
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
RL_SETSTATE(RL_STATE_DONE);
|
||||
return (rl_done = 1);
|
||||
#else
|
||||
eof_found = 1;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
lastc = c;
|
||||
_rl_dispatch ((unsigned char)c, _rl_keymap);
|
||||
|
||||
/* 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
|
||||
a prefix command, so nothing has changed yet. */
|
||||
if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
|
||||
_rl_last_command_was_kill = 0;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
/* In vi mode, when you exit insert mode, the cursor moves back
|
||||
over the previous character. We explicitly check for that here. */
|
||||
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
|
||||
rl_vi_check ();
|
||||
#endif /* VI_MODE */
|
||||
|
||||
if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
rl_newline (1, '\n');
|
||||
}
|
||||
|
||||
if (rl_done == 0)
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
/* If the application writer has told us to erase the entire line if
|
||||
the only character typed was something bound to rl_newline, do so. */
|
||||
if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
|
||||
rl_point == 0 && rl_end == 0)
|
||||
_rl_erase_entire_line ();
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
return 0;
|
||||
#else
|
||||
}
|
||||
|
||||
return (eof_found);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
static int
|
||||
readline_internal_charloop ()
|
||||
{
|
||||
int eof = 1;
|
||||
|
||||
while (rl_done == 0)
|
||||
eof = readline_internal_char ();
|
||||
return (eof);
|
||||
}
|
||||
#endif /* READLINE_CALLBACKS */
|
||||
|
||||
/* Read a line of input from the global rl_instream, doing output on
|
||||
the global rl_outstream.
|
||||
If rl_prompt is non-null, then that is our prompt. */
|
||||
static char *
|
||||
readline_internal ()
|
||||
{
|
||||
int eof;
|
||||
|
||||
readline_internal_setup ();
|
||||
eof = readline_internal_charloop ();
|
||||
return (readline_internal_teardown (eof));
|
||||
}
|
||||
|
||||
void
|
||||
_rl_init_line_state ()
|
||||
{
|
||||
rl_point = rl_end = rl_mark = 0;
|
||||
the_line = rl_line_buffer;
|
||||
the_line[0] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_set_the_line ()
|
||||
{
|
||||
the_line = rl_line_buffer;
|
||||
}
|
||||
|
||||
/* Do the command associated with KEY in MAP.
|
||||
If the associated command is really a keymap, then read
|
||||
another key, and dispatch into that map. */
|
||||
int
|
||||
_rl_dispatch (key, map)
|
||||
register int key;
|
||||
Keymap map;
|
||||
{
|
||||
return _rl_dispatch_subseq (key, map, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_rl_dispatch_subseq (key, map, got_subseq)
|
||||
register int key;
|
||||
Keymap map;
|
||||
int got_subseq;
|
||||
{
|
||||
int r, newkey;
|
||||
char *macro;
|
||||
rl_command_func_t *func;
|
||||
|
||||
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
|
||||
{
|
||||
if (map[ESC].type == ISKMAP)
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF))
|
||||
_rl_add_macro_char (ESC);
|
||||
map = FUNCTION_TO_KEYMAP (map, ESC);
|
||||
key = UNMETA (key);
|
||||
rl_key_sequence_length += 2;
|
||||
return (_rl_dispatch (key, map));
|
||||
}
|
||||
else
|
||||
rl_ding ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF))
|
||||
_rl_add_macro_char (key);
|
||||
|
||||
r = 0;
|
||||
switch (map[key].type)
|
||||
{
|
||||
case ISFUNC:
|
||||
func = map[key].function;
|
||||
if (func)
|
||||
{
|
||||
/* Special case rl_do_lowercase_version (). */
|
||||
if (func == rl_do_lowercase_version)
|
||||
return (_rl_dispatch (_rl_to_lower (key), map));
|
||||
|
||||
rl_executing_keymap = map;
|
||||
|
||||
#if 0
|
||||
_rl_suppress_redisplay = (map[key].function == rl_insert) && _rl_input_available ();
|
||||
#endif
|
||||
|
||||
rl_dispatching = 1;
|
||||
RL_SETSTATE(RL_STATE_DISPATCHING);
|
||||
r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
|
||||
RL_UNSETSTATE(RL_STATE_DISPATCHING);
|
||||
rl_dispatching = 0;
|
||||
|
||||
/* If we have input pending, then the last command was a prefix
|
||||
command. Don't change the state of rl_last_func. Otherwise,
|
||||
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;
|
||||
}
|
||||
else if (map[ANYOTHERKEY].function)
|
||||
{
|
||||
/* OK, there's no function bound in this map, but there is a
|
||||
shadow function that was overridden when the current keymap
|
||||
was created. Return -2 to note that. */
|
||||
_rl_unget_char (key);
|
||||
return -2;
|
||||
}
|
||||
else if (got_subseq)
|
||||
{
|
||||
/* Return -1 to note that we're in a subsequence, but we don't
|
||||
have a matching key, nor was one overridden. This means
|
||||
we need to back up the recursion chain and find the last
|
||||
subsequence that is bound to a function. */
|
||||
_rl_unget_char (key);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case ISKMAP:
|
||||
if (map[key].function != 0)
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
/* The only way this test will be true is if a subsequence has been
|
||||
bound starting with ESC, generally the arrow keys. What we do is
|
||||
check whether there's input in the queue, which there generally
|
||||
will be if an arrow key has been pressed, and, if there's not,
|
||||
just dispatch to (what we assume is) rl_vi_movement_mode right
|
||||
away. This is essentially an input test with a zero timeout. */
|
||||
if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap
|
||||
&& _rl_input_queued (0) == 0)
|
||||
return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
|
||||
#endif
|
||||
|
||||
rl_key_sequence_length++;
|
||||
|
||||
if (key == ESC)
|
||||
RL_SETSTATE(RL_STATE_METANEXT);
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
newkey = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
if (key == ESC)
|
||||
RL_UNSETSTATE(RL_STATE_METANEXT);
|
||||
|
||||
if (newkey < 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = _rl_dispatch_subseq (newkey, FUNCTION_TO_KEYMAP (map, key), got_subseq || map[ANYOTHERKEY].function);
|
||||
|
||||
if (r == -2)
|
||||
/* We didn't match anything, and the keymap we're indexed into
|
||||
shadowed a function previously bound to that prefix. Call
|
||||
the function. The recursive call to _rl_dispatch_subseq has
|
||||
already taken care of pushing any necessary input back onto
|
||||
the input queue with _rl_unget_char. */
|
||||
r = _rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key));
|
||||
else if (r && map[ANYOTHERKEY].function)
|
||||
{
|
||||
/* We didn't match (r is probably -1), so return something to
|
||||
tell the caller that it should try ANYOTHERKEY for an
|
||||
overridden function. */
|
||||
_rl_unget_char (key);
|
||||
return -2;
|
||||
}
|
||||
else if (r && got_subseq)
|
||||
{
|
||||
/* OK, back up the chain. */
|
||||
_rl_unget_char (key);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case ISMACR:
|
||||
if (map[key].function != 0)
|
||||
{
|
||||
macro = savestring ((char *)map[key].function);
|
||||
_rl_with_macro_input (macro);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
|
||||
key != ANYOTHERKEY &&
|
||||
_rl_vi_textmod_command (key))
|
||||
_rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
|
||||
#endif
|
||||
return (r);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Initializations */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Initialize readline (and terminal if not already). */
|
||||
int
|
||||
rl_initialize ()
|
||||
{
|
||||
/* If we have never been called before, initialize the
|
||||
terminal and data structures. */
|
||||
if (!rl_initialized)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_INITIALIZING);
|
||||
readline_initialize_everything ();
|
||||
RL_UNSETSTATE(RL_STATE_INITIALIZING);
|
||||
rl_initialized++;
|
||||
RL_SETSTATE(RL_STATE_INITIALIZED);
|
||||
}
|
||||
|
||||
/* Initialize the current line information. */
|
||||
_rl_init_line_state ();
|
||||
|
||||
/* We aren't done yet. We haven't even gotten started yet! */
|
||||
rl_done = 0;
|
||||
RL_UNSETSTATE(RL_STATE_DONE);
|
||||
|
||||
/* Tell the history routines what is going on. */
|
||||
_rl_start_using_history ();
|
||||
|
||||
/* Make the display buffer match the state of the line. */
|
||||
rl_reset_line_state ();
|
||||
|
||||
/* No such function typed yet. */
|
||||
rl_last_func = (rl_command_func_t *)NULL;
|
||||
|
||||
/* Parsing of key-bindings begins in an enabled state. */
|
||||
_rl_parsing_conditionalized_out = 0;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
_rl_vi_initialize_line ();
|
||||
#endif
|
||||
|
||||
/* Each line starts in insert mode (the default). */
|
||||
_rl_set_insert_mode (RL_IM_DEFAULT, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if defined (__EMX__)
|
||||
static void
|
||||
_emx_build_environ ()
|
||||
{
|
||||
TIB *tibp;
|
||||
PIB *pibp;
|
||||
char *t, **tp;
|
||||
int c;
|
||||
|
||||
DosGetInfoBlocks (&tibp, &pibp);
|
||||
t = pibp->pib_pchenv;
|
||||
for (c = 1; *t; c++)
|
||||
t += strlen (t) + 1;
|
||||
tp = environ = (char **)xmalloc ((c + 1) * sizeof (char *));
|
||||
t = pibp->pib_pchenv;
|
||||
while (*t)
|
||||
{
|
||||
*tp++ = t;
|
||||
t += strlen (t) + 1;
|
||||
}
|
||||
*tp = 0;
|
||||
}
|
||||
#endif /* __EMX__ */
|
||||
#endif
|
||||
|
||||
/* Initialize the entire state of the world. */
|
||||
static void
|
||||
readline_initialize_everything ()
|
||||
{
|
||||
#if 0
|
||||
#if defined (__EMX__)
|
||||
if (environ == 0)
|
||||
_emx_build_environ ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Find out if we are running in Emacs -- UNUSED. */
|
||||
running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
|
||||
#endif
|
||||
|
||||
/* Set up input and output if they are not already set up. */
|
||||
if (!rl_instream)
|
||||
rl_instream = stdin;
|
||||
|
||||
if (!rl_outstream)
|
||||
rl_outstream = stdout;
|
||||
|
||||
/* Bind _rl_in_stream and _rl_out_stream immediately. These values
|
||||
may change, but they may also be used before readline_internal ()
|
||||
is called. */
|
||||
_rl_in_stream = rl_instream;
|
||||
_rl_out_stream = rl_outstream;
|
||||
|
||||
/* Allocate data structures. */
|
||||
if (rl_line_buffer == 0)
|
||||
rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
|
||||
|
||||
/* Initialize the terminal interface. */
|
||||
if (rl_terminal_name == 0)
|
||||
rl_terminal_name = sh_get_env_value ("TERM");
|
||||
_rl_init_terminal_io (rl_terminal_name);
|
||||
|
||||
/* Bind tty characters to readline functions. */
|
||||
readline_default_bindings ();
|
||||
|
||||
/* Initialize the function names. */
|
||||
rl_initialize_funmap ();
|
||||
|
||||
/* Decide whether we should automatically go into eight-bit mode. */
|
||||
_rl_init_eightbit ();
|
||||
|
||||
/* Read in the init file. */
|
||||
rl_read_init_file ((char *)NULL);
|
||||
|
||||
/* XXX */
|
||||
if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
|
||||
{
|
||||
_rl_screenwidth--;
|
||||
_rl_screenchars -= _rl_screenheight;
|
||||
}
|
||||
|
||||
/* Override the effect of any `set keymap' assignments in the
|
||||
inputrc file. */
|
||||
rl_set_keymap_from_edit_mode ();
|
||||
|
||||
/* Try to bind a common arrow key prefix, if not already bound. */
|
||||
bind_arrow_keys ();
|
||||
|
||||
/* Enable the meta key, if this terminal has one. */
|
||||
if (_rl_enable_meta)
|
||||
_rl_enable_meta_key ();
|
||||
|
||||
/* If the completion parser's default word break characters haven't
|
||||
been set yet, then do so now. */
|
||||
if (rl_completer_word_break_characters == (char *)NULL)
|
||||
rl_completer_word_break_characters = rl_basic_word_break_characters;
|
||||
}
|
||||
|
||||
/* If this system allows us to look at the values of the regular
|
||||
input editing characters, then bind them to their readline
|
||||
equivalents, iff the characters are not bound to keymaps. */
|
||||
static void
|
||||
readline_default_bindings ()
|
||||
{
|
||||
rl_tty_set_default_bindings (_rl_keymap);
|
||||
}
|
||||
|
||||
/* Bind some common arrow key sequences in MAP. */
|
||||
static void
|
||||
bind_arrow_keys_internal (map)
|
||||
Keymap map;
|
||||
{
|
||||
Keymap xkeymap;
|
||||
|
||||
xkeymap = _rl_keymap;
|
||||
_rl_keymap = map;
|
||||
|
||||
#if defined (__MSDOS__)
|
||||
_rl_bind_if_unbound ("\033[0A", rl_get_previous_history);
|
||||
_rl_bind_if_unbound ("\033[0B", rl_backward_char);
|
||||
_rl_bind_if_unbound ("\033[0C", rl_forward_char);
|
||||
_rl_bind_if_unbound ("\033[0D", rl_get_next_history);
|
||||
#endif
|
||||
|
||||
_rl_bind_if_unbound ("\033[A", rl_get_previous_history);
|
||||
_rl_bind_if_unbound ("\033[B", rl_get_next_history);
|
||||
_rl_bind_if_unbound ("\033[C", rl_forward_char);
|
||||
_rl_bind_if_unbound ("\033[D", rl_backward_char);
|
||||
_rl_bind_if_unbound ("\033[H", rl_beg_of_line);
|
||||
_rl_bind_if_unbound ("\033[F", rl_end_of_line);
|
||||
|
||||
_rl_bind_if_unbound ("\033OA", rl_get_previous_history);
|
||||
_rl_bind_if_unbound ("\033OB", rl_get_next_history);
|
||||
_rl_bind_if_unbound ("\033OC", rl_forward_char);
|
||||
_rl_bind_if_unbound ("\033OD", rl_backward_char);
|
||||
_rl_bind_if_unbound ("\033OH", rl_beg_of_line);
|
||||
_rl_bind_if_unbound ("\033OF", rl_end_of_line);
|
||||
|
||||
_rl_keymap = xkeymap;
|
||||
}
|
||||
|
||||
/* Try and bind the common arrow key prefixes after giving termcap and
|
||||
the inputrc file a chance to bind them and create `real' keymaps
|
||||
for the arrow key prefix. */
|
||||
static void
|
||||
bind_arrow_keys ()
|
||||
{
|
||||
bind_arrow_keys_internal (emacs_standard_keymap);
|
||||
|
||||
#if defined (VI_MODE)
|
||||
bind_arrow_keys_internal (vi_movement_keymap);
|
||||
bind_arrow_keys_internal (vi_insertion_keymap);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Saving and Restoring Readline's state */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
int
|
||||
rl_save_state (sp)
|
||||
struct readline_state *sp;
|
||||
{
|
||||
if (sp == 0)
|
||||
return -1;
|
||||
|
||||
sp->point = rl_point;
|
||||
sp->end = rl_end;
|
||||
sp->mark = rl_mark;
|
||||
sp->buffer = rl_line_buffer;
|
||||
sp->buflen = rl_line_buffer_len;
|
||||
sp->ul = rl_undo_list;
|
||||
sp->prompt = rl_prompt;
|
||||
|
||||
sp->rlstate = rl_readline_state;
|
||||
sp->done = rl_done;
|
||||
sp->kmap = _rl_keymap;
|
||||
|
||||
sp->lastfunc = rl_last_func;
|
||||
sp->insmode = rl_insert_mode;
|
||||
sp->edmode = rl_editing_mode;
|
||||
sp->kseqlen = rl_key_sequence_length;
|
||||
sp->inf = rl_instream;
|
||||
sp->outf = rl_outstream;
|
||||
sp->pendingin = rl_pending_input;
|
||||
sp->macro = rl_executing_macro;
|
||||
|
||||
sp->catchsigs = rl_catch_signals;
|
||||
sp->catchsigwinch = rl_catch_sigwinch;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
rl_restore_state (sp)
|
||||
struct readline_state *sp;
|
||||
{
|
||||
if (sp == 0)
|
||||
return -1;
|
||||
|
||||
rl_point = sp->point;
|
||||
rl_end = sp->end;
|
||||
rl_mark = sp->mark;
|
||||
the_line = rl_line_buffer = sp->buffer;
|
||||
rl_line_buffer_len = sp->buflen;
|
||||
rl_undo_list = sp->ul;
|
||||
rl_prompt = sp->prompt;
|
||||
|
||||
rl_readline_state = sp->rlstate;
|
||||
rl_done = sp->done;
|
||||
_rl_keymap = sp->kmap;
|
||||
|
||||
rl_last_func = sp->lastfunc;
|
||||
rl_insert_mode = sp->insmode;
|
||||
rl_editing_mode = sp->edmode;
|
||||
rl_key_sequence_length = sp->kseqlen;
|
||||
rl_instream = sp->inf;
|
||||
rl_outstream = sp->outf;
|
||||
rl_pending_input = sp->pendingin;
|
||||
rl_executing_macro = sp->macro;
|
||||
|
||||
rl_catch_signals = sp->catchsigs;
|
||||
rl_catch_sigwinch = sp->catchsigwinch;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -0,0 +1,799 @@
|
|||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if !defined (_READLINE_H_)
|
||||
#define _READLINE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "rlstdc.h"
|
||||
# include "rltypedefs.h"
|
||||
# include "keymaps.h"
|
||||
# include "tilde.h"
|
||||
#else
|
||||
# include <readline/rlstdc.h>
|
||||
# include <readline/rltypedefs.h>
|
||||
# include <readline/keymaps.h>
|
||||
# include <readline/tilde.h>
|
||||
#endif
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0403 /* Readline 4.3 */
|
||||
#define RL_VERSION_MAJOR 4
|
||||
#define RL_VERSION_MINOR 3
|
||||
|
||||
/* Readline data structures. */
|
||||
|
||||
/* Maintaining the state of undo. We remember individual deletes and inserts
|
||||
on a chain of things to do. */
|
||||
|
||||
/* The actions that undo knows how to undo. Notice that UNDO_DELETE means
|
||||
to insert some text, and UNDO_INSERT means to delete some text. I.e.,
|
||||
the code tells undo what to undo, not how to undo it. */
|
||||
enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
|
||||
|
||||
/* What an element of THE_UNDO_LIST looks like. */
|
||||
typedef struct undo_list {
|
||||
struct undo_list *next;
|
||||
int start, end; /* Where the change took place. */
|
||||
char *text; /* The text to insert, if undoing a delete. */
|
||||
enum undo_code what; /* Delete, Insert, Begin, End. */
|
||||
} UNDO_LIST;
|
||||
|
||||
/* The current undo list for RL_LINE_BUFFER. */
|
||||
extern UNDO_LIST *rl_undo_list;
|
||||
|
||||
/* The data structure for mapping textual names to code addresses. */
|
||||
typedef struct _funmap {
|
||||
const char *name;
|
||||
rl_command_func_t *function;
|
||||
} FUNMAP;
|
||||
|
||||
extern FUNMAP **funmap;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions available to bind to key sequences */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Bindable commands for numeric arguments. */
|
||||
extern int rl_digit_argument PARAMS((int, int));
|
||||
extern int rl_universal_argument PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for moving the cursor. */
|
||||
extern int rl_forward_byte PARAMS((int, int));
|
||||
extern int rl_forward_char PARAMS((int, int));
|
||||
extern int rl_forward PARAMS((int, int));
|
||||
extern int rl_backward_byte PARAMS((int, int));
|
||||
extern int rl_backward_char PARAMS((int, int));
|
||||
extern int rl_backward PARAMS((int, int));
|
||||
extern int rl_beg_of_line PARAMS((int, int));
|
||||
extern int rl_end_of_line PARAMS((int, int));
|
||||
extern int rl_forward_word PARAMS((int, int));
|
||||
extern int rl_backward_word PARAMS((int, int));
|
||||
extern int rl_refresh_line PARAMS((int, int));
|
||||
extern int rl_clear_screen PARAMS((int, int));
|
||||
extern int rl_arrow_keys PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for inserting and deleting text. */
|
||||
extern int rl_insert PARAMS((int, int));
|
||||
extern int rl_quoted_insert PARAMS((int, int));
|
||||
extern int rl_tab_insert PARAMS((int, int));
|
||||
extern int rl_newline PARAMS((int, int));
|
||||
extern int rl_do_lowercase_version PARAMS((int, int));
|
||||
extern int rl_rubout PARAMS((int, int));
|
||||
extern int rl_delete PARAMS((int, int));
|
||||
extern int rl_rubout_or_delete PARAMS((int, int));
|
||||
extern int rl_delete_horizontal_space PARAMS((int, int));
|
||||
extern int rl_delete_or_show_completions PARAMS((int, int));
|
||||
extern int rl_insert_comment PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for changing case. */
|
||||
extern int rl_upcase_word PARAMS((int, int));
|
||||
extern int rl_downcase_word PARAMS((int, int));
|
||||
extern int rl_capitalize_word PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for transposing characters and words. */
|
||||
extern int rl_transpose_words PARAMS((int, int));
|
||||
extern int rl_transpose_chars PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for searching within a line. */
|
||||
extern int rl_char_search PARAMS((int, int));
|
||||
extern int rl_backward_char_search PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for readline's interface to the command history. */
|
||||
extern int rl_beginning_of_history PARAMS((int, int));
|
||||
extern int rl_end_of_history PARAMS((int, int));
|
||||
extern int rl_get_next_history PARAMS((int, int));
|
||||
extern int rl_get_previous_history PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for managing the mark and region. */
|
||||
extern int rl_set_mark PARAMS((int, int));
|
||||
extern int rl_exchange_point_and_mark PARAMS((int, int));
|
||||
|
||||
/* Bindable commands to set the editing mode (emacs or vi). */
|
||||
extern int rl_vi_editing_mode PARAMS((int, int));
|
||||
extern int rl_emacs_editing_mode PARAMS((int, int));
|
||||
|
||||
/* Bindable commands to change the insert mode (insert or overwrite) */
|
||||
extern int rl_overwrite_mode PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for managing key bindings. */
|
||||
extern int rl_re_read_init_file PARAMS((int, int));
|
||||
extern int rl_dump_functions PARAMS((int, int));
|
||||
extern int rl_dump_macros PARAMS((int, int));
|
||||
extern int rl_dump_variables PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for word completion. */
|
||||
extern int rl_complete PARAMS((int, int));
|
||||
extern int rl_possible_completions PARAMS((int, int));
|
||||
extern int rl_insert_completions PARAMS((int, int));
|
||||
extern int rl_menu_complete PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for killing and yanking text, and managing the kill ring. */
|
||||
extern int rl_kill_word PARAMS((int, int));
|
||||
extern int rl_backward_kill_word PARAMS((int, int));
|
||||
extern int rl_kill_line PARAMS((int, int));
|
||||
extern int rl_backward_kill_line PARAMS((int, int));
|
||||
extern int rl_kill_full_line PARAMS((int, int));
|
||||
extern int rl_unix_word_rubout PARAMS((int, int));
|
||||
extern int rl_unix_line_discard PARAMS((int, int));
|
||||
extern int rl_copy_region_to_kill PARAMS((int, int));
|
||||
extern int rl_kill_region PARAMS((int, int));
|
||||
extern int rl_copy_forward_word PARAMS((int, int));
|
||||
extern int rl_copy_backward_word PARAMS((int, int));
|
||||
extern int rl_yank PARAMS((int, int));
|
||||
extern int rl_yank_pop PARAMS((int, int));
|
||||
extern int rl_yank_nth_arg PARAMS((int, int));
|
||||
extern int rl_yank_last_arg PARAMS((int, int));
|
||||
/* Not available unless __CYGWIN__ is defined. */
|
||||
#ifdef __CYGWIN__
|
||||
extern int rl_paste_from_clipboard PARAMS((int, int));
|
||||
#endif
|
||||
|
||||
/* Bindable commands for incremental searching. */
|
||||
extern int rl_reverse_search_history PARAMS((int, int));
|
||||
extern int rl_forward_search_history PARAMS((int, int));
|
||||
|
||||
/* Bindable keyboard macro commands. */
|
||||
extern int rl_start_kbd_macro PARAMS((int, int));
|
||||
extern int rl_end_kbd_macro PARAMS((int, int));
|
||||
extern int rl_call_last_kbd_macro PARAMS((int, int));
|
||||
|
||||
/* Bindable undo commands. */
|
||||
extern int rl_revert_line PARAMS((int, int));
|
||||
extern int rl_undo_command PARAMS((int, int));
|
||||
|
||||
/* Bindable tilde expansion commands. */
|
||||
extern int rl_tilde_expand PARAMS((int, int));
|
||||
|
||||
/* Bindable terminal control commands. */
|
||||
extern int rl_restart_output PARAMS((int, int));
|
||||
extern int rl_stop_output PARAMS((int, int));
|
||||
|
||||
/* Miscellaneous bindable commands. */
|
||||
extern int rl_abort PARAMS((int, int));
|
||||
extern int rl_tty_status PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for incremental and non-incremental history searching. */
|
||||
extern int rl_history_search_forward PARAMS((int, int));
|
||||
extern int rl_history_search_backward PARAMS((int, int));
|
||||
extern int rl_noninc_forward_search PARAMS((int, int));
|
||||
extern int rl_noninc_reverse_search PARAMS((int, int));
|
||||
extern int rl_noninc_forward_search_again PARAMS((int, int));
|
||||
extern int rl_noninc_reverse_search_again PARAMS((int, int));
|
||||
|
||||
/* Bindable command used when inserting a matching close character. */
|
||||
extern int rl_insert_close PARAMS((int, int));
|
||||
|
||||
/* Not available unless READLINE_CALLBACKS is defined. */
|
||||
extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
|
||||
extern void rl_callback_read_char PARAMS((void));
|
||||
extern void rl_callback_handler_remove PARAMS((void));
|
||||
|
||||
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
|
||||
/* VI-mode bindable commands. */
|
||||
extern int rl_vi_redo PARAMS((int, int));
|
||||
extern int rl_vi_undo PARAMS((int, int));
|
||||
extern int rl_vi_yank_arg PARAMS((int, int));
|
||||
extern int rl_vi_fetch_history PARAMS((int, int));
|
||||
extern int rl_vi_search_again PARAMS((int, int));
|
||||
extern int rl_vi_search PARAMS((int, int));
|
||||
extern int rl_vi_complete PARAMS((int, int));
|
||||
extern int rl_vi_tilde_expand PARAMS((int, int));
|
||||
extern int rl_vi_prev_word PARAMS((int, int));
|
||||
extern int rl_vi_next_word PARAMS((int, int));
|
||||
extern int rl_vi_end_word PARAMS((int, int));
|
||||
extern int rl_vi_insert_beg PARAMS((int, int));
|
||||
extern int rl_vi_append_mode PARAMS((int, int));
|
||||
extern int rl_vi_append_eol PARAMS((int, int));
|
||||
extern int rl_vi_eof_maybe PARAMS((int, int));
|
||||
extern int rl_vi_insertion_mode PARAMS((int, int));
|
||||
extern int rl_vi_movement_mode PARAMS((int, int));
|
||||
extern int rl_vi_arg_digit PARAMS((int, int));
|
||||
extern int rl_vi_change_case PARAMS((int, int));
|
||||
extern int rl_vi_put PARAMS((int, int));
|
||||
extern int rl_vi_column PARAMS((int, int));
|
||||
extern int rl_vi_delete_to PARAMS((int, int));
|
||||
extern int rl_vi_change_to PARAMS((int, int));
|
||||
extern int rl_vi_yank_to PARAMS((int, int));
|
||||
extern int rl_vi_delete PARAMS((int, int));
|
||||
extern int rl_vi_back_to_indent PARAMS((int, int));
|
||||
extern int rl_vi_first_print PARAMS((int, int));
|
||||
extern int rl_vi_char_search PARAMS((int, int));
|
||||
extern int rl_vi_match PARAMS((int, int));
|
||||
extern int rl_vi_change_char PARAMS((int, int));
|
||||
extern int rl_vi_subst PARAMS((int, int));
|
||||
extern int rl_vi_overstrike PARAMS((int, int));
|
||||
extern int rl_vi_overstrike_delete PARAMS((int, int));
|
||||
extern int rl_vi_replace PARAMS((int, int));
|
||||
extern int rl_vi_set_mark PARAMS((int, int));
|
||||
extern int rl_vi_goto_mark PARAMS((int, int));
|
||||
|
||||
/* VI-mode utility functions. */
|
||||
extern int rl_vi_check PARAMS((void));
|
||||
extern int rl_vi_domove PARAMS((int, int *));
|
||||
extern int rl_vi_bracktype PARAMS((int));
|
||||
|
||||
/* VI-mode pseudo-bindable commands, used as utility functions. */
|
||||
extern int rl_vi_fWord PARAMS((int, int));
|
||||
extern int rl_vi_bWord PARAMS((int, int));
|
||||
extern int rl_vi_eWord PARAMS((int, int));
|
||||
extern int rl_vi_fword PARAMS((int, int));
|
||||
extern int rl_vi_bword PARAMS((int, int));
|
||||
extern int rl_vi_eword PARAMS((int, int));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Readline functions. */
|
||||
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
|
||||
extern char *readline PARAMS((const char *));
|
||||
|
||||
extern int rl_set_prompt PARAMS((const char *));
|
||||
extern int rl_expand_prompt PARAMS((char *));
|
||||
|
||||
extern int rl_initialize PARAMS((void));
|
||||
|
||||
/* Undocumented; unused by readline */
|
||||
extern int rl_discard_argument PARAMS((void));
|
||||
|
||||
/* Utility functions to bind keys to readline commands. */
|
||||
extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
|
||||
extern int rl_bind_key PARAMS((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_key PARAMS((int));
|
||||
extern int rl_unbind_key_in_map PARAMS((int, Keymap));
|
||||
extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
|
||||
extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
|
||||
extern int rl_variable_bind PARAMS((const char *, const char *));
|
||||
|
||||
/* Backwards compatibility, use rl_generic_bind instead. */
|
||||
extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
|
||||
|
||||
/* Undocumented in the texinfo manual; not really useful to programs. */
|
||||
extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
|
||||
extern char *rl_untranslate_keyseq PARAMS((int));
|
||||
|
||||
extern rl_command_func_t *rl_named_function PARAMS((const char *));
|
||||
extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
|
||||
|
||||
extern void rl_list_funmap_names PARAMS((void));
|
||||
extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
|
||||
extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
|
||||
|
||||
extern void rl_function_dumper PARAMS((int));
|
||||
extern void rl_macro_dumper PARAMS((int));
|
||||
extern void rl_variable_dumper PARAMS((int));
|
||||
|
||||
extern int rl_read_init_file PARAMS((const char *));
|
||||
extern int rl_parse_and_bind PARAMS((char *));
|
||||
|
||||
/* Functions for manipulating keymaps. */
|
||||
extern Keymap rl_make_bare_keymap PARAMS((void));
|
||||
extern Keymap rl_copy_keymap PARAMS((Keymap));
|
||||
extern Keymap rl_make_keymap PARAMS((void));
|
||||
extern void rl_discard_keymap PARAMS((Keymap));
|
||||
|
||||
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
|
||||
extern char *rl_get_keymap_name PARAMS((Keymap));
|
||||
extern void rl_set_keymap PARAMS((Keymap));
|
||||
extern Keymap rl_get_keymap PARAMS((void));
|
||||
/* Undocumented; used internally only. */
|
||||
extern void rl_set_keymap_from_edit_mode PARAMS((void));
|
||||
extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
|
||||
|
||||
/* Functions for manipulating the funmap, which maps command names to functions. */
|
||||
extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
|
||||
extern const char **rl_funmap_names PARAMS((void));
|
||||
/* Undocumented, only used internally -- there is only one funmap, and this
|
||||
function may be called only once. */
|
||||
extern void rl_initialize_funmap PARAMS((void));
|
||||
|
||||
/* Utility functions for managing keyboard macros. */
|
||||
extern void rl_push_macro_input PARAMS((char *));
|
||||
|
||||
/* Functions for undoing, from undo.c */
|
||||
extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
|
||||
extern void rl_free_undo_list PARAMS((void));
|
||||
extern int rl_do_undo PARAMS((void));
|
||||
extern int rl_begin_undo_group PARAMS((void));
|
||||
extern int rl_end_undo_group PARAMS((void));
|
||||
extern int rl_modifying PARAMS((int, int));
|
||||
|
||||
/* Functions for redisplay. */
|
||||
extern void rl_redisplay PARAMS((void));
|
||||
extern int rl_on_new_line PARAMS((void));
|
||||
extern int rl_on_new_line_with_prompt PARAMS((void));
|
||||
extern int rl_forced_update_display PARAMS((void));
|
||||
extern int rl_clear_message PARAMS((void));
|
||||
extern int rl_reset_line_state PARAMS((void));
|
||||
extern int rl_crlf PARAMS((void));
|
||||
|
||||
#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
|
||||
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
#else
|
||||
extern int rl_message ();
|
||||
#endif
|
||||
|
||||
extern int rl_show_char PARAMS((int));
|
||||
|
||||
/* Undocumented in texinfo manual. */
|
||||
extern int rl_character_len PARAMS((int, int));
|
||||
|
||||
/* Save and restore internal prompt redisplay information. */
|
||||
extern void rl_save_prompt PARAMS((void));
|
||||
extern void rl_restore_prompt PARAMS((void));
|
||||
|
||||
/* Modifying text. */
|
||||
extern void rl_replace_line PARAMS((const char *, int));
|
||||
extern int rl_insert_text PARAMS((const char *));
|
||||
extern int rl_delete_text PARAMS((int, int));
|
||||
extern int rl_kill_text PARAMS((int, int));
|
||||
extern char *rl_copy_text PARAMS((int, int));
|
||||
|
||||
/* Terminal and tty mode management. */
|
||||
extern void rl_prep_terminal PARAMS((int));
|
||||
extern void rl_deprep_terminal PARAMS((void));
|
||||
extern void rl_tty_set_default_bindings PARAMS((Keymap));
|
||||
|
||||
extern int rl_reset_terminal PARAMS((const char *));
|
||||
extern void rl_resize_terminal PARAMS((void));
|
||||
extern void rl_set_screen_size PARAMS((int, int));
|
||||
extern void rl_get_screen_size PARAMS((int *, int *));
|
||||
|
||||
extern char *rl_get_termcap PARAMS((const char *));
|
||||
|
||||
/* Functions for character input. */
|
||||
extern int rl_stuff_char PARAMS((int));
|
||||
extern int rl_execute_next PARAMS((int));
|
||||
extern int rl_clear_pending_input PARAMS((void));
|
||||
extern int rl_read_key PARAMS((void));
|
||||
extern int rl_getc PARAMS((FILE *));
|
||||
extern int rl_set_keyboard_input_timeout PARAMS((int));
|
||||
|
||||
/* `Public' utility functions . */
|
||||
extern void rl_extend_line_buffer PARAMS((int));
|
||||
extern int rl_ding PARAMS((void));
|
||||
extern int rl_alphabetic PARAMS((int));
|
||||
|
||||
/* Readline signal handling, from signals.c */
|
||||
extern int rl_set_signals PARAMS((void));
|
||||
extern int rl_clear_signals PARAMS((void));
|
||||
extern void rl_cleanup_after_signal PARAMS((void));
|
||||
extern void rl_reset_after_signal PARAMS((void));
|
||||
extern void rl_free_line_state PARAMS((void));
|
||||
|
||||
extern int rl_set_paren_blink_timeout PARAMS((int));
|
||||
|
||||
/* Undocumented. */
|
||||
extern int rl_maybe_save_line PARAMS((void));
|
||||
extern int rl_maybe_unsave_line PARAMS((void));
|
||||
extern int rl_maybe_replace_line PARAMS((void));
|
||||
|
||||
/* Completion functions. */
|
||||
extern int rl_complete_internal PARAMS((int));
|
||||
extern void rl_display_match_list PARAMS((char **, int, int));
|
||||
|
||||
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
|
||||
extern char *rl_username_completion_function PARAMS((const char *, int));
|
||||
extern char *rl_filename_completion_function PARAMS((const char *, int));
|
||||
|
||||
extern int rl_completion_mode PARAMS((rl_command_func_t *));
|
||||
|
||||
#if 0
|
||||
/* Backwards compatibility (compat.c). These will go away sometime. */
|
||||
extern void free_undo_list PARAMS((void));
|
||||
extern int maybe_save_line PARAMS((void));
|
||||
extern int maybe_unsave_line PARAMS((void));
|
||||
extern int maybe_replace_line PARAMS((void));
|
||||
|
||||
extern int ding PARAMS((void));
|
||||
extern int alphabetic PARAMS((int));
|
||||
extern int crlf PARAMS((void));
|
||||
|
||||
extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
|
||||
extern char *username_completion_function PARAMS((const char *, int));
|
||||
extern char *filename_completion_function PARAMS((const char *, int));
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Variables */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* The version of this incarnation of the readline library. */
|
||||
extern const char *rl_library_version; /* e.g., "4.2" */
|
||||
extern int rl_readline_version; /* e.g., 0x0402 */
|
||||
|
||||
/* True if this is real GNU readline. */
|
||||
extern int rl_gnu_readline_p;
|
||||
|
||||
/* Flags word encapsulating the current readline state. */
|
||||
extern int rl_readline_state;
|
||||
|
||||
/* Says which editing mode readline is currently using. 1 means emacs mode;
|
||||
0 means vi mode. */
|
||||
extern int rl_editing_mode;
|
||||
|
||||
/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means
|
||||
overwrite mode. Reset to insert mode on each input line. */
|
||||
extern int rl_insert_mode;
|
||||
|
||||
/* The name of the calling program. You should initialize this to
|
||||
whatever was in argv[0]. It is used when parsing conditionals. */
|
||||
extern const char *rl_readline_name;
|
||||
|
||||
/* The prompt readline uses. This is set from the argument to
|
||||
readline (), and should not be assigned to directly. */
|
||||
extern char *rl_prompt;
|
||||
|
||||
/* The line buffer that is in use. */
|
||||
extern char *rl_line_buffer;
|
||||
|
||||
/* The location of point, and end. */
|
||||
extern int rl_point;
|
||||
extern int rl_end;
|
||||
|
||||
/* The mark, or saved cursor position. */
|
||||
extern int rl_mark;
|
||||
|
||||
/* Flag to indicate that readline has finished with the current input
|
||||
line and should return it. */
|
||||
extern int rl_done;
|
||||
|
||||
/* If set to a character value, that will be the next keystroke read. */
|
||||
extern int rl_pending_input;
|
||||
|
||||
/* Non-zero if we called this function from _rl_dispatch(). It's present
|
||||
so functions can find out whether they were called from a key binding
|
||||
or directly from an application. */
|
||||
extern int rl_dispatching;
|
||||
|
||||
/* Non-zero if the user typed a numeric argument before executing the
|
||||
current function. */
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
/* The current value of the numeric argument specified by the user. */
|
||||
extern int rl_numeric_arg;
|
||||
|
||||
/* The address of the last command function Readline executed. */
|
||||
extern rl_command_func_t *rl_last_func;
|
||||
|
||||
/* The name of the terminal to use. */
|
||||
extern const char *rl_terminal_name;
|
||||
|
||||
/* The input and output streams. */
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal () prints the first prompt. */
|
||||
extern rl_hook_func_t *rl_startup_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call just before
|
||||
readline_internal_setup () returns and readline_internal starts
|
||||
reading input characters. */
|
||||
extern rl_hook_func_t *rl_pre_input_hook;
|
||||
|
||||
/* The address of a function to call periodically while Readline is
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
extern rl_hook_func_t *rl_event_hook;
|
||||
|
||||
/* The address of the function to call to fetch a character from the current
|
||||
Readline input stream */
|
||||
extern rl_getc_func_t *rl_getc_function;
|
||||
|
||||
extern rl_voidfunc_t *rl_redisplay_function;
|
||||
|
||||
extern rl_vintfunc_t *rl_prep_term_function;
|
||||
extern rl_voidfunc_t *rl_deprep_term_function;
|
||||
|
||||
/* Dispatch variables. */
|
||||
extern Keymap rl_executing_keymap;
|
||||
extern Keymap rl_binding_keymap;
|
||||
|
||||
/* Display variables. */
|
||||
/* If non-zero, readline will erase the entire line, including any prompt,
|
||||
if the only thing typed on an otherwise-blank line is something bound to
|
||||
rl_newline. */
|
||||
extern int rl_erase_empty_line;
|
||||
|
||||
/* If non-zero, the application has already printed the prompt (rl_prompt)
|
||||
before calling readline, so readline should not output it the first time
|
||||
redisplay is done. */
|
||||
extern int rl_already_prompted;
|
||||
|
||||
/* A non-zero value means to read only this many characters rather than
|
||||
up to a character bound to accept-line. */
|
||||
extern int rl_num_chars_to_read;
|
||||
|
||||
/* The text of a currently-executing keyboard macro. */
|
||||
extern char *rl_executing_macro;
|
||||
|
||||
/* Variables to control readline signal handling. */
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
|
||||
extern int rl_catch_signals;
|
||||
|
||||
/* If non-zero, readline will install a signal handler for SIGWINCH
|
||||
that also attempts to call any calling application's SIGWINCH signal
|
||||
handler. Note that the terminal is not cleaned up before the
|
||||
application's signal handler is called; use rl_cleanup_after_signal()
|
||||
to do that. */
|
||||
extern int rl_catch_sigwinch;
|
||||
|
||||
/* Completion variables. */
|
||||
/* Pointer to the generator function for completion_matches ().
|
||||
NULL means to use rl_filename_completion_function (), the default
|
||||
filename completer. */
|
||||
extern rl_compentry_func_t *rl_completion_entry_function;
|
||||
|
||||
/* If rl_ignore_some_completions_function is non-NULL it is the address
|
||||
of a function to call after all of the possible matches have been
|
||||
generated, but before the actual completion is done to the input line.
|
||||
The function is called with one argument; a NULL terminated array
|
||||
of (char *). If your function removes any of the elements, they
|
||||
must be free()'ed. */
|
||||
extern rl_compignore_func_t *rl_ignore_some_completions_function;
|
||||
|
||||
/* Pointer to alternative function to create matches.
|
||||
Function is called with TEXT, START, and END.
|
||||
START and END are indices in RL_LINE_BUFFER saying what the boundaries
|
||||
of TEXT are.
|
||||
If this function exists and returns NULL then call the value of
|
||||
rl_completion_entry_function to try to match, otherwise use the
|
||||
array of strings returned. */
|
||||
extern rl_completion_func_t *rl_attempted_completion_function;
|
||||
|
||||
/* The basic list of characters that signal a break between words for the
|
||||
completer routine. The initial contents of this variable is what
|
||||
breaks words in the shell, i.e. "n\"\\'`@$>". */
|
||||
extern const char *rl_basic_word_break_characters;
|
||||
|
||||
/* The list of characters that signal a break between words for
|
||||
rl_complete_internal. The default list is the contents of
|
||||
rl_basic_word_break_characters. */
|
||||
extern const char *rl_completer_word_break_characters;
|
||||
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
rl_completer_word_break_characters are treated as any other character,
|
||||
unless they also appear within this list. */
|
||||
extern const char *rl_completer_quote_characters;
|
||||
|
||||
/* List of quote characters which cause a word break. */
|
||||
extern const char *rl_basic_quote_characters;
|
||||
|
||||
/* List of characters that need to be quoted in filenames by the completer. */
|
||||
extern const char *rl_filename_quote_characters;
|
||||
|
||||
/* List of characters that are word break characters, but should be left
|
||||
in TEXT when it is passed to the completion function. The shell uses
|
||||
this to help determine what kind of completing to do. */
|
||||
extern const char *rl_special_prefixes;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. It
|
||||
changes what is displayed when the possible completions are printed
|
||||
or inserted. */
|
||||
extern rl_icppfunc_t *rl_directory_completion_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call when completing
|
||||
a directory name. This function takes the address of the directory name
|
||||
to be modified as an argument. Unlike rl_directory_completion_hook, it
|
||||
only modifies the directory name used in opendir(2), not what is displayed
|
||||
when the possible completions are printed or inserted. It is called
|
||||
before rl_directory_completion_hook. I'm not happy with how this works
|
||||
yet, so it's undocumented. */
|
||||
extern rl_icppfunc_t *rl_directory_rewrite_hook;
|
||||
|
||||
/* Backwards compatibility with previous versions of readline. */
|
||||
#define rl_symbolic_link_hook rl_directory_completion_hook
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing a word would normally display the list of possible matches.
|
||||
This function is called instead of actually doing the display.
|
||||
It takes three arguments: (char **matches, int num_matches, int max_length)
|
||||
where MATCHES is the array of strings that matched, NUM_MATCHES is the
|
||||
number of strings in that array, and MAX_LENGTH is the length of the
|
||||
longest string in that array. */
|
||||
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be treated
|
||||
as filenames. This is ALWAYS zero on entry, and can only be changed
|
||||
within a completion entry finder function. */
|
||||
extern int rl_filename_completion_desired;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be quoted using
|
||||
double quotes (or an application-specific quoting mechanism) if the
|
||||
filename contains any characters in rl_word_break_chars. This is
|
||||
ALWAYS non-zero on entry, and can only be changed within a completion
|
||||
entry finder function. */
|
||||
extern int rl_filename_quoting_desired;
|
||||
|
||||
/* Set to a function to quote a filename in an application-specific fashion.
|
||||
Called with the text to quote, the type of match found (single or multiple)
|
||||
and a pointer to the quoting character to be used, which the function can
|
||||
reset if desired. */
|
||||
extern rl_quote_func_t *rl_filename_quoting_function;
|
||||
|
||||
/* Function to call to remove quoting characters from a filename. Called
|
||||
before completion is attempted, so the embedded quotes do not interfere
|
||||
with matching names in the file system. */
|
||||
extern rl_dequote_func_t *rl_filename_dequoting_function;
|
||||
|
||||
/* Function to call to decide whether or not a word break character is
|
||||
quoted. If a character is quoted, it does not break words for the
|
||||
completer. */
|
||||
extern rl_linebuf_func_t *rl_char_is_quoted_p;
|
||||
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
extern int rl_attempted_completion_over;
|
||||
|
||||
/* Set to a character describing the type of completion being attempted by
|
||||
rl_complete_internal; available for use by application completion
|
||||
functions. */
|
||||
extern int rl_completion_type;
|
||||
|
||||
/* Character appended to completed words when at the end of the line. The
|
||||
default is a space. Nothing is added if this is '\0'. */
|
||||
extern int rl_completion_append_character;
|
||||
|
||||
/* If set to non-zero by an application completion function,
|
||||
rl_completion_append_character will not be appended. */
|
||||
extern int rl_completion_suppress_append;
|
||||
|
||||
/* Up to this many items will be displayed in response to a
|
||||
possible-completions call. After that, we ask the user if she
|
||||
is sure she wants to see them all. The default value is 100. */
|
||||
extern int rl_completion_query_items;
|
||||
|
||||
/* If non-zero, a slash will be appended to completed filenames that are
|
||||
symbolic links to directory names, subject to the value of the
|
||||
mark-directories variable (which is user-settable). This exists so
|
||||
that application completion functions can override the user's preference
|
||||
(set via the mark-symlinked-directories variable) if appropriate.
|
||||
It's set to the value of _rl_complete_mark_symlink_dirs in
|
||||
rl_complete_internal before any application-specific completion
|
||||
function is called, so without that function doing anything, the user's
|
||||
preferences are honored. */
|
||||
extern int rl_completion_mark_symlink_dirs;
|
||||
|
||||
/* If non-zero, then disallow duplicates in the matches. */
|
||||
extern int rl_ignore_completion_duplicates;
|
||||
|
||||
/* If this is non-zero, completion is (temporarily) inhibited, and the
|
||||
completion character will be inserted as any other. */
|
||||
extern int rl_inhibit_completion;
|
||||
|
||||
/* Definitions available for use by readline clients. */
|
||||
#define RL_PROMPT_START_IGNORE '\001'
|
||||
#define RL_PROMPT_END_IGNORE '\002'
|
||||
|
||||
/* Possible values for do_replace argument to rl_filename_quoting_function,
|
||||
called by rl_complete_internal. */
|
||||
#define NO_MATCH 0
|
||||
#define SINGLE_MATCH 1
|
||||
#define MULT_MATCH 2
|
||||
|
||||
/* Possible state values for rl_readline_state */
|
||||
#define RL_STATE_NONE 0x00000 /* no state; before first call */
|
||||
|
||||
#define RL_STATE_INITIALIZING 0x00001 /* initializing */
|
||||
#define RL_STATE_INITIALIZED 0x00002 /* initialization done */
|
||||
#define RL_STATE_TERMPREPPED 0x00004 /* terminal is prepped */
|
||||
#define RL_STATE_READCMD 0x00008 /* reading a command key */
|
||||
#define RL_STATE_METANEXT 0x00010 /* reading input after ESC */
|
||||
#define RL_STATE_DISPATCHING 0x00020 /* dispatching to a command */
|
||||
#define RL_STATE_MOREINPUT 0x00040 /* reading more input in a command function */
|
||||
#define RL_STATE_ISEARCH 0x00080 /* doing incremental search */
|
||||
#define RL_STATE_NSEARCH 0x00100 /* doing non-inc search */
|
||||
#define RL_STATE_SEARCH 0x00200 /* doing a history search */
|
||||
#define RL_STATE_NUMERICARG 0x00400 /* reading numeric argument */
|
||||
#define RL_STATE_MACROINPUT 0x00800 /* getting input from a macro */
|
||||
#define RL_STATE_MACRODEF 0x01000 /* defining keyboard macro */
|
||||
#define RL_STATE_OVERWRITE 0x02000 /* overwrite mode */
|
||||
#define RL_STATE_COMPLETING 0x04000 /* doing completion */
|
||||
#define RL_STATE_SIGHANDLER 0x08000 /* in readline sighandler */
|
||||
#define RL_STATE_UNDOING 0x10000 /* doing an undo */
|
||||
#define RL_STATE_INPUTPENDING 0x20000 /* rl_execute_next called */
|
||||
|
||||
#define RL_STATE_DONE 0x80000 /* done; accepted line */
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
#define RL_ISSTATE(x) (rl_readline_state & (x))
|
||||
|
||||
struct readline_state {
|
||||
/* line state */
|
||||
int point;
|
||||
int end;
|
||||
int mark;
|
||||
char *buffer;
|
||||
int buflen;
|
||||
UNDO_LIST *ul;
|
||||
char *prompt;
|
||||
|
||||
/* global state */
|
||||
int rlstate;
|
||||
int done;
|
||||
Keymap kmap;
|
||||
|
||||
/* input state */
|
||||
rl_command_func_t *lastfunc;
|
||||
int insmode;
|
||||
int edmode;
|
||||
int kseqlen;
|
||||
FILE *inf;
|
||||
FILE *outf;
|
||||
int pendingin;
|
||||
char *macro;
|
||||
|
||||
/* signal state */
|
||||
int catchsigs;
|
||||
int catchsigwinch;
|
||||
|
||||
/* reserved for future expansion, so the struct size doesn't change */
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
extern int rl_save_state PARAMS((struct readline_state *));
|
||||
extern int rl_restore_state PARAMS((struct readline_state *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _READLINE_H_ */
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/* rlconf.h -- readline configuration definitions */
|
||||
|
||||
/* Copyright (C) 1994 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.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#if !defined (_RLCONF_H_)
|
||||
#define _RLCONF_H_
|
||||
|
||||
/* Define this if you want the vi-mode editing available. */
|
||||
#define VI_MODE
|
||||
|
||||
/* Define this to get an indication of file type when listing completions. */
|
||||
#define VISIBLE_STATS
|
||||
|
||||
/* This definition is needed by readline.c, rltty.c, and signals.c. */
|
||||
/* If on, then readline handles signals in a way that doesn't screw. */
|
||||
#define HANDLE_SIGNALS
|
||||
|
||||
/* Ugly but working hack for binding prefix meta. */
|
||||
#define PREFIX_META_HACK
|
||||
|
||||
/* The final, last-ditch effort file name for an init file. */
|
||||
#define DEFAULT_INPUTRC "~/.inputrc"
|
||||
|
||||
/* If defined, expand tabs to spaces. */
|
||||
#define DISPLAY_TABS
|
||||
|
||||
/* If defined, use the terminal escape sequence to move the cursor forward
|
||||
over a character when updating the line rather than rewriting it. */
|
||||
/* #define HACK_TERMCAP_MOTION */
|
||||
|
||||
/* The string inserted by the `insert comment' command. */
|
||||
#define RL_COMMENT_BEGIN_DEFAULT "#"
|
||||
|
||||
/* Define this if you want code that allows readline to be used in an
|
||||
X `callback' style. */
|
||||
#define READLINE_CALLBACKS
|
||||
|
||||
/* Define this if you want the cursor to indicate insert or overwrite mode. */
|
||||
/* #define CURSOR_MODE */
|
||||
|
||||
#endif /* _RLCONF_H_ */
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
/* rldefs.h -- an attempt to isolate some of the system-specific defines
|
||||
for readline. This should be included after any files that define
|
||||
system-specific constants like _POSIX_VERSION or USG. */
|
||||
|
||||
/* Copyright (C) 1987,1989 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.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#if !defined (_RLDEFS_H_)
|
||||
#define _RLDEFS_H_
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "rlstdc.h"
|
||||
|
||||
#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
|
||||
# define TERMIOS_TTY_DRIVER
|
||||
#else
|
||||
# if defined (HAVE_TERMIO_H)
|
||||
# define TERMIO_TTY_DRIVER
|
||||
# else
|
||||
# define NEW_TTY_DRIVER
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Posix macro to check file in statbuf for directory-ness.
|
||||
This requires that <sys/stat.h> be included before this test. */
|
||||
#if defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/* Decide which flavor of the header file describing the C library
|
||||
string functions to include and include it. */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# if defined (PREFER_VARARGS)
|
||||
# include <varargs.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRCASECMP)
|
||||
#define _rl_stricmp strcasecmp
|
||||
#define _rl_strnicmp strncasecmp
|
||||
#else
|
||||
extern int _rl_stricmp PARAMS((char *, char *));
|
||||
extern int _rl_strnicmp PARAMS((char *, char *, int));
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRPBRK)
|
||||
# define _rl_strpbrk(a,b) strpbrk((a),(b))
|
||||
#else
|
||||
extern char *_rl_strpbrk PARAMS((const char *, const char *));
|
||||
#endif
|
||||
|
||||
#if !defined (emacs_mode)
|
||||
# define no_mode -1
|
||||
# define vi_mode 0
|
||||
# define emacs_mode 1
|
||||
#endif
|
||||
|
||||
#if !defined (RL_IM_INSERT)
|
||||
# define RL_IM_INSERT 1
|
||||
# define RL_IM_OVERWRITE 0
|
||||
#
|
||||
# define RL_IM_DEFAULT RL_IM_INSERT
|
||||
#endif
|
||||
|
||||
/* If you cast map[key].function to type (Keymap) on a Cray,
|
||||
the compiler takes the value of map[key].function and
|
||||
divides it by 4 to convert between pointer types (pointers
|
||||
to functions and pointers to structs are different sizes).
|
||||
This is not what is wanted. */
|
||||
#if defined (CRAY)
|
||||
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function)
|
||||
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)((int)(data))
|
||||
#else
|
||||
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function)
|
||||
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)(data)
|
||||
#endif
|
||||
|
||||
#ifndef savestring
|
||||
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
|
||||
#endif
|
||||
|
||||
/* Possible values for _rl_bell_preference. */
|
||||
#define NO_BELL 0
|
||||
#define AUDIBLE_BELL 1
|
||||
#define VISIBLE_BELL 2
|
||||
|
||||
/* Definitions used when searching the line for characters. */
|
||||
/* NOTE: it is necessary that opposite directions are inverses */
|
||||
#define FTO 1 /* forward to */
|
||||
#define BTO -1 /* backward to */
|
||||
#define FFIND 2 /* forward find */
|
||||
#define BFIND -2 /* backward find */
|
||||
|
||||
/* Possible values for the found_quote flags word used by the completion
|
||||
functions. It says what kind of (shell-like) quoting we found anywhere
|
||||
in the line. */
|
||||
#define RL_QF_SINGLE_QUOTE 0x01
|
||||
#define RL_QF_DOUBLE_QUOTE 0x02
|
||||
#define RL_QF_BACKSLASH 0x04
|
||||
#define RL_QF_OTHER_QUOTE 0x08
|
||||
|
||||
/* Default readline line buffer length. */
|
||||
#define DEFAULT_BUFFER_SIZE 256
|
||||
|
||||
#if !defined (STREQ)
|
||||
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
|
||||
#define STREQN(a, b, n) (((n) == 0) ? (1) \
|
||||
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
|
||||
#endif
|
||||
|
||||
#if !defined (FREE)
|
||||
# define FREE(x) if (x) free (x)
|
||||
#endif
|
||||
|
||||
#if !defined (SWAP)
|
||||
# define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
|
||||
#endif
|
||||
|
||||
/* CONFIGURATION SECTION */
|
||||
#include "rlconf.h"
|
||||
|
||||
#endif /* !_RLDEFS_H_ */
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/* rlmbutil.h -- utility functions for multibyte characters. */
|
||||
|
||||
/* Copyright (C) 2001 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if !defined (_RL_MBUTIL_H_)
|
||||
#define _RL_MBUTIL_H_
|
||||
|
||||
#include "rlstdc.h"
|
||||
|
||||
/************************************************/
|
||||
/* check multibyte capability for I18N code */
|
||||
/************************************************/
|
||||
|
||||
/* For platforms which support the ISO C amendement 1 functionality we
|
||||
support user defined character classes. */
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
||||
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
# if defined (HAVE_MBSRTOWCS) /* system is supposed to support XPG5 */
|
||||
# define HANDLE_MULTIBYTE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
|
||||
#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
|
||||
# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
|
||||
# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
|
||||
# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
|
||||
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
|
||||
# define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
|
||||
# define mbstate_t int
|
||||
#endif
|
||||
|
||||
/* Make sure MB_LEN_MAX is at least 16 on systems that claim to be able to
|
||||
handle multibyte chars (some systems define MB_LEN_MAX as 1) */
|
||||
#ifdef HANDLE_MULTIBYTE
|
||||
# include <limits.h>
|
||||
# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
|
||||
# undef MB_LEN_MAX
|
||||
# endif
|
||||
# if !defined (MB_LEN_MAX)
|
||||
# define MB_LEN_MAX 16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/************************************************/
|
||||
/* end of multibyte capability checks for I18N */
|
||||
/************************************************/
|
||||
|
||||
/*
|
||||
* Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar:
|
||||
*
|
||||
* MB_FIND_ANY find any multibyte character
|
||||
* MB_FIND_NONZERO find a non-zero-width multibyte character
|
||||
*/
|
||||
|
||||
#define MB_FIND_ANY 0x00
|
||||
#define MB_FIND_NONZERO 0x01
|
||||
|
||||
extern int _rl_find_prev_mbchar PARAMS((char *, int, int));
|
||||
extern int _rl_find_next_mbchar PARAMS((char *, int, int, int));
|
||||
|
||||
#ifdef HANDLE_MULTIBYTE
|
||||
|
||||
extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *));
|
||||
extern int _rl_get_char_len PARAMS((char *, mbstate_t *));
|
||||
extern int _rl_adjust_point PARAMS((char *, int, mbstate_t *));
|
||||
|
||||
extern int _rl_read_mbchar PARAMS((char *, int));
|
||||
extern int _rl_read_mbstring PARAMS((int, char *, int));
|
||||
|
||||
extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
|
||||
|
||||
#else /* !HANDLE_MULTIBYTE */
|
||||
|
||||
#undef MB_LEN_MAX
|
||||
#undef MB_CUR_MAX
|
||||
|
||||
#define MB_LEN_MAX 1
|
||||
#define MB_CUR_MAX 1
|
||||
|
||||
#define _rl_find_prev_mbchar(b, i, f) (((i) == 0) ? (i) : ((i) - 1))
|
||||
#define _rl_find_next_mbchar(b, i1, i2, f) ((i1) + (i2))
|
||||
|
||||
#endif /* !HANDLE_MULTIBYTE */
|
||||
|
||||
extern int rl_byte_oriented;
|
||||
|
||||
#endif /* _RL_MBUTIL_H_ */
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
/* rlprivate.h -- functions and variables global to the readline library,
|
||||
but not intended for use by applications. */
|
||||
|
||||
/* Copyright (C) 1999 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if !defined (_RL_PRIVATE_H_)
|
||||
#define _RL_PRIVATE_H_
|
||||
|
||||
#include "rlconf.h" /* for VISIBLE_STATS */
|
||||
#include "rlstdc.h"
|
||||
#include "posixjmp.h" /* defines procenv_t */
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global functions undocumented in texinfo manual and not in readline.h *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global variables undocumented in texinfo manual and not in readline.h *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* complete.c */
|
||||
extern int rl_complete_with_tilde_expansion;
|
||||
#if defined (VISIBLE_STATS)
|
||||
extern int rl_visible_stats;
|
||||
#endif /* VISIBLE_STATS */
|
||||
|
||||
/* readline.c */
|
||||
extern int rl_line_buffer_len;
|
||||
extern int rl_arg_sign;
|
||||
extern int rl_visible_prompt_length;
|
||||
extern int readline_echoing_p;
|
||||
extern int rl_key_sequence_length;
|
||||
extern int rl_byte_oriented;
|
||||
|
||||
/* display.c */
|
||||
extern int rl_display_fixed;
|
||||
|
||||
/* parens.c */
|
||||
extern int rl_blink_matching_paren;
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global functions and variables unsed and undocumented *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* kill.c */
|
||||
extern int rl_set_retained_kills PARAMS((int));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_set_screen_size PARAMS((int, int));
|
||||
|
||||
/* undo.c */
|
||||
extern int _rl_fix_last_undo_of_type PARAMS((int, int, int));
|
||||
|
||||
/* util.c */
|
||||
extern char *_rl_savestring PARAMS((const char *));
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Functions and variables private to the readline library *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* NOTE: Functions and variables prefixed with `_rl_' are
|
||||
pseudo-global: they are global so they can be shared
|
||||
between files in the readline library, but are not intended
|
||||
to be visible to readline callers. */
|
||||
|
||||
/*************************************************************************
|
||||
* Undocumented private functions *
|
||||
*************************************************************************/
|
||||
|
||||
#if defined(READLINE_CALLBACKS)
|
||||
|
||||
/* readline.c */
|
||||
extern void readline_internal_setup PARAMS((void));
|
||||
extern char *readline_internal_teardown PARAMS((int));
|
||||
extern int readline_internal_char PARAMS((void));
|
||||
|
||||
#endif /* READLINE_CALLBACKS */
|
||||
|
||||
/* bind.c */
|
||||
extern void _rl_bind_if_unbound PARAMS((const char *, rl_command_func_t *));
|
||||
|
||||
/* complete.c */
|
||||
extern char _rl_find_completion_word PARAMS((int *, int *));
|
||||
extern void _rl_free_match_list PARAMS((char **));
|
||||
|
||||
/* display.c */
|
||||
extern char *_rl_strip_prompt PARAMS((char *));
|
||||
extern void _rl_move_cursor_relative PARAMS((int, const char *));
|
||||
extern void _rl_move_vert PARAMS((int));
|
||||
extern void _rl_save_prompt PARAMS((void));
|
||||
extern void _rl_restore_prompt PARAMS((void));
|
||||
extern char *_rl_make_prompt_for_search PARAMS((int));
|
||||
extern void _rl_erase_at_end_of_line PARAMS((int));
|
||||
extern void _rl_clear_to_eol PARAMS((int));
|
||||
extern void _rl_clear_screen PARAMS((void));
|
||||
extern void _rl_update_final PARAMS((void));
|
||||
extern void _rl_redisplay_after_sigwinch PARAMS((void));
|
||||
extern void _rl_clean_up_for_exit PARAMS((void));
|
||||
extern void _rl_erase_entire_line PARAMS((void));
|
||||
extern int _rl_current_display_line PARAMS((void));
|
||||
|
||||
/* input.c */
|
||||
extern int _rl_any_typein PARAMS((void));
|
||||
extern int _rl_input_available PARAMS((void));
|
||||
extern int _rl_input_queued PARAMS((int));
|
||||
extern void _rl_insert_typein PARAMS((int));
|
||||
extern int _rl_unget_char PARAMS((int));
|
||||
|
||||
/* macro.c */
|
||||
extern void _rl_with_macro_input PARAMS((char *));
|
||||
extern int _rl_next_macro_key PARAMS((void));
|
||||
extern void _rl_push_executing_macro PARAMS((void));
|
||||
extern void _rl_pop_executing_macro PARAMS((void));
|
||||
extern void _rl_add_macro_char PARAMS((int));
|
||||
extern void _rl_kill_kbd_macro PARAMS((void));
|
||||
|
||||
/* misc.c */
|
||||
extern int _rl_init_argument PARAMS((void));
|
||||
extern void _rl_start_using_history PARAMS((void));
|
||||
extern int _rl_free_saved_history_line PARAMS((void));
|
||||
extern void _rl_set_insert_mode PARAMS((int, int));
|
||||
|
||||
/* nls.c */
|
||||
extern int _rl_init_eightbit PARAMS((void));
|
||||
|
||||
/* parens.c */
|
||||
extern void _rl_enable_paren_matching PARAMS((int));
|
||||
|
||||
/* readline.c */
|
||||
extern void _rl_init_line_state PARAMS((void));
|
||||
extern void _rl_set_the_line PARAMS((void));
|
||||
extern int _rl_dispatch PARAMS((int, Keymap));
|
||||
extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
|
||||
|
||||
/* rltty.c */
|
||||
extern int _rl_disable_tty_signals PARAMS((void));
|
||||
extern int _rl_restore_tty_signals PARAMS((void));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_get_screen_size PARAMS((int, int));
|
||||
extern int _rl_init_terminal_io PARAMS((const char *));
|
||||
#ifdef _MINIX
|
||||
extern void _rl_output_character_function PARAMS((int));
|
||||
#else
|
||||
extern int _rl_output_character_function PARAMS((int));
|
||||
#endif
|
||||
extern void _rl_output_some_chars PARAMS((const char *, int));
|
||||
extern int _rl_backspace PARAMS((int));
|
||||
extern void _rl_enable_meta_key PARAMS((void));
|
||||
extern void _rl_control_keypad PARAMS((int));
|
||||
extern void _rl_set_cursor PARAMS((int, int));
|
||||
|
||||
/* text.c */
|
||||
extern void _rl_fix_point PARAMS((int));
|
||||
extern int _rl_replace_text PARAMS((const char *, int, int));
|
||||
extern int _rl_insert_char PARAMS((int, int));
|
||||
extern int _rl_overwrite_char PARAMS((int, int));
|
||||
extern int _rl_overwrite_rubout PARAMS((int, int));
|
||||
extern int _rl_rubout_char PARAMS((int, int));
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
extern int _rl_char_search_internal PARAMS((int, int, char *, int));
|
||||
#else
|
||||
extern int _rl_char_search_internal PARAMS((int, int, int));
|
||||
#endif
|
||||
extern int _rl_set_mark_at_pos PARAMS((int));
|
||||
|
||||
/* util.c */
|
||||
extern int _rl_abort_internal PARAMS((void));
|
||||
extern char *_rl_strindex PARAMS((const char *, const char *));
|
||||
extern int _rl_qsort_string_compare PARAMS((char **, char **));
|
||||
extern int (_rl_uppercase_p) PARAMS((int));
|
||||
extern int (_rl_lowercase_p) PARAMS((int));
|
||||
extern int (_rl_pure_alphabetic) PARAMS((int));
|
||||
extern int (_rl_digit_p) PARAMS((int));
|
||||
extern int (_rl_to_lower) PARAMS((int));
|
||||
extern int (_rl_to_upper) PARAMS((int));
|
||||
extern int (_rl_digit_value) PARAMS((int));
|
||||
|
||||
/* vi_mode.c */
|
||||
extern void _rl_vi_initialize_line PARAMS((void));
|
||||
extern void _rl_vi_reset_last PARAMS((void));
|
||||
extern void _rl_vi_set_last PARAMS((int, int, int));
|
||||
extern int _rl_vi_textmod_command PARAMS((int));
|
||||
extern void _rl_vi_done_inserting PARAMS((void));
|
||||
|
||||
/*************************************************************************
|
||||
* Undocumented private variables *
|
||||
*************************************************************************/
|
||||
|
||||
/* bind.c */
|
||||
extern const char *_rl_possible_control_prefixes[];
|
||||
extern const char *_rl_possible_meta_prefixes[];
|
||||
|
||||
/* complete.c */
|
||||
extern int _rl_complete_show_all;
|
||||
extern int _rl_complete_mark_directories;
|
||||
extern int _rl_complete_mark_symlink_dirs;
|
||||
extern int _rl_print_completions_horizontally;
|
||||
extern int _rl_completion_case_fold;
|
||||
extern int _rl_match_hidden_files;
|
||||
extern int _rl_page_completions;
|
||||
|
||||
/* display.c */
|
||||
extern int _rl_vis_botlin;
|
||||
extern int _rl_last_c_pos;
|
||||
extern int _rl_suppress_redisplay;
|
||||
extern char *rl_display_prompt;
|
||||
|
||||
/* isearch.c */
|
||||
extern char *_rl_isearch_terminators;
|
||||
|
||||
/* macro.c */
|
||||
extern char *_rl_executing_macro;
|
||||
|
||||
/* misc.c */
|
||||
extern int _rl_history_preserve_point;
|
||||
extern int _rl_history_saved_point;
|
||||
|
||||
/* readline.c */
|
||||
extern int _rl_horizontal_scroll_mode;
|
||||
extern int _rl_mark_modified_lines;
|
||||
extern int _rl_bell_preference;
|
||||
extern int _rl_meta_flag;
|
||||
extern int _rl_convert_meta_chars_to_ascii;
|
||||
extern int _rl_output_meta_chars;
|
||||
extern char *_rl_comment_begin;
|
||||
extern unsigned char _rl_parsing_conditionalized_out;
|
||||
extern Keymap _rl_keymap;
|
||||
extern FILE *_rl_in_stream;
|
||||
extern FILE *_rl_out_stream;
|
||||
extern int _rl_last_command_was_kill;
|
||||
extern int _rl_eof_char;
|
||||
extern procenv_t readline_top_level;
|
||||
|
||||
/* terminal.c */
|
||||
extern int _rl_enable_keypad;
|
||||
extern int _rl_enable_meta;
|
||||
extern char *_rl_term_clreol;
|
||||
extern char *_rl_term_clrpag;
|
||||
extern char *_rl_term_im;
|
||||
extern char *_rl_term_ic;
|
||||
extern char *_rl_term_ei;
|
||||
extern char *_rl_term_DC;
|
||||
extern char *_rl_term_up;
|
||||
extern char *_rl_term_dc;
|
||||
extern char *_rl_term_cr;
|
||||
extern char *_rl_term_IC;
|
||||
extern int _rl_screenheight;
|
||||
extern int _rl_screenwidth;
|
||||
extern int _rl_screenchars;
|
||||
extern int _rl_terminal_can_insert;
|
||||
extern int _rl_term_autowrap;
|
||||
|
||||
/* undo.c */
|
||||
extern int _rl_doing_an_undo;
|
||||
extern int _rl_undo_group_level;
|
||||
|
||||
#endif /* _RL_PRIVATE_H_ */
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/* rlshell.h -- utility functions normally provided by bash. */
|
||||
|
||||
/* Copyright (C) 1999 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#if !defined (_RL_SHELL_H_)
|
||||
#define _RL_SHELL_H_
|
||||
|
||||
#include "rlstdc.h"
|
||||
|
||||
extern char *sh_single_quote PARAMS((char *));
|
||||
extern void sh_set_lines_and_columns PARAMS((int, int));
|
||||
extern char *sh_get_env_value PARAMS((const char *));
|
||||
extern char *sh_get_home_dir PARAMS((void));
|
||||
extern int sh_unset_nodelay_mode PARAMS((int));
|
||||
|
||||
#endif /* _RL_SHELL_H_ */
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/* stdc.h -- macros to make source compile on both ANSI C and K&R C
|
||||
compilers. */
|
||||
|
||||
/* Copyright (C) 1993 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 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. */
|
||||
|
||||
#if !defined (_RL_STDC_H_)
|
||||
#define _RL_STDC_H_
|
||||
|
||||
/* Adapted from BSD /usr/include/sys/cdefs.h. */
|
||||
|
||||
/* A function can be defined using prototypes and compile on both ANSI C
|
||||
and traditional C compilers with something like this:
|
||||
extern char *func PARAMS((char *, char *, int)); */
|
||||
|
||||
#if !defined (PARAMS)
|
||||
# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
|
||||
# define PARAMS(protos) protos
|
||||
# else
|
||||
# define PARAMS(protos) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* !_RL_STDC_H_ */
|
||||
|
|
@ -0,0 +1,911 @@
|
|||
/* rltty.c -- functions to prepare and restore the terminal for readline's
|
||||
use. */
|
||||
|
||||
/* Copyright (C) 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#include "rldefs.h"
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL */
|
||||
|
||||
#include "rltty.h"
|
||||
#include "readline.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
|
||||
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
|
||||
|
||||
static void block_sigint PARAMS((void));
|
||||
static void release_sigint PARAMS((void));
|
||||
|
||||
static void set_winsize PARAMS((int));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Signal Management */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
static sigset_t sigint_set, sigint_oset;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
static int sigint_oldmask;
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
static int sigint_blocked;
|
||||
|
||||
/* Cause SIGINT to not be delivered until the corresponding call to
|
||||
release_sigint(). */
|
||||
static void
|
||||
block_sigint ()
|
||||
{
|
||||
if (sigint_blocked)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigemptyset (&sigint_set);
|
||||
sigemptyset (&sigint_oset);
|
||||
sigaddset (&sigint_set, SIGINT);
|
||||
sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigint_oldmask = sigblock (sigmask (SIGINT));
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sighold (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
sigint_blocked = 1;
|
||||
}
|
||||
|
||||
/* Allow SIGINT to be delivered. */
|
||||
static void
|
||||
release_sigint ()
|
||||
{
|
||||
if (sigint_blocked == 0)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
|
||||
#else
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigsetmask (sigint_oldmask);
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sigrelse (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
sigint_blocked = 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Saving and Restoring the TTY */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Non-zero means that the terminal is in a prepped state. */
|
||||
static int terminal_prepped;
|
||||
|
||||
static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
|
||||
|
||||
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
|
||||
and output is suspended. */
|
||||
#if defined (__ksr1__)
|
||||
static int ksrflow;
|
||||
#endif
|
||||
|
||||
/* Dummy call to force a backgrounded readline to stop before it tries
|
||||
to get the tty settings. */
|
||||
static void
|
||||
set_winsize (tty)
|
||||
int tty;
|
||||
{
|
||||
#if defined (TIOCGWINSZ)
|
||||
struct winsize w;
|
||||
|
||||
if (ioctl (tty, TIOCGWINSZ, &w) == 0)
|
||||
(void) ioctl (tty, TIOCSWINSZ, &w);
|
||||
#endif /* TIOCGWINSZ */
|
||||
}
|
||||
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
|
||||
/* Values for the `flags' field of a struct bsdtty. This tells which
|
||||
elements of the struct bsdtty have been fetched from the system and
|
||||
are valid. */
|
||||
#define SGTTY_SET 0x01
|
||||
#define LFLAG_SET 0x02
|
||||
#define TCHARS_SET 0x04
|
||||
#define LTCHARS_SET 0x08
|
||||
|
||||
struct bsdtty {
|
||||
struct sgttyb sgttyb; /* Basic BSD tty driver information. */
|
||||
int lflag; /* Local mode flags, like LPASS8. */
|
||||
#if defined (TIOCGETC)
|
||||
struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */
|
||||
#endif
|
||||
#if defined (TIOCGLTC)
|
||||
struct ltchars ltchars; /* 4.2 BSD editing characters */
|
||||
#endif
|
||||
int flags; /* Bitmap saying which parts of the struct are valid. */
|
||||
};
|
||||
|
||||
#define TIOTYPE struct bsdtty
|
||||
|
||||
static TIOTYPE otio;
|
||||
|
||||
static void save_tty_chars PARAMS((TIOTYPE *));
|
||||
static int _get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int _set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
static void
|
||||
save_tty_chars (tiop)
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
_rl_last_tty_chars = _rl_tty_chars;
|
||||
|
||||
if (tiop->flags & SGTTY_SET)
|
||||
{
|
||||
_rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
|
||||
_rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
|
||||
}
|
||||
|
||||
if (tiop->flags & TCHARS_SET)
|
||||
{
|
||||
_rl_tty_chars.t_intr = tiop->tchars.t_intrc;
|
||||
_rl_tty_chars.t_quit = tiop->tchars.t_quitc;
|
||||
_rl_tty_chars.t_start = tiop->tchars.t_startc;
|
||||
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
|
||||
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
|
||||
_rl_tty_chars.t_eol = '\n';
|
||||
_rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
|
||||
}
|
||||
|
||||
if (tiop->flags & LTCHARS_SET)
|
||||
{
|
||||
_rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
|
||||
_rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
|
||||
_rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
|
||||
_rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
|
||||
_rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
|
||||
_rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
|
||||
}
|
||||
|
||||
_rl_tty_chars.t_status = -1;
|
||||
}
|
||||
|
||||
static int
|
||||
get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
set_winsize (tty);
|
||||
|
||||
tiop->flags = tiop->lflag = 0;
|
||||
|
||||
if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
|
||||
return -1;
|
||||
tiop->flags |= SGTTY_SET;
|
||||
|
||||
#if defined (TIOCLGET)
|
||||
if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
|
||||
tiop->flags |= LFLAG_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGETC)
|
||||
if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
|
||||
tiop->flags |= TCHARS_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGLTC)
|
||||
if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
|
||||
tiop->flags |= LTCHARS_SET;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
if (tiop->flags & SGTTY_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSETN, &(tiop->sgttyb));
|
||||
tiop->flags &= ~SGTTY_SET;
|
||||
}
|
||||
readline_echoing_p = 1;
|
||||
|
||||
#if defined (TIOCLSET)
|
||||
if (tiop->flags & LFLAG_SET)
|
||||
{
|
||||
ioctl (tty, TIOCLSET, &(tiop->lflag));
|
||||
tiop->flags &= ~LFLAG_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (TIOCSETC)
|
||||
if (tiop->flags & TCHARS_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSETC, &(tiop->tchars));
|
||||
tiop->flags &= ~TCHARS_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (TIOCSLTC)
|
||||
if (tiop->flags & LTCHARS_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSLTC, &(tiop->ltchars));
|
||||
tiop->flags &= ~LTCHARS_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
|
||||
|
||||
/* Copy the original settings to the structure we're going to use for
|
||||
our settings. */
|
||||
tiop->sgttyb = oldtio.sgttyb;
|
||||
tiop->lflag = oldtio.lflag;
|
||||
#if defined (TIOCGETC)
|
||||
tiop->tchars = oldtio.tchars;
|
||||
#endif
|
||||
#if defined (TIOCGLTC)
|
||||
tiop->ltchars = oldtio.ltchars;
|
||||
#endif
|
||||
tiop->flags = oldtio.flags;
|
||||
|
||||
/* First, the basic settings to put us into character-at-a-time, no-echo
|
||||
input mode. */
|
||||
tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
|
||||
tiop->sgttyb.sg_flags |= CBREAK;
|
||||
|
||||
/* If this terminal doesn't care how the 8th bit is used, then we can
|
||||
use it for the meta-key. If only one of even or odd parity is
|
||||
specified, then the terminal is using parity, and we cannot. */
|
||||
#if !defined (ANYP)
|
||||
# define ANYP (EVENP | ODDP)
|
||||
#endif
|
||||
if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
|
||||
((oldtio.sgttyb.sg_flags & ANYP) == 0))
|
||||
{
|
||||
tiop->sgttyb.sg_flags |= ANYP;
|
||||
|
||||
/* Hack on local mode flags if we can. */
|
||||
#if defined (TIOCLGET)
|
||||
# if defined (LPASS8)
|
||||
tiop->lflag |= LPASS8;
|
||||
# endif /* LPASS8 */
|
||||
#endif /* TIOCLGET */
|
||||
}
|
||||
|
||||
#if defined (TIOCGETC)
|
||||
# if defined (USE_XON_XOFF)
|
||||
/* Get rid of terminal output start and stop characters. */
|
||||
tiop->tchars.t_stopc = -1; /* C-s */
|
||||
tiop->tchars.t_startc = -1; /* C-q */
|
||||
|
||||
/* If there is an XON character, bind it to restart the output. */
|
||||
if (oldtio.tchars.t_startc != -1)
|
||||
rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
|
||||
# endif /* USE_XON_XOFF */
|
||||
|
||||
/* If there is an EOF char, bind _rl_eof_char to it. */
|
||||
if (oldtio.tchars.t_eofc != -1)
|
||||
_rl_eof_char = oldtio.tchars.t_eofc;
|
||||
|
||||
# if defined (NO_KILL_INTR)
|
||||
/* Get rid of terminal-generated SIGQUIT and SIGINT. */
|
||||
tiop->tchars.t_quitc = -1; /* C-\ */
|
||||
tiop->tchars.t_intrc = -1; /* C-c */
|
||||
# endif /* NO_KILL_INTR */
|
||||
#endif /* TIOCGETC */
|
||||
|
||||
#if defined (TIOCGLTC)
|
||||
/* Make the interrupt keys go away. Just enough to make people happy. */
|
||||
tiop->ltchars.t_dsuspc = -1; /* C-y */
|
||||
tiop->ltchars.t_lnextc = -1; /* C-v */
|
||||
#endif /* TIOCGLTC */
|
||||
}
|
||||
|
||||
#else /* !defined (NEW_TTY_DRIVER) */
|
||||
|
||||
#if !defined (VMIN)
|
||||
# define VMIN VEOF
|
||||
#endif
|
||||
|
||||
#if !defined (VTIME)
|
||||
# define VTIME VEOL
|
||||
#endif
|
||||
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# define TIOTYPE struct termios
|
||||
# define DRAIN_OUTPUT(fd) tcdrain (fd)
|
||||
# define GETATTR(tty, tiop) (tcgetattr (tty, tiop))
|
||||
# ifdef M_UNIX
|
||||
# define SETATTR(tty, tiop) (tcsetattr (tty, TCSANOW, tiop))
|
||||
# else
|
||||
# define SETATTR(tty, tiop) (tcsetattr (tty, TCSADRAIN, tiop))
|
||||
# endif /* !M_UNIX */
|
||||
#else
|
||||
# define TIOTYPE struct termio
|
||||
# define DRAIN_OUTPUT(fd)
|
||||
# define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop))
|
||||
# define SETATTR(tty, tiop) (ioctl (tty, TCSETAW, tiop))
|
||||
#endif /* !TERMIOS_TTY_DRIVER */
|
||||
|
||||
static TIOTYPE otio;
|
||||
|
||||
static void save_tty_chars PARAMS((TIOTYPE *));
|
||||
static int _get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int get_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int _set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
static int set_tty_settings PARAMS((int, TIOTYPE *));
|
||||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
#if defined (FLUSHO)
|
||||
# define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO)
|
||||
#else
|
||||
# define OUTPUT_BEING_FLUSHED(tp) 0
|
||||
#endif
|
||||
|
||||
static void
|
||||
save_tty_chars (tiop)
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
_rl_last_tty_chars = _rl_tty_chars;
|
||||
|
||||
_rl_tty_chars.t_eof = tiop->c_cc[VEOF];
|
||||
_rl_tty_chars.t_eol = tiop->c_cc[VEOL];
|
||||
#ifdef VEOL2
|
||||
_rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
|
||||
#endif
|
||||
_rl_tty_chars.t_erase = tiop->c_cc[VERASE];
|
||||
#ifdef VWERASE
|
||||
_rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
|
||||
#endif
|
||||
_rl_tty_chars.t_kill = tiop->c_cc[VKILL];
|
||||
#ifdef VREPRINT
|
||||
_rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
|
||||
#endif
|
||||
_rl_tty_chars.t_intr = tiop->c_cc[VINTR];
|
||||
_rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
|
||||
#ifdef VSUSP
|
||||
_rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
|
||||
#endif
|
||||
#ifdef VDSUSP
|
||||
_rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
|
||||
#endif
|
||||
#ifdef VSTART
|
||||
_rl_tty_chars.t_start = tiop->c_cc[VSTART];
|
||||
#endif
|
||||
#ifdef VSTOP
|
||||
_rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
|
||||
#endif
|
||||
#ifdef VLNEXT
|
||||
_rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
|
||||
#endif
|
||||
#ifdef VDISCARD
|
||||
_rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
|
||||
#endif
|
||||
#ifdef VSTATUS
|
||||
_rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (_AIX) || defined (_AIX41)
|
||||
/* Currently this is only used on AIX */
|
||||
static void
|
||||
rltty_warning (msg)
|
||||
char *msg;
|
||||
{
|
||||
fprintf (stderr, "readline: warning: %s\n", msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_AIX)
|
||||
void
|
||||
setopost(tp)
|
||||
TIOTYPE *tp;
|
||||
{
|
||||
if ((tp->c_oflag & OPOST) == 0)
|
||||
{
|
||||
rltty_warning ("turning on OPOST for terminal\r");
|
||||
tp->c_oflag |= OPOST|ONLCR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
_get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
int ioctl_ret;
|
||||
|
||||
while (1)
|
||||
{
|
||||
ioctl_ret = GETATTR (tty, tiop);
|
||||
if (ioctl_ret < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (OUTPUT_BEING_FLUSHED (tiop))
|
||||
{
|
||||
#if defined (FLUSHO) && defined (_AIX41)
|
||||
rltty_warning ("turning off output flushing");
|
||||
tiop->c_lflag &= ~FLUSHO;
|
||||
break;
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
set_winsize (tty);
|
||||
|
||||
if (_get_tty_settings (tty, tiop) < 0)
|
||||
return -1;
|
||||
|
||||
#if defined (_AIX)
|
||||
setopost(tiop);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
while (SETATTR (tty, tiop) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
errno = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
if (_set_tty_settings (tty, tiop) < 0)
|
||||
return -1;
|
||||
|
||||
#if 0
|
||||
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
if (ksrflow)
|
||||
{
|
||||
ksrflow = 0;
|
||||
tcflow (tty, TCOON);
|
||||
}
|
||||
# else /* !ksr1 */
|
||||
tcflow (tty, TCOON); /* Simulate a ^Q. */
|
||||
# endif /* !ksr1 */
|
||||
#else
|
||||
ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
|
||||
#endif /* !TERMIOS_TTY_DRIVER */
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
readline_echoing_p = (oldtio.c_lflag & ECHO);
|
||||
|
||||
tiop->c_lflag &= ~(ICANON | ECHO);
|
||||
|
||||
if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
|
||||
_rl_eof_char = oldtio.c_cc[VEOF];
|
||||
|
||||
#if defined (USE_XON_XOFF)
|
||||
#if defined (IXANY)
|
||||
tiop->c_iflag &= ~(IXON | IXOFF | IXANY);
|
||||
#else
|
||||
/* `strict' Posix systems do not define IXANY. */
|
||||
tiop->c_iflag &= ~(IXON | IXOFF);
|
||||
#endif /* IXANY */
|
||||
#endif /* USE_XON_XOFF */
|
||||
|
||||
/* Only turn this off if we are using all 8 bits. */
|
||||
if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag)
|
||||
tiop->c_iflag &= ~(ISTRIP | INPCK);
|
||||
|
||||
/* Make sure we differentiate between CR and NL on input. */
|
||||
tiop->c_iflag &= ~(ICRNL | INLCR);
|
||||
|
||||
#if !defined (HANDLE_SIGNALS)
|
||||
tiop->c_lflag &= ~ISIG;
|
||||
#else
|
||||
tiop->c_lflag |= ISIG;
|
||||
#endif
|
||||
|
||||
tiop->c_cc[VMIN] = 1;
|
||||
tiop->c_cc[VTIME] = 0;
|
||||
|
||||
#if defined (FLUSHO)
|
||||
if (OUTPUT_BEING_FLUSHED (tiop))
|
||||
{
|
||||
tiop->c_lflag &= ~FLUSHO;
|
||||
oldtio.c_lflag &= ~FLUSHO;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Turn off characters that we need on Posix systems with job control,
|
||||
just to be sure. This includes ^Y and ^V. This should not really
|
||||
be necessary. */
|
||||
#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
|
||||
|
||||
#if defined (VLNEXT)
|
||||
tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
#if defined (VDSUSP)
|
||||
tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
|
||||
}
|
||||
#endif /* NEW_TTY_DRIVER */
|
||||
|
||||
/* Put the terminal in CBREAK mode so that we can detect key presses. */
|
||||
void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
{
|
||||
int tty;
|
||||
TIOTYPE tio;
|
||||
|
||||
if (terminal_prepped)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being INTerrupted. */
|
||||
block_sigint ();
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
if (get_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
otio = tio;
|
||||
|
||||
save_tty_chars (&otio);
|
||||
|
||||
prepare_terminal_settings (meta_flag, otio, &tio);
|
||||
|
||||
if (set_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_rl_enable_keypad)
|
||||
_rl_control_keypad (1);
|
||||
|
||||
fflush (rl_outstream);
|
||||
terminal_prepped = 1;
|
||||
RL_SETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
release_sigint ();
|
||||
}
|
||||
|
||||
/* Restore the terminal's normal settings and modes. */
|
||||
void
|
||||
rl_deprep_terminal ()
|
||||
{
|
||||
int tty;
|
||||
|
||||
if (!terminal_prepped)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being interrupted. */
|
||||
block_sigint ();
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
if (_rl_enable_keypad)
|
||||
_rl_control_keypad (0);
|
||||
|
||||
fflush (rl_outstream);
|
||||
|
||||
if (set_tty_settings (tty, &otio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
terminal_prepped = 0;
|
||||
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
release_sigint ();
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Bogus Flow Control */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
int
|
||||
rl_restart_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int fildes = fileno (rl_outstream);
|
||||
#if defined (TIOCSTART)
|
||||
#if defined (apollo)
|
||||
ioctl (&fildes, TIOCSTART, 0);
|
||||
#else
|
||||
ioctl (fildes, TIOCSTART, 0);
|
||||
#endif /* apollo */
|
||||
|
||||
#else /* !TIOCSTART */
|
||||
# if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
if (ksrflow)
|
||||
{
|
||||
ksrflow = 0;
|
||||
tcflow (fildes, TCOON);
|
||||
}
|
||||
# else /* !ksr1 */
|
||||
tcflow (fildes, TCOON); /* Simulate a ^Q. */
|
||||
# endif /* !ksr1 */
|
||||
# else /* !TERMIOS_TTY_DRIVER */
|
||||
# if defined (TCXONC)
|
||||
ioctl (fildes, TCXONC, TCOON);
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTART */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rl_stop_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int fildes = fileno (rl_instream);
|
||||
|
||||
#if defined (TIOCSTOP)
|
||||
# if defined (apollo)
|
||||
ioctl (&fildes, TIOCSTOP, 0);
|
||||
# else
|
||||
ioctl (fildes, TIOCSTOP, 0);
|
||||
# endif /* apollo */
|
||||
#else /* !TIOCSTOP */
|
||||
# if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
ksrflow = 1;
|
||||
# endif /* ksr1 */
|
||||
tcflow (fildes, TCOOFF);
|
||||
# else
|
||||
# if defined (TCXONC)
|
||||
ioctl (fildes, TCXONC, TCOON);
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTOP */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Default Key Bindings */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Set the system's default editing characters to their readline equivalents
|
||||
in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */
|
||||
void
|
||||
rltty_set_default_bindings (kmap)
|
||||
Keymap kmap;
|
||||
{
|
||||
TIOTYPE ttybuff;
|
||||
int tty = fileno (rl_instream);
|
||||
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
|
||||
#define SET_SPECIAL(sc, func) \
|
||||
do \
|
||||
{ \
|
||||
int ic; \
|
||||
ic = sc; \
|
||||
if (ic != -1 && kmap[(unsigned char)ic].type == ISFUNC) \
|
||||
kmap[(unsigned char)ic].function = func; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
if (get_tty_settings (tty, &ttybuff) == 0)
|
||||
{
|
||||
if (ttybuff.flags & SGTTY_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
|
||||
}
|
||||
|
||||
# if defined (TIOCGLTC)
|
||||
if (ttybuff.flags & LTCHARS_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
|
||||
SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
|
||||
}
|
||||
# endif /* TIOCGLTC */
|
||||
}
|
||||
|
||||
#else /* !NEW_TTY_DRIVER */
|
||||
|
||||
#define SET_SPECIAL(sc, func) \
|
||||
do \
|
||||
{ \
|
||||
unsigned char uc; \
|
||||
uc = ttybuff.c_cc[sc]; \
|
||||
if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
|
||||
kmap[uc].function = func; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
if (get_tty_settings (tty, &ttybuff) == 0)
|
||||
{
|
||||
SET_SPECIAL (VERASE, rl_rubout);
|
||||
SET_SPECIAL (VKILL, rl_unix_line_discard);
|
||||
|
||||
# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VLNEXT, rl_quoted_insert);
|
||||
# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
|
||||
|
||||
# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VWERASE, rl_unix_word_rubout);
|
||||
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
|
||||
}
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
}
|
||||
|
||||
/* New public way to set the system default editing chars to their readline
|
||||
equivalents. */
|
||||
void
|
||||
rl_tty_set_default_bindings (kmap)
|
||||
Keymap kmap;
|
||||
{
|
||||
rltty_set_default_bindings (kmap);
|
||||
}
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
int
|
||||
_rl_disable_tty_signals ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_restore_tty_signals ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
static TIOTYPE sigstty, nosigstty;
|
||||
static int tty_sigs_disabled = 0;
|
||||
|
||||
int
|
||||
_rl_disable_tty_signals ()
|
||||
{
|
||||
if (tty_sigs_disabled)
|
||||
return 0;
|
||||
|
||||
if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
|
||||
return -1;
|
||||
|
||||
nosigstty = sigstty;
|
||||
|
||||
nosigstty.c_lflag &= ~ISIG;
|
||||
nosigstty.c_iflag &= ~IXON;
|
||||
|
||||
if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
|
||||
return (_set_tty_settings (fileno (rl_instream), &sigstty));
|
||||
|
||||
tty_sigs_disabled = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_restore_tty_signals ()
|
||||
{
|
||||
int r;
|
||||
|
||||
if (tty_sigs_disabled == 0)
|
||||
return 0;
|
||||
|
||||
r = _set_tty_settings (fileno (rl_instream), &sigstty);
|
||||
|
||||
if (r == 0)
|
||||
tty_sigs_disabled = 0;
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
|
||||
#endif /* HANDLE_SIGNALS */
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/* rltty.h - tty driver-related definitions used by some library files. */
|
||||
|
||||
/* Copyright (C) 1995 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.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#if !defined (_RLTTY_H_)
|
||||
#define _RLTTY_H_
|
||||
|
||||
/* Posix systems use termios and the Posix signal functions. */
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# include <termios.h>
|
||||
#endif /* TERMIOS_TTY_DRIVER */
|
||||
|
||||
/* System V machines use termio. */
|
||||
#if defined (TERMIO_TTY_DRIVER)
|
||||
# include <termio.h>
|
||||
# if !defined (TCOON)
|
||||
# define TCOON 1
|
||||
# endif
|
||||
#endif /* TERMIO_TTY_DRIVER */
|
||||
|
||||
/* Other (BSD) machines use sgtty. */
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
# include <sgtty.h>
|
||||
#endif
|
||||
|
||||
#include "rlwinsize.h"
|
||||
|
||||
/* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
|
||||
it is not already defined. It is used both to determine if a
|
||||
special character is disabled and to disable certain special
|
||||
characters. Posix systems should set to 0, USG systems to -1. */
|
||||
#if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE)
|
||||
# if defined (_SVR4_VDISABLE)
|
||||
# define _POSIX_VDISABLE _SVR4_VDISABLE
|
||||
# else
|
||||
# if defined (_POSIX_VERSION)
|
||||
# define _POSIX_VDISABLE 0
|
||||
# else /* !_POSIX_VERSION */
|
||||
# define _POSIX_VDISABLE -1
|
||||
# endif /* !_POSIX_VERSION */
|
||||
# endif /* !_SVR4_DISABLE */
|
||||
#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
|
||||
|
||||
typedef struct _rl_tty_chars {
|
||||
char t_eof;
|
||||
char t_eol;
|
||||
char t_eol2;
|
||||
char t_erase;
|
||||
char t_werase;
|
||||
char t_kill;
|
||||
char t_reprint;
|
||||
char t_intr;
|
||||
char t_quit;
|
||||
char t_susp;
|
||||
char t_dsusp;
|
||||
char t_start;
|
||||
char t_stop;
|
||||
char t_lnext;
|
||||
char t_flush;
|
||||
char t_status;
|
||||
} _RL_TTY_CHARS;
|
||||
|
||||
#endif /* _RLTTY_H_ */
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/* rltypedefs.h -- Type declarations for readline functions. */
|
||||
|
||||
/* Copyright (C) 2000 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#ifndef _RL_TYPEDEFS_H_
|
||||
#define _RL_TYPEDEFS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Old-style */
|
||||
|
||||
#if !defined (_FUNCTION_DEF)
|
||||
# define _FUNCTION_DEF
|
||||
|
||||
typedef int Function ();
|
||||
typedef void VFunction ();
|
||||
typedef char *CPFunction ();
|
||||
typedef char **CPPFunction ();
|
||||
|
||||
#endif /* _FUNCTION_DEF */
|
||||
|
||||
/* New style. */
|
||||
|
||||
#if !defined (_RL_FUNCTION_TYPEDEF)
|
||||
# define _RL_FUNCTION_TYPEDEF
|
||||
|
||||
/* Bindable functions */
|
||||
typedef int rl_command_func_t PARAMS((int, int));
|
||||
|
||||
/* Typedefs for the completion system */
|
||||
typedef char *rl_compentry_func_t PARAMS((const char *, int));
|
||||
typedef char **rl_completion_func_t PARAMS((const char *, int, int));
|
||||
|
||||
typedef char *rl_quote_func_t PARAMS((char *, int, char *));
|
||||
typedef char *rl_dequote_func_t PARAMS((char *, int));
|
||||
|
||||
typedef int rl_compignore_func_t PARAMS((char **));
|
||||
|
||||
typedef void rl_compdisp_func_t PARAMS((char **, int, int));
|
||||
|
||||
/* Type for input and pre-read hook functions like rl_event_hook */
|
||||
typedef int rl_hook_func_t PARAMS((void));
|
||||
|
||||
/* Input function type */
|
||||
typedef int rl_getc_func_t PARAMS((FILE *));
|
||||
|
||||
/* Generic function that takes a character buffer (which could be the readline
|
||||
line buffer) and an index into it (which could be rl_point) and returns
|
||||
an int. */
|
||||
typedef int rl_linebuf_func_t PARAMS((char *, int));
|
||||
|
||||
/* `Generic' function pointer typedefs */
|
||||
typedef int rl_intfunc_t PARAMS((int));
|
||||
#define rl_ivoidfunc_t rl_hook_func_t
|
||||
typedef int rl_icpfunc_t PARAMS((char *));
|
||||
typedef int rl_icppfunc_t PARAMS((char **));
|
||||
|
||||
typedef void rl_voidfunc_t PARAMS((void));
|
||||
typedef void rl_vintfunc_t PARAMS((int));
|
||||
typedef void rl_vcpfunc_t PARAMS((char *));
|
||||
typedef void rl_vcppfunc_t PARAMS((char **));
|
||||
#endif /* _RL_FUNCTION_TYPEDEF */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RL_TYPEDEFS_H_ */
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/* rlwinsize.h -- an attempt to isolate some of the system-specific defines
|
||||
for `struct winsize' and TIOCGWINSZ. */
|
||||
|
||||
/* Copyright (C) 1997 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.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#if !defined (_RLWINSIZE_H_)
|
||||
#define _RLWINSIZE_H_
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
|
||||
|
||||
#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
# include <termios.h>
|
||||
#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
/* Not in either of the standard places, look around. */
|
||||
#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif /* HAVE_SYS_STREAM_H */
|
||||
# if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */
|
||||
# include <sys/ptem.h>
|
||||
# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */
|
||||
# endif /* HAVE_SYS_PTEM_H */
|
||||
# if defined (HAVE_SYS_PTE_H) /* ??? */
|
||||
# include <sys/pte.h>
|
||||
# endif /* HAVE_SYS_PTE_H */
|
||||
#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
#endif /* _RL_WINSIZE_H */
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/* savestring.c */
|
||||
|
||||
/* Copyright (C) 1998 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
|
||||
#include <config.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Backwards compatibility, now that savestring has been removed from
|
||||
all `public' readline header files. */
|
||||
char *
|
||||
savestring (s)
|
||||
const char *s;
|
||||
{
|
||||
return ((char *)strcpy ((char *)xmalloc (1 + strlen (s)), (s)));
|
||||
}
|
||||
|
|
@ -0,0 +1,465 @@
|
|||
/* search.c - code for non-incremental searching in emacs and vi modes. */
|
||||
|
||||
/* Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#ifdef abs
|
||||
# undef abs
|
||||
#endif
|
||||
#define abs(x) (((x) >= 0) ? (x) : -(x))
|
||||
|
||||
extern HIST_ENTRY *_rl_saved_line_for_history;
|
||||
|
||||
/* Functions imported from the rest of the library. */
|
||||
extern int _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
static char *noninc_search_string = (char *) NULL;
|
||||
static int noninc_history_pos;
|
||||
|
||||
static char *prev_line_found = (char *) NULL;
|
||||
|
||||
static int rl_history_search_len;
|
||||
static int rl_history_search_pos;
|
||||
static char *history_search_string;
|
||||
static int history_string_size;
|
||||
|
||||
static void make_history_line_current PARAMS((HIST_ENTRY *));
|
||||
static int noninc_search_from_pos PARAMS((char *, int, int));
|
||||
static void noninc_dosearch PARAMS((char *, int));
|
||||
static void noninc_search PARAMS((int, int));
|
||||
static int rl_history_search_internal PARAMS((int, int));
|
||||
static void rl_history_search_reinit PARAMS((void));
|
||||
|
||||
/* Make the data from the history entry ENTRY be the contents of the
|
||||
current line. This doesn't do anything with rl_point; the caller
|
||||
must set it. */
|
||||
static void
|
||||
make_history_line_current (entry)
|
||||
HIST_ENTRY *entry;
|
||||
{
|
||||
rl_replace_line (entry->line, 0);
|
||||
rl_undo_list = (UNDO_LIST *)entry->data;
|
||||
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
POS. If STRING begins with `^', the search must match STRING at the
|
||||
beginning of a history line, otherwise a full substring match is performed
|
||||
for STRING. DIR < 0 means to search backwards through the history list,
|
||||
DIR >= 0 means to search forward. */
|
||||
static int
|
||||
noninc_search_from_pos (string, pos, dir)
|
||||
char *string;
|
||||
int pos, dir;
|
||||
{
|
||||
int ret, old;
|
||||
|
||||
if (pos < 0)
|
||||
return -1;
|
||||
|
||||
old = where_history ();
|
||||
if (history_set_pos (pos) == 0)
|
||||
return -1;
|
||||
|
||||
RL_SETSTATE(RL_STATE_SEARCH);
|
||||
if (*string == '^')
|
||||
ret = history_search_prefix (string + 1, dir);
|
||||
else
|
||||
ret = history_search (string, dir);
|
||||
RL_UNSETSTATE(RL_STATE_SEARCH);
|
||||
|
||||
if (ret != -1)
|
||||
ret = where_history ();
|
||||
|
||||
history_set_pos (old);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Search for a line in the history containing STRING. If DIR is < 0, the
|
||||
search is backwards through previous entries, else through subsequent
|
||||
entries. */
|
||||
static void
|
||||
noninc_dosearch (string, dir)
|
||||
char *string;
|
||||
int dir;
|
||||
{
|
||||
int oldpos, pos;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
|
||||
{
|
||||
rl_ding ();
|
||||
return;
|
||||
}
|
||||
|
||||
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir);
|
||||
if (pos == -1)
|
||||
{
|
||||
/* Search failed, current history position unchanged. */
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = 0;
|
||||
rl_ding ();
|
||||
return;
|
||||
}
|
||||
|
||||
noninc_history_pos = pos;
|
||||
|
||||
oldpos = where_history ();
|
||||
history_set_pos (noninc_history_pos);
|
||||
entry = current_history ();
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode != vi_mode)
|
||||
#endif
|
||||
history_set_pos (oldpos);
|
||||
|
||||
make_history_line_current (entry);
|
||||
|
||||
rl_point = 0;
|
||||
rl_mark = rl_end;
|
||||
|
||||
rl_clear_message ();
|
||||
}
|
||||
|
||||
/* Search non-interactively through the history list. DIR < 0 means to
|
||||
search backwards through the history of previous commands; otherwise
|
||||
the search is for commands subsequent to the current position in the
|
||||
history list. PCHAR is the character to use for prompting when reading
|
||||
the search string; if not specified (0), it defaults to `:'. */
|
||||
static void
|
||||
noninc_search (dir, pchar)
|
||||
int dir;
|
||||
int pchar;
|
||||
{
|
||||
int saved_point, saved_mark, c;
|
||||
char *p;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
char mb[MB_LEN_MAX];
|
||||
#endif
|
||||
|
||||
rl_maybe_save_line ();
|
||||
saved_point = rl_point;
|
||||
saved_mark = rl_mark;
|
||||
|
||||
/* Use the line buffer to read the search string. */
|
||||
rl_line_buffer[0] = 0;
|
||||
rl_end = rl_point = 0;
|
||||
|
||||
p = _rl_make_prompt_for_search (pchar ? pchar : ':');
|
||||
rl_message (p, 0, 0);
|
||||
free (p);
|
||||
|
||||
#define SEARCH_RETURN rl_restore_prompt (); RL_UNSETSTATE(RL_STATE_NSEARCH); return
|
||||
|
||||
RL_SETSTATE(RL_STATE_NSEARCH);
|
||||
/* Read the search string. */
|
||||
while (1)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
|
||||
#endif
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case CTRL('H'):
|
||||
case RUBOUT:
|
||||
if (rl_point == 0)
|
||||
{
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = saved_point;
|
||||
rl_mark = saved_mark;
|
||||
SEARCH_RETURN;
|
||||
}
|
||||
_rl_rubout_char (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('W'):
|
||||
rl_unix_word_rubout (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('U'):
|
||||
rl_unix_line_discard (1, c);
|
||||
break;
|
||||
|
||||
case RETURN:
|
||||
case NEWLINE:
|
||||
goto dosearch;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
|
||||
case CTRL('C'):
|
||||
case CTRL('G'):
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = saved_point;
|
||||
rl_mark = saved_mark;
|
||||
rl_ding ();
|
||||
SEARCH_RETURN;
|
||||
|
||||
default:
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
rl_insert_text (mb);
|
||||
else
|
||||
#endif
|
||||
_rl_insert_char (1, c);
|
||||
break;
|
||||
}
|
||||
(*rl_redisplay_function) ();
|
||||
}
|
||||
|
||||
dosearch:
|
||||
rl_mark = saved_mark;
|
||||
|
||||
/* If rl_point == 0, we want to re-use the previous search string and
|
||||
start from the saved history position. If there's no previous search
|
||||
string, punt. */
|
||||
if (rl_point == 0)
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
SEARCH_RETURN;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We want to start the search from the current history position. */
|
||||
noninc_history_pos = where_history ();
|
||||
FREE (noninc_search_string);
|
||||
noninc_search_string = savestring (rl_line_buffer);
|
||||
}
|
||||
|
||||
rl_restore_prompt ();
|
||||
noninc_dosearch (noninc_search_string, dir);
|
||||
RL_UNSETSTATE(RL_STATE_NSEARCH);
|
||||
}
|
||||
|
||||
/* Search forward through the history list for a string. If the vi-mode
|
||||
code calls this, KEY will be `?'. */
|
||||
int
|
||||
rl_noninc_forward_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
noninc_search (1, (key == '?') ? '?' : 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reverse search the history list for a string. If the vi-mode code
|
||||
calls this, KEY will be `/'. */
|
||||
int
|
||||
rl_noninc_reverse_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
noninc_search (-1, (key == '/') ? '/' : 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Search forward through the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_forward_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
noninc_dosearch (noninc_search_string, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reverse search in the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_reverse_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
noninc_dosearch (noninc_search_string, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rl_history_search_internal (count, dir)
|
||||
int count, dir;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
int ret, oldpos;
|
||||
|
||||
rl_maybe_save_line ();
|
||||
temp = (HIST_ENTRY *)NULL;
|
||||
|
||||
/* Search COUNT times through the history for a line whose prefix
|
||||
matches history_search_string. When this loop finishes, TEMP,
|
||||
if non-null, is the history line to copy into the line buffer. */
|
||||
while (count)
|
||||
{
|
||||
ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir);
|
||||
if (ret == -1)
|
||||
break;
|
||||
|
||||
/* Get the history entry we found. */
|
||||
rl_history_search_pos = ret;
|
||||
oldpos = where_history ();
|
||||
history_set_pos (rl_history_search_pos);
|
||||
temp = current_history ();
|
||||
history_set_pos (oldpos);
|
||||
|
||||
/* Don't find multiple instances of the same line. */
|
||||
if (prev_line_found && STREQ (prev_line_found, temp->line))
|
||||
continue;
|
||||
prev_line_found = temp->line;
|
||||
count--;
|
||||
}
|
||||
|
||||
/* If we didn't find anything at all, return. */
|
||||
if (temp == 0)
|
||||
{
|
||||
rl_maybe_unsave_line ();
|
||||
rl_ding ();
|
||||
/* If you don't want the saved history line (last match) to show up
|
||||
in the line buffer after the search fails, change the #if 0 to
|
||||
#if 1 */
|
||||
#if 0
|
||||
if (rl_point > rl_history_search_len)
|
||||
{
|
||||
rl_point = rl_end = rl_history_search_len;
|
||||
rl_line_buffer[rl_end] = '\0';
|
||||
rl_mark = 0;
|
||||
}
|
||||
#else
|
||||
rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */
|
||||
rl_mark = rl_end;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Copy the line we found into the current line buffer. */
|
||||
make_history_line_current (temp);
|
||||
|
||||
rl_point = rl_history_search_len;
|
||||
rl_mark = rl_end;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rl_history_search_reinit ()
|
||||
{
|
||||
rl_history_search_pos = where_history ();
|
||||
rl_history_search_len = rl_point;
|
||||
prev_line_found = (char *)NULL;
|
||||
if (rl_point)
|
||||
{
|
||||
if (rl_history_search_len >= history_string_size - 2)
|
||||
{
|
||||
history_string_size = rl_history_search_len + 2;
|
||||
history_search_string = (char *)xrealloc (history_search_string, history_string_size);
|
||||
}
|
||||
history_search_string[0] = '^';
|
||||
strncpy (history_search_string + 1, rl_line_buffer, rl_point);
|
||||
history_search_string[rl_point + 1] = '\0';
|
||||
}
|
||||
_rl_free_saved_history_line ();
|
||||
}
|
||||
|
||||
/* Search forward in the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_search_forward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_search_forward &&
|
||||
rl_last_func != rl_history_search_backward)
|
||||
rl_history_search_reinit ();
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_next_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
|
||||
}
|
||||
|
||||
/* Search backward through the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_search_backward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_search_forward &&
|
||||
rl_last_func != rl_history_search_backward)
|
||||
rl_history_search_reinit ();
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_previous_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
|
||||
}
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
/* shell.c -- readline utility functions that are normally provided by
|
||||
bash when readline is linked as part of the shell. */
|
||||
|
||||
/* Copyright (C) 1997 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if defined (HAVE_LIMITS_H)
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rlstdc.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid PARAMS((uid_t));
|
||||
#endif /* !HAVE_GETPW_DECLS */
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* Nonzero if the integer type T is signed. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
|
||||
/* Bound on length of the string representing an integer value of type T.
|
||||
Subtract one for the sign bit if T is signed;
|
||||
302 / 1000 is log10 (2) rounded up;
|
||||
add one for integer division truncation;
|
||||
add one more for a minus sign if t is signed. */
|
||||
#define INT_STRLEN_BOUND(t) \
|
||||
((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \
|
||||
+ 1 + TYPE_SIGNED (t))
|
||||
|
||||
/* All of these functions are resolved from bash if we are linking readline
|
||||
as part of bash. */
|
||||
|
||||
/* Does shell-like quoting using single quotes. */
|
||||
char *
|
||||
sh_single_quote (string)
|
||||
char *string;
|
||||
{
|
||||
register int c;
|
||||
char *result, *r, *s;
|
||||
|
||||
result = (char *)xmalloc (3 + (4 * strlen (string)));
|
||||
r = result;
|
||||
*r++ = '\'';
|
||||
|
||||
for (s = string; s && (c = *s); s++)
|
||||
{
|
||||
*r++ = c;
|
||||
|
||||
if (c == '\'')
|
||||
{
|
||||
*r++ = '\\'; /* insert escaped single quote */
|
||||
*r++ = '\'';
|
||||
*r++ = '\''; /* start new quoted string */
|
||||
}
|
||||
}
|
||||
|
||||
*r++ = '\'';
|
||||
*r = '\0';
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Set the environment variables LINES and COLUMNS to lines and cols,
|
||||
respectively. */
|
||||
void
|
||||
sh_set_lines_and_columns (lines, cols)
|
||||
int lines, cols;
|
||||
{
|
||||
char *b;
|
||||
|
||||
#if defined (HAVE_PUTENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
|
||||
sprintf (b, "LINES=%d", lines);
|
||||
putenv (b);
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
|
||||
sprintf (b, "COLUMNS=%d", cols);
|
||||
putenv (b);
|
||||
#else /* !HAVE_PUTENV */
|
||||
# if defined (HAVE_SETENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
|
||||
sprintf (b, "%d", lines);
|
||||
setenv ("LINES", b, 1);
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
|
||||
sprintf (b, "%d", cols);
|
||||
setenv ("COLUMNS", b, 1);
|
||||
# endif /* HAVE_SETENV */
|
||||
#endif /* !HAVE_PUTENV */
|
||||
}
|
||||
|
||||
char *
|
||||
sh_get_env_value (varname)
|
||||
const char *varname;
|
||||
{
|
||||
return ((char *)getenv (varname));
|
||||
}
|
||||
|
||||
char *
|
||||
sh_get_home_dir ()
|
||||
{
|
||||
char *home_dir;
|
||||
struct passwd *entry;
|
||||
|
||||
home_dir = (char *)NULL;
|
||||
entry = getpwuid (getuid ());
|
||||
if (entry)
|
||||
home_dir = entry->pw_dir;
|
||||
return (home_dir);
|
||||
}
|
||||
|
||||
#if !defined (O_NDELAY)
|
||||
# if defined (FNDELAY)
|
||||
# define O_NDELAY FNDELAY
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int
|
||||
sh_unset_nodelay_mode (fd)
|
||||
int fd;
|
||||
{
|
||||
int flags, bflags;
|
||||
|
||||
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
|
||||
return -1;
|
||||
|
||||
bflags = 0;
|
||||
|
||||
#ifdef O_NONBLOCK
|
||||
bflags |= O_NONBLOCK;
|
||||
#endif
|
||||
|
||||
#ifdef O_NDELAY
|
||||
bflags |= O_NDELAY;
|
||||
#endif
|
||||
|
||||
if (flags & bflags)
|
||||
{
|
||||
flags &= ~bflags;
|
||||
return (fcntl (fd, F_SETFL, flags));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,437 @@
|
|||
## -*- text -*- ##
|
||||
# Makefile for the GNU readline library shared library support.
|
||||
#
|
||||
# Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
# This program 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.
|
||||
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
RL_LIBRARY_VERSION = @LIBVERSION@
|
||||
RL_LIBRARY_NAME = readline
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@top_srcdir@
|
||||
topdir = @top_srcdir@
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
CC = @CC@
|
||||
RANLIB = @RANLIB@
|
||||
AR = @AR@
|
||||
ARFLAGS = @ARFLAGS@
|
||||
RM = rm -f
|
||||
CP = cp
|
||||
MV = mv
|
||||
LN = ln
|
||||
|
||||
SHELL = @MAKE_SHELL@
|
||||
|
||||
host_os = @host_os@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
includedir = @includedir@
|
||||
libdir = @libdir@
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
||||
CFLAGS = @CFLAGS@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@ @CFLAGS@
|
||||
|
||||
DEFS = @DEFS@
|
||||
LOCAL_DEFS = @LOCAL_DEFS@
|
||||
|
||||
#
|
||||
# These values are generated for configure by ${topdir}/support/shobj-conf.
|
||||
# If your system is not supported by that script, but includes facilities for
|
||||
# dynamic loading of shared objects, please update the script and send the
|
||||
# changes to bash-maintainers@gnu.org.
|
||||
#
|
||||
SHOBJ_CC = @SHOBJ_CC@
|
||||
SHOBJ_CFLAGS = @SHOBJ_CFLAGS@
|
||||
SHOBJ_LD = @SHOBJ_LD@
|
||||
|
||||
SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@
|
||||
SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@
|
||||
SHOBJ_LIBS = @SHOBJ_LIBS@
|
||||
|
||||
SHLIB_XLDFLAGS = @SHLIB_XLDFLAGS@
|
||||
SHLIB_LIBS = @SHLIB_LIBS@
|
||||
SHLIB_LIBSUFF = @SHLIB_LIBSUFF@
|
||||
|
||||
SHLIB_LIBVERSION = @SHLIB_LIBVERSION@
|
||||
|
||||
SHLIB_STATUS = @SHLIB_STATUS@
|
||||
|
||||
# shared library versioning
|
||||
SHLIB_MAJOR= @SHLIB_MAJOR@
|
||||
# shared library systems like SVR4's do not use minor versions
|
||||
SHLIB_MINOR= .@SHLIB_MINOR@
|
||||
|
||||
# For libraries which include headers from other libraries.
|
||||
INCLUDES = -I. -I.. -I$(topdir)
|
||||
|
||||
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS)
|
||||
|
||||
.SUFFIXES: .so
|
||||
|
||||
.c.so:
|
||||
${RM} $@
|
||||
$(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_CFLAGS) -o $*.o $<
|
||||
$(MV) $*.o $@
|
||||
|
||||
# The name of the main library target.
|
||||
|
||||
SHARED_READLINE = libreadline.$(SHLIB_LIBVERSION)
|
||||
SHARED_HISTORY = libhistory.$(SHLIB_LIBVERSION)
|
||||
SHARED_LIBS = $(SHARED_READLINE) $(SHARED_HISTORY)
|
||||
|
||||
# The C code source files for this library.
|
||||
CSOURCES = $(topdir)/readline.c $(topdir)/funmap.c $(topdir)/keymaps.c \
|
||||
$(topdir)/vi_mode.c $(topdir)/parens.c $(topdir)/rltty.c \
|
||||
$(topdir)/complete.c $(topdir)/bind.c $(topdir)/isearch.c \
|
||||
$(topdir)/display.c $(topdir)/signals.c $(topdir)/emacs_keymap.c \
|
||||
$(topdir)/vi_keymap.c $(topdir)/util.c $(topdir)/kill.c \
|
||||
$(topdir)/undo.c $(topdir)/macro.c $(topdir)/input.c \
|
||||
$(topdir)/callback.c $(topdir)/terminal.c $(topdir)/xmalloc.c \
|
||||
$(topdir)/history.c $(topdir)/histsearch.c $(topdir)/histexpand.c \
|
||||
$(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \
|
||||
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \
|
||||
$(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \
|
||||
$(topdir)/mbutil.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
|
||||
posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
|
||||
ansi_stdlib.h tcap.h xmalloc.h rlprivate.h rlshell.h rlmbutil.h
|
||||
|
||||
SHARED_HISTOBJ = history.so histexpand.so histfile.so histsearch.so shell.so \
|
||||
mbutil.so
|
||||
SHARED_TILDEOBJ = tilde.so
|
||||
SHARED_OBJ = readline.so vi_mode.so funmap.so keymaps.so parens.so search.so \
|
||||
rltty.so complete.so bind.so isearch.so display.so signals.so \
|
||||
util.so kill.so undo.so macro.so input.so callback.so terminal.so \
|
||||
text.so nls.so misc.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) \
|
||||
compat.so
|
||||
|
||||
##########################################################################
|
||||
|
||||
all: $(SHLIB_STATUS)
|
||||
|
||||
supported: $(SHARED_LIBS)
|
||||
|
||||
unsupported:
|
||||
@echo "Your system and compiler (${host_os}-${CC}) are not supported by the"
|
||||
@echo "${topdir}/support/shobj-conf script."
|
||||
@echo "If your operating system provides facilities for creating"
|
||||
@echo "shared libraries, please update the script and re-run configure."
|
||||
@echo "Please send the changes you made to bash-maintainers@gnu.org"
|
||||
@echo "for inclusion in future bash and readline releases."
|
||||
|
||||
$(SHARED_READLINE): $(SHARED_OBJ)
|
||||
$(RM) $@
|
||||
$(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_OBJ) $(SHLIB_LIBS)
|
||||
|
||||
$(SHARED_HISTORY): $(SHARED_HISTOBJ) xmalloc.so
|
||||
$(RM) $@
|
||||
$(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_HISTOBJ) xmalloc.so $(SHLIB_LIBS)
|
||||
|
||||
# Since tilde.c is shared between readline and bash, make sure we compile
|
||||
# it with the right flags when it's built as part of readline
|
||||
tilde.so: tilde.c
|
||||
${RM} $@
|
||||
$(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_CFLAGS) -DREADLINE_LIBRARY -c -o tilde.o $(topdir)/tilde.c
|
||||
$(MV) tilde.o $@
|
||||
|
||||
installdirs: $(topdir)/support/mkdirs
|
||||
-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(libdir)
|
||||
|
||||
install: installdirs $(SHLIB_STATUS)
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
|
||||
@echo install: you may need to run ldconfig
|
||||
|
||||
uninstall:
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -U $(SHARED_HISTORY)
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -U $(SHARED_READLINE)
|
||||
@echo uninstall: you may need to run ldconfig
|
||||
|
||||
clean mostlyclean: force
|
||||
$(RM) $(SHARED_OBJ) $(SHARED_LIBS)
|
||||
|
||||
distclean maintainer-clean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
force:
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
||||
# Dependencies
|
||||
bind.so: $(topdir)/ansi_stdlib.h $(topdir)/posixstat.h
|
||||
bind.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
bind.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
bind.so: $(topdir)/rltypedefs.h
|
||||
bind.so: $(topdir)/tilde.h $(topdir)/history.h
|
||||
compat.so: $(topdir)/rlstdc.h
|
||||
callback.so: $(topdir)/rlconf.h
|
||||
callback.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h
|
||||
callback.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
callback.so: $(topdir)/rltypedefs.h
|
||||
callback.so: $(topdir)/tilde.h
|
||||
complete.so: $(topdir)/ansi_stdlib.h posixdir.h $(topdir)/posixstat.h
|
||||
complete.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
complete.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
complete.so: $(topdir)/rltypedefs.h
|
||||
complete.so: $(topdir)/tilde.h
|
||||
display.so: $(topdir)/ansi_stdlib.h $(topdir)/posixstat.h
|
||||
display.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
display.so: $(topdir)/tcap.h
|
||||
display.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
display.so: $(topdir)/rltypedefs.h
|
||||
display.so: $(topdir)/tilde.h $(topdir)/history.h
|
||||
funmap.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
funmap.so: $(topdir)/rltypedefs.h
|
||||
funmap.so: $(topdir)/rlconf.h $(topdir)/ansi_stdlib.h
|
||||
funmap.so: ${BUILD_DIR}/config.h $(topdir)/tilde.h
|
||||
histexpand.so: $(topdir)/ansi_stdlib.h
|
||||
histexpand.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
|
||||
histexpand.so: ${BUILD_DIR}/config.h
|
||||
histfile.so: $(topdir)/ansi_stdlib.h
|
||||
histfile.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
|
||||
histfile.so: ${BUILD_DIR}/config.h
|
||||
history.so: $(topdir)/ansi_stdlib.h
|
||||
history.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
|
||||
history.so: ${BUILD_DIR}/config.h
|
||||
histsearch.so: $(topdir)/ansi_stdlib.h
|
||||
histsearch.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
|
||||
histsearch.so: ${BUILD_DIR}/config.h
|
||||
input.so: $(topdir)/ansi_stdlib.h
|
||||
input.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
input.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
input.so: $(topdir)/rltypedefs.h
|
||||
input.so: $(topdir)/tilde.h
|
||||
isearch.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
isearch.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
isearch.so: $(topdir)/rltypedefs.h
|
||||
isearch.so: $(topdir)/ansi_stdlib.h $(topdir)/history.h $(topdir)/tilde.h
|
||||
keymaps.so: emacs_keymap.c vi_keymap.c
|
||||
keymaps.so: $(topdir)/keymaps.h $(topdir)/chardefs.h $(topdir)/rlconf.h
|
||||
keymaps.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
keymaps.so: $(topdir)/rltypedefs.h
|
||||
keymaps.so: ${BUILD_DIR}/config.h $(topdir)/ansi_stdlib.h $(topdir)/tilde.h
|
||||
kill.so: $(topdir)/ansi_stdlib.h
|
||||
kill.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
kill.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
kill.so: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rltypedefs.h
|
||||
macro.so: $(topdir)/ansi_stdlib.h
|
||||
macro.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
macro.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
macro.so: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rltypedefs.h
|
||||
mbutil.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
mbutil.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/rltypedefs.h
|
||||
mbutil.so: $(topdir)/chardefs.h $(topdir)/rlstdc.h
|
||||
misc.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
misc.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
misc.so: $(topdir)/rltypedefs.h
|
||||
misc.so: $(topdir)/history.h $(topdir)/tilde.h $(topdir)/ansi_stdlib.h
|
||||
nls.so: $(topdir)/ansi_stdlib.h
|
||||
nls.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
nls.o: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
nls.o: $(topdir)/rltypedefs.h
|
||||
nls.o: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rlstdc.h
|
||||
parens.so: $(topdir)/rlconf.h ${BUILD_DIR}/config.h
|
||||
parens.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
parens.so: $(topdir)/rltypedefs.h
|
||||
parens.so: $(topdir)/tilde.h
|
||||
rltty.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
rltty.so: $(topdir)/rltty.h $(topdir)/tilde.h
|
||||
rltty.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
rltty.so: $(topdir)/rltypedefs.h
|
||||
search.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
search.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
search.so: $(topdir)/ansi_stdlib.h $(topdir)/history.h $(topdir)/tilde.h
|
||||
search.so: $(topdir)/rltypedefs.h
|
||||
signals.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
signals.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
signals.so: $(topdir)/history.h $(topdir)/tilde.h
|
||||
signals.so: $(topdir)/rltypedefs.h
|
||||
terminal.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
terminal.so: $(topdir)/tcap.h
|
||||
terminal.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
terminal.so: $(topdir)/tilde.h $(topdir)/history.h
|
||||
terminal.so: $(topdir)/rltypedefs.h
|
||||
text.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
text.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
text.so: $(topdir)/rltypedefs.h
|
||||
text.so: $(topdir)/history.h $(topdir)/tilde.h $(topdir)/ansi_stdlib.h
|
||||
tilde.so: $(topdir)/ansi_stdlib.h ${BUILD_DIR}/config.h $(topdir)/tilde.h
|
||||
undo.so: $(topdir)/ansi_stdlib.h
|
||||
undo.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
undo.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
undo.so: $(topdir)/rltypedefs.h
|
||||
undo.so: $(topdir)/tilde.h $(topdir)/history.h
|
||||
util.so: $(topdir)/posixjmp.h $(topdir)/ansi_stdlib.h
|
||||
util.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
util.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
util.so: $(topdir)/rltypedefs.h $(topdir)/tilde.h
|
||||
vi_mode.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
|
||||
vi_mode.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
|
||||
vi_mode.so: $(topdir)/history.h $(topdir)/ansi_stdlib.h $(topdir)/tilde.h
|
||||
vi_mode.so: $(topdir)/rltypedefs.h
|
||||
xmalloc.so: ${BUILD_DIR}/config.h
|
||||
xmalloc.so: $(topdir)/ansi_stdlib.h
|
||||
|
||||
bind.so: $(topdir)/rlshell.h
|
||||
histfile.so: $(topdir)/rlshell.h
|
||||
nls.so: $(topdir)/rlshell.h
|
||||
readline.so: $(topdir)/rlshell.h
|
||||
shell.so: $(topdir)/rlshell.h
|
||||
terminal.so: $(topdir)/rlshell.h
|
||||
histexpand.so: $(topdir)/rlshell.h
|
||||
|
||||
bind.so: $(topdir)/rlprivate.h
|
||||
callback.so: $(topdir)/rlprivate.h
|
||||
complete.so: $(topdir)/rlprivate.h
|
||||
display.so: $(topdir)/rlprivate.h
|
||||
input.so: $(topdir)/rlprivate.h
|
||||
isearch.so: $(topdir)/rlprivate.h
|
||||
kill.so: $(topdir)/rlprivate.h
|
||||
macro.so: $(topdir)/rlprivate.h
|
||||
mbutil.so: $(topdir)/rlprivate.h
|
||||
misc.so: $(topdir)/rlprivate.h
|
||||
nls.so: $(topdir)/rlprivate.h
|
||||
parens.so: $(topdir)/rlprivate.h
|
||||
readline.so: $(topdir)/rlprivate.h
|
||||
rltty.so: $(topdir)/rlprivate.h
|
||||
search.so: $(topdir)/rlprivate.h
|
||||
signals.so: $(topdir)/rlprivate.h
|
||||
terminal.so: $(topdir)/rlprivate.h
|
||||
text.so: $(topdir)/rlprivate.h
|
||||
undo.so: $(topdir)/rlprivate.h
|
||||
util.so: $(topdir)/rlprivate.h
|
||||
vi_mode.so: $(topdir)/rlprivate.h
|
||||
|
||||
bind.so: $(topdir)/xmalloc.h
|
||||
complete.so: $(topdir)/xmalloc.h
|
||||
display.so: $(topdir)/xmalloc.h
|
||||
funmap.so: $(topdir)/xmalloc.h
|
||||
histexpand.so: $(topdir)/xmalloc.h
|
||||
histfile.so: $(topdir)/xmalloc.h
|
||||
history.so: $(topdir)/xmalloc.h
|
||||
input.so: $(topdir)/xmalloc.h
|
||||
isearch.so: $(topdir)/xmalloc.h
|
||||
keymaps.so: $(topdir)/xmalloc.h
|
||||
kill.so: $(topdir)/xmalloc.h
|
||||
macro.so: $(topdir)/xmalloc.h
|
||||
mbutil.so: $(topdir)/xmalloc.h
|
||||
misc.so: $(topdir)/xmalloc.h
|
||||
readline.so: $(topdir)/xmalloc.h
|
||||
savestring.so: $(topdir)/xmalloc.h
|
||||
search.so: $(topdir)/xmalloc.h
|
||||
shell.so: $(topdir)/xmalloc.h
|
||||
terminal.so: $(topdir)/xmalloc.h
|
||||
text.so: $(topdir)/xmalloc.h
|
||||
tilde.so: $(topdir)/xmalloc.h
|
||||
undo.so: $(topdir)/xmalloc.h
|
||||
util.so: $(topdir)/xmalloc.h
|
||||
vi_mode.so: $(topdir)/xmalloc.h
|
||||
xmalloc.so: $(topdir)/xmalloc.h
|
||||
|
||||
complete.o: $(topdir)/rlmbutil.h
|
||||
display.o: $(topdir)/rlmbutil.h
|
||||
histexpand.o: $(topdir)/rlmbutil.h
|
||||
input.o: $(topdir)/rlmbutil.h
|
||||
isearch.o: $(topdir)/rlmbutil.h
|
||||
mbutil.o: $(topdir)/rlmbutil.h
|
||||
misc.o: $(topdir)/rlmbutil.h
|
||||
readline.o: $(topdir)/rlmbutil.h
|
||||
search.o: $(topdir)/rlmbutil.h
|
||||
text.o: $(topdir)/rlmbutil.h
|
||||
vi_mode.o: $(topdir)/rlmbutil.h
|
||||
|
||||
bind.so: $(topdir)/bind.c
|
||||
callback.so: $(topdir)/callback.c
|
||||
compat.so: $(topdir)/compat.c
|
||||
complete.so: $(topdir)/complete.c
|
||||
display.so: $(topdir)/display.c
|
||||
funmap.so: $(topdir)/funmap.c
|
||||
input.so: $(topdir)/input.c
|
||||
isearch.so: $(topdir)/isearch.c
|
||||
keymaps.so: $(topdir)/keymaps.c $(topdir)/emacs_keymap.c $(topdir)/vi_keymap.c
|
||||
kill.so: $(topdir)/kill.c
|
||||
macro.so: $(topdir)/macro.c
|
||||
mbutil.so: $(topdir)/mbutil.c
|
||||
misc.so: $(topdir)/mbutil.c
|
||||
nls.so: $(topdir)/nls.c
|
||||
parens.so: $(topdir)/parens.c
|
||||
readline.so: $(topdir)/readline.c
|
||||
rltty.so: $(topdir)/rltty.c
|
||||
savestring.so: $(topdir)/savestring.c
|
||||
search.so: $(topdir)/search.c
|
||||
shell.so: $(topdir)/shell.c
|
||||
signals.so: $(topdir)/signals.c
|
||||
terminal.so: $(topdir)/terminal.c
|
||||
text.so: $(topdir)/terminal.c
|
||||
tilde.so: $(topdir)/tilde.c
|
||||
undo.so: $(topdir)/undo.c
|
||||
util.so: $(topdir)/util.c
|
||||
vi_mode.so: $(topdir)/vi_mode.c
|
||||
xmalloc.so: $(topdir)/xmalloc.c
|
||||
|
||||
histexpand.so: $(topdir)/histexpand.c
|
||||
histfile.so: $(topdir)/histfile.c
|
||||
history.so: $(topdir)/history.c
|
||||
histsearch.so: $(topdir)/histsearch.c
|
||||
|
||||
bind.so: bind.c
|
||||
callback.so: callback.c
|
||||
comapt.so: compat.c
|
||||
complete.so: complete.c
|
||||
display.so: display.c
|
||||
funmap.so: funmap.c
|
||||
input.so: input.c
|
||||
isearch.so: isearch.c
|
||||
keymaps.so: keymaps.c emacs_keymap.c vi_keymap.c
|
||||
kill.so: kill.c
|
||||
macro.so: macro.c
|
||||
mbutil.so: mbutil.c
|
||||
misc.so: misc.c
|
||||
nls.so: nls.c
|
||||
parens.so: parens.c
|
||||
readline.so: readline.c
|
||||
rltty.so: rltty.c
|
||||
savestring.so: savestring.c
|
||||
search.so: search.c
|
||||
signals.so: signals.c
|
||||
shell.so: shell.c
|
||||
terminal.so: terminal.c
|
||||
text.so: terminal.c
|
||||
tilde.so: tilde.c
|
||||
undo.so: undo.c
|
||||
util.so: util.c
|
||||
vi_mode.so: vi_mode.c
|
||||
xmalloc.so: xmalloc.c
|
||||
|
||||
histexpand.so: histexpand.c
|
||||
histfile.so: histfile.c
|
||||
history.so: history.c
|
||||
histsearch.so: histsearch.c
|
||||
|
|
@ -0,0 +1,398 @@
|
|||
/* signals.c -- signal handling support for readline. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* Just for NULL. Yuck. */
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL */
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
|
||||
#if !defined (RETSIGTYPE)
|
||||
# if defined (VOID_SIGHANDLER)
|
||||
# define RETSIGTYPE void
|
||||
# else
|
||||
# define RETSIGTYPE int
|
||||
# endif /* !VOID_SIGHANDLER */
|
||||
#endif /* !RETSIGTYPE */
|
||||
|
||||
#if defined (VOID_SIGHANDLER)
|
||||
# define SIGHANDLER_RETURN return
|
||||
#else
|
||||
# define SIGHANDLER_RETURN return (0)
|
||||
#endif
|
||||
|
||||
/* This typedef is equivalent to the one for Function; it allows us
|
||||
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
|
||||
typedef RETSIGTYPE SigHandler ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
typedef struct sigaction sighandler_cxt;
|
||||
# define rl_sigaction(s, nh, oh) sigaction(s, nh, oh)
|
||||
#else
|
||||
typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
|
||||
# define sigemptyset(m)
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
|
||||
/* Exported variables for use by applications. */
|
||||
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
|
||||
int rl_catch_signals = 1;
|
||||
|
||||
/* If non-zero, readline will install a signal handler for SIGWINCH. */
|
||||
#ifdef SIGWINCH
|
||||
int rl_catch_sigwinch = 1;
|
||||
#endif
|
||||
|
||||
static int signals_set_flag;
|
||||
static int sigwinch_set_flag;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Signal Handling */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static sighandler_cxt old_int, old_term, old_alrm, old_quit;
|
||||
#if defined (SIGTSTP)
|
||||
static sighandler_cxt old_tstp, old_ttou, old_ttin;
|
||||
#endif
|
||||
#if defined (SIGWINCH)
|
||||
static sighandler_cxt old_winch;
|
||||
#endif
|
||||
|
||||
/* Readline signal handler functions. */
|
||||
|
||||
static RETSIGTYPE
|
||||
rl_signal_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigset_t set;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
long omask;
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
sighandler_cxt dummy_cxt; /* needed for rl_set_sighandler call */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
RL_SETSTATE(RL_STATE_SIGHANDLER);
|
||||
|
||||
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
|
||||
/* Since the signal will not be blocked while we are in the signal
|
||||
handler, ignore it until rl_clear_signals resets the catcher. */
|
||||
if (sig == SIGINT || sig == SIGALRM)
|
||||
rl_set_sighandler (sig, SIG_IGN, &dummy_cxt);
|
||||
#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case SIGINT:
|
||||
rl_free_line_state ();
|
||||
/* FALLTHROUGH */
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
case SIGTSTP:
|
||||
case SIGTTOU:
|
||||
case SIGTTIN:
|
||||
#endif /* SIGTSTP */
|
||||
case SIGALRM:
|
||||
case SIGTERM:
|
||||
case SIGQUIT:
|
||||
rl_cleanup_after_signal ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
|
||||
sigdelset (&set, sig);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
omask = sigblock (0);
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
#if defined (__EMX__)
|
||||
signal (sig, SIG_ACK);
|
||||
#endif
|
||||
|
||||
kill (getpid (), sig);
|
||||
|
||||
/* Let the signal that we just sent through. */
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigsetmask (omask & ~(sigmask (sig)));
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
rl_reset_after_signal ();
|
||||
}
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
static RETSIGTYPE
|
||||
rl_sigwinch_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
SigHandler *oh;
|
||||
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
sighandler_cxt dummy_winch;
|
||||
|
||||
/* We don't want to change old_winch -- it holds the state of SIGWINCH
|
||||
disposition set by the calling application. We need this state
|
||||
because we call the application's SIGWINCH handler after updating
|
||||
our own idea of the screen size. */
|
||||
rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch);
|
||||
#endif
|
||||
|
||||
RL_SETSTATE(RL_STATE_SIGHANDLER);
|
||||
rl_resize_terminal ();
|
||||
|
||||
/* If another sigwinch handler has been installed, call it. */
|
||||
oh = (SigHandler *)old_winch.sa_handler;
|
||||
if (oh && oh != (SigHandler *)SIG_IGN && oh != (SigHandler *)SIG_DFL)
|
||||
(*oh) (sig);
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
/* Functions to manage signal handling. */
|
||||
|
||||
#if !defined (HAVE_POSIX_SIGNALS)
|
||||
static int
|
||||
rl_sigaction (sig, nh, oh)
|
||||
int sig;
|
||||
sighandler_cxt *nh, *oh;
|
||||
{
|
||||
oh->sa_handler = signal (sig, nh->sa_handler);
|
||||
return 0;
|
||||
}
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
/* Set up a readline-specific signal handler, saving the old signal
|
||||
information in OHANDLER. Return the old signal handler, like
|
||||
signal(). */
|
||||
static SigHandler *
|
||||
rl_set_sighandler (sig, handler, ohandler)
|
||||
int sig;
|
||||
SigHandler *handler;
|
||||
sighandler_cxt *ohandler;
|
||||
{
|
||||
sighandler_cxt old_handler;
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
struct sigaction act;
|
||||
|
||||
act.sa_handler = handler;
|
||||
act.sa_flags = 0; /* XXX - should we set SA_RESTART for SIGWINCH? */
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&ohandler->sa_mask);
|
||||
sigaction (sig, &act, &old_handler);
|
||||
#else
|
||||
old_handler.sa_handler = (SigHandler *)signal (sig, handler);
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
/* XXX -- assume we have memcpy */
|
||||
/* If rl_set_signals is called twice in a row, don't set the old handler to
|
||||
rl_signal_handler, because that would cause infinite recursion. */
|
||||
if (handler != rl_signal_handler || old_handler.sa_handler != rl_signal_handler)
|
||||
memcpy (ohandler, &old_handler, sizeof (sighandler_cxt));
|
||||
|
||||
return (ohandler->sa_handler);
|
||||
}
|
||||
|
||||
static void
|
||||
rl_maybe_set_sighandler (sig, handler, ohandler)
|
||||
int sig;
|
||||
SigHandler *handler;
|
||||
sighandler_cxt *ohandler;
|
||||
{
|
||||
sighandler_cxt dummy;
|
||||
SigHandler *oh;
|
||||
|
||||
sigemptyset (&dummy.sa_mask);
|
||||
oh = rl_set_sighandler (sig, handler, ohandler);
|
||||
if (oh == (SigHandler *)SIG_IGN)
|
||||
rl_sigaction (sig, ohandler, &dummy);
|
||||
}
|
||||
|
||||
int
|
||||
rl_set_signals ()
|
||||
{
|
||||
sighandler_cxt dummy;
|
||||
SigHandler *oh;
|
||||
|
||||
if (rl_catch_signals && signals_set_flag == 0)
|
||||
{
|
||||
rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
|
||||
rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
|
||||
rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
|
||||
|
||||
oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
|
||||
if (oh == (SigHandler *)SIG_IGN)
|
||||
rl_sigaction (SIGALRM, &old_alrm, &dummy);
|
||||
#if defined (HAVE_POSIX_SIGNALS) && defined (SA_RESTART)
|
||||
/* If the application using readline has already installed a signal
|
||||
handler with SA_RESTART, SIGALRM will cause reads to be restarted
|
||||
automatically, so readline should just get out of the way. Since
|
||||
we tested for SIG_IGN above, we can just test for SIG_DFL here. */
|
||||
if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
|
||||
rl_sigaction (SIGALRM, &old_alrm, &dummy);
|
||||
#endif /* HAVE_POSIX_SIGNALS */
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
rl_maybe_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp);
|
||||
#endif /* SIGTSTP */
|
||||
|
||||
#if defined (SIGTTOU)
|
||||
rl_maybe_set_sighandler (SIGTTOU, rl_signal_handler, &old_ttou);
|
||||
#endif /* SIGTTOU */
|
||||
|
||||
#if defined (SIGTTIN)
|
||||
rl_maybe_set_sighandler (SIGTTIN, rl_signal_handler, &old_ttin);
|
||||
#endif /* SIGTTIN */
|
||||
|
||||
signals_set_flag = 1;
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
if (rl_catch_sigwinch && sigwinch_set_flag == 0)
|
||||
{
|
||||
rl_maybe_set_sighandler (SIGWINCH, rl_sigwinch_handler, &old_winch);
|
||||
sigwinch_set_flag = 1;
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rl_clear_signals ()
|
||||
{
|
||||
sighandler_cxt dummy;
|
||||
|
||||
if (rl_catch_signals && signals_set_flag == 1)
|
||||
{
|
||||
sigemptyset (&dummy.sa_mask);
|
||||
|
||||
rl_sigaction (SIGINT, &old_int, &dummy);
|
||||
rl_sigaction (SIGTERM, &old_term, &dummy);
|
||||
rl_sigaction (SIGQUIT, &old_quit, &dummy);
|
||||
rl_sigaction (SIGALRM, &old_alrm, &dummy);
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
rl_sigaction (SIGTSTP, &old_tstp, &dummy);
|
||||
#endif /* SIGTSTP */
|
||||
|
||||
#if defined (SIGTTOU)
|
||||
rl_sigaction (SIGTTOU, &old_ttou, &dummy);
|
||||
#endif /* SIGTTOU */
|
||||
|
||||
#if defined (SIGTTIN)
|
||||
rl_sigaction (SIGTTIN, &old_ttin, &dummy);
|
||||
#endif /* SIGTTIN */
|
||||
|
||||
signals_set_flag = 0;
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
if (rl_catch_sigwinch && sigwinch_set_flag == 1)
|
||||
{
|
||||
sigemptyset (&dummy.sa_mask);
|
||||
rl_sigaction (SIGWINCH, &old_winch, &dummy);
|
||||
sigwinch_set_flag = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Clean up the terminal and readline state after catching a signal, before
|
||||
resending it to the calling application. */
|
||||
void
|
||||
rl_cleanup_after_signal ()
|
||||
{
|
||||
_rl_clean_up_for_exit ();
|
||||
(*rl_deprep_term_function) ();
|
||||
rl_clear_signals ();
|
||||
rl_clear_pending_input ();
|
||||
}
|
||||
|
||||
/* Reset the terminal and readline state after a signal handler returns. */
|
||||
void
|
||||
rl_reset_after_signal ()
|
||||
{
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
rl_set_signals ();
|
||||
}
|
||||
|
||||
/* Free up the readline variable line state for the current line (undo list,
|
||||
any partial history entry, any keyboard macros in progress, and any
|
||||
numeric arguments in process) after catching a signal, before calling
|
||||
rl_cleanup_after_signal(). */
|
||||
void
|
||||
rl_free_line_state ()
|
||||
{
|
||||
register HIST_ENTRY *entry;
|
||||
|
||||
rl_free_undo_list ();
|
||||
|
||||
entry = current_history ();
|
||||
if (entry)
|
||||
entry->data = (char *)NULL;
|
||||
|
||||
_rl_kill_kbd_macro ();
|
||||
rl_clear_message ();
|
||||
_rl_init_argument ();
|
||||
}
|
||||
|
||||
#endif /* HANDLE_SIGNALS */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,247 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5.
|
||||
#
|
||||
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
tranformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# mkdirs - a work-alike for `mkdir -p'
|
||||
#
|
||||
# Chet Ramey
|
||||
# chet@po.cwru.edu
|
||||
|
||||
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
for dir
|
||||
do
|
||||
|
||||
test -d "$dir" && continue
|
||||
|
||||
tomake=$dir
|
||||
while test -n "$dir" ; do
|
||||
# dir=${dir%/*}
|
||||
# dir=`expr "$dir" ':' '\(/.*\)/[^/]*'`
|
||||
if dir=`expr "$dir" ':' '\(.*\)/[^/]*'`; then
|
||||
tomake="$dir $tomake"
|
||||
else
|
||||
dir=
|
||||
fi
|
||||
done
|
||||
|
||||
for d in $tomake
|
||||
do
|
||||
test -d "$d" && continue
|
||||
echo mkdir "$d"
|
||||
mkdir "$d"
|
||||
done
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
#! /bin/bash -
|
||||
#
|
||||
# mkdist - make a distribution directory from a master manifest file
|
||||
#
|
||||
# usage: mkdist [-m manifest] [-s srcdir] [-r rootname] [-v] version
|
||||
#
|
||||
# SRCDIR defaults to src
|
||||
# MANIFEST defaults to $SRCDIR/MANIFEST
|
||||
#
|
||||
# Chet Ramey
|
||||
# chet@po.cwru.edu
|
||||
|
||||
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
SRCDIR=src
|
||||
ROOTNAME=bash
|
||||
|
||||
usage()
|
||||
{
|
||||
echo usage: mkdist [-m manifest] [-s srcdir] [-r rootname] [-v] version 1>&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
vmsg()
|
||||
{
|
||||
if [ -n "$verbose" ]; then
|
||||
echo mkdist: "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts m:s:r:v name
|
||||
do
|
||||
case $name in
|
||||
m) MANIFEST=$OPTARG ;;
|
||||
s) SRCDIR=$OPTARG ;;
|
||||
r) ROOTNAME=$OPTARG ;;
|
||||
v) verbose=yes ;;
|
||||
?) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
: ${MANIFEST:=$SRCDIR/MANIFEST}
|
||||
|
||||
vmsg using $MANIFEST
|
||||
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
version=$1
|
||||
newdir=${ROOTNAME}-$version
|
||||
|
||||
vmsg creating distribution for $ROOTNAME version $version in $newdir
|
||||
|
||||
if [ ! -d $newdir ]; then
|
||||
mkdir $newdir || { echo $0: cannot make directory $newdir 1>&2 ; exit 1; }
|
||||
fi
|
||||
|
||||
dirmode=755
|
||||
filmode=644
|
||||
|
||||
while read fname type mode
|
||||
do
|
||||
[ -z "$fname" ] && continue
|
||||
|
||||
case "$fname" in
|
||||
\#*) continue ;;
|
||||
esac
|
||||
|
||||
case "$type" in
|
||||
d) mkdir $newdir/$fname ;;
|
||||
f) cp -p $SRCDIR/$fname $newdir/$fname ;;
|
||||
s) ln -s $mode $newdir/$fname ; mode= ;; # symlink
|
||||
l) ln $mode $newdir/$fname ; mode= ;; # hard link
|
||||
*) echo "unknown file type $type" 1>&2 ;;
|
||||
esac
|
||||
|
||||
if [ -n "$mode" ]; then
|
||||
chmod $mode $newdir/$fname
|
||||
fi
|
||||
|
||||
done < $MANIFEST
|
||||
|
||||
# cut off the `-alpha' in something like `2.0-alpha', leaving just the
|
||||
# numeric version
|
||||
#version=${version%%-*}
|
||||
|
||||
#case "$version" in
|
||||
#*.*.*) vers=${version%.*} ;;
|
||||
#*.*) vers=${version} ;;
|
||||
#esac
|
||||
|
||||
#echo $vers > $newdir/.distribution
|
||||
|
||||
#case "$version" in
|
||||
#*.*.*) plevel=${version##*.} ;;
|
||||
#*) plevel=0 ;;
|
||||
#esac
|
||||
#[ -z "$plevel" ] && plevel=0
|
||||
#echo ${plevel} > $newdir/.patchlevel
|
||||
|
||||
vmsg $newdir created
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# shlib-install - install a shared library and do any necessary host-specific
|
||||
# post-installation configuration (like ldconfig)
|
||||
#
|
||||
# usage: shlib-install [-D] -O host_os -d installation-dir -i install-prog [-U] library
|
||||
#
|
||||
# Chet Ramey
|
||||
# chet@po.cwru.edu
|
||||
|
||||
#
|
||||
# defaults
|
||||
#
|
||||
INSTALLDIR=/usr/local/lib
|
||||
LDCONFIG=ldconfig
|
||||
|
||||
PROGNAME=`basename $0`
|
||||
USAGE="$PROGNAME [-D] -O host_os -d installation-dir -i install-prog [-U] library"
|
||||
|
||||
# process options
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-O) shift; host_os="$1"; shift ;;
|
||||
-d) shift; INSTALLDIR="$1"; shift ;;
|
||||
-i) shift; INSTALLPROG="$1" ; shift ;;
|
||||
-D) echo=echo ; shift ;;
|
||||
-U) uninstall=true ; shift ;;
|
||||
-*) echo "$USAGE" >&2 ; exit 2;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# set install target name
|
||||
LIBNAME="$1"
|
||||
|
||||
if [ -z "$LIBNAME" ]; then
|
||||
echo "$USAGE" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
OLDSUFF=old
|
||||
MV=mv
|
||||
RM="rm -f"
|
||||
LN="ln -s"
|
||||
|
||||
# pre-install
|
||||
|
||||
if [ -z "$uninstall" ]; then
|
||||
${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
|
||||
if [ -f "$INSTALLDIR/$LIBNAME" ]; then
|
||||
${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
|
||||
fi
|
||||
fi
|
||||
|
||||
# install/uninstall
|
||||
|
||||
if [ -z "$uninstall" ] ; then
|
||||
${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
|
||||
else
|
||||
${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
|
||||
fi
|
||||
|
||||
# post-install/uninstall
|
||||
|
||||
# HP-UX and Darwin/MacOS X require that a shared library have execute permission
|
||||
case "$host_os" in
|
||||
hpux*|darwin*|macosx*)
|
||||
if [ -z "$uninstall" ]; then
|
||||
chmod 555 ${INSTALLDIR}/${LIBNAME}
|
||||
fi ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
case "$LIBNAME" in
|
||||
*.*.[0-9].[0-9]) # libname.so.M.N
|
||||
LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
|
||||
LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
|
||||
;;
|
||||
*.*.[0-9]) # libname.so.M
|
||||
LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
|
||||
;;
|
||||
*.[0-9]) # libname.M
|
||||
LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
|
||||
;;
|
||||
*.[0-9].[0-9].dylib) # libname.M.N.dylib
|
||||
LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'` # libname.M.dylib
|
||||
LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'` # libname.dylib
|
||||
esac
|
||||
|
||||
INSTALL_LINK1='cd $INSTALLDIR ; ln -s $LIBNAME $LINK1'
|
||||
INSTALL_LINK2='cd $INSTALLDIR ; ln -s $LIBNAME $LINK2'
|
||||
|
||||
#
|
||||
# Create symlinks to the installed library. This section is incomplete.
|
||||
#
|
||||
case "$host_os" in
|
||||
*linux*|bsdi4*|*gnu*|darwin*|macosx*)
|
||||
# libname.so.M -> libname.so.M.N
|
||||
${echo} ${RM} ${INSTALLDIR}/$LINK2
|
||||
if [ -z "$uninstall" ]; then
|
||||
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
|
||||
fi
|
||||
|
||||
# libname.so -> libname.so.M.N
|
||||
${echo} ${RM} ${INSTALLDIR}/$LINK1
|
||||
if [ -z "$uninstall" ]; then
|
||||
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
|
||||
fi
|
||||
;;
|
||||
|
||||
solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
|
||||
# libname.so -> libname.so.M
|
||||
${echo} ${RM} ${INSTALLDIR}/$LINK1
|
||||
if [ -z "$uninstall" ]; then
|
||||
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
# FreeBSD 3.x and above can have either a.out or ELF shared libraries
|
||||
freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
|
||||
if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
|
||||
# libname.so -> libname.so.M
|
||||
${echo} ${RM} ${INSTALLDIR}/$LINK1
|
||||
if [ -z "$uninstall" ]; then
|
||||
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
|
||||
fi
|
||||
else
|
||||
# libname.so.M -> libname.so.M.N
|
||||
${echo} ${RM} ${INSTALLDIR}/$LINK2
|
||||
if [ -z "$uninstall" ]; then
|
||||
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
|
||||
fi
|
||||
|
||||
# libname.so -> libname.so.M.N
|
||||
${echo} ${RM} ${INSTALLDIR}/$LINK1
|
||||
if [ -z "$uninstall" ]; then
|
||||
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
hpux1*)
|
||||
# libname.sl -> libname.M
|
||||
${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
|
||||
if [ -z "$uninstall" ]; then
|
||||
# ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}.sl
|
||||
${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}
|
||||
fi
|
||||
;;
|
||||
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,458 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# shobj-conf -- output a series of variable assignments to be substituted
|
||||
# into a Makefile by configure which specify system-dependent
|
||||
# information for creating shared objects that may be loaded
|
||||
# into bash with `enable -f'
|
||||
#
|
||||
# usage: shobj-conf [-C compiler] -c host_cpu -o host_os -v host_vendor
|
||||
#
|
||||
# Chet Ramey
|
||||
# chet@po.cwru.edu
|
||||
|
||||
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
#
|
||||
# defaults
|
||||
#
|
||||
SHOBJ_STATUS=supported
|
||||
SHLIB_STATUS=supported
|
||||
|
||||
SHOBJ_CC=cc
|
||||
SHOBJ_CFLAGS=
|
||||
SHOBJ_LD=
|
||||
SHOBJ_LDFLAGS=
|
||||
SHOBJ_XLDFLAGS=
|
||||
SHOBJ_LIBS=
|
||||
|
||||
SHLIB_XLDFLAGS=
|
||||
SHLIB_LIBS=
|
||||
SHLIB_LIBSUFF='so'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF)'
|
||||
|
||||
PROGNAME=`basename $0`
|
||||
USAGE="$PROGNAME [-C compiler] -c host_cpu -o host_os -v host_vendor"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-C) shift; SHOBJ_CC="$1"; shift ;;
|
||||
-c) shift; host_cpu="$1"; shift ;;
|
||||
-o) shift; host_os="$1"; shift ;;
|
||||
-v) shift; host_vendor="$1"; shift ;;
|
||||
*) echo "$USAGE" >&2 ; exit 2;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "${host_os}-${SHOBJ_CC}" in
|
||||
sunos4*-*gcc*)
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD=/usr/bin/ld
|
||||
SHOBJ_LDFLAGS='-assert pure-text'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
|
||||
;;
|
||||
|
||||
sunos4*)
|
||||
SHOBJ_CFLAGS=-pic
|
||||
SHOBJ_LD=/usr/bin/ld
|
||||
SHOBJ_LDFLAGS='-assert pure-text'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
|
||||
;;
|
||||
|
||||
sunos5*-*gcc*|solaris2*-*gcc*)
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD='${CC}'
|
||||
# This line works for the Solaris linker in /usr/ccs/bin/ld
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
|
||||
# This line works for the GNU ld
|
||||
# SHOBJ_LDFLAGS='-shared -Wl,-h,$@'
|
||||
|
||||
# SHLIB_XLDFLAGS='-R $(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
sunos5*|solaris2*)
|
||||
SHOBJ_CFLAGS='-K pic'
|
||||
SHOBJ_LD=/usr/ccs/bin/ld
|
||||
SHOBJ_LDFLAGS='-G -dy -z text -i -h $@'
|
||||
|
||||
# SHLIB_XLDFLAGS='-R $(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
# All versions of Linux or the semi-mythical GNU Hurd.
|
||||
linux*|gnu*)
|
||||
SHOBJ_CFLAGS=-fPIC
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
|
||||
|
||||
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir) -Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
|
||||
;;
|
||||
|
||||
freebsd2* | netbsd*)
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS='-x -Bshareable'
|
||||
|
||||
SHLIB_XLDFLAGS='-R$(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
|
||||
;;
|
||||
|
||||
# FreeBSD-3.x ELF
|
||||
freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD='${CC}'
|
||||
|
||||
if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
|
||||
|
||||
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
else
|
||||
SHOBJ_LDFLAGS='-shared'
|
||||
|
||||
SHLIB_XLDFLAGS='-R$(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
|
||||
fi
|
||||
;;
|
||||
|
||||
# Darwin/MacOS X
|
||||
darwin*|macosx*)
|
||||
SHOBJ_STATUS=unsupported
|
||||
SHLIB_STATUS=supported
|
||||
|
||||
SHOBJ_CFLAGS='-dynamic -fno-common'
|
||||
|
||||
SHOBJ_LD=/usr/bin/libtool
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
|
||||
SHLIB_LIBSUFF='dylib'
|
||||
|
||||
SHOBJ_LDFLAGS='-dynamic'
|
||||
SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
|
||||
|
||||
SHLIB_LIBS='-lSystem'
|
||||
;;
|
||||
|
||||
openbsd*)
|
||||
SHOBJ_CFLAGS=-fPIC
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared'
|
||||
|
||||
SHLIB_XLDFLAGS='-R$(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
|
||||
;;
|
||||
|
||||
bsdi2*)
|
||||
SHOBJ_CC=shlicc2
|
||||
SHOBJ_CFLAGS=
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS=-r
|
||||
SHOBJ_LIBS=-lc_s.2.1.0
|
||||
|
||||
# BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
|
||||
# the ass -- they require changing {/usr/lib,etc}/shlib.map on
|
||||
# each system, and the library creation process is byzantine
|
||||
SHLIB_STATUS=unsupported
|
||||
;;
|
||||
|
||||
bsdi3*)
|
||||
SHOBJ_CC=shlicc2
|
||||
SHOBJ_CFLAGS=
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS=-r
|
||||
SHOBJ_LIBS=-lc_s.3.0.0
|
||||
|
||||
# BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
|
||||
# the ass -- they require changing {/usr/lib,etc}/shlib.map on
|
||||
# each system, and the library creation process is byzantine
|
||||
SHLIB_STATUS=unsupported
|
||||
;;
|
||||
|
||||
bsdi4*)
|
||||
# BSD/OS 4.x now supports ELF and SunOS-style dynamically-linked
|
||||
# shared libraries. gcc 2.x is the standard compiler, and the
|
||||
# `normal' gcc options should work as they do in Linux.
|
||||
|
||||
SHOBJ_CFLAGS=-fPIC
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
|
||||
|
||||
SHLIB_XLDFLAGS='-Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
|
||||
;;
|
||||
|
||||
osf*-*gcc*)
|
||||
# Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
|
||||
|
||||
SHLIB_XLDFLAGS='-rpath $(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
osf*)
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS='-shared -soname $@ -expect_unresolved "*"'
|
||||
|
||||
SHLIB_XLDFLAGS='-rpath $(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD='ld'
|
||||
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
|
||||
SHOBJ_XLDFLAGS='-G'
|
||||
|
||||
SHLIB_XLDFLAGS='-bM:SRE'
|
||||
SHLIB_LIBS='-lcurses -lc'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
aix4.[2-9]*)
|
||||
SHOBJ_CFLAGS=-K
|
||||
SHOBJ_LD='ld'
|
||||
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
|
||||
SHOBJ_XLDFLAGS='-G'
|
||||
|
||||
SHLIB_XLDFLAGS='-bM:SRE'
|
||||
SHLIB_LIBS='-lcurses -lc'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
#
|
||||
# THE FOLLOWING ARE UNTESTED -- and some may not support the dlopen interface
|
||||
#
|
||||
irix[56]*-*gcc*)
|
||||
SHOBJ_CFLAGS='-fpic'
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
|
||||
|
||||
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
irix[56]*)
|
||||
SHOBJ_CFLAGS='-K PIC'
|
||||
SHOBJ_LD=ld
|
||||
# SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
|
||||
# Change from David Kaelbling <drk@sgi.com>. If you have problems,
|
||||
# remove the `-no_unresolved'
|
||||
SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@'
|
||||
|
||||
SHLIB_XLDFLAGS='-rpath $(libdir)'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
hpux9*-*gcc*)
|
||||
# must use gcc; the bundled cc cannot compile PIC code
|
||||
SHOBJ_CFLAGS='-fpic'
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s'
|
||||
|
||||
SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
|
||||
SHLIB_LIBSUFF='sl'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
hpux9*)
|
||||
SHOBJ_STATUS=unsupported
|
||||
SHLIB_STATUS=unsupported
|
||||
|
||||
# If you are using the HP ANSI C compiler, you can uncomment and use
|
||||
# this code (I have not tested it)
|
||||
# SHOBJ_STATUS=supported
|
||||
# SHLIB_STATUS=supported
|
||||
#
|
||||
# SHOBJ_CFLAGS='+z'
|
||||
# SHOBJ_LD='ld'
|
||||
# SHOBJ_LDFLAGS='-b +s'
|
||||
#
|
||||
# SHLIB_XLDFLAGS='+b $(libdir)'
|
||||
# SHLIB_LIBSUFF='sl'
|
||||
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
|
||||
;;
|
||||
|
||||
hpux10*-*gcc*)
|
||||
# must use gcc; the bundled cc cannot compile PIC code
|
||||
SHOBJ_CFLAGS='-fpic'
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s'
|
||||
|
||||
SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)'
|
||||
SHLIB_LIBSUFF='sl'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
hpux10*)
|
||||
SHOBJ_STATUS=unsupported
|
||||
SHLIB_STATUS=unsupported
|
||||
|
||||
# If you are using the HP ANSI C compiler, you can uncomment and use
|
||||
# this code (I have not tested it)
|
||||
# SHOBJ_STATUS=supported
|
||||
# SHLIB_STATUS=supported
|
||||
#
|
||||
# SHOBJ_CFLAGS='+z'
|
||||
# SHOBJ_LD='ld'
|
||||
# SHOBJ_LDFLAGS='-b +s +h $@'
|
||||
#
|
||||
# SHLIB_XLDFLAGS='+b $(libdir)'
|
||||
# SHLIB_LIBSUFF='sl'
|
||||
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
|
||||
;;
|
||||
|
||||
hpux11*-*gcc*)
|
||||
# must use gcc; the bundled cc cannot compile PIC code
|
||||
SHOBJ_CFLAGS='-fpic'
|
||||
SHOBJ_LD='${CC}'
|
||||
# SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,-B,symbolic -Wl,+s -Wl,+std -Wl,+h,$@'
|
||||
SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s -Wl,+h,$@'
|
||||
|
||||
SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
|
||||
SHLIB_LIBSUFF='sl'
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
hpux11*)
|
||||
SHOBJ_STATUS=unsupported
|
||||
SHLIB_STATUS=unsupported
|
||||
|
||||
# If you are using the HP ANSI C compiler, you can uncomment and use
|
||||
# this code (I have not tested it)
|
||||
# SHOBJ_STATUS=supported
|
||||
# SHLIB_STATUS=supported
|
||||
#
|
||||
# SHOBJ_CFLAGS='+z'
|
||||
# SHOBJ_LD='ld'
|
||||
# SHOBJ_LDFLAGS='-b +s +h $@'
|
||||
#
|
||||
# SHLIB_XLDFLAGS='+b $(libdir)'
|
||||
# SHLIB_LIBSUFF='sl'
|
||||
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
|
||||
;;
|
||||
|
||||
sysv4*-*gcc*)
|
||||
SHOBJ_CFLAGS=-shared
|
||||
SHOBJ_LDFLAGS='-shared -h $@'
|
||||
SHOBJ_LD='${CC}'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
sysv4*)
|
||||
SHOBJ_CFLAGS='-K PIC'
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS='-dy -z text -G -h $@'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
sco3.2v5*-*gcc*)
|
||||
SHOBJ_CFLAGS='-fpic' # DEFAULTS TO ELF
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
sco3.2v5*)
|
||||
SHOBJ_CFLAGS='-K pic -b elf'
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS='-G -b elf -dy -z text -h $@'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
sysv5uw7*-*gcc*)
|
||||
SHOBJ_CFLAGS='-fpic'
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
sysv5uw7*)
|
||||
SHOBJ_CFLAGS='-K PIC'
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS='-G -dy -z text -h $@'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
dgux*-*gcc*)
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
dgux*)
|
||||
SHOBJ_CFLAGS='-K pic'
|
||||
SHOBJ_LD=ld
|
||||
SHOBJ_LDFLAGS='-G -dy -h $@'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
msdos*)
|
||||
SHOBJ_STATUS=unsupported
|
||||
SHLIB_STATUS=unsupported
|
||||
;;
|
||||
|
||||
#
|
||||
# Rely on correct gcc configuration for everything else
|
||||
#
|
||||
*-*gcc*)
|
||||
SHOBJ_CFLAGS=-fpic
|
||||
SHOBJ_LD='${CC}'
|
||||
SHOBJ_LDFLAGS='-shared'
|
||||
|
||||
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
|
||||
;;
|
||||
|
||||
*)
|
||||
SHOBJ_STATUS=unsupported
|
||||
SHLIB_STATUS=unsupported
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
echo SHOBJ_CC=\'"$SHOBJ_CC"\'
|
||||
echo SHOBJ_CFLAGS=\'"$SHOBJ_CFLAGS"\'
|
||||
echo SHOBJ_LD=\'"$SHOBJ_LD"\'
|
||||
echo SHOBJ_LDFLAGS=\'"$SHOBJ_LDFLAGS"\'
|
||||
echo SHOBJ_XLDFLAGS=\'"$SHOBJ_XLDFLAGS"\'
|
||||
echo SHOBJ_LIBS=\'"$SHOBJ_LIBS"\'
|
||||
|
||||
echo SHLIB_XLDFLAGS=\'"$SHLIB_XLDFLAGS"\'
|
||||
echo SHLIB_LIBS=\'"$SHLIB_LIBS"\'
|
||||
echo SHLIB_LIBSUFF=\'"$SHLIB_LIBSUFF"\'
|
||||
echo SHLIB_LIBVERSION=\'"$SHLIB_LIBVERSION"\'
|
||||
|
||||
echo SHOBJ_STATUS=\'"$SHOBJ_STATUS"\'
|
||||
echo SHLIB_STATUS=\'"$SHLIB_STATUS"\'
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
* This is an implementation of wcwidth() and wcswidth() as defined in
|
||||
* "The Single UNIX Specification, Version 2, The Open Group, 1997"
|
||||
* <http://www.UNIX-systems.org/online.html>
|
||||
*
|
||||
* Markus Kuhn -- 2001-09-08 -- public domain
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
struct interval {
|
||||
unsigned short first;
|
||||
unsigned short last;
|
||||
};
|
||||
|
||||
/* auxiliary function for binary search in interval table */
|
||||
static int bisearch(wchar_t ucs, const struct interval *table, int max) {
|
||||
int min = 0;
|
||||
int mid;
|
||||
|
||||
if (ucs < table[0].first || ucs > table[max].last)
|
||||
return 0;
|
||||
while (max >= min) {
|
||||
mid = (min + max) / 2;
|
||||
if (ucs > table[mid].last)
|
||||
min = mid + 1;
|
||||
else if (ucs < table[mid].first)
|
||||
max = mid - 1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* The following functions define the column width of an ISO 10646
|
||||
* character as follows:
|
||||
*
|
||||
* - The null character (U+0000) has a column width of 0.
|
||||
*
|
||||
* - Other C0/C1 control characters and DEL will lead to a return
|
||||
* value of -1.
|
||||
*
|
||||
* - Non-spacing and enclosing combining characters (general
|
||||
* category code Mn or Me in the Unicode database) have a
|
||||
* column width of 0.
|
||||
*
|
||||
* - Other format characters (general category code Cf in the Unicode
|
||||
* database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
|
||||
*
|
||||
* - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
|
||||
* have a column width of 0.
|
||||
*
|
||||
* - Spacing characters in the East Asian Wide (W) or East Asian
|
||||
* FullWidth (F) category as defined in Unicode Technical
|
||||
* Report #11 have a column width of 2.
|
||||
*
|
||||
* - All remaining characters (including all printable
|
||||
* ISO 8859-1 and WGL4 characters, Unicode control characters,
|
||||
* etc.) have a column width of 1.
|
||||
*
|
||||
* This implementation assumes that wchar_t characters are encoded
|
||||
* in ISO 10646.
|
||||
*/
|
||||
|
||||
int wcwidth(wchar_t ucs)
|
||||
{
|
||||
/* sorted list of non-overlapping intervals of non-spacing characters */
|
||||
static const struct interval combining[] = {
|
||||
{ 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
|
||||
{ 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
|
||||
{ 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
|
||||
{ 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
|
||||
{ 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
|
||||
{ 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
|
||||
{ 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
|
||||
{ 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
|
||||
{ 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
|
||||
{ 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
|
||||
{ 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
|
||||
{ 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
|
||||
{ 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
|
||||
{ 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
|
||||
{ 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
|
||||
{ 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
|
||||
{ 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
|
||||
{ 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
|
||||
{ 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
|
||||
{ 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
|
||||
{ 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
|
||||
{ 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
|
||||
{ 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
|
||||
{ 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
|
||||
{ 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
|
||||
{ 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
|
||||
{ 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
|
||||
{ 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
|
||||
{ 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
|
||||
{ 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
|
||||
{ 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
|
||||
{ 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
|
||||
{ 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
|
||||
{ 0xFFF9, 0xFFFB }
|
||||
};
|
||||
|
||||
/* test for 8-bit control characters */
|
||||
if (ucs == 0)
|
||||
return 0;
|
||||
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
|
||||
return -1;
|
||||
|
||||
/* binary search in table of non-spacing characters */
|
||||
if (bisearch(ucs, combining,
|
||||
sizeof(combining) / sizeof(struct interval) - 1))
|
||||
return 0;
|
||||
|
||||
/* if we arrive here, ucs is not a combining or C0/C1 control character */
|
||||
|
||||
return 1 +
|
||||
(ucs >= 0x1100 &&
|
||||
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
|
||||
(ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
|
||||
ucs != 0x303f) || /* CJK ... Yi */
|
||||
(ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
|
||||
(ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
|
||||
(ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
|
||||
(ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
|
||||
(ucs >= 0xffe0 && ucs <= 0xffe6) ||
|
||||
(ucs >= 0x20000 && ucs <= 0x2ffff)));
|
||||
}
|
||||
|
||||
|
||||
int wcswidth(const wchar_t *pwcs, size_t n)
|
||||
{
|
||||
int w, width = 0;
|
||||
|
||||
for (;*pwcs && n-- > 0; pwcs++)
|
||||
if ((w = wcwidth(*pwcs)) < 0)
|
||||
return -1;
|
||||
else
|
||||
width += w;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The following function is the same as wcwidth(), except that
|
||||
* spacing characters in the East Asian Ambiguous (A) category as
|
||||
* defined in Unicode Technical Report #11 have a column width of 2.
|
||||
* This experimental variant might be useful for users of CJK legacy
|
||||
* encodings who want to migrate to UCS. It is not otherwise
|
||||
* recommended for general use.
|
||||
*/
|
||||
static int wcwidth_cjk(wchar_t ucs)
|
||||
{
|
||||
/* sorted list of non-overlapping intervals of East Asian Ambiguous
|
||||
* characters */
|
||||
static const struct interval ambiguous[] = {
|
||||
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
|
||||
{ 0x00AA, 0x00AA }, { 0x00AD, 0x00AE }, { 0x00B0, 0x00B4 },
|
||||
{ 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 },
|
||||
{ 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 },
|
||||
{ 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED },
|
||||
{ 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA },
|
||||
{ 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 },
|
||||
{ 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B },
|
||||
{ 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 },
|
||||
{ 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 },
|
||||
{ 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 },
|
||||
{ 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE },
|
||||
{ 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 },
|
||||
{ 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA },
|
||||
{ 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 },
|
||||
{ 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB },
|
||||
{ 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB },
|
||||
{ 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0300, 0x034E },
|
||||
{ 0x0360, 0x0362 }, { 0x0391, 0x03A1 }, { 0x03A3, 0x03A9 },
|
||||
{ 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 }, { 0x0401, 0x0401 },
|
||||
{ 0x0410, 0x044F }, { 0x0451, 0x0451 }, { 0x2010, 0x2010 },
|
||||
{ 0x2013, 0x2016 }, { 0x2018, 0x2019 }, { 0x201C, 0x201D },
|
||||
{ 0x2020, 0x2022 }, { 0x2024, 0x2027 }, { 0x2030, 0x2030 },
|
||||
{ 0x2032, 0x2033 }, { 0x2035, 0x2035 }, { 0x203B, 0x203B },
|
||||
{ 0x203E, 0x203E }, { 0x2074, 0x2074 }, { 0x207F, 0x207F },
|
||||
{ 0x2081, 0x2084 }, { 0x20AC, 0x20AC }, { 0x2103, 0x2103 },
|
||||
{ 0x2105, 0x2105 }, { 0x2109, 0x2109 }, { 0x2113, 0x2113 },
|
||||
{ 0x2116, 0x2116 }, { 0x2121, 0x2122 }, { 0x2126, 0x2126 },
|
||||
{ 0x212B, 0x212B }, { 0x2153, 0x2155 }, { 0x215B, 0x215E },
|
||||
{ 0x2160, 0x216B }, { 0x2170, 0x2179 }, { 0x2190, 0x2199 },
|
||||
{ 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 },
|
||||
{ 0x21E7, 0x21E7 }, { 0x2200, 0x2200 }, { 0x2202, 0x2203 },
|
||||
{ 0x2207, 0x2208 }, { 0x220B, 0x220B }, { 0x220F, 0x220F },
|
||||
{ 0x2211, 0x2211 }, { 0x2215, 0x2215 }, { 0x221A, 0x221A },
|
||||
{ 0x221D, 0x2220 }, { 0x2223, 0x2223 }, { 0x2225, 0x2225 },
|
||||
{ 0x2227, 0x222C }, { 0x222E, 0x222E }, { 0x2234, 0x2237 },
|
||||
{ 0x223C, 0x223D }, { 0x2248, 0x2248 }, { 0x224C, 0x224C },
|
||||
{ 0x2252, 0x2252 }, { 0x2260, 0x2261 }, { 0x2264, 0x2267 },
|
||||
{ 0x226A, 0x226B }, { 0x226E, 0x226F }, { 0x2282, 0x2283 },
|
||||
{ 0x2286, 0x2287 }, { 0x2295, 0x2295 }, { 0x2299, 0x2299 },
|
||||
{ 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF }, { 0x2312, 0x2312 },
|
||||
{ 0x2329, 0x232A }, { 0x2460, 0x24BF }, { 0x24D0, 0x24E9 },
|
||||
{ 0x2500, 0x254B }, { 0x2550, 0x2574 }, { 0x2580, 0x258F },
|
||||
{ 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 },
|
||||
{ 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD },
|
||||
{ 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB },
|
||||
{ 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF },
|
||||
{ 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F },
|
||||
{ 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 },
|
||||
{ 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 },
|
||||
{ 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F },
|
||||
{ 0x273D, 0x273D }, { 0x3008, 0x300B }, { 0x3014, 0x3015 },
|
||||
{ 0x3018, 0x301B }, { 0xFFFD, 0xFFFD }
|
||||
};
|
||||
|
||||
/* binary search in table of non-spacing characters */
|
||||
if (bisearch(ucs, ambiguous,
|
||||
sizeof(ambiguous) / sizeof(struct interval) - 1))
|
||||
return 2;
|
||||
|
||||
return wcwidth(ucs);
|
||||
}
|
||||
|
||||
|
||||
int wcswidth_cjk(const wchar_t *pwcs, size_t n)
|
||||
{
|
||||
int w, width = 0;
|
||||
|
||||
for (;*pwcs && n-- > 0; pwcs++)
|
||||
if ((w = wcwidth_cjk(*pwcs)) < 0)
|
||||
return -1;
|
||||
else
|
||||
width += w;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/* tcap.h -- termcap library functions and variables. */
|
||||
|
||||
/* Copyright (C) 1996 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.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#if !defined (_RLTCAP_H_)
|
||||
#define _RLTCAP_H_
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_TERMCAP_H)
|
||||
# if defined (__linux__) && !defined (SPEED_T_IN_SYS_TYPES)
|
||||
# include "rltty.h"
|
||||
# endif
|
||||
# include <termcap.h>
|
||||
#else
|
||||
|
||||
/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC.
|
||||
Unfortunately, PC is a global variable used by the termcap library. */
|
||||
#ifdef PC
|
||||
# undef PC
|
||||
#endif
|
||||
|
||||
extern char PC;
|
||||
extern char *UP, *BC;
|
||||
|
||||
extern short ospeed;
|
||||
|
||||
extern int tgetent ();
|
||||
extern int tgetflag ();
|
||||
extern int tgetnum ();
|
||||
extern char *tgetstr ();
|
||||
|
||||
extern int tputs ();
|
||||
|
||||
extern char *tgoto ();
|
||||
|
||||
#endif /* HAVE_TERMCAP_H */
|
||||
|
||||
#endif /* !_RLTCAP_H_ */
|
||||
|
|
@ -0,0 +1,662 @@
|
|||
/* terminal.c -- controlling the terminal with termcap. */
|
||||
|
||||
/* Copyright (C) 1996 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "posixstat.h"
|
||||
#include <fcntl.h>
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif /* HAVE_SYS_FILE_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_LOCALE_H)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
|
||||
|
||||
#include "rltty.h"
|
||||
#include "tcap.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
|
||||
#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Terminal and Termcap */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static char *term_buffer = (char *)NULL;
|
||||
static char *term_string_buffer = (char *)NULL;
|
||||
|
||||
static int tcap_initialized;
|
||||
|
||||
#if !defined (__linux__)
|
||||
# if defined (__EMX__) || defined (NEED_EXTERN_PC)
|
||||
extern
|
||||
# endif /* __EMX__ || NEED_EXTERN_PC */
|
||||
char PC, *BC, *UP;
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* Some strings to control terminal actions. These are output by tputs (). */
|
||||
char *_rl_term_clreol;
|
||||
char *_rl_term_clrpag;
|
||||
char *_rl_term_cr;
|
||||
char *_rl_term_backspace;
|
||||
char *_rl_term_goto;
|
||||
char *_rl_term_pc;
|
||||
|
||||
/* Non-zero if we determine that the terminal can do character insertion. */
|
||||
int _rl_terminal_can_insert = 0;
|
||||
|
||||
/* How to insert characters. */
|
||||
char *_rl_term_im;
|
||||
char *_rl_term_ei;
|
||||
char *_rl_term_ic;
|
||||
char *_rl_term_ip;
|
||||
char *_rl_term_IC;
|
||||
|
||||
/* How to delete characters. */
|
||||
char *_rl_term_dc;
|
||||
char *_rl_term_DC;
|
||||
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
char *_rl_term_forward_char;
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
|
||||
/* How to go up a line. */
|
||||
char *_rl_term_up;
|
||||
|
||||
/* A visible bell; char if the terminal can be made to flash the screen. */
|
||||
static char *_rl_visible_bell;
|
||||
|
||||
/* Non-zero means the terminal can auto-wrap lines. */
|
||||
int _rl_term_autowrap;
|
||||
|
||||
/* Non-zero means that this terminal has a meta key. */
|
||||
static int term_has_meta;
|
||||
|
||||
/* The sequences to write to turn on and off the meta key, if this
|
||||
terminal has one. */
|
||||
static char *_rl_term_mm;
|
||||
static char *_rl_term_mo;
|
||||
|
||||
/* The key sequences output by the arrow keys, if this terminal has any. */
|
||||
static char *_rl_term_ku;
|
||||
static char *_rl_term_kd;
|
||||
static char *_rl_term_kr;
|
||||
static char *_rl_term_kl;
|
||||
|
||||
/* How to initialize and reset the arrow keys, if this terminal has any. */
|
||||
static char *_rl_term_ks;
|
||||
static char *_rl_term_ke;
|
||||
|
||||
/* The key sequences sent by the Home and End keys, if any. */
|
||||
static char *_rl_term_kh;
|
||||
static char *_rl_term_kH;
|
||||
static char *_rl_term_at7; /* @7 */
|
||||
|
||||
/* Insert key */
|
||||
static char *_rl_term_kI;
|
||||
|
||||
/* Cursor control */
|
||||
static char *_rl_term_vs; /* very visible */
|
||||
static char *_rl_term_ve; /* normal */
|
||||
|
||||
static void bind_termcap_arrow_keys PARAMS((Keymap));
|
||||
|
||||
/* Variables that hold the screen dimensions, used by the display code. */
|
||||
int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
|
||||
|
||||
/* Non-zero means the user wants to enable the keypad. */
|
||||
int _rl_enable_keypad;
|
||||
|
||||
/* Non-zero means the user wants to enable a meta key. */
|
||||
int _rl_enable_meta = 1;
|
||||
|
||||
#if defined (__EMX__)
|
||||
static void
|
||||
_emx_get_screensize (swp, shp)
|
||||
int *swp, *shp;
|
||||
{
|
||||
int sz[2];
|
||||
|
||||
_scrsize (sz);
|
||||
|
||||
if (swp)
|
||||
*swp = sz[0];
|
||||
if (shp)
|
||||
*shp = sz[1];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get readline's idea of the screen size. TTY is a file descriptor open
|
||||
to the terminal. If IGNORE_ENV is true, we do not pay attention to the
|
||||
values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being
|
||||
non-null serve to check whether or not we have initialized termcap. */
|
||||
void
|
||||
_rl_get_screen_size (tty, ignore_env)
|
||||
int tty, ignore_env;
|
||||
{
|
||||
char *ss;
|
||||
#if defined (TIOCGWINSZ)
|
||||
struct winsize window_size;
|
||||
#endif /* TIOCGWINSZ */
|
||||
|
||||
#if defined (TIOCGWINSZ)
|
||||
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
|
||||
{
|
||||
_rl_screenwidth = (int) window_size.ws_col;
|
||||
_rl_screenheight = (int) window_size.ws_row;
|
||||
}
|
||||
#endif /* TIOCGWINSZ */
|
||||
|
||||
#if defined (__EMX__)
|
||||
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
|
||||
#endif
|
||||
|
||||
/* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
|
||||
is unset. */
|
||||
if (_rl_screenwidth <= 0)
|
||||
{
|
||||
if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
|
||||
_rl_screenwidth = atoi (ss);
|
||||
|
||||
#if !defined (__DJGPP__)
|
||||
if (_rl_screenwidth <= 0 && term_string_buffer)
|
||||
_rl_screenwidth = tgetnum ("co");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Environment variable LINES overrides setting of "li" if IGNORE_ENV
|
||||
is unset. */
|
||||
if (_rl_screenheight <= 0)
|
||||
{
|
||||
if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
|
||||
_rl_screenheight = atoi (ss);
|
||||
|
||||
#if !defined (__DJGPP__)
|
||||
if (_rl_screenheight <= 0 && term_string_buffer)
|
||||
_rl_screenheight = tgetnum ("li");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* If all else fails, default to 80x24 terminal. */
|
||||
if (_rl_screenwidth <= 1)
|
||||
_rl_screenwidth = 80;
|
||||
|
||||
if (_rl_screenheight <= 0)
|
||||
_rl_screenheight = 24;
|
||||
|
||||
/* If we're being compiled as part of bash, set the environment
|
||||
variables $LINES and $COLUMNS to new values. Otherwise, just
|
||||
do a pair of putenv () or setenv () calls. */
|
||||
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
|
||||
|
||||
if (_rl_term_autowrap == 0)
|
||||
_rl_screenwidth--;
|
||||
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_set_screen_size (rows, cols)
|
||||
int rows, cols;
|
||||
{
|
||||
if (rows == 0 || cols == 0)
|
||||
return;
|
||||
|
||||
_rl_screenheight = rows;
|
||||
_rl_screenwidth = cols;
|
||||
|
||||
if (_rl_term_autowrap == 0)
|
||||
_rl_screenwidth--;
|
||||
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
}
|
||||
|
||||
void
|
||||
rl_set_screen_size (rows, cols)
|
||||
int rows, cols;
|
||||
{
|
||||
_rl_set_screen_size (rows, cols);
|
||||
}
|
||||
|
||||
void
|
||||
rl_get_screen_size (rows, cols)
|
||||
int *rows, *cols;
|
||||
{
|
||||
if (rows)
|
||||
*rows = _rl_screenheight;
|
||||
if (cols)
|
||||
*cols = _rl_screenwidth;
|
||||
}
|
||||
|
||||
void
|
||||
rl_resize_terminal ()
|
||||
{
|
||||
if (readline_echoing_p)
|
||||
{
|
||||
_rl_get_screen_size (fileno (rl_instream), 1);
|
||||
if (CUSTOM_REDISPLAY_FUNC ())
|
||||
rl_forced_update_display ();
|
||||
else
|
||||
_rl_redisplay_after_sigwinch ();
|
||||
}
|
||||
}
|
||||
|
||||
struct _tc_string {
|
||||
const char *tc_var;
|
||||
char **tc_value;
|
||||
};
|
||||
|
||||
/* This should be kept sorted, just in case we decide to change the
|
||||
search algorithm to something smarter. */
|
||||
static struct _tc_string tc_strings[] =
|
||||
{
|
||||
{ "@7", &_rl_term_at7 },
|
||||
{ "DC", &_rl_term_DC },
|
||||
{ "IC", &_rl_term_IC },
|
||||
{ "ce", &_rl_term_clreol },
|
||||
{ "cl", &_rl_term_clrpag },
|
||||
{ "cr", &_rl_term_cr },
|
||||
{ "dc", &_rl_term_dc },
|
||||
{ "ei", &_rl_term_ei },
|
||||
{ "ic", &_rl_term_ic },
|
||||
{ "im", &_rl_term_im },
|
||||
{ "kH", &_rl_term_kH }, /* home down ?? */
|
||||
{ "kI", &_rl_term_kI }, /* insert */
|
||||
{ "kd", &_rl_term_kd },
|
||||
{ "ke", &_rl_term_ke }, /* end keypad mode */
|
||||
{ "kh", &_rl_term_kh }, /* home */
|
||||
{ "kl", &_rl_term_kl },
|
||||
{ "kr", &_rl_term_kr },
|
||||
{ "ks", &_rl_term_ks }, /* start keypad mode */
|
||||
{ "ku", &_rl_term_ku },
|
||||
{ "le", &_rl_term_backspace },
|
||||
{ "mm", &_rl_term_mm },
|
||||
{ "mo", &_rl_term_mo },
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
{ "nd", &_rl_term_forward_char },
|
||||
#endif
|
||||
{ "pc", &_rl_term_pc },
|
||||
{ "up", &_rl_term_up },
|
||||
{ "vb", &_rl_visible_bell },
|
||||
{ "vs", &_rl_term_vs },
|
||||
{ "ve", &_rl_term_ve },
|
||||
};
|
||||
|
||||
#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
|
||||
|
||||
/* Read the desired terminal capability strings into BP. The capabilities
|
||||
are described in the TC_STRINGS table. */
|
||||
static void
|
||||
get_term_capabilities (bp)
|
||||
char **bp;
|
||||
{
|
||||
#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < NUM_TC_STRINGS; i++)
|
||||
# ifdef __LCC__
|
||||
*(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
|
||||
# else
|
||||
*(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp);
|
||||
# endif
|
||||
#endif
|
||||
tcap_initialized = 1;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_init_terminal_io (terminal_name)
|
||||
const char *terminal_name;
|
||||
{
|
||||
const char *term;
|
||||
char *buffer;
|
||||
int tty, tgetent_ret;
|
||||
|
||||
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
|
||||
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
|
||||
tty = rl_instream ? fileno (rl_instream) : 0;
|
||||
_rl_screenwidth = _rl_screenheight = 0;
|
||||
|
||||
if (term == 0)
|
||||
term = "dumb";
|
||||
|
||||
/* I've separated this out for later work on not calling tgetent at all
|
||||
if the calling application has supplied a custom redisplay function,
|
||||
(and possibly if the application has supplied a custom input function). */
|
||||
if (CUSTOM_REDISPLAY_FUNC())
|
||||
{
|
||||
tgetent_ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (term_string_buffer == 0)
|
||||
term_string_buffer = (char *)xmalloc(2032);
|
||||
|
||||
if (term_buffer == 0)
|
||||
term_buffer = (char *)xmalloc(4080);
|
||||
|
||||
buffer = term_string_buffer;
|
||||
|
||||
tgetent_ret = tgetent (term_buffer, term);
|
||||
}
|
||||
|
||||
if (tgetent_ret <= 0)
|
||||
{
|
||||
FREE (term_string_buffer);
|
||||
FREE (term_buffer);
|
||||
buffer = term_buffer = term_string_buffer = (char *)NULL;
|
||||
|
||||
_rl_term_autowrap = 0; /* used by _rl_get_screen_size */
|
||||
|
||||
#if defined (__EMX__)
|
||||
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
|
||||
_rl_screenwidth--;
|
||||
#else /* !__EMX__ */
|
||||
_rl_get_screen_size (tty, 0);
|
||||
#endif /* !__EMX__ */
|
||||
|
||||
/* Defaults. */
|
||||
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
|
||||
{
|
||||
_rl_screenwidth = 79;
|
||||
_rl_screenheight = 24;
|
||||
}
|
||||
|
||||
/* Everything below here is used by the redisplay code (tputs). */
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
_rl_term_cr = "\r";
|
||||
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
|
||||
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
|
||||
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
|
||||
_rl_term_kh = _rl_term_kH = _rl_term_kI = (char *)NULL;
|
||||
_rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
|
||||
_rl_term_mm = _rl_term_mo = (char *)NULL;
|
||||
_rl_term_ve = _rl_term_vs = (char *)NULL;
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
term_forward_char = (char *)NULL;
|
||||
#endif
|
||||
_rl_terminal_can_insert = term_has_meta = 0;
|
||||
|
||||
/* Reasonable defaults for tgoto(). Readline currently only uses
|
||||
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
|
||||
change that later... */
|
||||
PC = '\0';
|
||||
BC = _rl_term_backspace = "\b";
|
||||
UP = _rl_term_up;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
get_term_capabilities (&buffer);
|
||||
|
||||
/* Set up the variables that the termcap library expects the application
|
||||
to provide. */
|
||||
PC = _rl_term_pc ? *_rl_term_pc : 0;
|
||||
BC = _rl_term_backspace;
|
||||
UP = _rl_term_up;
|
||||
|
||||
if (!_rl_term_cr)
|
||||
_rl_term_cr = "\r";
|
||||
|
||||
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
|
||||
|
||||
_rl_get_screen_size (tty, 0);
|
||||
|
||||
/* "An application program can assume that the terminal can do
|
||||
character insertion if *any one of* the capabilities `IC',
|
||||
`im', `ic' or `ip' is provided." But we can't do anything if
|
||||
only `ip' is provided, so... */
|
||||
_rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
|
||||
|
||||
/* Check to see if this terminal has a meta key and clear the capability
|
||||
variables if there is none. */
|
||||
term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
|
||||
if (!term_has_meta)
|
||||
_rl_term_mm = _rl_term_mo = (char *)NULL;
|
||||
|
||||
/* Attempt to find and bind the arrow keys. Do not override already
|
||||
bound keys in an overzealous attempt, however. */
|
||||
|
||||
bind_termcap_arrow_keys (emacs_standard_keymap);
|
||||
|
||||
#if defined (VI_MODE)
|
||||
bind_termcap_arrow_keys (vi_movement_keymap);
|
||||
bind_termcap_arrow_keys (vi_insertion_keymap);
|
||||
#endif /* VI_MODE */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Bind the arrow key sequences from the termcap description in MAP. */
|
||||
static void
|
||||
bind_termcap_arrow_keys (map)
|
||||
Keymap map;
|
||||
{
|
||||
Keymap xkeymap;
|
||||
|
||||
xkeymap = _rl_keymap;
|
||||
_rl_keymap = map;
|
||||
|
||||
_rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
|
||||
_rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
|
||||
_rl_bind_if_unbound (_rl_term_kr, rl_forward);
|
||||
_rl_bind_if_unbound (_rl_term_kl, rl_backward);
|
||||
|
||||
_rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
|
||||
_rl_bind_if_unbound (_rl_term_at7, rl_end_of_line); /* End */
|
||||
|
||||
_rl_keymap = xkeymap;
|
||||
}
|
||||
|
||||
char *
|
||||
rl_get_termcap (cap)
|
||||
const char *cap;
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (tcap_initialized == 0)
|
||||
return ((char *)NULL);
|
||||
for (i = 0; i < NUM_TC_STRINGS; i++)
|
||||
{
|
||||
if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
|
||||
return *(tc_strings[i].tc_value);
|
||||
}
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
/* Re-initialize the terminal considering that the TERM/TERMCAP variable
|
||||
has changed. */
|
||||
int
|
||||
rl_reset_terminal (terminal_name)
|
||||
const char *terminal_name;
|
||||
{
|
||||
_rl_init_terminal_io (terminal_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* A function for the use of tputs () */
|
||||
#ifdef _MINIX
|
||||
void
|
||||
_rl_output_character_function (c)
|
||||
int c;
|
||||
{
|
||||
putc (c, _rl_out_stream);
|
||||
}
|
||||
#else /* !_MINIX */
|
||||
int
|
||||
_rl_output_character_function (c)
|
||||
int c;
|
||||
{
|
||||
return putc (c, _rl_out_stream);
|
||||
}
|
||||
#endif /* !_MINIX */
|
||||
|
||||
/* Write COUNT characters from STRING to the output stream. */
|
||||
void
|
||||
_rl_output_some_chars (string, count)
|
||||
const char *string;
|
||||
int count;
|
||||
{
|
||||
fwrite (string, 1, count, _rl_out_stream);
|
||||
}
|
||||
|
||||
/* Move the cursor back. */
|
||||
int
|
||||
_rl_backspace (count)
|
||||
int count;
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (_rl_term_backspace)
|
||||
for (i = 0; i < count; i++)
|
||||
tputs (_rl_term_backspace, 1, _rl_output_character_function);
|
||||
else
|
||||
for (i = 0; i < count; i++)
|
||||
putc ('\b', _rl_out_stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Move to the start of the next line. */
|
||||
int
|
||||
rl_crlf ()
|
||||
{
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
if (_rl_term_cr)
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif /* NEW_TTY_DRIVER */
|
||||
putc ('\n', _rl_out_stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ring the terminal bell. */
|
||||
int
|
||||
rl_ding ()
|
||||
{
|
||||
if (readline_echoing_p)
|
||||
{
|
||||
switch (_rl_bell_preference)
|
||||
{
|
||||
case NO_BELL:
|
||||
default:
|
||||
break;
|
||||
case VISIBLE_BELL:
|
||||
if (_rl_visible_bell)
|
||||
{
|
||||
tputs (_rl_visible_bell, 1, _rl_output_character_function);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
case AUDIBLE_BELL:
|
||||
fprintf (stderr, "\007");
|
||||
fflush (stderr);
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Controlling the Meta Key and Keypad */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
void
|
||||
_rl_enable_meta_key ()
|
||||
{
|
||||
#if !defined (__DJGPP__)
|
||||
if (term_has_meta && _rl_term_mm)
|
||||
tputs (_rl_term_mm, 1, _rl_output_character_function);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_rl_control_keypad (on)
|
||||
int on;
|
||||
{
|
||||
#if !defined (__DJGPP__)
|
||||
if (on && _rl_term_ks)
|
||||
tputs (_rl_term_ks, 1, _rl_output_character_function);
|
||||
else if (!on && _rl_term_ke)
|
||||
tputs (_rl_term_ke, 1, _rl_output_character_function);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Controlling the Cursor */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Set the cursor appropriately depending on IM, which is one of the
|
||||
insert modes (insert or overwrite). Insert mode gets the normal
|
||||
cursor. Overwrite mode gets a very visible cursor. Only does
|
||||
anything if we have both capabilities. */
|
||||
void
|
||||
_rl_set_cursor (im, force)
|
||||
int im, force;
|
||||
{
|
||||
if (_rl_term_ve && _rl_term_vs)
|
||||
{
|
||||
if (force || im != rl_insert_mode)
|
||||
{
|
||||
if (im == RL_IM_OVERWRITE)
|
||||
tputs (_rl_term_vs, 1, _rl_output_character_function);
|
||||
else
|
||||
tputs (_rl_term_ve, 1, _rl_output_character_function);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,458 @@
|
|||
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
|
||||
|
||||
/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU 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 2, 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; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "tilde.h"
|
||||
|
||||
#if defined (TEST) || defined (STATIC_MALLOC)
|
||||
static void *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
# include "xmalloc.h"
|
||||
#endif /* TEST || STATIC_MALLOC */
|
||||
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid PARAMS((uid_t));
|
||||
extern struct passwd *getpwnam PARAMS((const char *));
|
||||
#endif /* !HAVE_GETPW_DECLS */
|
||||
|
||||
#if !defined (savestring)
|
||||
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
|
||||
#endif /* !savestring */
|
||||
|
||||
#if !defined (NULL)
|
||||
# if defined (__STDC__)
|
||||
# define NULL ((void *) 0)
|
||||
# else
|
||||
# define NULL 0x0
|
||||
# endif /* !__STDC__ */
|
||||
#endif /* !NULL */
|
||||
|
||||
/* If being compiled as part of bash, these will be satisfied from
|
||||
variables.o. If being compiled as part of readline, they will
|
||||
be satisfied from shell.o. */
|
||||
extern char *sh_get_home_dir PARAMS((void));
|
||||
extern char *sh_get_env_value PARAMS((const char *));
|
||||
|
||||
/* The default value of tilde_additional_prefixes. This is set to
|
||||
whitespace preceding a tilde so that simple programs which do not
|
||||
perform any word separation get desired behaviour. */
|
||||
static const char *default_prefixes[] =
|
||||
{ " ~", "\t~", (const char *)NULL };
|
||||
|
||||
/* The default value of tilde_additional_suffixes. This is set to
|
||||
whitespace or newline so that simple programs which do not
|
||||
perform any word separation get desired behaviour. */
|
||||
static const char *default_suffixes[] =
|
||||
{ " ", "\n", (const char *)NULL };
|
||||
|
||||
/* If non-null, this contains the address of a function that the application
|
||||
wants called before trying the standard tilde expansions. The function
|
||||
is called with the text sans tilde, and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if the expansion fails. */
|
||||
tilde_hook_func_t *tilde_expansion_preexpansion_hook = (tilde_hook_func_t *)NULL;
|
||||
|
||||
/* If non-null, this contains the address of a function to call if the
|
||||
standard meaning for expanding a tilde fails. The function is called
|
||||
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if there is no expansion. */
|
||||
tilde_hook_func_t *tilde_expansion_failure_hook = (tilde_hook_func_t *)NULL;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which
|
||||
are duplicates for a tilde prefix. Bash uses this to expand
|
||||
`=~' and `:~'. */
|
||||
char **tilde_additional_prefixes = (char **)default_prefixes;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which match
|
||||
the end of a username, instead of just "/". Bash sets this to
|
||||
`:' and `=~'. */
|
||||
char **tilde_additional_suffixes = (char **)default_suffixes;
|
||||
|
||||
static int tilde_find_prefix PARAMS((const char *, int *));
|
||||
static int tilde_find_suffix PARAMS((const char *));
|
||||
static char *isolate_tilde_prefix PARAMS((const char *, int *));
|
||||
static char *glue_prefix_and_suffix PARAMS((char *, const char *, int));
|
||||
|
||||
/* Find the start of a tilde expansion in STRING, and return the index of
|
||||
the tilde which starts the expansion. Place the length of the text
|
||||
which identified this tilde starter in LEN, excluding the tilde itself. */
|
||||
static int
|
||||
tilde_find_prefix (string, len)
|
||||
const char *string;
|
||||
int *len;
|
||||
{
|
||||
register int i, j, string_len;
|
||||
register char **prefixes;
|
||||
|
||||
prefixes = tilde_additional_prefixes;
|
||||
|
||||
string_len = strlen (string);
|
||||
*len = 0;
|
||||
|
||||
if (*string == '\0' || *string == '~')
|
||||
return (0);
|
||||
|
||||
if (prefixes)
|
||||
{
|
||||
for (i = 0; i < string_len; i++)
|
||||
{
|
||||
for (j = 0; prefixes[j]; j++)
|
||||
{
|
||||
if (strncmp (string + i, prefixes[j], strlen (prefixes[j])) == 0)
|
||||
{
|
||||
*len = strlen (prefixes[j]) - 1;
|
||||
return (i + *len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (string_len);
|
||||
}
|
||||
|
||||
/* Find the end of a tilde expansion in STRING, and return the index of
|
||||
the character which ends the tilde definition. */
|
||||
static int
|
||||
tilde_find_suffix (string)
|
||||
const char *string;
|
||||
{
|
||||
register int i, j, string_len;
|
||||
register char **suffixes;
|
||||
|
||||
suffixes = tilde_additional_suffixes;
|
||||
string_len = strlen (string);
|
||||
|
||||
for (i = 0; i < string_len; i++)
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
|
||||
#else
|
||||
if (string[i] == '/' /* || !string[i] */)
|
||||
#endif
|
||||
break;
|
||||
|
||||
for (j = 0; suffixes && suffixes[j]; j++)
|
||||
{
|
||||
if (strncmp (string + i, suffixes[j], strlen (suffixes[j])) == 0)
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
/* Return a new string which is the result of tilde expanding STRING. */
|
||||
char *
|
||||
tilde_expand (string)
|
||||
const char *string;
|
||||
{
|
||||
char *result;
|
||||
int result_size, result_index;
|
||||
|
||||
result_index = result_size = 0;
|
||||
if (result = strchr (string, '~'))
|
||||
result = (char *)xmalloc (result_size = (strlen (string) + 16));
|
||||
else
|
||||
result = (char *)xmalloc (result_size = (strlen (string) + 1));
|
||||
|
||||
/* Scan through STRING expanding tildes as we come to them. */
|
||||
while (1)
|
||||
{
|
||||
register int start, end;
|
||||
char *tilde_word, *expansion;
|
||||
int len;
|
||||
|
||||
/* Make START point to the tilde which starts the expansion. */
|
||||
start = tilde_find_prefix (string, &len);
|
||||
|
||||
/* Copy the skipped text into the result. */
|
||||
if ((result_index + start + 1) > result_size)
|
||||
result = (char *)xrealloc (result, 1 + (result_size += (start + 20)));
|
||||
|
||||
strncpy (result + result_index, string, start);
|
||||
result_index += start;
|
||||
|
||||
/* Advance STRING to the starting tilde. */
|
||||
string += start;
|
||||
|
||||
/* Make END be the index of one after the last character of the
|
||||
username. */
|
||||
end = tilde_find_suffix (string);
|
||||
|
||||
/* If both START and END are zero, we are all done. */
|
||||
if (!start && !end)
|
||||
break;
|
||||
|
||||
/* Expand the entire tilde word, and copy it into RESULT. */
|
||||
tilde_word = (char *)xmalloc (1 + end);
|
||||
strncpy (tilde_word, string, end);
|
||||
tilde_word[end] = '\0';
|
||||
string += end;
|
||||
|
||||
expansion = tilde_expand_word (tilde_word);
|
||||
free (tilde_word);
|
||||
|
||||
len = strlen (expansion);
|
||||
#ifdef __CYGWIN__
|
||||
/* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
|
||||
$HOME for `user' is /. On cygwin, // denotes a network drive. */
|
||||
if (len > 1 || *expansion != '/' || *string != '/')
|
||||
#endif
|
||||
{
|
||||
if ((result_index + len + 1) > result_size)
|
||||
result = (char *)xrealloc (result, 1 + (result_size += (len + 20)));
|
||||
|
||||
strcpy (result + result_index, expansion);
|
||||
result_index += len;
|
||||
}
|
||||
free (expansion);
|
||||
}
|
||||
|
||||
result[result_index] = '\0';
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Take FNAME and return the tilde prefix we want expanded. If LENP is
|
||||
non-null, the index of the end of the prefix into FNAME is returned in
|
||||
the location it points to. */
|
||||
static char *
|
||||
isolate_tilde_prefix (fname, lenp)
|
||||
const char *fname;
|
||||
int *lenp;
|
||||
{
|
||||
char *ret;
|
||||
int i;
|
||||
|
||||
ret = (char *)xmalloc (strlen (fname));
|
||||
#if defined (__MSDOS__)
|
||||
for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
|
||||
#else
|
||||
for (i = 1; fname[i] && fname[i] != '/'; i++)
|
||||
#endif
|
||||
ret[i - 1] = fname[i];
|
||||
ret[i - 1] = '\0';
|
||||
if (lenp)
|
||||
*lenp = i;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return a string that is PREFIX concatenated with SUFFIX starting at
|
||||
SUFFIND. */
|
||||
static char *
|
||||
glue_prefix_and_suffix (prefix, suffix, suffind)
|
||||
char *prefix;
|
||||
const char *suffix;
|
||||
int suffind;
|
||||
{
|
||||
char *ret;
|
||||
int plen, slen;
|
||||
|
||||
plen = (prefix && *prefix) ? strlen (prefix) : 0;
|
||||
slen = strlen (suffix + suffind);
|
||||
ret = (char *)xmalloc (plen + slen + 1);
|
||||
if (plen)
|
||||
strcpy (ret, prefix);
|
||||
strcpy (ret + plen, suffix + suffind);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
|
||||
tilde. If there is no expansion, call tilde_expansion_failure_hook.
|
||||
This always returns a newly-allocated string, never static storage. */
|
||||
char *
|
||||
tilde_expand_word (filename)
|
||||
const char *filename;
|
||||
{
|
||||
char *dirname, *expansion, *username;
|
||||
int user_len;
|
||||
struct passwd *user_entry;
|
||||
|
||||
if (filename == 0)
|
||||
return ((char *)NULL);
|
||||
|
||||
if (*filename != '~')
|
||||
return (savestring (filename));
|
||||
|
||||
/* A leading `~/' or a bare `~' is *always* translated to the value of
|
||||
$HOME or the home directory of the current user, regardless of any
|
||||
preexpansion hook. */
|
||||
if (filename[1] == '\0' || filename[1] == '/')
|
||||
{
|
||||
/* Prefix $HOME to the rest of the string. */
|
||||
expansion = sh_get_env_value ("HOME");
|
||||
|
||||
/* If there is no HOME variable, look up the directory in
|
||||
the password database. */
|
||||
if (expansion == 0)
|
||||
expansion = sh_get_home_dir ();
|
||||
|
||||
return (glue_prefix_and_suffix (expansion, filename, 1));
|
||||
}
|
||||
|
||||
username = isolate_tilde_prefix (filename, &user_len);
|
||||
|
||||
if (tilde_expansion_preexpansion_hook)
|
||||
{
|
||||
expansion = (*tilde_expansion_preexpansion_hook) (username);
|
||||
if (expansion)
|
||||
{
|
||||
dirname = glue_prefix_and_suffix (expansion, filename, user_len);
|
||||
free (username);
|
||||
free (expansion);
|
||||
return (dirname);
|
||||
}
|
||||
}
|
||||
|
||||
/* No preexpansion hook, or the preexpansion hook failed. Look in the
|
||||
password database. */
|
||||
dirname = (char *)NULL;
|
||||
user_entry = getpwnam (username);
|
||||
if (user_entry == 0)
|
||||
{
|
||||
/* If the calling program has a special syntax for expanding tildes,
|
||||
and we couldn't find a standard expansion, then let them try. */
|
||||
if (tilde_expansion_failure_hook)
|
||||
{
|
||||
expansion = (*tilde_expansion_failure_hook) (username);
|
||||
if (expansion)
|
||||
{
|
||||
dirname = glue_prefix_and_suffix (expansion, filename, user_len);
|
||||
free (expansion);
|
||||
}
|
||||
}
|
||||
free (username);
|
||||
/* If we don't have a failure hook, or if the failure hook did not
|
||||
expand the tilde, return a copy of what we were passed. */
|
||||
if (dirname == 0)
|
||||
dirname = savestring (filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
free (username);
|
||||
dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
|
||||
}
|
||||
|
||||
endpwent ();
|
||||
return (dirname);
|
||||
}
|
||||
|
||||
|
||||
#if defined (TEST)
|
||||
#undef NULL
|
||||
#include <stdio.h>
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *result, line[512];
|
||||
int done = 0;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
printf ("~expand: ");
|
||||
fflush (stdout);
|
||||
|
||||
if (!gets (line))
|
||||
strcpy (line, "done");
|
||||
|
||||
if ((strcmp (line, "done") == 0) ||
|
||||
(strcmp (line, "quit") == 0) ||
|
||||
(strcmp (line, "exit") == 0))
|
||||
{
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
result = tilde_expand (line);
|
||||
printf (" --> %s\n", result);
|
||||
free (result);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
static void memory_error_and_abort ();
|
||||
|
||||
static void *
|
||||
xmalloc (bytes)
|
||||
size_t bytes;
|
||||
{
|
||||
void *temp = (char *)malloc (bytes);
|
||||
|
||||
if (!temp)
|
||||
memory_error_and_abort ();
|
||||
return (temp);
|
||||
}
|
||||
|
||||
static void *
|
||||
xrealloc (pointer, bytes)
|
||||
void *pointer;
|
||||
int bytes;
|
||||
{
|
||||
void *temp;
|
||||
|
||||
if (!pointer)
|
||||
temp = malloc (bytes);
|
||||
else
|
||||
temp = realloc (pointer, bytes);
|
||||
|
||||
if (!temp)
|
||||
memory_error_and_abort ();
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
static void
|
||||
memory_error_and_abort ()
|
||||
{
|
||||
fprintf (stderr, "readline: out of virtual memory\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* compile-command: "gcc -g -DTEST -o tilde tilde.c"
|
||||
* end:
|
||||
*/
|
||||
#endif /* TEST */
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/* tilde.h: Externally available variables and function in libtilde.a. */
|
||||
|
||||
/* Copyright (C) 1992 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.
|
||||
|
||||
The 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 (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.
|
||||
|
||||
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. */
|
||||
|
||||
#if !defined (_TILDE_H_)
|
||||
# define _TILDE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* A function can be defined using prototypes and compile on both ANSI C
|
||||
and traditional C compilers with something like this:
|
||||
extern char *func PARAMS((char *, char *, int)); */
|
||||
|
||||
#if !defined (PARAMS)
|
||||
# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
|
||||
# define PARAMS(protos) protos
|
||||
# else
|
||||
# define PARAMS(protos) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef char *tilde_hook_func_t PARAMS((char *));
|
||||
|
||||
/* If non-null, this contains the address of a function that the application
|
||||
wants called before trying the standard tilde expansions. The function
|
||||
is called with the text sans tilde, and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if the expansion fails. */
|
||||
extern tilde_hook_func_t *tilde_expansion_preexpansion_hook;
|
||||
|
||||
/* If non-null, this contains the address of a function to call if the
|
||||
standard meaning for expanding a tilde fails. The function is called
|
||||
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if there is no expansion. */
|
||||
extern tilde_hook_func_t *tilde_expansion_failure_hook;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which
|
||||
are duplicates for a tilde prefix. Bash uses this to expand
|
||||
`=~' and `:~'. */
|
||||
extern char **tilde_additional_prefixes;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which match
|
||||
the end of a username, instead of just "/". Bash sets this to
|
||||
`:' and `=~'. */
|
||||
extern char **tilde_additional_suffixes;
|
||||
|
||||
/* Return a new string which is the result of tilde expanding STRING. */
|
||||
extern char *tilde_expand PARAMS((const char *));
|
||||
|
||||
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
|
||||
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
|
||||
extern char *tilde_expand_word PARAMS((const char *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TILDE_H_ */
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
/* readline.c -- a general facility for reading lines of input
|
||||
with emacs style editing and completion. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#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"
|
||||
|
||||
/* 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 */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* 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 = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST));
|
||||
temp->what = what;
|
||||
temp->start = start;
|
||||
temp->end = end;
|
||||
temp->text = text;
|
||||
temp->next = rl_undo_list;
|
||||
rl_undo_list = temp;
|
||||
}
|
||||
|
||||
/* Free the existing undo list. */
|
||||
void
|
||||
rl_free_undo_list ()
|
||||
{
|
||||
while (rl_undo_list)
|
||||
{
|
||||
UNDO_LIST *release = rl_undo_list;
|
||||
rl_undo_list = rl_undo_list->next;
|
||||
|
||||
if (release->what == UNDO_DELETE)
|
||||
free (release->text);
|
||||
|
||||
free (release);
|
||||
}
|
||||
rl_undo_list = (UNDO_LIST *)NULL;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
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;
|
||||
free (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)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
while (rl_undo_list)
|
||||
rl_do_undo ();
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,338 @@
|
|||
/* util.c -- readline utility functions */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 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.
|
||||
|
||||
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
|
||||
(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
|
||||
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. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include "posixjmp.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>
|
||||
#include <ctype.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
#if defined (TIOCSTAT_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* TIOCSTAT_IN_SYS_IOCTL */
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Utility Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Return 0 if C is not a member of the class of characters that belong
|
||||
in words, or 1 if it is. */
|
||||
|
||||
int _rl_allow_pathname_alphabetic_chars = 0;
|
||||
static const char *pathname_alphabetic_chars = "/-_=~.#$";
|
||||
|
||||
int
|
||||
rl_alphabetic (c)
|
||||
int c;
|
||||
{
|
||||
if (ALPHABETIC (c))
|
||||
return (1);
|
||||
|
||||
return (_rl_allow_pathname_alphabetic_chars &&
|
||||
strchr (pathname_alphabetic_chars, c) != NULL);
|
||||
}
|
||||
|
||||
/* How to abort things. */
|
||||
int
|
||||
_rl_abort_internal ()
|
||||
{
|
||||
rl_ding ();
|
||||
rl_clear_message ();
|
||||
_rl_init_argument ();
|
||||
rl_clear_pending_input ();
|
||||
|
||||
RL_UNSETSTATE (RL_STATE_MACRODEF);
|
||||
while (rl_executing_macro)
|
||||
_rl_pop_executing_macro ();
|
||||
|
||||
rl_last_func = (rl_command_func_t *)NULL;
|
||||
longjmp (readline_top_level, 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
rl_abort (count, key)
|
||||
int count, key;
|
||||
{
|
||||
return (_rl_abort_internal ());
|
||||
}
|
||||
|
||||
int
|
||||
rl_tty_status (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (TIOCSTAT)
|
||||
ioctl (1, TIOCSTAT, (char *)0);
|
||||
rl_refresh_line (count, key);
|
||||
#else
|
||||
rl_ding ();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return a copy of the string between FROM and TO.
|
||||
FROM is inclusive, TO is not. */
|
||||
char *
|
||||
rl_copy_text (from, to)
|
||||
int from, to;
|
||||
{
|
||||
register int length;
|
||||
char *copy;
|
||||
|
||||
/* Fix it if the caller is confused. */
|
||||
if (from > to)
|
||||
SWAP (from, to);
|
||||
|
||||
length = to - from;
|
||||
copy = (char *)xmalloc (1 + length);
|
||||
strncpy (copy, rl_line_buffer + from, length);
|
||||
copy[length] = '\0';
|
||||
return (copy);
|
||||
}
|
||||
|
||||
/* Increase the size of RL_LINE_BUFFER until it has enough space to hold
|
||||
LEN characters. */
|
||||
void
|
||||
rl_extend_line_buffer (len)
|
||||
int len;
|
||||
{
|
||||
while (len >= rl_line_buffer_len)
|
||||
{
|
||||
rl_line_buffer_len += DEFAULT_BUFFER_SIZE;
|
||||
rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len);
|
||||
}
|
||||
|
||||
_rl_set_the_line ();
|
||||
}
|
||||
|
||||
|
||||
/* A function for simple tilde expansion. */
|
||||
int
|
||||
rl_tilde_expand (ignore, key)
|
||||
int ignore, key;
|
||||
{
|
||||
register int start, end;
|
||||
char *homedir, *temp;
|
||||
int len;
|
||||
|
||||
end = rl_point;
|
||||
start = end - 1;
|
||||
|
||||
if (rl_point == rl_end && rl_line_buffer[rl_point] == '~')
|
||||
{
|
||||
homedir = tilde_expand ("~");
|
||||
_rl_replace_text (homedir, start, end);
|
||||
return (0);
|
||||
}
|
||||
else if (rl_line_buffer[start] != '~')
|
||||
{
|
||||
for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
|
||||
;
|
||||
start++;
|
||||
}
|
||||
|
||||
end = start;
|
||||
do
|
||||
end++;
|
||||
while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
|
||||
|
||||
if (whitespace (rl_line_buffer[end]) || end >= rl_end)
|
||||
end--;
|
||||
|
||||
/* If the first character of the current word is a tilde, perform
|
||||
tilde expansion and insert the result. If not a tilde, do
|
||||
nothing. */
|
||||
if (rl_line_buffer[start] == '~')
|
||||
{
|
||||
len = end - start + 1;
|
||||
temp = (char *)xmalloc (len + 1);
|
||||
strncpy (temp, rl_line_buffer + start, len);
|
||||
temp[len] = '\0';
|
||||
homedir = tilde_expand (temp);
|
||||
free (temp);
|
||||
|
||||
_rl_replace_text (homedir, start, end);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* String Utility Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Determine if s2 occurs in s1. If so, return a pointer to the
|
||||
match in s1. The compare is case insensitive. */
|
||||
char *
|
||||
_rl_strindex (s1, s2)
|
||||
register const char *s1, *s2;
|
||||
{
|
||||
register int i, l, len;
|
||||
|
||||
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
|
||||
if (_rl_strnicmp (s1 + i, s2, l) == 0)
|
||||
return ((char *) (s1 + i));
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRPBRK
|
||||
/* Find the first occurrence in STRING1 of any character from STRING2.
|
||||
Return a pointer to the character in STRING1. */
|
||||
char *
|
||||
_rl_strpbrk (string1, string2)
|
||||
const char *string1, *string2;
|
||||
{
|
||||
register const char *scan;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
mbstate_t ps;
|
||||
register int i, v;
|
||||
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
#endif
|
||||
|
||||
for (; *string1; string1++)
|
||||
{
|
||||
for (scan = string2; *scan; scan++)
|
||||
{
|
||||
if (*string1 == *scan)
|
||||
return ((char *)string1);
|
||||
}
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
v = _rl_get_char_len (string1, &ps);
|
||||
if (v > 1)
|
||||
string += v - 1; /* -1 to account for auto-increment in loop */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return ((char *)NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_STRCASECMP)
|
||||
/* Compare at most COUNT characters from string1 to string2. Case
|
||||
doesn't matter. */
|
||||
int
|
||||
_rl_strnicmp (string1, string2, count)
|
||||
char *string1, *string2;
|
||||
int count;
|
||||
{
|
||||
register char ch1, ch2;
|
||||
|
||||
while (count)
|
||||
{
|
||||
ch1 = *string1++;
|
||||
ch2 = *string2++;
|
||||
if (_rl_to_upper(ch1) == _rl_to_upper(ch2))
|
||||
count--;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
/* strcmp (), but caseless. */
|
||||
int
|
||||
_rl_stricmp (string1, string2)
|
||||
char *string1, *string2;
|
||||
{
|
||||
register char ch1, ch2;
|
||||
|
||||
while (*string1 && *string2)
|
||||
{
|
||||
ch1 = *string1++;
|
||||
ch2 = *string2++;
|
||||
if (_rl_to_upper(ch1) != _rl_to_upper(ch2))
|
||||
return (1);
|
||||
}
|
||||
return (*string1 - *string2);
|
||||
}
|
||||
#endif /* !HAVE_STRCASECMP */
|
||||
|
||||
/* Stupid comparison routine for qsort () ing strings. */
|
||||
int
|
||||
_rl_qsort_string_compare (s1, s2)
|
||||
char **s1, **s2;
|
||||
{
|
||||
#if defined (HAVE_STRCOLL)
|
||||
return (strcoll (*s1, *s2));
|
||||
#else
|
||||
int result;
|
||||
|
||||
result = **s1 - **s2;
|
||||
if (result == 0)
|
||||
result = strcmp (*s1, *s2);
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Function equivalents for the macros defined in chardefs.h. */
|
||||
#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); }
|
||||
|
||||
FUNCTION_FOR_MACRO (_rl_digit_p)
|
||||
FUNCTION_FOR_MACRO (_rl_digit_value)
|
||||
FUNCTION_FOR_MACRO (_rl_lowercase_p)
|
||||
FUNCTION_FOR_MACRO (_rl_pure_alphabetic)
|
||||
FUNCTION_FOR_MACRO (_rl_to_lower)
|
||||
FUNCTION_FOR_MACRO (_rl_to_upper)
|
||||
FUNCTION_FOR_MACRO (_rl_uppercase_p)
|
||||
|
||||
/* Backwards compatibility, now that savestring has been removed from
|
||||
all `public' readline header files. */
|
||||
#undef _rl_savestring
|
||||
char *
|
||||
_rl_savestring (s)
|
||||
const char *s;
|
||||
{
|
||||
return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue