diff options
author | Stan Shebs <shebs@codesourcery.com> | 1999-04-16 01:34:07 +0000 |
---|---|---|
committer | Stan Shebs <shebs@codesourcery.com> | 1999-04-16 01:34:07 +0000 |
commit | 071ea11e85eb9d529cc5eb3d35f6247466a21b99 (patch) | |
tree | 5deda65b8d7b04d1f4cbc534c3206d328e1267ec /readline | |
parent | 1730ec6b1848f0f32154277f788fb29f88d8475b (diff) | |
download | gdb-071ea11e85eb9d529cc5eb3d35f6247466a21b99.zip gdb-071ea11e85eb9d529cc5eb3d35f6247466a21b99.tar.gz gdb-071ea11e85eb9d529cc5eb3d35f6247466a21b99.tar.bz2 |
Initial creation of sourceware repository
Diffstat (limited to 'readline')
56 files changed, 0 insertions, 25967 deletions
diff --git a/readline/.Sanitize b/readline/.Sanitize deleted file mode 100644 index 5889399..0000000 --- a/readline/.Sanitize +++ /dev/null @@ -1,95 +0,0 @@ -# .Sanitize for devo/readline. - -# Each directory to survive its way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this directory. - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -CHANGELOG -CHANGES -COPYING -ChangeLog -INSTALL -MANIFEST -MANIFEST.doc -Makefile.in -README -acconfig.h -aclocal.m4 -ansi_stdlib.h -bind.c -callback.c -chardefs.h -complete.c -config.h.bot -config.h.in -configure -configure.in -cross-build -display.c -doc -emacs_keymap.c -examples -funmap.c -histexpand.c -histfile.c -histlib.h -history.c -history.h -histsearch.c -input.c -isearch.c -keymaps.c -keymaps.h -kill.c -macro.c -nls.c -parens.c -posixdir.h -posixjmp.h -posixstat.h -readline.c -readline.h -rlconf.h -rldefs.h -rltty.c -rltty.h -rlwinsize.h -search.c -shell.c -signals.c -support -tcap.h -terminal.c -tilde.c -tilde.h -undo.c -util.c -vi_keymap.c -vi_mode.c -xmalloc.c - -Things-to-lose: - - -Do-last: - -# End of file. diff --git a/readline/COPYING b/readline/COPYING deleted file mode 100644 index 1bb82d1..0000000 --- a/readline/COPYING +++ /dev/null @@ -1,257 +0,0 @@ - - GNU GENERAL PUBLIC LICENSE - Version 1, February 1989 - - Copyright (C) 1989 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -The Free Software Foundation has exempted Bash from the requirement of -Paragraph 2c of the General Public License. This is to say, there is -no requirement for Bash to print a notice when it is started -interactively in the usual way. We made this exception because users -and standards expect shells not to print such messages. This -exception applies to any program that serves as a shell and that is -based primarily on Bash as opposed to other GNU software. - - Preamble - - The license agreements of most software companies try to keep users -at the mercy of those companies. By contrast, our 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. The -General Public License applies to the Free Software Foundation's -software and to any other program whose authors commit to using it. -You can use it for your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Specifically, the General Public License is designed to make -sure that you have the freedom to give away or sell copies of free -software, 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 a 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 tell them 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. - - 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 Agreement 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 work containing the -Program or a portion of it, either verbatim or with modifications. Each -licensee is addressed as "you". - - 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 -General Public License and to the absence of any warranty; and give any -other recipients of the Program a copy of this General Public License -along with the Program. You may charge a fee for the physical act of -transferring a copy. - - 2. You may modify your copy or copies of the Program or any portion of -it, and copy and distribute such modifications under the terms of Paragraph -1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating that - you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, that - in whole or in part contains the Program or any part thereof, either - with or without modifications, to be licensed at no charge to all - third parties under the terms of this General Public License (except - that you may choose to grant warranty protection to some or all - third parties, at your option). - - c) If the modified program normally reads commands interactively when - run, you must cause it, when started running for such interactive use - in the simplest and most usual 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 General - Public License. - - d) 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. - -Mere aggregation of another independent work with the Program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other work under the scope of these terms. - - 3. You may copy and distribute the Program (or a portion or derivative of -it, under Paragraph 2) in object code or executable form under the terms of -Paragraphs 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 - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal charge - for the cost of distribution) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -Source code for a work means the preferred form of the work for making -modifications to it. For an executable file, complete source code means -all the source code for all modules it contains; but, as a special -exception, it need not include source code for modules which are standard -libraries that accompany the operating system on which the executable -file runs, or for standard header files or definitions files that -accompany that operating system. - - 4. You may not copy, modify, sublicense, distribute or transfer the -Program except as expressly provided under this General Public License. -Any attempt otherwise to copy, modify, sublicense, distribute or transfer -the Program is void, and will automatically terminate your rights to use -the Program under this License. However, parties who have received -copies, or rights to use copies, from you under this General Public -License will not have their licenses terminated so long as such parties -remain in full compliance. - - 5. By copying, distributing or modifying 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. - - 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. - - 7. 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 the 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 -the license, you may choose any version ever published by the Free Software -Foundation. - - 8. 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 - - 9. 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. - - 10. 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 humanity, 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, 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) 19xx 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 a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - program `Gnomovision' (a program to direct compilers to make passes - at assemblers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/readline/ChangeLog b/readline/ChangeLog deleted file mode 100644 index 75ea09d..0000000 --- a/readline/ChangeLog +++ /dev/null @@ -1,961 +0,0 @@ -Tue Feb 9 10:38:57 1999 Elena Zannoni <ezannoni@kwikemart.cygnus.com> - - * configure.in: Do not use the ./support directory. - * configure: Regenerate. - -Wed Jan 6 12:24:19 1999 Christopher Faylor <cgf@cygnus.com> - - * configure.in: Use LOCAL_CFLAGS rather than CFLAGS for - searching libtermcap directory. - * configure: Regenerate. - -Thu Dec 31 12:07:01 1998 Christopher Faylor <cgf@cygnus.com> - - * configure.in: Search devo libtermcap directory for termcap.h - when compiling for cygwin. - * configure: Regenerated. - -1998-12-30 Michael Meissner <meissner@cygnus.com> - - * Makefile.in (install): Only try to copy libreadline.a and - libhistory.a if they exist. - -Tue Dec 29 23:49:20 1998 Christopher Faylor <cgf@cygnus.com> - - * cross-build/cygwin.cache: Add a couple more known settings. - * configure.in: Fix typo. - * configure: Regenerated. - -Tue Dec 29 18:11:28 1998 Elena Zannoni <ezannoni@kwikemart.cygnus.com> - - * cross-build: new directory. - - * cross-build/cygwin.cache: new file. Used for Cygwin cross builds. - - * configure.in: added tests for cross-build for Cygwin. - -1998-12-24 Jason Molenda (jsm@bugshack.cygnus.com) - - * Makefile.in: Add CYGNUS LOCAL comment. - * acconfig.h: Add missing defines. - * config.h.bot: Add missing content. - * configure, config.h.in: Regenerated. - -Wed Dec 23 16:21:41 1998 Elena Zannoni <ezannoni@kwikemart.cygnus.com> - - * Makefile.in: comment out the rule to rebuild configure by - running autoconf. - -Tue Dec 22 10:00:30 1998 Elena Zannoni <ezannoni@kwikemart.cygnus.com> - - * shell.c (savestring): ifdef'd it out. - - * Imported new version of Readline 2.2.1. Removed all the Cygnus - local changes. - - New files: acconfig.h, aclocal.m4, ansi_stdlib.h, callback.c, - config.h.in, configure, histexpand.c, histfile.c, histlib.h, - histsearch.c, input.c, kill.c, macro.c, nls.c, posixdir.h, - posixjmp.h, posixstat.h, rlconf.h, rltty.h, rlwinsize.h, shell.c, - tcap.h, terminal.c, undo.c, util.c, support directory. - - Removed files: sysdep*, config directory. - - -Fri Dec 4 15:25:41 1998 David Taylor <taylor@texas.cygnus.com> - - The following changes were made by Jim Blandy - <jimb@zwingli.cygnus.com> and David Taylor - <taylor@texas.cygnus.com> as part of a project to merge in changes - made by HP; HP did not create ChangeLog entries. - - * config/mp-enable-tui: New file. - (TUI_CFLAGS): Search devo's include directory, as long as we're - totally ruining modularity. - (INCLUDE_SRCDIR): New var. - (GDB_TUI_SRCDIR): Fix syntax error. - - * configure.in: Check the --enable-tui flag; if it's set, include - a makefile fragment that #defines TUI and adds the needed #include - directories. - (*-*-hpux*): New host; use sysdep-hpux.h. - - * Makefile.in (.c.o): Check the variable set in the makefile - fragment above. - - * display.c (term_goto): declare it. - (insert_some_chars): set it. - (delete_chars): set it. - - * readline.c: add tui include files surrounded by TUI. - (rl_reset): new function, move some of rl_abort functionality to - here. - (rl_abort): call rl_reset. - (rl_getc): tui changes. - (init_terminal_io): tui changes. - - * readline.h (tui_version, fputc_unfiltered, fputs_unfiltered, - tui_tputs): declare if TUI is defined. - - * rltty.c (prepare_terminal_settings): additional comment. - - * signals.c: add tui include files surrounded by TUI. move #if - and #endif to column 1 so HP's compiler will accept them. Remove - declaration of tuiDoAndReturnToTop since it's declared in tui.h. - (rl_handle_sigwinch): call tuiDoAndReturnToTop if TUI defined. - (rl_handle_sigwinch_on_clear): define if TUI defined. - (rl_set_signals): if TUI, avoid infinite recursion. - (rl_clear_signals): install rl_handle_sigwinch_on_clear. - - * sysdep-hpux.h: New file. - -Mon Nov 2 15:26:33 1998 Geoffrey Noer <noer@cygnus.com> - - * configure.in: Check cygwin* instead of cygwin32*. - -Tue Jul 28 09:43:27 1998 Jeffrey A Law (law@cygnus.com) - - * sysdep-hpux11.h: New file. - * configure.in (*-*-*-hpux11*): Use sysdep-hpux11.h. - -Thu Jul 23 17:48:21 1998 Ian Lance Taylor <ian@cygnus.com> - - * configure.bat: Remove obsolete file. - * examples/configure.bat: Remove obsolete file. - -Wed May 13 13:41:53 1998 Ian Lance Taylor <ian@cygnus.com> - - * sysdep-6irix.h: New file. - * configure.in (*-*-irix6*): New host; use sysdep-6irix.h. - - * Makefile.in (isearch.o, search.o): Depend upon sysdep.h. - (Makefile): Depend upon $(srcdir)/configure.in. - -Thu Apr 9 11:59:38 1998 Ian Dall (<Ian.Dall@dsto.defence.gov.au> - - * configure.in (host==netbsd): Include config/mh-bsd44. - * config/mh-bsd44: New file. - -Wed Dec 3 16:48:20 1997 Michael Snyder (msnyder@cleaver.cygnus.com) - - * rltty.c: fix typos. - -Tue Oct 8 08:59:24 1996 Stu Grossman (grossman@critters.cygnus.com) - - * tilde.c (tilde_word_expand): __MSDOS___ -> __MSDOS__ - -Sat Oct 05 11:24:34 1996 Mark Alexander <marka@cygnus.com> - - * rldefs.h: On Linux, include <termios.h> to fix compile error - in <termcap.h>. - -Wed Sep 4 18:06:51 1996 Stu Grossman (grossman@critters.cygnus.com) - - * rldefs.h: Enable HANDLE_SIGNALS for cygwin32. - -Thu Aug 29 16:59:45 1996 Michael Meissner <meissner@tiktok.cygnus.com> - - * configure.in (i[345]86-*-*): Recognize i686 for pentium pro. - -Fri Aug 16 17:49:57 1996 Stu Grossman (grossman@critters.cygnus.com) - - * complete.c: Include <pwd.h> if not DOS, and if cygwin32 or not - win32. - * configure.in: Add test for *-*-cygwin32* to use config/mh-posix. - * readline.c: Move decl of tgetstr to rldefs.h. - * (_rl_set_screen_size): Remove redundant ifdef MINIMALs. - * rldefs.h: Don't do MINIMAL for cygwin32. Cygwin32 now uses - full-blown readline, except for termcap. - -Sun Aug 11 21:06:26 1996 Stu Grossman (grossman@critters.cygnus.com) - - * rldefs.c: Get rid of define of SIGALRM if _WIN32 or __MSDOS__. - * Don't define ScreenCols/ScreenRows/... if cygwin32. - * sysdep-norm.h: Don't include <malloc.h> if cygwin32. - -Sun Aug 11 14:59:09 1996 Fred Fish <fnf@cygnus.com> - - * rldefs.h: If __osf__is defined, include <termio.h> instead of - <sgtty.h>. - -Fri Aug 9 08:54:26 1996 Stu Grossman (grossman@critters.cygnus.com) - - * bind.c complete.c history.c readline.c: Don't include sys/file.h. - * complete.c display.c parens.c readline.c rldefs.h rltty.c - signals.c tilde.c: Change refs to _MSC_VER and __WIN32__ to _WIN32. - * signals.c (rl_signal_handler): Ifdef out kill if _WIN32. - * sysdep-norm.h: Ifdef out include of dirent.h if _WIN32. - Include malloc.h if _WIN32. - -Thu Jul 18 15:59:35 1996 Michael Meissner <meissner@tiktok.cygnus.com> - - * rldefs.h (sys/uio.h) Before sys/stream.h is included under AIX, - include sys/uio.h, which prevents an undefined structure used in a - prototype message from being generated. - -Tue Jun 25 23:05:55 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) - - * Makefile.in (datadir): Set to $(prefix)/share. - (docdir): Removed. - -Sun May 26 15:14:42 1996 Fred Fish <fnf@cygnus.com> - - From: David Mosberger-Tang <davidm@azstarnet.com> - - * sysdep-linux.h: New file. - * display.c: Add include of "sysdep.h" to get HAVE_VARARGS_H. - * configure.in: Change pattern i[345]86-*-linux* into *-*-linux* to - support non-x86 based Linux platforms. - -Sun Apr 7 22:06:11 1996 Fred Fish <fnf@cygnus.com> - - From: Miles Bader <miles@gnu.ai.mit.edu> - * config/mh-gnu: New file. - * configure.in (*-*-gnu*): New host. - -Sun Apr 7 13:21:51 1996 Fred Fish <fnf@cygnus.com> - - From: Robert Lipe <robertl@dgii.com> - * configure.in: SCO OpenServer 5 (a.k.a 3.2v5*) is more like - SCO 3.2v4 than 3.2v2. - -Wed Jan 3 18:22:10 1996 steve chamberlain <sac@slash.cygnus.com> - - * readline.c, display.c, complete.c: Add _MSC_VER to list of - things which can't do most things. - -Thu Nov 16 15:39:05 1995 Geoffrey Noer <noer@cygnus.com> - - * complete.c: Change WIN32 to __WIN32__, added #else return NULL - to end of that define. - -Tue Oct 31 10:38:58 1995 steve chamberlain <sac@slash.cygnus.com> - - * display.c, parens.c, readline.c, rldefs.h: Change use of - WIN32 to __WIN32__. - -Tue Oct 10 11:07:23 1995 Fred Fish <fnf@cygnus.com> - - * Makefile.in (BISON): Remove macro. - -Tue Oct 10 08:49:00 1995 steve chamberlain <sac@slash.cygnus.com> - - * complete.c (filename_completion_function): Enable for - win32 when not MSC. - -Sun Oct 8 04:17:19 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) - - * configure.in: Handle powerpc-ibm-aix* like rs6000-ibm-aix*. - -Sat Oct 7 20:36:16 1995 Michael Meissner <meissner@cygnus.com> - - * rltty.c (outchar): Return an int, like tputs expects. - * signals.c (_rl_output_character_function): Ditto. - -Fri Sep 29 15:19:23 1995 steve chamberlain <sac@slash.cygnus.com> - - Fixes for when the host WIN32, but not MSC. - * complete.c: Sometimes have pwd.h - * parens.c: WIN32 has similar restrictions to __GO32__. - * readline.c (__GO32__): Some of this moved into rldefs.h - * signals.c (__GO32__): Likewise. - * rldefs.h (MSDOS||WIN32) becomes MSDOS||MSC. - (WIN32&&!WIN32): New definitions. - -Wed Sep 20 12:57:17 1995 Ian Lance Taylor <ian@cygnus.com> - - * Makefile.in (maintainer-clean): New synonym for realclean. - -Wed Mar 1 13:33:43 1995 Michael Meissner <meissner@tiktok.cygnus.com> - - * rltty.c (outchar): Provide prototype for outchar, to silence - type warnings in passing outchar to tputs on systems like Linux - that have full prototypes. - - * signals.c (_rl_output_character_function): Provide prototype to - silence type warnings. - -Sun Jan 15 14:10:37 1995 Steve Chamberlain <sac@splat> - - * rldefs.h: Define MINIMAL for __GO32__ and WIN32. - * complete.c, display.c, readline.c, rltty.c: Test MINIMAL - instead of __GO32__. - -Wed Aug 24 13:04:47 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) - - * configure.in: Change i[34]86 to i[345]86. - -Sat Jul 16 13:26:31 1994 Stan Shebs (shebs@andros.cygnus.com) - - * configure.in (m88*-harris-cxux7*): Recognize. - * sysdep-cxux7.h: New file. - -Fri Jul 8 13:18:33 1994 Steve Chamberlain (sac@jonny.cygnus.com) - - * rttty.c (control_meta_key_on): Remove superfluous testing of - __GO32__. - -Thu Jun 30 15:21:54 1994 Steve Chamberlain (sac@jonny.cygnus.com) - - * rltty.c (control_meta_key_on): Don't compile if __GO32__ is - defined. - (rltty_set_default_bindings): Likewise. - * display.c (insert_some_chars, delete_chars): row_start should be - a short. - * parens.c (rl_insert_close): No FD_SET if using __GO32__. - * readline.c (rl_gather_tyi): Strip off spurious high bits. - -Sun Jun 12 03:51:52 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) - - * history.c: Swap inclusion of rldefs.h and chardefs.h to avoid - CTRL macro redefinition. - -Mon May 9 18:29:42 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) - - * readline.c (readline_default_bindings): Don't compile if - __GO32__ is defined. - (_rl_set_screen_size): Likewise. - * rltty.c (rltty_set_default_bindings): Likewise. - (control_meta_key): Likewise. - * display.c: If __GO32__ is defined, include <sys/pc.h>. - * parens.c: If __GO32__ is defined, undefine FD_SET. - * signals.c: Include SIGWINCH handling in the set of things which - is not done if HANDLE_SIGNALS is not set. - -Fri May 6 13:38:39 1994 Steve Chamberlain (sac@cygnus.com) - - * config/mh-go32: New fragment. - * configure.in (host==go32): Use go32 fragment. - -Wed May 4 14:36:53 1994 Stu Grossman (grossman@cygnus.com) - - * chardefs.h, rldefs.h: Move decls of string funcs from chardefs.h - to rldefs.h so that they don't pollute apps that include - readline.h. - * history.c: include rldefs.h to get decls of string funcs. - -Wed May 4 12:15:11 1994 Stan Shebs (shebs@andros.cygnus.com) - - * configure.in (rs6000-bull-bosx*): New configuration, RS/6000 - variant. - -Wed Apr 20 10:43:52 1994 Jim Kingdon (kingdon@lioth.cygnus.com) - - * configure.in: Use mh-posix for sunos4.1*. - -Wed Apr 13 21:28:44 1994 Jim Kingdon (kingdon@deneb.cygnus.com) - - * rltty.c (set_tty_settings): Don't set readline_echoing_p. - (rl_deprep_terminal) [NEW_TTY_DRIVER]: Set readline_echoing_p. - -Sun Mar 13 09:13:12 1994 Jim Kingdon (kingdon@lioth.cygnus.com) - - * Makefile.in: Add TAGS target. - -Wed Mar 9 18:01:31 1994 Jim Kingdon (kingdon@lioth.cygnus.com) - - * isearch.c, search.c: Include sysdep.h. - -Thu Mar 3 17:40:03 1994 Jim Kingdon (kingdon@deneb.cygnus.com) - - * configure.in: For ISC, use mh-sysv, not mh-isc. - -Thu Feb 24 04:13:53 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) - - * Merge in changes from bash-1.13.5. Merge changes from glob/tilde.c - into tilde.c and use it. Add system function declarations where - necessary. Check for __GO32__, not _GO32_ consistently. - * Makefile.in: Update dependencies. - * rltty.c: Include <sys/file.h> to match include file setup - in readline.c for rldefs.h. Otherwise we get inconsistent - TTY_DRIVER definitions in readline.c and rltty.c. - * bind.c, complete.c: Do not include <sys/types.h>, it is already - included via sysdep.h, which causes problems if <sys/types.h> has - no multiple inclusion protection. - * readline.c (_rl_set_screen_size): Reestablish test for - TIOCGWINSZ_BROKEN. - * rldefs.h: Define S_ISREG if necessary. - -Fri Feb 18 08:56:35 1994 Jim Kingdon (kingdon@lioth.cygnus.com) - - * Makefile.in: Add search.o rule for Sun make. - -Wed Feb 16 16:35:49 1994 Per Bothner (bothner@kalessin.cygnus.com) - - * rltty.c: #if out some code if __GO32__. - -Tue Feb 15 14:07:08 1994 Per Bothner (bothner@kalessin.cygnus.com) - - * readline.c (_rl_output_character_function), display.c: - Return int, not void, to conform with the expected arg of tputs. - * readline.c (init_terminal_io): tgetflag only takes 1 arg. - * readline.c (_rl_savestring): New function. - * chardefs.h: To avoid conflicts and/or warnings, define - savestring as a macro wrapper for _rl_savestring. - * display.c (extern term_xn): It's an int flag, not a string. - * charsdefs.h, rldefs.h: Remove HAVE_STRING_H-related junk. - -Sat Feb 5 08:32:30 1994 Jim Kingdon (kingdon@lioth.cygnus.com) - - * Makefile.in: Remove obsolete rules for history.info and - readline.info. - -Thu Jan 27 17:04:01 1994 Jim Kingdon (kingdon@deneb.cygnus.com) - - * chardefs.h: Only declare strrchr if it is not #define'd. - -Tue Jan 25 11:30:06 1994 Jim Kingdon (kingdon@lioth.cygnus.com) - - * rldefs.h: Accept __hpux as well as hpux for HP compiler in ANSI mode. - -Fri Jan 21 17:31:26 1994 Jim Kingdon (kingdon@lisa.cygnus.com) - - * chardefs.h, tilde.c: Just declare strrchr rather than trying to - include a system header. - -Fri Jan 21 14:40:43 1994 Fred Fish (fnf@cygnus.com) - - * Makefile.in (distclean, realclean): Expand local-distclean - inline after doing recursion. You can't recurse after removing - Makefile. Make them depend on local-clean. - * Makefile.in (local-distclean): Remove now superfluous target. - -Mon Jan 17 12:42:07 1994 Ken Raeburn (raeburn@cujo.cygnus.com) - - * readline.c (doing_an_undo): Delete second declaration, since it - confuses the alpha-osf1 native compiler. - -Sun Jan 16 12:33:11 1994 Jim Kingdon (kingdon@lioth.cygnus.com) - - * complete.c, bind.c: Include <sys/stat.h>. - * complete.c: Define X_OK if not defined by a system header. - - * chardefs.h: Don't declare xmalloc. - - * keymaps.h: Include "chardefs.h" not <readline/chardefs.h>. - - * Makefile.in (clean mostlyclean distclean realclean): Recurse - into subdirectories as well as doing this directory. Add clean-dvi - target. - -Sat Jan 15 19:36:12 1994 Per Bothner (bothner@kalessin.cygnus.com) - - * readline.c, display.c: Patches to allow use of all 80 - columns on most terminals (those with am and xn). - - Merge in changes from bash-1.13. The most obvious one is - that the file readline.c has been split into multiple files. - * bind.c, complete.c, dispay.c, isearch.c, parens.c, rldefs.h, - rltty.c, search.c signals.c, tilde.c, tilde.h, xmalloc.c: New files. - -Sat Dec 11 16:29:17 1993 Steve Chamberlain (sac@thepub.cygnus.com) - - * readline.c (rl_getc): If GO32, trim high bit from getkey, - otherwise fancy PC keys cause grief. - -Fri Nov 5 11:49:47 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - - * configure.in: Add doc to configdirs. - * Makefile.in (info dvi install-info clean-info): Recurse into doc. - -Fri Oct 22 07:55:08 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - - * configure.in: Add * to end of all OS names. - -Tue Oct 5 12:33:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - - * readline.c: Add stuff for HIUX to place where we detect termio - vs. sgtty (ugh, but I don't see a simple better way). - -Wed Sep 29 11:02:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - - * readline.c (parser_if): Free tname when done with it (change - imported from from bash 1.12 readline). - -Tue Sep 7 17:15:37 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - - * configure.in (m88k-*-sysvr4*): Comment out previous change. - -Fri Jul 2 11:05:34 1993 Ian Lance Taylor (ian@cygnus.com) - - * configure.in (*-*-riscos*): New entry; use mh-sysv. - -Wed Jun 23 13:00:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - - * configure.in: Add comment. - -Mon Jun 14 14:28:55 1993 Jim Kingdon (kingdon@eric) - - * configure.in (m88k-*-sysvr4*): Use sysdep-norm.h. - -Sun Jun 13 13:04:09 1993 Jim Kingdon (kingdon@cygnus.com) - - * Makefile.in ({real,dist}clean): Remove sysdep.h. - -Thu Jun 10 11:22:41 1993 Jim Kingdon (kingdon@cygnus.com) - - * Makefile.in: Add mostlyclean, distclean, and realclean targets. - -Fri May 21 17:09:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - - * config/mh-isc: New file. - * configure.in: Use it. - -Sat Apr 17 00:40:12 1993 Jim Kingdon (kingdon at calvin) - - * readline.c, history.c: Don't include sys/types.h; sysdep.h does. - - * config/mh-sysv: Define TIOCGWINSZ_BROKEN. - readline.c: Check it. - -Wed Mar 24 02:06:15 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com) - - * Makefile.in: add installcheck & dvi targets - -Fri Mar 12 18:36:53 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) - - * configure.in: recognize *-*-solaris2* instead of *-*-solaris* (a - number of people want to call SunOS 4.1.2 "solaris1.0" - and get it right) - -Tue Mar 2 21:25:36 1993 Fred Fish (fnf@cygnus.com) - - * sysdep-sysv4.h: New file for SVR4. - * configure.in (*-*-sysv4*): Use sysdep-sysv4.h. - - * configure.in (*-*-ultrix2): Add triplet from Michael Rendell - (michael@mercury.cs.mun.ca) - -Tue Dec 15 12:38:16 1992 Ian Lance Taylor (ian@cygnus.com) - - * configure.in (i[34]86-*-sco3.2v4*): use mh-sco4. - * config/mh-sco4: New file, like mh-sco but without defining - _POSIX_SOURCE. - -Wed Nov 11 21:20:14 1992 John Gilmore (gnu@cygnus.com) - - * configure.in: Reformat to one-case-per-line. - Handle SunOS 3.5, as per Karl Berry, <karl@claude.cs.umb.edu>. - -Wed Nov 4 15:32:31 1992 Stu Grossman (grossman at cygnus.com) - - * sysdep-norm.h: Remove some crud, install dire warning. - -Thu Oct 22 01:08:13 1992 Stu Grossman (grossman at cygnus.com) - - * configure.in: Make SCO work again... - -Mon Oct 12 15:04:07 1992 Ian Lance Taylor (ian@cygnus.com) - - * readline.c (init_terminal_io): if tgetent returns 0, the - terminal type is unknown. - -Thu Oct 1 23:44:14 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) - - * configure.in: use cpu-vendor-os triple instead of nested cases - -Wed Sep 30 12:58:57 1992 Stu Grossman (grossman at cygnus.com) - - * readline.c (rl_complete_internal): Cast alloca to (char *) to - avoid warning. - -Fri Sep 25 12:45:05 1992 Stu Grossman (grossman at cygnus.com) - - * readline.c (clear_to_eol, rl_generic_bind): Make static. - (rl_digit_loop): Add arg to call to rl_message(). - * vi_mode.c (rl_vi_first_print): Add arg to call to - rl_back_to_indent(). - -Wed Aug 19 14:59:07 1992 Ian Lance Taylor (ian@cygnus.com) - - * Makefile.in: always create installation directories, use full - file name for install target. - -Wed Aug 12 15:50:57 1992 John Gilmore (gnu@cygnus.com) - - * readline.c (last_readline_init_file): Fix typo made by Steve - Chamberlain/DJ Delorie. Proper control file name is ~/.inputrc, - not ~/inputrc. - -Thu Jun 25 16:15:27 1992 Stu Grossman (grossman at cygnus.com) - - * configure.in: Make bsd based systems use sysdep-obsd.h. - -Tue Jun 23 23:22:53 1992 Per Bothner (bothner@cygnus.com) - - * config/mh-posix: New file, for Posix-compliant systems. - * configure.in: Use mh-posix for Linux (free Unix clone). - -Tue Jun 23 21:59:20 1992 Fred Fish (fnf@cygnus.com) - - * sysdep-norm.h (alloca): Protect against previous definition as - a macro with arguments. - -Fri Jun 19 15:48:54 1992 Stu Grossman (grossman at cygnus.com) - - * sysdep-obsd.h: #include <sys/types.h> to make this more Kosher. - -Fri Jun 19 12:53:28 1992 John Gilmore (gnu at cygnus.com) - - * config/mh-apollo68v, mh-sco, mh-sysv, mh-sysv4}: RANLIB=true. - -Mon Jun 15 13:50:34 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) - - * configure.in: use mh-sysv4 on solaris2 - -Mon Jun 15 12:28:24 1992 Fred Fish (fnf@cygnus.com) - - * config/mh-ncr3000 (INSTALL): Don't use /usr/ucb/install, - it is broken on ncr 3000's. - * config/mh-ncr3000 (RANLIB): Use RANLIB=true. - -Mon Jun 15 01:35:55 1992 John Gilmore (gnu at cygnus.com) - - * readline.c: Make new SIGNALS_* macros to parameterize the - ugly changes in signal blocking. Use them throughout, - reducing #ifdef HAVE_POSIX_SIGNALS and HAVE_BSD_SIGNALS clutter - significantly. Make all such places use POSIX if available, - to avoid losing with poor `sigsetmask' emulation from libiberty. - -Sun Jun 14 15:19:51 1992 Stu Grossman (grossman at cygnus.com) - - * readline.c (insert_some_chars): Return void. - -Thu Jun 11 01:27:45 1992 John Gilmore (gnu at cygnus.com) - - * readline.c: #undef PC, which Solaris2 defines in sys/types.h, - clobbering the termcap global variable PC. - -Tue Jun 9 17:30:23 1992 Fred Fish (fnf@cygnus.com) - - * config/{mh-ncr3000, mh-sysv4}: Change INSTALL to use - /usr/ucb/install. - -Mon Jun 8 23:10:07 1992 Fred Fish (fnf@cygnus.com) - - * readline.h (rl_completer_quote_characters): Add declaration. - * readline.c (rl_completer_quote_characters): Add global var. - * readline.c (strpbrk): Add prototype and function. - * readline.c (rl_complete_internal): Add code to handle - expansion of quoted strings. - -Mon May 11 12:39:30 1992 John Gilmore (gnu at cygnus.com) - - * readline.c: Can't initialize FILE *'s with stdin and stdout, - because they might not be constant. Patch from Tom Quinn, - trq@dinoysos.thphys.ox.ac.uk. - -Tue Apr 28 21:52:34 1992 John Gilmore (gnu at cygnus.com) - - * readline.h: Declare rl_event_hook (which already existed). - Suggested by Christoph Tietz <tietz@zi.gmd.dbp.de>. - -Wed Apr 22 18:08:01 1992 K. Richard Pixley (rich@rtl.cygnus.com) - - * configure.in: remove subdirs declaration. The obsolete semantic - for subdirs has been usurped by per's new meaning. - -Tue Apr 21 11:54:23 1992 K. Richard Pixley (rich@cygnus.com) - - * Makefile.in: rework CFLAGS so that they can be set on the - command line to make. Remove MINUS_G. Default CFLAGS to -g. - -Fri Apr 10 23:02:27 1992 Fred Fish (fnf@cygnus.com) - - * configure.in: Recognize new ncr3000 config. - * config/mh-ncr3000: New NCR 3000 config file. - -Wed Mar 25 10:46:30 1992 John Gilmore (gnu at cygnus.com) - - * history.c (stifle_history): Negative arg treated as zero. - -Tue Mar 24 23:46:20 1992 K. Richard Pixley (rich@cygnus.com) - - * config/mh-sysv: INSTALL_PROG -> INSTALL. - -Mon Feb 10 01:41:35 1992 Brian Fox (bfox at gnuwest.fsf.org) - - * history.c (history_do_write) Build a buffer of all of the lines - to write and write them in one fell swoop (lower overhead than - calling write () for each line). Suggested by Peter Ho. - - * vi_mode.c (rl_vi_subst) Don't forget to end the undo group. - -Sat Mar 7 00:15:36 1992 K. Richard Pixley (rich@rtl.cygnus.com) - - * Makefile.in: remove FIXME's on info and install-info targets. - -Fri Mar 6 22:02:04 1992 K. Richard Pixley (rich@cygnus.com) - - * Makefile.in: added check target. - -Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com) - - * Makefile.in, configure.in: removed traces of namesubdir, - -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced - copyrights to '92, changed some from Cygnus to FSF. - -Fri Feb 21 14:37:32 1992 Steve Chamberlain (sac at rtl.cygnus.com) - - * readline.c, examples/fileman.c: patches from DJ to support DOS - -Thu Feb 20 23:23:16 1992 Stu Grossman (grossman at cygnus.com) - - * readline.c (rl_read_init_file): Make sure that null filename is - not passed to open() or else we end up opening the directory, and - read a bunch of garbage into keymap[]. - -Mon Feb 17 17:15:09 1992 Fred Fish (fnf at cygnus.com) - - * readline.c (readline_default_bindings): Only make use of VLNEXT - when both VLNEXT and TERMIOS_TTY_DRIVER is defined. On SVR4 - <termio.h> includes <termios.h>, so VLNEXT is always defined. - - * sysdep-norm.h (_POSIX_VERSION): Define this for all SVR4 - systems so that <termios.h> gets used, instead of <termio.h>. - -Fri Dec 20 12:04:31 1991 Fred Fish (fnf at cygnus.com) - - * configure.in: Change svr4 references to sysv4. - -Tue Dec 10 04:07:20 1991 K. Richard Pixley (rich at rtl.cygnus.com) - - * Makefile.in: infodir belongs in datadir. - -Fri Dec 6 23:23:14 1991 K. Richard Pixley (rich at rtl.cygnus.com) - - * Makefile.in: remove spaces following hyphens, bsd make can't - cope. added clean-info. added standards.text support. Don't - know how to make info anymore. - - * configure.in: commontargets is no longer a recognized hook, so - remove it. new subdir called doc. - -Thu Dec 5 22:46:10 1991 K. Richard Pixley (rich at rtl.cygnus.com) - - * Makefile.in: idestdir and ddestdir go away. Added copyrights - and shift gpl to v2. Added ChangeLog if it didn't exist. docdir - and mandir now keyed off datadir by default. - -Fri Nov 22 09:02:32 1991 John Gilmore (gnu at cygnus.com) - - * sysdep-obsd.h: Rename from sysdep-newsos.h. - * configure.in: Use sysdep-obsd for Mach as well as NEWs. - - * sysdep-norm.h, sysdep-aix.h: Add <sys/types.h>, which POSIX - requires to make <dirent.h> work. Improve Sun alloca decl. - -Thu Nov 21 18:48:08 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Clean up ../glob/tilde.c -> tilde.o path. - Clean up makefile a bit in general. - -Thu Nov 21 14:40:29 1991 Stu Grossman (grossman at cygnus.com) - - * configure.in, config/mh-svr4: Make SVR4 work. - - * readline.c: Move config stuff to sysdep.h, use typedef dirent - consistently, remove refs to d_namlen (& D_NAMLEN) to improve - portability. Also, update copyright notice. - readline.h: remove config stuff that I added erroneously in the - first place. - - * emacs_keymap.c, funmap.c, history.c, keymaps.c, vi_keymap.c, - vi_mode.c: move config stuff to sysdep.h, update copyright notices. - -Tue Nov 19 15:02:13 1991 Stu Grossman (grossman at cygnus.com) - - * history.c: #include "sysdep.h". - -Tue Nov 19 10:49:17 1991 Fred Fish (fnf at cygnus.com) - - * Makefile.in, config/hm-sysv, config/hm-sco: Change SYSV to - USG to match current usage. - - * readline.c: Add USGr4 to list of defined things to check for - to use <dirent.h> style directory access. - - * config/hm-svr4: New file for System V Release 4 (USGr4). - -Mon Nov 18 23:59:52 1991 Stu Grossman (grossman at cygnus.com) - - * readline.c (filename_completion_function): use struct dirent - instead of struct direct. - -Fri Nov 1 07:02:13 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c (rl_translate_keyseq) Make C-? translate to RUBOUT - unconditionally. - -Mon Oct 28 11:34:52 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c; Use Posix directory routines and macros. - - * funmap.c; Add entry for call-last-kbd-macro. - - * readline.c (rl_prep_term); Use system EOF character on POSIX - systems also. - -Thu Oct 3 16:19:53 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c; Make a distinction between having a TERMIOS tty - driver, and having POSIX signal handling. You might one without - the other. New defines used HAVE_POSIX_SIGNALS, and - TERMIOS_TTY_DRIVER. - -Tue Jul 30 22:37:26 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c: rl_getc () If a call to read () returns without an - error, but with zero characters, the file is empty, so return EOF. - -Thu Jul 11 20:58:38 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c: (rl_get_next_history, rl_get_previous_history) - Reallocate the buffer space if the line being moved to is longer - the the current space allocated. Amazing that no one has found - this bug until now. - -Sun Jul 7 02:37:05 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c:(rl_parse_and_bind) Allow leading whitespace. - Make sure TERMIO and TERMIOS systems treat CR and NL - disctinctly. - -Tue Jun 25 04:09:27 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c: Rework parsing conditionals to pay attention to the - prior states of the conditional stack. This makes $if statements - work correctly. - -Mon Jun 24 20:45:59 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c: support for displaying key binding information - includes the functions rl_list_funmap_names (), - invoking_keyseqs_in_map (), rl_invoking_keyseqs (), - rl_dump_functions (), and rl_function_dumper (). - - funmap.c: support for same includes rl_funmap_names (). - - readline.c, funmap.c: no longer define STATIC_MALLOC. However, - update both version of xrealloc () to handle a null pointer. - -Thu Apr 25 12:03:49 1991 Brian Fox (bfox at gnuwest.fsf.org) - - * vi_mode.c (rl_vi_fword, fWord, etc. All functions use - the macro `isident()'. Fixed movement bug which prevents - continious movement through the text. - -Fri Jul 27 16:47:01 1990 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c (parser_if) Allow "$if term=foo" construct. - -Wed May 23 16:10:33 1990 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c (rl_dispatch) Correctly remember the last command - executed. Fixed typo in username_completion_function (). - -Mon Apr 9 19:55:48 1990 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c: username_completion_function (); For text passed in - with a leading `~', remember that this could be a filename (after - it is completed). - -Thu Apr 5 13:44:24 1990 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c: rl_search_history (): Correctly handle case of an - unfound search string, but a graceful exit (as with ESC). - - * readline.c: rl_restart_output (); The Apollo passes the address - of the file descriptor to TIOCSTART, not the descriptor itself. - -Tue Mar 20 05:38:55 1990 Brian Fox (bfox at gnuwest.fsf.org) - - * readline.c: rl_complete (); second call in a row causes possible - completions to be listed. - - * readline.c: rl_redisplay (), added prompt_this_line variable - which is the first character character following \n in prompt. - -Sun Mar 11 04:32:03 1990 Brian Fox (bfox at gnuwest.fsf.org) - - * Signals are now supposedly handled inside of SYSV compilation. - -Wed Jan 17 19:24:09 1990 Brian Fox (bfox at sbphy.ucsb.edu) - - * history.c: history_expand (); fixed overwriting memory error, - added needed argument to call to get_history_event (). - -Thu Jan 11 10:54:04 1990 Brian Fox (bfox at sbphy.ucsb.edu) - - * readline.c: added mark_modified_lines to control the - display of an asterisk on modified history lines. Also - added a user variable called mark-modified-lines to the - `set' command. - -Thu Jan 4 10:38:05 1990 Brian Fox (bfox at sbphy.ucsb.edu) - - * readline.c: start_insert (). Only use IC if we don't have an im - capability. - -Fri Sep 8 09:00:45 1989 Brian Fox (bfox at aurel) - - * readline.c: rl_prep_terminal (). Only turn on 8th bit - as meta-bit iff the terminal is not using parity. - -Sun Sep 3 08:57:40 1989 Brian Fox (bfox at aurel) - - * readline.c: start_insert (). Uses multiple - insertion call in cases where that makes sense. - - rl_insert (). Read type-ahead buffer for additional - keys that are bound to rl_insert, and insert them - all at once. Make insertion of single keys given - with an argument much more efficient. - -Tue Aug 8 18:13:57 1989 Brian Fox (bfox at aurel) - - * readline.c: Changed handling of EOF. readline () returns - (char *)EOF or consed string. The EOF character is read from the - tty, or if the tty doesn't have one, defaults to C-d. - - * readline.c: Added support for event driven programs. - rl_event_hook is the address of a function you want called - while Readline is waiting for input. - - * readline.c: Cleanup time. Functions without type declarations - do not use return with a value. - - * history.c: history_expand () has new variable which is the - characters to ignore immediately following history_expansion_char. - -Sun Jul 16 08:14:00 1989 Brian Fox (bfox at aurel) - - * rl_prep_terminal () - BSD version turns off C-s, C-q, C-y, C-v. - - * readline.c -- rl_prep_terminal () - SYSV version hacks readline_echoing_p. - BSD version turns on passing of the 8th bit for the duration - of reading the line. - -Tue Jul 11 06:25:01 1989 Brian Fox (bfox at aurel) - - * readline.c: new variable rl_tilde_expander. - 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. - - * readline.h - new file chardefs.h - Separates things that only readline.c needs from the standard - header file publishing interesting things about readline. - - * readline.c: - readline_default_bindings () now looks at terminal chararacters - and binds those as well. - -Wed Jun 28 20:20:51 1989 Brian Fox (bfox at aurel) - - * Made readline and history into independent libraries. - diff --git a/readline/INSTALL b/readline/INSTALL deleted file mode 100644 index 95d84c8..0000000 --- a/readline/INSTALL +++ /dev/null @@ -1,176 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - 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 each directory of the package. -It may also create one or more `.h' files 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 the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' 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 simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package 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 awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -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 the package 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 the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -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 - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -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: not all `configure' scripts look for a site script. - -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. - diff --git a/readline/MANIFEST.doc b/readline/MANIFEST.doc deleted file mode 100644 index ed27cb3..0000000 --- a/readline/MANIFEST.doc +++ /dev/null @@ -1,16 +0,0 @@ -# -# Master Manifest file for documentation-only distribution -# -doc d -MANIFEST.doc f -doc/readline.ps f -doc/history.ps f -doc/readline.dvi f -doc/history.dvi f -doc/readline.info f -doc/history.info f -doc/readline.html f -doc/readline_toc.html f -doc/history.html f -doc/history_toc.html f -doc/readline.0 f diff --git a/readline/Makefile.in b/readline/Makefile.in deleted file mode 100644 index bb759a3..0000000 --- a/readline/Makefile.in +++ /dev/null @@ -1,560 +0,0 @@ -## -*- 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., 675 Mass Ave, Cambridge, MA 02139, 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@ -LD = ld # needed when building shared libraries -RANLIB = @RANLIB@ -AR = ar -RM = rm -f -CP = cp -MV = mv - -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -libdir = @libdir@ -mandir = @mandir@ -includedir = @includedir@ - -infodir = @infodir@ - -man3dir = $(mandir)/man3 - -SHELL = /bin/sh - -# 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@ -LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@ @CFLAGS@ - -DEFS = @DEFS@ -LOCAL_DEFS = @LOCAL_DEFS@ - -# For libraries which include headers from other libraries. -INCLUDES = -I. -I$(srcdir) -I$(includedir) - -CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS) - -# these two options need tweaking for compiler/OS versions other than gcc -# and SunOS4 -PICFLAG= -fpic # -pic for some versions of cc -SHLIB_OPTS= -assert pure-text -ldl # -Bshareable for some versions of gcc - -MAJOR= 3 -# shared library systems like SVR4's do not use minor versions -MINOR= .0 - -.SUFFIXES: .so - -.c.o: - $(CC) -c $(CCFLAGS) $< - -.c.so: - -mv $*.o z$*.o - $(CC) -c $(PICFLAG) $(CCFLAGS) $< - mv $*.o $@ - -mv z$*.o $*.o - -# The name of the main library target. -LIBRARY_NAME = libreadline.a -STATIC_LIBS = libreadline.a libhistory.a - -SHARED_READLINE = libreadline.so.$(MAJOR)$(MINOR) -SHARED_HISTORY = libhistory.so.$(MAJOR)$(MINOR) -SHARED_LIBS = $(SHARED_READLINE) $(SHARED_HISTORY) - -# 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)/tilde.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 - -HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.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 \ - nls.o xmalloc.o $(HISTOBJ) $(TILDEOBJ) - -SHARED_HISTOBJ = history.so histexpand.so histfile.so histsearch.so shell.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 \ - nls.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_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 -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 - -########################################################################## - -all: static - -static: $(STATIC_LIBS) -shared: $(SHARED_LIBS) - -libreadline.a: $(OBJECTS) - $(RM) $@ - $(AR) cr $@ $(OBJECTS) - -test -n "$(RANLIB)" && $(RANLIB) $@ - -libhistory.a: $(HISTOBJ) xmalloc.o - $(RM) $@ - $(AR) cr $@ $(HISTOBJ) xmalloc.o - -test -n "$(RANLIB)" && $(RANLIB) $@ - -$(SHARED_READLINE): $(SHARED_OBJ) - $(RM) $@ - $(LD) ${SHLIB_OPTS} -o $@ $(SHARED_OBJ) - -$(SHARED_HISTORY): $(SHARED_HISTOBJ) xmalloc.so - $(RM) $@ - $(LD) ${SHLIB_OPTS} -o $@ $(SHARED_HISTOBJ) xmalloc.so - -readline: $(OBJECTS) readline.h rldefs.h chardefs.h - $(CC) $(CCFLAGS) -o $@ ./examples/rl.c ./libreadline.a -ltermcap - -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 > $@ - -# CYGNUS LOCAL: Never run autoconf. -#$(srcdir)/configure: $(srcdir)/configure.in Comment-me-out in distribution -# cd $(srcdir) && autoconf Comment-me-out in distribution - -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: installdirs $(STATIC_LIBS) - for f in ${INSTALLED_HEADERS}; do \ - $(INSTALL_DATA) $(srcdir)/$$f $(includedir)/readline ; \ - done - -$(MV) $(libdir)/libreadline.a $(libdir)/libreadline.old - $(INSTALL_DATA) libreadline.a $(libdir)/libreadline.a - -test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libreadline.a - -$(MV) $(libdir)/libhistory.a $(libdir)/libhistory.old - $(INSTALL_DATA) libhistory.a $(libdir)/libhistory.a - -test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libhistory.a - -( if test -d doc ; then \ - cd doc && \ - ${MAKE} ${MFLAGS} infodir=$(infodir) $@; \ - fi ) - -installdirs: $(srcdir)/support/mkdirs - -$(SHELL) $(srcdir)/support/mkdirs $(includedir) \ - $(includedir)/readline $(libdir) $(infodir) $(man3dir) - -uninstall: - -test -n "$(includedir)" && cd $(includedir)/readline && \ - ${RM} ${INSTALLED_HEADERS} - -test -n "$(libdir)" && cd $(libdir) && \ - ${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS) - -install-shared: installdirs shared - -$(MV) $(libdir)/$(SHARED_HISTORY) $(libdir)/$(SHARED_HISTORY).old - $(INSTALL_DATA) $(SHARED_HISTORY) $(libdir)/$(SHARED_HISTORY) - -$(MV) $(libdir)/$(SHARED_READLINE) $(libdir)/$(SHARED_READLINE).old - $(INSTALL_DATA) $(SHARED_READLINE) $(libdir)/$(SHARED_READLINE) - -uninstall-shared: - -test -n "$(libdir)" && cd $(libdir) && ${RM} ${SHARED_LIBS} - -TAGS: force - $(ETAGS) $(CSOURCES) $(HSOURCES) - -tags: force - $(CTAGS) $(CSOURCES) $(HSOURCES) - -clean: force - $(RM) $(OBJECTS) $(STATIC_LIBS) - $(RM) $(SHARED_OBJ) $(SHARED_LIBS) - -( cd doc && $(MAKE) $(MFLAGS) $@ ) - -( cd examples && $(MAKE) $(MFLAGS) $@ ) - -mostlyclean: clean - -( cd doc && $(MAKE) $(MFLAGS) $@ ) - -( cd examples && $(MAKE) $(MFLAGS) $@ ) - -distclean maintainer-clean: clean - -( 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 chardefs.h tilde.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 chardefs.h tilde.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 chardefs.h tilde.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 chardefs.h tilde.h -display.o: history.h -funmap.o: readline.h keymaps.h chardefs.h tilde.h -funmap.o: rlconf.h ansi_stdlib.h -funmap.o: ${BUILD_DIR}/config.h -histexpand.o: ansi_stdlib.h -histexpand.o: history.h histlib.h -histexpand.o: ${BUILD_DIR}/config.h -histfile.o: ansi_stdlib.h -histfile.o: history.h histlib.h -histfile.o: ${BUILD_DIR}/config.h -history.o: ansi_stdlib.h -history.o: history.h histlib.h -history.o: ${BUILD_DIR}/config.h -histsearch.o: ansi_stdlib.h -histsearch.o: history.h histlib.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 chardefs.h tilde.h -isearch.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -isearch.o: readline.h keymaps.h chardefs.h tilde.h -isearch.o: ansi_stdlib.h history.h -keymaps.o: emacs_keymap.c vi_keymap.c -keymaps.o: keymaps.h chardefs.h rlconf.h ansi_stdlib.h -keymaps.o: readline.h keymaps.h chardefs.h tilde.h -keymaps.o: ${BUILD_DIR}/config.h -kill.o: ansi_stdlib.h -kill.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -kill.o: readline.h keymaps.h chardefs.h tilde.h -kill.o: history.h -macro.o: ansi_stdlib.h -macro.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -macro.o: readline.h keymaps.h chardefs.h tilde.h -macro.o: history.h -nls.o: ansi_stdlib.h -nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -parens.o: rlconf.h -parens.o: ${BUILD_DIR}/config.h -parens.o: readline.h keymaps.h chardefs.h tilde.h -readline.o: readline.h keymaps.h chardefs.h tilde.h -readline.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -readline.o: history.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 chardefs.h tilde.h -search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -search.o: readline.h keymaps.h chardefs.h tilde.h -search.o: ansi_stdlib.h history.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 chardefs.h tilde.h -signals.o: history.h -terminal.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -terminal.o: tcap.h -terminal.o: readline.h keymaps.h chardefs.h tilde.h -terminal.o: history.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 chardefs.h tilde.h -undo.o: history.h -util.o: posixjmp.h ansi_stdlib.h -util.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -util.o: readline.h keymaps.h chardefs.h tilde.h -vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h -vi_mode.o: readline.h keymaps.h chardefs.h tilde.h -vi_mode.o: history.h ansi_stdlib.h -xmalloc.o: ${BUILD_DIR}/config.h -xmalloc.o: ansi_stdlib.h - -readline.o: $(srcdir)/readline.c -vi_mode.o: $(srcdir)/vi_mode.c -funmap.o: $(srcdir)/funmap.c -keymaps.o: $(srcdir)/keymaps.c -parens.o: $(srcdir)/parens.c -search.o: $(srcdir)/search.c -rltty.o: $(srcdir)/rltty.c -complete.o: $(srcdir)/complete.c -bind.o: $(srcdir)/bind.c -isearch.o: $(srcdir)/isearch.c -display.o: $(srcdir)/display.c -signals.o: $(srcdir)/signals.c -util.o: $(srcdir)/util.c -kill.o: $(srcdir)/kill.c -undo.o: $(srcdir)/undo.c -macro.o: $(srcdir)/macro.c -input.o: $(srcdir)/input.c -callback.o: $(srcdir)/callback.c -terminal.o: $(srcdir)/terminal.c -nls.o: $(srcdir)/nls.c -xmalloc.o: $(srcdir)/xmalloc.c -history.o: $(srcdir)/history.c -histexpand.o: $(srcdir)/histexpand.c -histfile.o: $(srcdir)/histfile.c -histsearch.o: $(srcdir)/histsearch.c -shell.o: $(srcdir)/shell.c -tilde.o: $(srcdir)/tilde.c - -bind.so: ansi_stdlib.h posixstat.h -bind.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -bind.so: readline.h keymaps.h chardefs.h tilde.h -bind.so: history.h -callback.so: rlconf.h -callback.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -callback.so: readline.h keymaps.h chardefs.h tilde.h -complete.so: ansi_stdlib.h posixdir.h posixstat.h -complete.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -complete.so: readline.h keymaps.h chardefs.h tilde.h -display.so: ansi_stdlib.h posixstat.h -display.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -display.so: tcap.h -display.so: readline.h keymaps.h chardefs.h tilde.h -display.so: history.h -funmap.so: readline.h keymaps.h chardefs.h tilde.h -funmap.so: rlconf.h ansi_stdlib.h -funmap.so: ${BUILD_DIR}/config.h -histexpand.so: ansi_stdlib.h -histexpand.so: history.h histlib.h -histexpand.so: ${BUILD_DIR}/config.h -histfile.so: ansi_stdlib.h -histfile.so: history.h histlib.h -histfile.so: ${BUILD_DIR}/config.h -history.so: ansi_stdlib.h -history.so: history.h histlib.h -history.so: ${BUILD_DIR}/config.h -histsearch.so: ansi_stdlib.h -histsearch.so: history.h histlib.h -histsearch.so: ${BUILD_DIR}/config.h -input.so: ansi_stdlib.h -input.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -input.so: readline.h keymaps.h chardefs.h tilde.h -isearch.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -isearch.so: readline.h keymaps.h chardefs.h tilde.h -isearch.so: ansi_stdlib.h history.h -keymaps.so: emacs_keymap.c vi_keymap.c -keymaps.so: keymaps.h chardefs.h rlconf.h ansi_stdlib.h -keymaps.so: readline.h keymaps.h chardefs.h tilde.h -keymaps.so: ${BUILD_DIR}/config.h -kill.so: ansi_stdlib.h -kill.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -kill.so: readline.h keymaps.h chardefs.h tilde.h -kill.so: history.h -macro.so: ansi_stdlib.h -macro.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -macro.so: readline.h keymaps.h chardefs.h tilde.h -macro.so: history.h -nls.so: ansi_stdlib.h -nls.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -parens.so: rlconf.h -parens.so: ${BUILD_DIR}/config.h -parens.so: readline.h keymaps.h chardefs.h tilde.h -readline.so: readline.h keymaps.h chardefs.h tilde.h -readline.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -readline.so: history.h -readline.so: posixstat.h ansi_stdlib.h posixjmp.h -rltty.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -rltty.so: rltty.h -rltty.so: readline.h keymaps.h chardefs.h tilde.h -search.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -search.so: readline.h keymaps.h chardefs.h tilde.h -search.so: ansi_stdlib.h history.h -signals.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -signals.so: readline.h keymaps.h chardefs.h tilde.h -signals.so: history.h -terminal.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -terminal.so: tcap.h -terminal.so: readline.h keymaps.h chardefs.h tilde.h -terminal.so: history.h -tilde.so: ansi_stdlib.h -tilde.so: ${BUILD_DIR}/config.h -tilde.so: tilde.h -undo.so: ansi_stdlib.h -undo.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -undo.so: readline.h keymaps.h chardefs.h tilde.h -undo.so: history.h -util.so: posixjmp.h ansi_stdlib.h -util.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -util.so: readline.h keymaps.h chardefs.h tilde.h -vi_mode.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h -vi_mode.so: readline.h keymaps.h chardefs.h tilde.h -vi_mode.so: history.h ansi_stdlib.h -xmalloc.so: ${BUILD_DIR}/config.h -xmalloc.so: ansi_stdlib.h - -readline.o: readline.c -vi_mode.o: vi_mode.c -funmap.o: funmap.c -keymaps.o: keymaps.c -parens.o: parens.c -search.o: search.c -rltty.o: rltty.c -complete.o: complete.c -bind.o: bind.c -isearch.o: isearch.c -display.o: display.c -signals.o: signals.c -util.o: util.c -kill.o: kill.c -undo.o: undo.c -macro.o: macro.c -input.o: input.c -callback.o: callback.c -terminal.o: terminal.c -nls.o: nls.c -xmalloc.o: xmalloc.c -history.o: history.c -histexpand.o: histexpand.c -histfile.o: histfile.c -histsearch.o: histsearch.c -shell.o: shell.c -tilde.o: tilde.c - -readline.so: $(srcdir)/readline.c -vi_mode.so: $(srcdir)/vi_mode.c -funmap.so: $(srcdir)/funmap.c -keymaps.so: $(srcdir)/keymaps.c -parens.so: $(srcdir)/parens.c -search.so: $(srcdir)/search.c -rltty.so: $(srcdir)/rltty.c -complete.so: $(srcdir)/complete.c -bind.so: $(srcdir)/bind.c -isearch.so: $(srcdir)/isearch.c -display.so: $(srcdir)/display.c -signals.so: $(srcdir)/signals.c -util.so: $(srcdir)/util.c -kill.so: $(srcdir)/kill.c -undo.so: $(srcdir)/undo.c -macro.so: $(srcdir)/macro.c -input.so: $(srcdir)/input.c -callback.so: $(srcdir)/callback.c -terminal.so: $(srcdir)/terminal.c -nls.so: $(srcdir)/nls.c -xmalloc.so: $(srcdir)/xmalloc.c -history.so: $(srcdir)/history.c -histexpand.so: $(srcdir)/histexpand.c -histfile.so: $(srcdir)/histfile.c -histsearch.so: $(srcdir)/histsearch.c -shell.so: $(srcdir)/shell.c -tilde.so: $(srcdir)/tilde.c - -readline.so: readline.c -vi_mode.so: vi_mode.c -funmap.so: funmap.c -keymaps.so: keymaps.c -parens.so: parens.c -search.so: search.c -rltty.so: rltty.c -complete.so: complete.c -bind.so: bind.c -isearch.so: isearch.c -display.so: display.c -signals.so: signals.c -util.so: util.c -kill.so: kill.c -undo.so: undo.c -macro.so: macro.c -input.so: input.c -callback.so: callback.c -terminal.so: terminal.c -nls.so: nls.c -xmalloc.so: xmalloc.c -history.so: history.c -histexpand.so: histexpand.c -histfile.so: histfile.c -histsearch.so: histsearch.c -shell.so: shell.c -tilde.so: tilde.c diff --git a/readline/acconfig.h b/readline/acconfig.h deleted file mode 100644 index b41ac51..0000000 --- a/readline/acconfig.h +++ /dev/null @@ -1,56 +0,0 @@ -/* acconfig.h - This file is in the public domain. - - Descriptive text for the C preprocessor macros that - the distributed Autoconf macros can define. - No software package will use all of them; autoheader copies the ones - your configure.in uses into your configuration header file templates. - - The entries are in sort -df order: alphabetical, case insensitive, - ignoring punctuation (such as underscores). Although this order - can split up related entries, it makes it easier to check whether - a given entry is in the file. - - Leave the following blank line there!! Autoheader needs it. */ - - -/* Definitions pulled in from aclocal.m4. */ -#undef VOID_SIGHANDLER - -#undef TIOCGWINSZ_IN_SYS_IOCTL - -#undef TIOCSTAT_IN_SYS_IOCTL - -#undef HAVE_GETPW_DECLS - -#undef FIONREAD_IN_SYS_IOCTL - -#undef HAVE_BSD_SIGNALS - -#undef HAVE_LSTAT - -#undef HAVE_POSIX_SIGNALS - -#undef HAVE_POSIX_SIGSETJMP - -#undef HAVE_USG_SIGHOLD - -#undef MUST_REINSTALL_SIGHANDLERS - -#undef SPEED_T_IN_SYS_TYPES - -#undef STRCOLL_BROKEN - -#undef STRUCT_DIRENT_HAS_D_FILENO - -#undef STRUCT_DIRENT_HAS_D_INO - -#undef STRUCT_WINSIZE_IN_SYS_IOCTL - -#undef STRUCT_WINSIZE_IN_TERMIOS - - -/* Leave that blank line there!! Autoheader needs it. - If you're adding to this file, keep in mind: - The entries are in sort -df order: alphabetical, case insensitive, - ignoring punctuation (such as underscores). */ diff --git a/readline/bind.c b/readline/bind.c deleted file mode 100644 index a7ffe25..0000000 --- a/readline/bind.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* bind.c -- key binding and startup file support for the readline library. */ - -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "sysdep.h" -#include <stdio.h> -#include <sys/types.h> -#include <fcntl.h> -#ifndef NO_SYS_FILE -#include <sys/file.h> -#endif - -#include <errno.h> -/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ -#if !defined (errno) -extern int errno; -#endif /* !errno */ - -/* System-specific feature definitions and include files. */ -#include "rldefs.h" - -/* Some standard library routines. */ -#include "readline.h" -#include "history.h" - -#if !defined (strchr) && !defined (__STDC__) -extern char *strchr (), *strrchr (); -#endif /* !strchr && !__STDC__ */ - -extern char *tilde_expand (); - -extern int _rl_horizontal_scroll_mode; -extern int _rl_mark_modified_lines; -extern int _rl_prefer_visible_bell; -extern int _rl_meta_flag; -extern int rl_blink_matching_paren; -extern int _rl_convert_meta_chars_to_ascii; -#if defined (VISIBLE_STATS) -extern int rl_visible_stats; -#endif /* VISIBLE_STATS */ -extern int rl_complete_with_tilde_expansion; -extern int rl_completion_query_items; - -extern int rl_explicit_arg; -extern int rl_editing_mode; -extern unsigned short _rl_parsing_conditionalized_out; -extern Keymap _rl_keymap; - -extern char *possible_control_prefixes[], *possible_meta_prefixes[]; - -extern char **rl_funmap_names (); - -static void rl_generic_bind (); -static int glean_key_from_name (); -static int stricmp (), strnicmp (); - -#if defined (STATIC_MALLOC) -static char *xmalloc (), *xrealloc (); -#else -extern char *xmalloc (), *xrealloc (); -#endif /* STATIC_MALLOC */ - -/* **************************************************************** */ -/* */ -/* Binding keys */ -/* */ -/* **************************************************************** */ - -/* rl_add_defun (char *name, Function *function, int key) - Add NAME to the list of named functions. Make FUNCTION be the function - that gets called. If KEY is not -1, then bind it. */ -rl_add_defun (name, function, key) - char *name; - Function *function; - int key; -{ - if (key != -1) - rl_bind_key (key, function); - rl_add_funmap_entry (name, function); -} - -/* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */ -int -rl_bind_key (key, function) - int key; - Function *function; -{ - if (key < 0) - return (key); - - if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii) - { - if (_rl_keymap[ESC].type == ISKMAP) - { - Keymap escmap = (Keymap)_rl_keymap[ESC].function; - - key = UNMETA (key); - escmap[key].type = ISFUNC; - escmap[key].function = function; - return (0); - } - return (key); - } - - _rl_keymap[key].type = ISFUNC; - _rl_keymap[key].function = function; - return (0); -} - -/* Bind KEY to FUNCTION in MAP. Returns non-zero in case of invalid - KEY. */ -int -rl_bind_key_in_map (key, function, map) - int key; - Function *function; - Keymap map; -{ - int result; - Keymap oldmap = _rl_keymap; - - _rl_keymap = map; - result = rl_bind_key (key, function); - _rl_keymap = oldmap; - return (result); -} - -/* Make KEY do nothing in the currently selected keymap. - Returns non-zero in case of error. */ -int -rl_unbind_key (key) - int key; -{ - return (rl_bind_key (key, (Function *)NULL)); -} - -/* Make KEY do nothing in MAP. - Returns non-zero in case of error. */ -int -rl_unbind_key_in_map (key, map) - int key; - Keymap map; -{ - return (rl_bind_key_in_map (key, (Function *)NULL, map)); -} - -/* Bind the key sequence represented by the string KEYSEQ to - FUNCTION. This makes new keymaps as necessary. The initial - place to do bindings is in MAP. */ -rl_set_key (keyseq, function, map) - char *keyseq; - Function *function; - Keymap map; -{ - rl_generic_bind (ISFUNC, keyseq, function, map); -} - -/* Bind the key sequence represented by the string KEYSEQ to - the string of characters MACRO. This makes new keymaps as - necessary. The initial place to do bindings is in MAP. */ -rl_macro_bind (keyseq, macro, map) - char *keyseq, *macro; - Keymap map; -{ - char *macro_keys; - int macro_keys_len; - - macro_keys = (char *)xmalloc ((2 * strlen (macro)) + 1); - - if (rl_translate_keyseq (macro, macro_keys, ¯o_keys_len)) - { - free (macro_keys); - return; - } - rl_generic_bind (ISMACR, keyseq, macro_keys, map); -} - -/* Bind the key sequence represented by the string KEYSEQ to - the arbitrary pointer DATA. TYPE says what kind of data is - pointed to by DATA, right now this can be a function (ISFUNC), - a macro (ISMACR), or a keymap (ISKMAP). This makes new keymaps - as necessary. The initial place to do bindings is in MAP. */ - -static void -rl_generic_bind (type, keyseq, data, map) - int type; - char *keyseq, *data; - Keymap map; -{ - char *keys; - int keys_len; - register int i; - - /* If no keys to bind to, exit right away. */ - if (!keyseq || !*keyseq) - { - if (type == ISMACR) - free (data); - return; - } - - keys = (char *)alloca (1 + (2 * strlen (keyseq))); - - /* Translate the ASCII representation of KEYSEQ into an array of - characters. Stuff the characters into KEYS, and the length of - KEYS into KEYS_LEN. */ - if (rl_translate_keyseq (keyseq, keys, &keys_len)) - return; - - /* Bind keys, making new keymaps as necessary. */ - for (i = 0; i < keys_len; i++) - { - int ic = (int) ((unsigned char)keys[i]); - - if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic)) - { - ic = UNMETA (ic); - if (map[ESC].type == ISKMAP) - map = (Keymap) map[ESC].function; - } - - if ((i + 1) < keys_len) - { - if (map[ic].type != ISKMAP) - { - if (map[ic].type == ISMACR) - free ((char *)map[ic].function); - - map[ic].type = ISKMAP; - map[ic].function = (Function *)rl_make_bare_keymap (); - } - map = (Keymap)map[ic].function; - } - else - { - if (map[ic].type == ISMACR) - free ((char *)map[ic].function); - - map[ic].function = (Function *)data; - map[ic].type = type; - } - } -} - -/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY, - an array of characters. LEN gets the final length of ARRAY. Return - non-zero if there was an error parsing SEQ. */ -rl_translate_keyseq (seq, array, len) - char *seq, *array; - int *len; -{ - register int i, c, l = 0; - - for (i = 0; c = seq[i]; i++) - { - if (c == '\\') - { - c = seq[++i]; - - if (!c) - break; - - if (((c == 'C' || c == 'M') && seq[i + 1] == '-') || - (c == 'e')) - { - /* Handle special case of backwards define. */ - if (strncmp (&seq[i], "C-\\M-", 5) == 0) - { - array[l++] = ESC; - i += 5; - array[l++] = CTRL (to_upper (seq[i])); - if (!seq[i]) - i--; - continue; - } - - switch (c) - { - case 'M': - i++; - array[l++] = ESC; - break; - - case 'C': - i += 2; - /* Special hack for C-?... */ - if (seq[i] == '?') - array[l++] = RUBOUT; - else - array[l++] = CTRL (to_upper (seq[i])); - break; - - case 'e': - array[l++] = ESC; - } - - continue; - } - } - array[l++] = c; - } - - *len = l; - array[l] = '\0'; - return (0); -} - -/* Return a pointer to the function that STRING represents. - If STRING doesn't have a matching function, then a NULL pointer - is returned. */ -Function * -rl_named_function (string) - char *string; -{ - register int i; - - rl_initialize_funmap (); - - for (i = 0; funmap[i]; i++) - if (stricmp (funmap[i]->name, string) == 0) - return (funmap[i]->function); - return ((Function *)NULL); -} - -/* Return the function (or macro) definition which would be invoked via - KEYSEQ if executed in MAP. If MAP is NULL, then the current keymap is - used. TYPE, if non-NULL, is a pointer to an int which will receive the - type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap), - or ISMACR (macro). */ -Function * -rl_function_of_keyseq (keyseq, map, type) - char *keyseq; - Keymap map; - int *type; -{ - register int i; - - if (!map) - map = _rl_keymap; - - for (i = 0; keyseq && keyseq[i]; i++) - { - int ic = keyseq[i]; - - if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) - { - if (map[ESC].type != ISKMAP) - { - if (type) - *type = map[ESC].type; - - return (map[ESC].function); - } - else - { - map = (Keymap)map[ESC].function; - ic = UNMETA (ic); - } - } - - if (map[ic].type == ISKMAP) - { - /* If this is the last key in the key sequence, return the - map. */ - if (!keyseq[i + 1]) - { - if (type) - *type = ISKMAP; - - return (map[ic].function); - } - else - map = (Keymap)map[ic].function; - } - else - { - if (type) - *type = map[ic].type; - - return (map[ic].function); - } - } -} - -/* The last key bindings file read. */ -static char *last_readline_init_file = (char *)NULL; - -/* Re-read the current keybindings file. */ -rl_re_read_init_file (count, ignore) - int count, ignore; -{ - rl_read_init_file ((char *)NULL); -} - -/* The final, last-ditch effort file name for an init file. */ -#ifdef __MSDOS__ -/* Don't know what to do, but this is a guess */ -#define DEFAULT_INPUTRC "/INPUTRC"; -#else -#define DEFAULT_INPUTRC "~/.inputrc" -#endif - -/* Do key bindings from a file. If FILENAME is NULL it defaults - to `~/.inputrc'. If the file existed and could be opened and - read, 0 is returned, otherwise errno is returned. */ -int -rl_read_init_file (filename) - char *filename; -{ - register int i; - char *buffer, *openname, *line, *end; - struct stat finfo; - int file; - - /* Default the filename. */ - if (!filename) - { - if (last_readline_init_file) - filename = last_readline_init_file; - else - filename = DEFAULT_INPUTRC; - } - - openname = tilde_expand (filename); - - if (!openname || *openname == '\000') - return ENOENT; - - if ((stat (openname, &finfo) < 0) || - (file = open (openname, O_RDONLY, 0666)) < 0) - { - free (openname); - return (errno); - } - else - free (openname); - - if (last_readline_init_file) - free (last_readline_init_file); - - last_readline_init_file = savestring (filename); - - /* Read the file into BUFFER. */ - buffer = (char *)xmalloc ((int)finfo.st_size + 1); - i = read (file, buffer, finfo.st_size); - close (file); - - if (i != finfo.st_size) - return (errno); - - /* Loop over the lines in the file. Lines that start with `#' are - comments; all other lines are commands for readline initialization. */ - line = buffer; - end = buffer + finfo.st_size; - while (line < end) - { - /* Find the end of this line. */ - for (i = 0; line + i != end && line[i] != '\n'; i++); - - /* Mark end of line. */ - line[i] = '\0'; - - /* If the line is not a comment, then parse it. */ - if (*line && *line != '#') - rl_parse_and_bind (line); - - /* Move to the next line. */ - line += i + 1; - } - free (buffer); - return (0); -} - -/* **************************************************************** */ -/* */ -/* Parser Directives */ -/* */ -/* **************************************************************** */ - -/* Conditionals. */ - -/* Calling programs set this to have their argv[0]. */ -char *rl_readline_name = "other"; - -/* Stack of previous values of parsing_conditionalized_out. */ -static unsigned char *if_stack = (unsigned char *)NULL; -static int if_stack_depth = 0; -static int if_stack_size = 0; - -/* Push _rl_parsing_conditionalized_out, and set parser state based - on ARGS. */ -static int -parser_if (args) - char *args; -{ - register int i; - - /* Push parser state. */ - if (if_stack_depth + 1 >= if_stack_size) - { - if (!if_stack) - if_stack = (unsigned char *)xmalloc (if_stack_size = 20); - else - if_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20); - } - if_stack[if_stack_depth++] = _rl_parsing_conditionalized_out; - - /* If parsing is turned off, then nothing can turn it back on except - for finding the matching endif. In that case, return right now. */ - if (_rl_parsing_conditionalized_out) - return 0; - - /* Isolate first argument. */ - for (i = 0; args[i] && !whitespace (args[i]); i++); - - if (args[i]) - args[i++] = '\0'; - - /* Handle "if term=foo" and "if mode=emacs" constructs. If this - isn't term=foo, or mode=emacs, then check to see if the first - word in ARGS is the same as the value stored in rl_readline_name. */ - if (rl_terminal_name && strnicmp (args, "term=", 5) == 0) - { - char *tem, *tname; - - /* Terminals like "aaa-60" are equivalent to "aaa". */ - tname = savestring (rl_terminal_name); - tem = (char*) strrchr (tname, '-'); - if (tem) - *tem = '\0'; - - /* Test the `long' and `short' forms of the terminal name so that - if someone has a `sun-cmd' and does not want to have bindings - that will be executed if the terminal is a `sun', they can put - `$if term=sun-cmd' into their .inputrc. */ - if ((stricmp (args + 5, tname) == 0) || - (stricmp (args + 5, rl_terminal_name) == 0)) - _rl_parsing_conditionalized_out = 0; - else - _rl_parsing_conditionalized_out = 1; - - free (tname); - } -#if defined (VI_MODE) - else if (strnicmp (args, "mode=", 5) == 0) - { - int mode; - - if (stricmp (args + 5, "emacs") == 0) - mode = emacs_mode; - else if (stricmp (args + 5, "vi") == 0) - mode = vi_mode; - else - mode = no_mode; - - if (mode == rl_editing_mode) - _rl_parsing_conditionalized_out = 0; - else - _rl_parsing_conditionalized_out = 1; - } -#endif /* VI_MODE */ - /* Check to see if the first word in ARGS is the same as the - value stored in rl_readline_name. */ - else if (stricmp (args, rl_readline_name) == 0) - _rl_parsing_conditionalized_out = 0; - else - _rl_parsing_conditionalized_out = 1; - return 0; -} - -/* Invert the current parser state if there is anything on the stack. */ -static int -parser_else (args) - char *args; -{ - register int i; - - if (!if_stack_depth) - { - /* Error message? */ - return 0; - } - - /* Check the previous (n - 1) levels of the stack to make sure that - we haven't previously turned off parsing. */ - for (i = 0; i < if_stack_depth - 1; i++) - if (if_stack[i] == 1) - return 0; - - /* Invert the state of parsing if at top level. */ - _rl_parsing_conditionalized_out = !_rl_parsing_conditionalized_out; - return 0; -} - -/* Terminate a conditional, popping the value of - _rl_parsing_conditionalized_out from the stack. */ -static int -parser_endif (args) - char *args; -{ - if (if_stack_depth) - _rl_parsing_conditionalized_out = if_stack[--if_stack_depth]; - else - { - /* *** What, no error message? *** */ - } - return 0; -} - -/* Associate textual names with actual functions. */ -static struct { - char *name; - Function *function; -} parser_directives [] = { - { "if", parser_if }, - { "endif", parser_endif }, - { "else", parser_else }, - { (char *)0x0, (Function *)0x0 } -}; - -/* Handle a parser directive. STATEMENT is the line of the directive - without any leading `$'. */ -static int -handle_parser_directive (statement) - char *statement; -{ - register int i; - char *directive, *args; - - /* Isolate the actual directive. */ - - /* Skip whitespace. */ - for (i = 0; whitespace (statement[i]); i++); - - directive = &statement[i]; - - for (; statement[i] && !whitespace (statement[i]); i++); - - if (statement[i]) - statement[i++] = '\0'; - - for (; statement[i] && whitespace (statement[i]); i++); - - args = &statement[i]; - - /* Lookup the command, and act on it. */ - for (i = 0; parser_directives[i].name; i++) - if (stricmp (directive, parser_directives[i].name) == 0) - { - (*parser_directives[i].function) (args); - return (0); - } - - /* *** Should an error message be output? */ - return (1); -} - -/* Ugly but working hack for binding prefix meta. */ -#define PREFIX_META_HACK - -static int substring_member_of_array (); - -/* Read the binding command from STRING and perform it. - A key binding command looks like: Keyname: function-name\0, - a variable binding command looks like: set variable value. - A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */ -rl_parse_and_bind (string) - char *string; -{ - char *funname, *kname; - register int c, i; - int key, equivalency; - - while (string && whitespace (*string)) - string++; - - if (!string || !*string || *string == '#') - return; - - /* If this is a parser directive, act on it. */ - if (*string == '$') - { - handle_parser_directive (&string[1]); - return; - } - - /* If we aren't supposed to be parsing right now, then we're done. */ - if (_rl_parsing_conditionalized_out) - return; - - i = 0; - /* If this keyname is a complex key expression surrounded by quotes, - advance to after the matching close quote. This code allows the - backslash to quote characters in the key expression. */ - if (*string == '"') - { - int passc = 0; - - for (i = 1; c = string[i]; i++) - { - if (passc) - { - passc = 0; - continue; - } - - if (c == '\\') - { - passc++; - continue; - } - - if (c == '"') - break; - } - } - - /* Advance to the colon (:) or whitespace which separates the two objects. */ - for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ ); - - equivalency = (c == ':' && string[i + 1] == '='); - - /* Mark the end of the command (or keyname). */ - if (string[i]) - string[i++] = '\0'; - - /* If doing assignment, skip the '=' sign as well. */ - if (equivalency) - string[i++] = '\0'; - - /* If this is a command to set a variable, then do that. */ - if (stricmp (string, "set") == 0) - { - char *var = string + i; - char *value; - - /* Make VAR point to start of variable name. */ - while (*var && whitespace (*var)) var++; - - /* Make value point to start of value string. */ - value = var; - while (*value && !whitespace (*value)) value++; - if (*value) - *value++ = '\0'; - while (*value && whitespace (*value)) value++; - - rl_variable_bind (var, value); - return; - } - - /* Skip any whitespace between keyname and funname. */ - for (; string[i] && whitespace (string[i]); i++); - funname = &string[i]; - - /* Now isolate funname. - For straight function names just look for whitespace, since - that will signify the end of the string. But this could be a - macro definition. In that case, the string is quoted, so skip - to the matching delimiter. We allow the backslash to quote the - delimiter characters in the macro body. */ - /* This code exists to allow whitespace in macro expansions, which - would otherwise be gobbled up by the next `for' loop.*/ - /* XXX - it may be desirable to allow backslash quoting only if " is - the quoted string delimiter, like the shell. */ - if (*funname == '\'' || *funname == '"') - { - int delimiter = string[i++]; - int passc = 0; - - for (; c = string[i]; i++) - { - if (passc) - { - passc = 0; - continue; - } - - if (c == '\\') - { - passc = 1; - continue; - } - - if (c == delimiter) - break; - } - if (c) - i++; - } - - /* Advance to the end of the string. */ - for (; string[i] && !whitespace (string[i]); i++); - - /* No extra whitespace at the end of the string. */ - string[i] = '\0'; - - /* Handle equivalency bindings here. Make the left-hand side be exactly - whatever the right-hand evaluates to, including keymaps. */ - if (equivalency) - { - return; - } - - /* If this is a new-style key-binding, then do the binding with - rl_set_key (). Otherwise, let the older code deal with it. */ - if (*string == '"') - { - char *seq = (char *)alloca (1 + strlen (string)); - register int j, k = 0; - int passc = 0; - - for (j = 1; string[j]; j++) - { - /* Allow backslash to quote characters, but leave them in place. - This allows a string to end with a backslash quoting another - backslash, or with a backslash quoting a double quote. The - backslashes are left in place for rl_translate_keyseq (). */ - if (passc || (string[j] == '\\')) - { - seq[k++] = string[j]; - passc = !passc; - continue; - } - - if (string[j] == '"') - break; - - seq[k++] = string[j]; - } - seq[k] = '\0'; - - /* Binding macro? */ - if (*funname == '\'' || *funname == '"') - { - j = strlen (funname); - - /* Remove the delimiting quotes from each end of FUNNAME. */ - if (j && funname[j - 1] == *funname) - funname[j - 1] = '\0'; - - rl_macro_bind (seq, &funname[1], _rl_keymap); - } - else - rl_set_key (seq, rl_named_function (funname), _rl_keymap); - - return; - } - - /* Get the actual character we want to deal with. */ - kname = (char*) strrchr (string, '-'); - if (!kname) - kname = string; - else - kname++; - - key = glean_key_from_name (kname); - - /* Add in control and meta bits. */ - if (substring_member_of_array (string, possible_control_prefixes)) - key = CTRL (to_upper (key)); - - if (substring_member_of_array (string, possible_meta_prefixes)) - key = META (key); - - /* Temporary. Handle old-style keyname with macro-binding. */ - if (*funname == '\'' || *funname == '"') - { - char seq[2]; - int fl = strlen (funname); - - seq[0] = key; seq[1] = '\0'; - if (fl && funname[fl - 1] == *funname) - funname[fl - 1] = '\0'; - - rl_macro_bind (seq, &funname[1], _rl_keymap); - } -#if defined (PREFIX_META_HACK) - /* Ugly, but working hack to keep prefix-meta around. */ - else if (stricmp (funname, "prefix-meta") == 0) - { - char seq[2]; - - seq[0] = key; - seq[1] = '\0'; - rl_generic_bind (ISKMAP, seq, (char *)emacs_meta_keymap, _rl_keymap); - } -#endif /* PREFIX_META_HACK */ - else - rl_bind_key (key, rl_named_function (funname)); -} - -/* Simple structure for boolean readline variables (i.e., those that can - have one of two values; either "On" or 1 for truth, or "Off" or 0 for - false. */ - -static struct { - char *name; - int *value; -} boolean_varlist [] = { - { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode }, - { "mark-modified-lines", &_rl_mark_modified_lines }, - { "prefer-visible-bell", &_rl_prefer_visible_bell }, - { "meta-flag", &_rl_meta_flag }, - { "blink-matching-paren", &rl_blink_matching_paren }, - { "convert-meta", &_rl_convert_meta_chars_to_ascii }, -#if defined (VISIBLE_STATS) - { "visible-stats", &rl_visible_stats }, -#endif /* VISIBLE_STATS */ - { "expand-tilde", &rl_complete_with_tilde_expansion }, - { (char *)NULL, (int *)NULL } -}; - -rl_variable_bind (name, value) - char *name, *value; -{ - register int i; - - /* Check for simple variables first. */ - for (i = 0; boolean_varlist[i].name; i++) - { - if (stricmp (name, boolean_varlist[i].name) == 0) - { - /* A variable is TRUE if the "value" is "on", "1" or "". */ - if ((!*value) || - (stricmp (value, "On") == 0) || - (value[0] == '1' && value[1] == '\0')) - *boolean_varlist[i].value = 1; - else - *boolean_varlist[i].value = 0; - return; - } - } - - /* Not a boolean variable, so check for specials. */ - - /* Editing mode change? */ - if (stricmp (name, "editing-mode") == 0) - { - if (strnicmp (value, "vi", 2) == 0) - { -#if defined (VI_MODE) - _rl_keymap = vi_insertion_keymap; - rl_editing_mode = vi_mode; -#else -#if defined (NOTDEF) - /* What state is the terminal in? I'll tell you: - non-determinate! That means we cannot do any output. */ - ding (); -#endif /* NOTDEF */ -#endif /* VI_MODE */ - } - else if (strnicmp (value, "emacs", 5) == 0) - { - _rl_keymap = emacs_standard_keymap; - rl_editing_mode = emacs_mode; - } - } - - /* Comment string change? */ - else if (stricmp (name, "comment-begin") == 0) - { -#if defined (VI_MODE) - extern char *rl_vi_comment_begin; - - if (*value) - { - if (rl_vi_comment_begin) - free (rl_vi_comment_begin); - - rl_vi_comment_begin = savestring (value); - } -#endif /* VI_MODE */ - } - else if (stricmp (name, "completion-query-items") == 0) - { - int nval = 100; - if (*value) - { - nval = atoi (value); - if (nval < 0) - nval = 0; - } - rl_completion_query_items = nval; - } -} - -/* Return the character which matches NAME. - For example, `Space' returns ' '. */ - -typedef struct { - char *name; - int value; -} assoc_list; - -static assoc_list name_key_alist[] = { - { "DEL", 0x7f }, - { "ESC", '\033' }, - { "Escape", '\033' }, - { "LFD", '\n' }, - { "Newline", '\n' }, - { "RET", '\r' }, - { "Return", '\r' }, - { "Rubout", 0x7f }, - { "SPC", ' ' }, - { "Space", ' ' }, - { "Tab", 0x09 }, - { (char *)0x0, 0 } -}; - -static int -glean_key_from_name (name) - char *name; -{ - register int i; - - for (i = 0; name_key_alist[i].name; i++) - if (stricmp (name, name_key_alist[i].name) == 0) - return (name_key_alist[i].value); - - return (*(unsigned char *)name); /* XXX was return (*name) */ -} - -/* Auxiliary functions to manage keymaps. */ -static struct { - char *name; - Keymap map; -} keymap_names[] = { - { "emacs", emacs_standard_keymap }, - { "emacs-standard", emacs_standard_keymap }, - { "emacs-meta", emacs_meta_keymap }, - { "emacs-ctlx", emacs_ctlx_keymap }, -#if defined (VI_MODE) - { "vi", vi_movement_keymap }, - { "vi-move", vi_movement_keymap }, - { "vi-command", vi_movement_keymap }, - { "vi-insert", vi_insertion_keymap }, -#endif /* VI_MODE */ - { (char *)0x0, (Keymap)0x0 } -}; - -Keymap -rl_get_keymap_by_name (name) - char *name; -{ - register int i; - - for (i = 0; keymap_names[i].name; i++) - if (strcmp (name, keymap_names[i].name) == 0) - return (keymap_names[i].map); - return ((Keymap) NULL); -} - -void -rl_set_keymap (map) - Keymap map; -{ - if (map) - _rl_keymap = map; -} - -Keymap -rl_get_keymap () -{ - return (_rl_keymap); -} - -void -rl_set_keymap_from_edit_mode () -{ - if (rl_editing_mode == emacs_mode) - _rl_keymap = emacs_standard_keymap; - else if (rl_editing_mode == vi_mode) - _rl_keymap = vi_insertion_keymap; -} - -/* **************************************************************** */ -/* */ -/* Key Binding and Function Information */ -/* */ -/* **************************************************************** */ - -/* Each of the following functions produces information about the - state of keybindings and functions known to Readline. The info - is always printed to rl_outstream, and in such a way that it can - be read back in (i.e., passed to rl_parse_and_bind (). */ - -/* Print the names of functions known to Readline. */ -void -rl_list_funmap_names (ignore) - int ignore; -{ - register int i; - char **funmap_names; - - funmap_names = rl_funmap_names (); - - if (!funmap_names) - return; - - for (i = 0; funmap_names[i]; i++) - fprintf (rl_outstream, "%s\n", funmap_names[i]); - - free (funmap_names); -} - -/* Return a NULL terminated array of strings which represent the key - sequences that are used to invoke FUNCTION in MAP. */ -static char ** -invoking_keyseqs_in_map (function, map) - Function *function; - Keymap map; -{ - register int key; - char **result; - int result_index, result_size; - - result = (char **)NULL; - result_index = result_size = 0; - - for (key = 0; key < 128; key++) - { - switch (map[key].type) - { - case ISMACR: - /* Macros match, if, and only if, the pointers are identical. - Thus, they are treated exactly like functions in here. */ - case ISFUNC: - /* If the function in the keymap is the one we are looking for, - then add the current KEY to the list of invoking keys. */ - if (map[key].function == function) - { - char *keyname = (char *)xmalloc (5); - - if (CTRL_P (key)) - sprintf (keyname, "\\C-%c", to_lower (UNCTRL (key))); - else if (key == RUBOUT) - sprintf (keyname, "\\C-?"); - else if (key == '\\' || key == '"') - { - keyname[0] = '\\'; - keyname[1] = (char) key; - keyname[2] = '\0'; - } - else - { - keyname[0] = (char) key; - keyname[1] = '\0'; - } - - if (result_index + 2 > result_size) - result = (char **) xrealloc - (result, (result_size += 10) * sizeof (char *)); - - result[result_index++] = keyname; - result[result_index] = (char *)NULL; - } - break; - - case ISKMAP: - { - char **seqs = (char **)NULL; - - /* Find the list of keyseqs in this map which have FUNCTION as - their target. Add the key sequences found to RESULT. */ - if (map[key].function) - seqs = - invoking_keyseqs_in_map (function, (Keymap)map[key].function); - - if (seqs) - { - register int i; - - for (i = 0; seqs[i]; i++) - { - char *keyname = (char *)xmalloc (6 + strlen (seqs[i])); - - if (key == ESC) - sprintf (keyname, "\\e"); - else if (CTRL_P (key)) - sprintf (keyname, "\\C-%c", to_lower (UNCTRL (key))); - else if (key == RUBOUT) - sprintf (keyname, "\\C-?"); - else if (key == '\\' || key == '"') - { - keyname[0] = '\\'; - keyname[1] = (char) key; - keyname[2] = '\0'; - } - else - { - keyname[0] = (char) key; - keyname[1] = '\0'; - } - - strcat (keyname, seqs[i]); - - if (result_index + 2 > result_size) - result = (char **) xrealloc - (result, (result_size += 10) * sizeof (char *)); - - result[result_index++] = keyname; - result[result_index] = (char *)NULL; - } - } - } - break; - } - } - return (result); -} - -/* Return a NULL terminated array of strings which represent the key - sequences that can be used to invoke FUNCTION using the current keymap. */ -char ** -rl_invoking_keyseqs (function) - Function *function; -{ - return (invoking_keyseqs_in_map (function, _rl_keymap)); -} - -/* Print all of the current functions and their bindings to - rl_outstream. If an explicit argument is given, then print - the output in such a way that it can be read back in. */ -int -rl_dump_functions (count) - int count; -{ - void rl_function_dumper (); - - rl_function_dumper (rl_explicit_arg); - rl_on_new_line (); - return (0); -} - -/* Print all of the functions and their bindings to rl_outstream. If - PRINT_READABLY is non-zero, then print the output in such a way - that it can be read back in. */ -void -rl_function_dumper (print_readably) - int print_readably; -{ - register int i; - char **names; - char *name; - - names = rl_funmap_names (); - - fprintf (rl_outstream, "\n"); - - for (i = 0; name = names[i]; i++) - { - Function *function; - char **invokers; - - function = rl_named_function (name); - invokers = invoking_keyseqs_in_map (function, _rl_keymap); - - if (print_readably) - { - if (!invokers) - fprintf (rl_outstream, "# %s (not bound)\n", name); - else - { - register int j; - - for (j = 0; invokers[j]; j++) - { - fprintf (rl_outstream, "\"%s\": %s\n", - invokers[j], name); - free (invokers[j]); - } - - free (invokers); - } - } - else - { - if (!invokers) - fprintf (rl_outstream, "%s is not bound to any keys\n", - name); - else - { - register int j; - - fprintf (rl_outstream, "%s can be found on ", name); - - for (j = 0; invokers[j] && j < 5; j++) - { - fprintf (rl_outstream, "\"%s\"%s", invokers[j], - invokers[j + 1] ? ", " : ".\n"); - } - - if (j == 5 && invokers[j]) - fprintf (rl_outstream, "...\n"); - - for (j = 0; invokers[j]; j++) - free (invokers[j]); - - free (invokers); - } - } - } -} - - -/* **************************************************************** */ -/* */ -/* String Utility Functions */ -/* */ -/* **************************************************************** */ - -static char *strindex (); - -/* Return non-zero if any members of ARRAY are a substring in STRING. */ -static int -substring_member_of_array (string, array) - char *string, **array; -{ - while (*array) - { - if (strindex (string, *array)) - return (1); - array++; - } - return (0); -} - -/* Whoops, Unix doesn't have strnicmp. */ - -/* Compare at most COUNT characters from string1 to string2. Case - doesn't matter. */ -static int -strnicmp (string1, string2, count) - char *string1, *string2; -{ - register char ch1, ch2; - - while (count) - { - ch1 = *string1++; - ch2 = *string2++; - if (to_upper(ch1) == to_upper(ch2)) - count--; - else break; - } - return (count); -} - -/* strcmp (), but caseless. */ -static int -stricmp (string1, string2) - char *string1, *string2; -{ - register char ch1, ch2; - - while (*string1 && *string2) - { - ch1 = *string1++; - ch2 = *string2++; - if (to_upper(ch1) != to_upper(ch2)) - return (1); - } - return (*string1 | *string2); -} - -/* Determine if s2 occurs in s1. If so, return a pointer to the - match in s1. The compare is case insensitive. */ -static char * -strindex (s1, s2) - register char *s1, *s2; -{ - register int i, l = strlen (s2); - register int len = strlen (s1); - - for (i = 0; (len - i) >= l; i++) - if (strnicmp (&s1[i], s2, l) == 0) - return (s1 + i); - return ((char *)NULL); -} diff --git a/readline/chardefs.h b/readline/chardefs.h deleted file mode 100644 index 06dbd9f..0000000 --- a/readline/chardefs.h +++ /dev/null @@ -1,84 +0,0 @@ -/* chardefs.h -- Character definitions for readline. */ -#ifndef _CHARDEFS_ -#define _CHARDEFS_ - -#include <ctype.h> - -#ifndef savestring -#define savestring(X) _rl_savestring(X) -extern char * _rl_savestring (); -#endif - -#ifndef whitespace -#define whitespace(c) (((c) == ' ') || ((c) == '\t')) -#endif - -#ifdef CTRL -#undef CTRL -#endif - -/* Some character stuff. */ -#define control_character_threshold 0x020 /* Smaller than this is control. */ -#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 META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) -#define CTRL(c) ((c) & (~control_character_bit)) -#define META(c) ((c) | meta_character_bit) - -#define UNMETA(c) ((c) & (~meta_character_bit)) -#define UNCTRL(c) to_upper(((c)|control_character_bit)) - -#define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) -#define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) - -#define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c)) - -#ifndef to_upper -#define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c)) -#define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c)) -#endif - -#define CTRL_P(c) ((c) < control_character_threshold) -#define META_P(c) ((c) > meta_character_threshold) - -#ifndef NEWLINE -#define NEWLINE '\n' -#endif - -#ifndef RETURN -#define RETURN CTRL('M') -#endif - -#ifndef RUBOUT -#define RUBOUT 0x07f -#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 0x020 - -#ifdef ESC -#undef ESC -#endif - -#define ESC CTRL('[') - -#endif /* _CHARDEFS_ */ diff --git a/readline/complete.c b/readline/complete.c deleted file mode 100644 index 0a996a7..0000000 --- a/readline/complete.c +++ /dev/null @@ -1,1319 +0,0 @@ -/* complete.c -- filename completion 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "sysdep.h" -#include <stdio.h> -#include <fcntl.h> -#if !defined (NO_SYS_FILE) -# include <sys/file.h> -#endif /* !NO_SYS_FILE */ - -#include <errno.h> -/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ -#if !defined (errno) -extern int errno; -#endif /* !errno */ - -/* These next are for filename completion. Perhaps this belongs - in a different place. */ -#if !defined(__MSDOS__) && !defined(_MSC_VER) -#include <pwd.h> -#endif /* __MSDOS__ */ -#if defined (USG) && !defined (isc386) && !defined (sgi) -extern struct passwd *getpwuid (), *getpwent (); -#endif -#if defined (isc386) && !defined (__STDC__) && defined (_POSIX_SOURCE) -extern struct passwd *getpwent (); -#endif - -/* Included by <fcntl.h> on some systems, but not SCO, so include it here. */ -#include <sys/stat.h> - -/* System-specific feature definitions and include files. */ -#include "rldefs.h" - -/* Some standard library routines. */ -#include "readline.h" - -/* Possible values for do_replace in rl_complete_internal. */ -#define NO_MATCH 0 -#define SINGLE_MATCH 1 -#define MULT_MATCH 2 - -#if !defined (strchr) && !defined (__STDC__) -extern char *strchr (), *strrchr (); -#endif /* !strchr && !__STDC__ */ - -extern char *tilde_expand (); -extern char *rl_copy_text (); - -extern Function *rl_last_func; -extern int rl_editing_mode; -extern int screenwidth; - -/* Forward declarations for functions defined and used in this file. */ -char *filename_completion_function (); -char **completion_matches (); - -static int compare_strings (); -static char *rl_strpbrk (); - -#if defined (STATIC_MALLOC) -static char *xmalloc (), *xrealloc (); -#else -extern char *xmalloc (), *xrealloc (); -#endif /* STATIC_MALLOC */ - -/* 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. */ -Function *rl_symbolic_link_hook = (Function *)NULL; - -/* Non-zero means readline completion functions perform tilde expansion. */ -int rl_complete_with_tilde_expansion = 0; - -#define VISIBLE_STATS - -#if defined (VISIBLE_STATS) -# if !defined (X_OK) -# define X_OK 1 -# endif - -static int stat_char (); - -/* Non-zero means add an additional character to each filename displayed - during listing completion iff rl_filename_completion_desired which helps - to indicate the type of file being listed. */ -int rl_visible_stats = 0; -#endif /* VISIBLE_STATS */ - -/* **************************************************************** */ -/* */ -/* Completion matching, from readline's point of view. */ -/* */ -/* **************************************************************** */ - -/* Pointer to the generator function for completion_matches (). - NULL means to use filename_entry_function (), the default filename - completer. */ -Function *rl_completion_entry_function = (Function *)NULL; - -/* 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. */ -CPPFunction *rl_attempted_completion_function = (CPPFunction *)NULL; - -/* Local variable states what happened during the last completion attempt. */ -static int completion_changed_buffer = 0; - -/* Complete the word at or before point. You have supplied the function - that does the initial simple matching selection algorithm (see - completion_matches ()). The default is to do filename completion. */ - -rl_complete (ignore, invoking_key) - int ignore, invoking_key; -{ - if (rl_last_func == rl_complete && !completion_changed_buffer) - rl_complete_internal ('?'); - else - rl_complete_internal (TAB); -} - -/* List the possible completions. See description of rl_complete (). */ -rl_possible_completions (ignore, invoking_key) - int ignore, invoking_key; -{ - rl_complete_internal ('?'); -} - -rl_insert_completions (ignore, invoking_key) - int ignore, invoking_key; -{ - rl_complete_internal ('*'); -} - -/* The user must press "y" or "n". Non-zero return means "y" pressed. */ -get_y_or_n () -{ - int c; - - for (;;) - { - c = rl_read_key (); - if (c == 'y' || c == 'Y') - return (1); - if (c == 'n' || c == 'N') - return (0); - if (c == ABORT_CHAR) - rl_abort (); - ding (); - } -} - -/* 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. */ -int rl_completion_query_items = 100; - -/* The basic list of characters that signal a break between words for the - completer routine. The contents of this variable is what breaks words - in the shell, i.e. " \t\n\"\\'`@$><=" */ -char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{("; - -/* 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. */ -char *rl_completer_word_break_characters = (char *)NULL; - -/* 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. */ -char *rl_completer_quote_characters = (char *)NULL; - -/* 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. */ -char *rl_special_prefixes = (char *)NULL; - -/* If non-zero, then disallow duplicates in the matches. */ -int rl_ignore_completion_duplicates = 1; - -/* 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. */ -int rl_filename_completion_desired = 0; - -/* This function, if defined, is called by the completer when real - filename completion is done, after all the matching names have been - generated. It is passed a (char**) known as matches in the code below. - It consists of a NULL-terminated array of pointers to potential - matching strings. The 1st element (matches[0]) is the maximal - substring that is common to all matches. This function can re-arrange - the list of matches as required, but all elements of the array must be - free()'d if they are deleted. The main intent of this function is - to implement FIGNORE a la SunOS csh. */ -Function *rl_ignore_some_completions_function = (Function *)NULL; - -#if defined (SHELL) -/* A function to strip quotes that are not protected by backquotes. It - allows single quotes to appear within double quotes, and vice versa. - It should be smarter. It's fairly shell-specific, hence the SHELL - definition wrapper. */ -static char * -_delete_quotes (text) - char *text; -{ - char *ret, *p, *r; - int l, quoted; - - l = strlen (text); - ret = xmalloc (l + 1); - for (quoted = 0, p = text, r = ret; p && *p; p++) - { - /* Allow backslash-quoted characters to pass through unscathed. */ - if (*p == '\\') - continue; - /* Close quote. */ - if (quoted && *p == quoted) - { - quoted = 0; - continue; - } - /* Open quote. */ - if (quoted == 0 && (*p == '\'' || *p == '"')) - { - quoted = *p; - continue; - } - *r++ = *p; - } - *r = '\0'; - return ret; -} -#endif /* SHELL */ - -/* Complete the word at or before point. - WHAT_TO_DO says what to do with the completion. - `?' means list the possible completions. - TAB means do standard completion. - `*' means insert all of the possible completions. */ -rl_complete_internal (what_to_do) - int what_to_do; -{ - char **matches; - Function *our_func; - int start, scan, end, delimiter = 0, pass_next; - char *text, *saved_line_buffer; - char *replacement; - char quote_char = '\0'; -#if defined (SHELL) - int found_quote = 0; -#endif - - if (rl_line_buffer) - saved_line_buffer = savestring (rl_line_buffer); - else - saved_line_buffer = (char *)NULL; - - if (rl_completion_entry_function) - our_func = rl_completion_entry_function; - else - our_func = (Function *)filename_completion_function; - - /* Only the completion entry function can change this. */ - rl_filename_completion_desired = 0; - - /* We now look backwards for the start of a filename/variable word. */ - end = rl_point; - - if (rl_point) - { - if (rl_completer_quote_characters) - { - /* We have a list of characters which can be used in pairs to - quote substrings for the completer. Try to find the start - of an unclosed quoted substring. */ - /* FOUND_QUOTE is set so we know what kind of quotes we found. */ - for (scan = pass_next = 0; scan < end; scan++) - { - if (pass_next) - { - pass_next = 0; - continue; - } - - if (rl_line_buffer[scan] == '\\') - { - pass_next = 1; - continue; - } - - if (quote_char != '\0') - { - /* Ignore everything until the matching close quote char. */ - if (rl_line_buffer[scan] == quote_char) - { - /* Found matching close. Abandon this substring. */ - quote_char = '\0'; - rl_point = end; - } - } - else if (strchr (rl_completer_quote_characters, rl_line_buffer[scan])) - { - /* Found start of a quoted substring. */ - quote_char = rl_line_buffer[scan]; - rl_point = scan + 1; -#if defined (SHELL) - if (quote_char == '\'') - found_quote |= 1; - else if (quote_char == '"') - found_quote |= 2; -#endif - } - } - } - - if (rl_point == end) - { - int quoted = 0; - /* We didn't find an unclosed quoted substring up which to do - completion, so use the word break characters to find the - substring on which to complete. */ - while (--rl_point) - { -#if defined (SHELL) - /* Don't let word break characters in quoted substrings break - words for the completer. */ - if (found_quote) - { - if (strchr (rl_completer_quote_characters, rl_line_buffer[rl_point])) - { - quoted = !quoted; - continue; - } - if (quoted) - continue; - } -#endif /* SHELL */ - if (strchr (rl_completer_word_break_characters, rl_line_buffer[rl_point])) - break; - } - } - - /* If we are at a word break, then advance past it. */ - if (strchr (rl_completer_word_break_characters, rl_line_buffer[rl_point])) - { - /* If the character that caused the word break was a quoting - character, then remember it as the delimiter. */ - if (strchr ("\"'", rl_line_buffer[rl_point]) && (end - rl_point) > 1) - delimiter = rl_line_buffer[rl_point]; - - /* If the character isn't needed to determine something special - about what kind of completion to perform, then advance past it. */ - if (!rl_special_prefixes || - !strchr (rl_special_prefixes, rl_line_buffer[rl_point])) - rl_point++; - } - } - - /* At this point, we know we have an open quote if quote_char != '\0'. */ - start = rl_point; - rl_point = end; - text = rl_copy_text (start, end); - - /* If the user wants to TRY to complete, but then wants to give - up and use the default completion function, they set the - variable rl_attempted_completion_function. */ - if (rl_attempted_completion_function) - { - matches = (*rl_attempted_completion_function) (text, start, end); - - if (matches) - { - /* XXX - This is questionable code. - XXX */ - if (matches == (char **)-1) - matches = (char **)NULL; - our_func = (Function *)NULL; - goto after_usual_completion; - } - } - -#if defined (SHELL) - /* Beware -- we're stripping the quotes here. Do this only if we know - we are doing filename completion. */ - if (found_quote && our_func == (Function *)filename_completion_function) - { - /* delete single and double quotes */ - replacement = _delete_quotes (text); - free (text); - text = replacement; - replacement = (char *)0; - } -#endif /* SHELL */ - - matches = completion_matches (text, our_func); - - after_usual_completion: - free (text); - - if (!matches) - ding (); - else - { - register int i; - - /* It seems to me that in all the cases we handle we would like - to ignore duplicate possiblilities. Scan for the text to - insert being identical to the other completions. */ - if (rl_ignore_completion_duplicates) - { - char *lowest_common; - int j, newlen = 0; - char dead_slot; - - /* Sort the items. */ - /* It is safe to sort this array, because the lowest common - denominator found in matches[0] will remain in place. */ - for (i = 0; matches[i]; i++); - qsort (matches, i, sizeof (char *), compare_strings); - - /* Remember the lowest common denominator for it may be unique. */ - lowest_common = savestring (matches[0]); - - for (i = 0; matches[i + 1]; i++) - { - if (strcmp (matches[i], matches[i + 1]) == 0) - { - free (matches[i]); - matches[i] = (char *)&dead_slot; - } - else - newlen++; - } - - /* We have marked all the dead slots with (char *)&dead_slot. - Copy all the non-dead entries into a new array. */ - { - char **temp_array = - (char **)xmalloc ((3 + newlen) * sizeof (char *)); - - for (i = 1, j = 1; matches[i]; i++) - { - if (matches[i] != (char *)&dead_slot) - temp_array[j++] = matches[i]; - } - - temp_array[j] = (char *)NULL; - - if (matches[0] != (char *)&dead_slot) - free (matches[0]); - - free (matches); - - matches = temp_array; - } - - /* Place the lowest common denominator back in [0]. */ - matches[0] = lowest_common; - - /* If there is one string left, and it is identical to the - lowest common denominator, then the LCD is the string to - insert. */ - if (j == 2 && strcmp (matches[0], matches[1]) == 0) - { - free (matches[1]); - matches[1] = (char *)NULL; - } - } - - switch (what_to_do) - { - case TAB: - /* If we are matching filenames, then here is our chance to - do clever processing by re-examining the list. Call the - ignore function with the array as a parameter. It can - munge the array, deleting matches as it desires. */ - if (rl_ignore_some_completions_function && - our_func == (Function *)filename_completion_function) - (void)(*rl_ignore_some_completions_function)(matches); - - /* If we are doing completion on quoted substrings, and any matches - contain any of the completer_word_break_characters, then auto- - matically prepend the substring with a quote character (just pick - the first one from the list of such) if it does not already begin - with a quote string. FIXME: Need to remove any such automatically - inserted quote character when it no longer is necessary, such as - if we change the string we are completing on and the new set of - matches don't require a quoted substring. */ - replacement = matches[0]; - - if (matches[0] && rl_completer_quote_characters && !quote_char && - rl_filename_completion_desired) - { - int do_replace; - - do_replace = NO_MATCH; - - /* If there is a single match, see if we need to quote it. - This also checks whether the common prefix of several - matches needs to be quoted. If the common prefix should - not be checked, add !matches[1] to the if clause. */ - if (rl_strpbrk (matches[0], rl_completer_word_break_characters)) - do_replace = matches[1] ? MULT_MATCH : SINGLE_MATCH; - - if (do_replace != NO_MATCH) - { -#if defined (SHELL) - /* XXX - experimental */ - /* Quote the replacement, since we found an - embedded word break character in a potential - match. */ - char *rtext, *mtext; - int rlen; - extern char *double_quote (); /* in builtins/common.c */ - - /* If DO_REPLACE == MULT_MATCH, it means that there is - more than one match. In this case, we do not add - the closing quote or attempt to perform tilde - expansion. If DO_REPLACE == SINGLE_MATCH, we try - to perform tilde expansion, because double quotes - inhibit tilde expansion by the shell. */ - - mtext = matches[0]; - if (mtext[0] == '~' && do_replace == SINGLE_MATCH) - mtext = tilde_expand (matches[0]); - rtext = double_quote (mtext); - if (mtext != matches[0]) - free (mtext); - - rlen = strlen (rtext); - replacement = (char *)alloca (rlen + 1); - strcpy (replacement, rtext); - if (do_replace == MULT_MATCH) - replacement[rlen - 1] = '\0'; - free (rtext); -#else /* !SHELL */ - /* Found an embedded word break character in a potential - match, so we need to prepend a quote character if we - are replacing the completion string. */ - replacement = (char *)alloca (strlen (matches[0]) + 2); - quote_char = *rl_completer_quote_characters; - *replacement = quote_char; - strcpy (replacement + 1, matches[0]); -#endif /* SHELL */ - } - } - - if (replacement) - { - rl_delete_text (start, rl_point); - rl_point = start; - rl_insert_text (replacement); - } - - /* If there are more matches, ring the bell to indicate. - If this was the only match, and we are hacking files, - check the file to see if it was a directory. If so, - add a '/' to the name. If not, and we are at the end - of the line, then add a space. */ - if (matches[1]) - { - if (rl_editing_mode != vi_mode) - ding (); /* There are other matches remaining. */ - } - else - { - char temp_string[4]; - int temp_string_index = 0; - - if (quote_char) - temp_string[temp_string_index++] = quote_char; - - temp_string[temp_string_index++] = delimiter ? delimiter : ' '; - temp_string[temp_string_index++] = '\0'; - - if (rl_filename_completion_desired) - { - struct stat finfo; - char *filename = tilde_expand (matches[0]); - - if ((stat (filename, &finfo) == 0) && - S_ISDIR (finfo.st_mode)) - { - if (rl_line_buffer[rl_point] != '/') - rl_insert_text ("/"); - } - else - { - if (rl_point == rl_end) - rl_insert_text (temp_string); - } - free (filename); - } - else - { - if (rl_point == rl_end) - rl_insert_text (temp_string); - } - } - break; - - case '*': - { - int i = 1; - - rl_delete_text (start, rl_point); - rl_point = start; - rl_begin_undo_group (); - if (matches[1]) - { - while (matches[i]) - { - rl_insert_text (matches[i++]); - rl_insert_text (" "); - } - } - else - { - rl_insert_text (matches[0]); - rl_insert_text (" "); - } - rl_end_undo_group (); - } - break; - - case '?': - { - int len, count, limit, max = 0; - int j, k, l; - - /* Handle simple case first. What if there is only one answer? */ - if (!matches[1]) - { - char *temp = (char *)NULL; - - if (rl_filename_completion_desired) - temp = strrchr (matches[0], '/'); - - if (!temp) - temp = matches[0]; - else - temp++; - - crlf (); - fprintf (rl_outstream, "%s", temp); -#if defined (VISIBLE_STATS) - if (rl_filename_completion_desired && rl_visible_stats) - { - int extension_char; - - extension_char = stat_char (matches[0]); - if (extension_char) - putc (extension_char, rl_outstream); - } -#endif /* VISIBLE_STATS */ - crlf (); - goto restart; - } - - /* There is more than one answer. Find out how many there are, - and find out what the maximum printed length of a single entry - is. */ - for (i = 1; matches[i]; i++) - { - char *temp; - int name_length; - - /* If we are hacking filenames, then only count the characters - after the last slash in the pathname. */ - if (rl_filename_completion_desired) - temp = strrchr (matches[i], '/'); - else - temp = (char *)NULL; - - if (!temp) - temp = matches[i]; - else - temp++; - - name_length = strlen (temp); - - if (name_length > max) - max = name_length; - } - - len = i - 1; - - /* If there are many items, then ask the user if she - really wants to see them all. */ - if (len >= rl_completion_query_items) - { - crlf (); - fprintf (rl_outstream, - "There are %d possibilities. Do you really", len); - crlf (); - fprintf (rl_outstream, "wish to see them all? (y or n)"); - fflush (rl_outstream); - if (!get_y_or_n ()) - { - crlf (); - goto restart; - } - } - - /* How many items of MAX length can we fit in the screen window? */ - max += 2; - limit = screenwidth / max; - if (limit != 1 && (limit * max == screenwidth)) - limit--; - - /* Avoid a possible floating exception. If max > screenwidth, - limit will be 0 and a divide-by-zero fault will result. */ - if (limit == 0) - limit = 1; - - /* How many iterations of the printing loop? */ - count = (len + (limit - 1)) / limit; - - /* Watch out for special case. If LEN is less than LIMIT, then - just do the inner printing loop. */ - if (len < limit) - count = 1; - - /* Sort the items if they are not already sorted. */ - if (!rl_ignore_completion_duplicates) - qsort (matches, len, sizeof (char *), compare_strings); - - /* Print the sorted items, up-and-down alphabetically, like - ls might. */ - crlf (); - - for (i = 1; i < count + 1; i++) - { - for (j = 0, l = i; j < limit; j++) - { - if (l > len || !matches[l]) - { - break; - } - else - { - char *temp = (char *)NULL; - int printed_length; - - if (rl_filename_completion_desired) - temp = strrchr (matches[l], '/'); - - if (!temp) - temp = matches[l]; - else - temp++; - - printed_length = strlen (temp); - fprintf (rl_outstream, "%s", temp); - -#if defined (VISIBLE_STATS) - if (rl_filename_completion_desired && - rl_visible_stats) - { - int extension_char; - - extension_char = stat_char (matches[l]); - - if (extension_char) - { - putc (extension_char, rl_outstream); - printed_length++; - } - } -#endif /* VISIBLE_STATS */ - - if (j + 1 < limit) - { - for (k = 0; k < max - printed_length; k++) - putc (' ', rl_outstream); - } - } - l += count; - } - crlf (); - } - restart: - - rl_on_new_line (); - } - break; - - default: - fprintf (stderr, "\r\nreadline: bad value for what_to_do in rl_complete\n"); - abort (); - } - - for (i = 0; matches[i]; i++) - free (matches[i]); - free (matches); - } - - /* Check to see if the line has changed through all of this manipulation. */ - if (saved_line_buffer) - { - if (strcmp (rl_line_buffer, saved_line_buffer) != 0) - completion_changed_buffer = 1; - else - completion_changed_buffer = 0; - - free (saved_line_buffer); - } -} - -#if defined (VISIBLE_STATS) -/* Return the character which best describes FILENAME. - `@' for symbolic links - `/' for directories - `*' for executables - `=' for sockets */ -static int -stat_char (filename) - char *filename; -{ - struct stat finfo; - int character = 0; - - if (stat (filename, &finfo) == -1) - return (character); - - if (S_ISDIR (finfo.st_mode)) - character = '/'; -#if defined (S_ISLNK) - else if (S_ISLNK (finfo.st_mode)) - character = '@'; -#endif /* S_ISLNK */ -#if defined (S_ISSOCK) - else if (S_ISSOCK (finfo.st_mode)) - character = '='; -#endif /* S_ISSOCK */ - else if (S_ISREG (finfo.st_mode)) - { - if (access (filename, X_OK) == 0) - character = '*'; - } - return (character); -} -#endif /* VISIBLE_STATS */ - -/* Stupid comparison routine for qsort () ing strings. */ -static int -compare_strings (s1, s2) - char **s1, **s2; -{ - return (strcmp (*s1, *s2)); -} - -/* A completion function for usernames. - TEXT contains a partial username preceded by a random - character (usually `~'). */ -char * -username_completion_function (text, state) - int state; - char *text; -{ -#if defined (MINIMAL) - return (char *)NULL; -#else /* !MINIMAL */ - static char *username = (char *)NULL; - static struct passwd *entry; - static int namelen, first_char, first_char_loc; - - if (!state) - { - if (username) - free (username); - - first_char = *text; - - if (first_char == '~') - first_char_loc = 1; - else - first_char_loc = 0; - - username = savestring (&text[first_char_loc]); - namelen = strlen (username); - setpwent (); - } - - while (entry = getpwent ()) - { - if (strncmp (username, entry->pw_name, namelen) == 0) - break; - } - - if (!entry) - { - endpwent (); - return ((char *)NULL); - } - else - { - char *value = (char *)xmalloc (2 + strlen (entry->pw_name)); - - *value = *text; - - strcpy (value + first_char_loc, entry->pw_name); - - if (first_char == '~') - rl_filename_completion_desired = 1; - - return (value); - } -#endif /* !MINIMAL */ -} - -/* **************************************************************** */ -/* */ -/* Completion */ -/* */ -/* **************************************************************** */ - -/* Non-zero means that case is not significant in completion. */ -int completion_case_fold = 0; - -/* Return an array of (char *) which is a list of completions for TEXT. - If there are no completions, return a NULL pointer. - The first entry in the returned array is the substitution for TEXT. - The remaining entries are the possible completions. - The array is terminated with a NULL pointer. - - ENTRY_FUNCTION is a function of two args, and returns a (char *). - The first argument is TEXT. - The second is a state argument; it should be zero on the first call, and - non-zero on subsequent calls. It returns a NULL pointer to the caller - when there are no more matches. - */ -char ** -completion_matches (text, entry_function) - char *text; - CPFunction *entry_function; -{ - /* Number of slots in match_list. */ - int match_list_size; - - /* The list of matches. */ - char **match_list = - (char **)xmalloc (((match_list_size = 10) + 1) * sizeof (char *)); - - /* Number of matches actually found. */ - int matches = 0; - - /* Temporary string binder. */ - char *string; - - match_list[1] = (char *)NULL; - - while (string = (*entry_function) (text, matches)) - { - if (matches + 1 == match_list_size) - match_list = (char **)xrealloc - (match_list, ((match_list_size += 10) + 1) * sizeof (char *)); - - match_list[++matches] = string; - match_list[matches + 1] = (char *)NULL; - } - - /* If there were any matches, then look through them finding out the - lowest common denominator. That then becomes match_list[0]. */ - if (matches) - { - register int i = 1; - int low = 100000; /* Count of max-matched characters. */ - - /* If only one match, just use that. */ - if (matches == 1) - { - match_list[0] = match_list[1]; - match_list[1] = (char *)NULL; - } - else - { - /* Otherwise, compare each member of the list with - the next, finding out where they stop matching. */ - - while (i < matches) - { - register int c1, c2, si; - - if (completion_case_fold) - { - for (si = 0; - (c1 = to_lower(match_list[i][si])) && - (c2 = to_lower(match_list[i + 1][si])); - si++) - if (c1 != c2) break; - } - else - { - for (si = 0; - (c1 = match_list[i][si]) && - (c2 = match_list[i + 1][si]); - si++) - if (c1 != c2) break; - } - - if (low > si) low = si; - i++; - } - match_list[0] = (char *)xmalloc (low + 1); - strncpy (match_list[0], match_list[1], low); - match_list[0][low] = '\0'; - } - } - else /* There were no matches. */ - { - free (match_list); - match_list = (char **)NULL; - } - return (match_list); -} - -/* Okay, now we write the entry_function for filename completion. In the - general case. Note that completion in the shell is a little different - because of all the pathnames that must be followed when looking up the - completion for a command. */ -char * -filename_completion_function (text, state) - int state; - char *text; -{ -#ifndef WIN32 - static DIR *directory; - static char *filename = (char *)NULL; - static char *dirname = (char *)NULL; - static char *users_dirname = (char *)NULL; - static int filename_len; - - dirent *entry = (dirent *)NULL; - - /* If we don't have any state, then do some initialization. */ - if (!state) - { - char *temp; - - if (dirname) free (dirname); - if (filename) free (filename); - if (users_dirname) free (users_dirname); - - filename = savestring (text); - if (!*text) text = "."; - dirname = savestring (text); - - temp = strrchr (dirname, '/'); - - if (temp) - { - strcpy (filename, ++temp); - *temp = '\0'; - } - else - strcpy (dirname, "."); - - /* We aren't done yet. We also support the "~user" syntax. */ - - /* Save the version of the directory that the user typed. */ - users_dirname = savestring (dirname); - { - char *temp_dirname; - - temp_dirname = tilde_expand (dirname); - free (dirname); - dirname = temp_dirname; - - if (rl_symbolic_link_hook) - (*rl_symbolic_link_hook) (&dirname); - } - directory = opendir (dirname); - filename_len = strlen (filename); - - rl_filename_completion_desired = 1; - } - - /* At this point we should entertain the possibility of hacking wildcarded - filenames, like /usr/man/man<WILD>/te<TAB>. If the directory name - contains globbing characters, then build an array of directories, and - then map over that list while completing. */ - /* *** UNIMPLEMENTED *** */ - - /* Now that we have some state, we can read the directory. */ - - while (directory && (entry = readdir (directory))) - { - /* Special case for no filename. - All entries except "." and ".." match. */ - if (!filename_len) - { - if ((strcmp (entry->d_name, ".") != 0) && - (strcmp (entry->d_name, "..") != 0)) - break; - } - else - { - /* Otherwise, if these match upto the length of filename, then - it is a match. */ - if (((int)D_NAMLEN (entry)) >= filename_len && - (entry->d_name[0] == filename[0]) && - (strncmp (filename, entry->d_name, filename_len) == 0)) - { - break; - } - } - } - - if (!entry) - { - if (directory) - { - closedir (directory); - directory = (DIR *)NULL; - } - - if (dirname) - { - free (dirname); - dirname = (char *)NULL; - } - if (filename) - { - free (filename); - filename = (char *)NULL; - } - if (users_dirname) - { - free (users_dirname); - users_dirname = (char *)NULL; - } - - return (char *)NULL; - } - else - { - char *temp; - - if (dirname && (strcmp (dirname, ".") != 0)) - { - if (rl_complete_with_tilde_expansion && *users_dirname == '~') - { - int dirlen = strlen (dirname); - temp = (char *)xmalloc (2 + dirlen + D_NAMLEN (entry)); - strcpy (temp, dirname); - /* Canonicalization cuts off any final slash present. We need - to add it back. */ - if (dirname[dirlen - 1] != '/') - { - temp[dirlen] = '/'; - temp[dirlen + 1] = '\0'; - } - } - else - { - temp = (char *) - xmalloc (1 + strlen (users_dirname) + D_NAMLEN (entry)); - strcpy (temp, users_dirname); - } - - strcat (temp, entry->d_name); - } - else - { - temp = (savestring (entry->d_name)); - } - return (temp); - } -#endif -} - -/* A function for simple tilde expansion. */ -int -rl_tilde_expand (ignore, key) - int ignore, key; -{ - register int start, end; - char *homedir; - - end = rl_point; - start = end - 1; - - if (rl_point == rl_end && rl_line_buffer[rl_point] == '~') - { - homedir = tilde_expand ("~"); - goto insert; - } - 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]) && 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] == '~') - { - char *temp; - int len; - - len = end - start + 1; - temp = (char *)alloca (len + 1); - strncpy (temp, rl_line_buffer + start, len); - temp[len] = '\0'; - homedir = tilde_expand (temp); - - insert: - rl_begin_undo_group (); - rl_delete_text (start, end + 1); - rl_point = start; - rl_insert_text (homedir); - rl_end_undo_group (); - } - - return (0); -} - -/* Find the first occurrence in STRING1 of any character from STRING2. - Return a pointer to the character in STRING1. */ -static char * -rl_strpbrk (string1, string2) - char *string1, *string2; -{ - register char *scan; - - for (; *string1; string1++) - { - for (scan = string2; *scan; scan++) - { - if (*string1 == *scan) - { - return (string1); - } - } - } - return ((char *)NULL); -} - -#if defined (STATIC_MALLOC) - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)malloc (bytes); - else - temp = (char *)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 (); -} -#endif /* STATIC_MALLOC */ diff --git a/readline/config.h.bot b/readline/config.h.bot deleted file mode 100644 index d7a6dc4..0000000 --- a/readline/config.h.bot +++ /dev/null @@ -1,22 +0,0 @@ -/* config.h.bot */ -/* 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 diff --git a/readline/config.h.in b/readline/config.h.in deleted file mode 100644 index 65927a8..0000000 --- a/readline/config.h.in +++ /dev/null @@ -1,145 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on MINIX. */ -#undef _MINIX - -/* Define as the return type of signal handlers (int or void). */ -#undef RETSIGTYPE - -/* 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 lstat function. */ -#undef HAVE_LSTAT - -/* 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 strcasecmp function. */ -#undef HAVE_STRCASECMP - -/* Define if you have the setlocale function. */ -#undef HAVE_SETLOCALE - -/* Define if you have the tcgetattr function. */ -#undef HAVE_TCGETATTR - -/* Define if you have the strcoll function. */ -#undef HAVE_STRCOLL - -#undef STRCOLL_BROKEN - -/* Define if you have the <dirent.h> header file. */ -#undef HAVE_DIRENT_H - -/* Define if you have the <ndir.h> header file. */ -#undef HAVE_NDIR_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 <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 <stdarg.h> header file. */ -#undef HAVE_STDARG_H - -#undef HAVE_LOCALE_H - -/* 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 - -/* config.h.bot */ -/* 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 diff --git a/readline/configure b/readline/configure deleted file mode 100755 index f1a3fc1..0000000 --- a/readline/configure +++ /dev/null @@ -1,2877 +0,0 @@ -#! /bin/sh - -# From configure.in for Readline 2.2, version 2.07, from autoconf version 2.12.2 -LIBVERSION=2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12.2 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help ---with-curses use the curses library instead of the termcap library" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12.2" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=readline.h - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - - - - -ac_aux_dir= -for ac_dir in ./support $srcdir/./support; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in ./support $srcdir/./support" 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - - - -# Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:646: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - - -opt_curses=no -opt_shared=no - -# Check whether --with-curses or --without-curses was given. -if test "${with_curses+set}" = set; then - withval="$with_curses" - opt_curses=$withval -fi - - -if test "$opt_curses" = "yes"; then - prefer_curses=yes -fi - -# We want these before the checks, so the checks can modify their values. -test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:687: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:716: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_prog_rejected=no - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# -gt 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" - fi -fi -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:766: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } -fi - -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:797: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -cat > conftest.$ac_ext <<EOF -#line 807 "configure" -#include "confdefs.h" -main(){return(0);} -EOF -if { (eval echo configure:811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no -fi -rm -fr conftest* - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:831: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:836: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:845: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 - -if test $ac_cv_prog_gcc = yes; then - GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:864: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi - -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:896: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 911 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:917: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 928 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:934: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext <<EOF -#line 945 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:951: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - -ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 -echo "configure:977: checking for minix/config.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 982 "configure" -#include "confdefs.h" -#include <minix/config.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:987: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - MINIX=yes -else - echo "$ac_t""no" 1>&6 -MINIX= -fi - -if test "$MINIX" = yes; then - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _POSIX_1_SOURCE 2 -EOF - - cat >> confdefs.h <<\EOF -#define _MINIX 1 -EOF - -fi - - - - -if test "x$cross_compiling" = "xyes"; then - case "${host}" in - *-cygwin*) - cross_cache=${srcdir}/cross-build/cygwin.cache - if test -r "${cross_cache}"; then - echo "loading cross-build cache file ${cross_cache}" - . ${cross_cache} - fi - CFLAGS="$CFLAGS -I${srcdir}/../libtermcap" - unset cross_cache - ;; - *) echo "configure: cross-compiling for a non-cygwin target is not supported" >&2 - ;; - esac -fi - -if test "x$cross_compiling" = "xyes"; then - CROSS_COMPILING_FLAG=-DCROSS_COMPILING -else - CROSS_COMPILING_FLAG= -fi - - -if test -z "$CC_FOR_BUILD"; then - if test "x$cross_compiling" = "xno"; then - CC_FOR_BUILD='$(CC)' - else - CC_FOR_BUILD=gcc - fi -fi - - - - - -# 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" - -if test $ac_cv_prog_gcc = yes; then - echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:1067: checking whether ${CC-cc} needs -traditional" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_pattern="Autoconf.*'x'" - cat > conftest.$ac_ext <<EOF -#line 1073 "configure" -#include "confdefs.h" -#include <sgtty.h> -Autoconf TIOCGETP -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_prog_gcc_traditional=yes -else - rm -rf conftest* - ac_cv_prog_gcc_traditional=no -fi -rm -f conftest* - - - if test $ac_cv_prog_gcc_traditional = no; then - cat > conftest.$ac_ext <<EOF -#line 1091 "configure" -#include "confdefs.h" -#include <termio.h> -Autoconf TCGETA -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_prog_gcc_traditional=yes -fi -rm -f conftest* - - fi -fi - -echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 - if test $ac_cv_prog_gcc_traditional = yes; then - CC="$CC -traditional" - fi -fi - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1124: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1177: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1205: checking return type of signal handlers" >&5 -if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1210 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <signal.h> -#ifdef signal -#undef signal -#endif -#ifdef __cplusplus -extern "C" void (*signal (int, void (*)(int)))(int); -#else -void (*signal ()) (); -#endif - -int main() { -int i; -; return 0; } -EOF -if { (eval echo configure:1227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_type_signal=void -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_type_signal=int -fi -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_type_signal" 1>&6 -cat >> confdefs.h <<EOF -#define RETSIGTYPE $ac_cv_type_signal -EOF - - - -echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6 -echo "configure:1247: checking whether stat file-mode macros are broken" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1252 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <sys/stat.h> - -#if defined(S_ISBLK) && defined(S_IFDIR) -# if S_ISBLK (S_IFDIR) -You lose. -# endif -#endif - -#if defined(S_ISBLK) && defined(S_IFCHR) -# if S_ISBLK (S_IFCHR) -You lose. -# endif -#endif - -#if defined(S_ISLNK) && defined(S_IFREG) -# if S_ISLNK (S_IFREG) -You lose. -# endif -#endif - -#if defined(S_ISSOCK) && defined(S_IFREG) -# if S_ISSOCK (S_IFREG) -You lose. -# endif -#endif - -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "You lose" >/dev/null 2>&1; then - rm -rf conftest* - ac_cv_header_stat_broken=yes -else - rm -rf conftest* - ac_cv_header_stat_broken=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$ac_cv_header_stat_broken" 1>&6 -if test $ac_cv_header_stat_broken = yes; then - cat >> confdefs.h <<\EOF -#define STAT_MACROS_BROKEN 1 -EOF - -fi - -ac_header_dirent=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:1307: checking for $ac_hdr that defines DIR" >&5 -if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1312 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <$ac_hdr> -int main() { -DIR *dirp = 0; -; return 0; } -EOF -if { (eval echo configure:1320: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - ac_header_dirent=$ac_hdr; break -else - echo "$ac_t""no" 1>&6 -fi -done -# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. -if test $ac_header_dirent = dirent.h; then -echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:1345: checking for opendir in -ldir" >&5 -ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldir $LIBS" -cat > conftest.$ac_ext <<EOF -#line 1353 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir(); - -int main() { -opendir() -; return 0; } -EOF -if { (eval echo configure:1364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -ldir" -else - echo "$ac_t""no" 1>&6 -fi - -else -echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:1386: checking for opendir in -lx" >&5 -ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lx $LIBS" -cat > conftest.$ac_ext <<EOF -#line 1394 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir(); - -int main() { -opendir() -; return 0; } -EOF -if { (eval echo configure:1405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -lx" -else - echo "$ac_t""no" 1>&6 -fi - -fi - - -for ac_func in strcasecmp select setenv putenv tcgetattr setlocale lstat -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1431: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1436 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - - -echo $ac_n "checking for working strcoll""... $ac_c" 1>&6 -echo "configure:1485: checking for working strcoll" >&5 -if eval "test \"`echo '$''{'ac_cv_func_strcoll_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_strcoll_works=no -else - cat > conftest.$ac_ext <<EOF -#line 1493 "configure" -#include "confdefs.h" -#include <string.h> -main () -{ - exit (strcoll ("abc", "def") >= 0 || - strcoll ("ABC", "DEF") >= 0 || - strcoll ("123", "456") >= 0); -} -EOF -if { (eval echo configure:1503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_func_strcoll_works=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_func_strcoll_works=no -fi -rm -fr conftest* -fi - -fi - -echo "$ac_t""$ac_cv_func_strcoll_works" 1>&6 -if test $ac_cv_func_strcoll_works = yes; then - cat >> confdefs.h <<\EOF -#define HAVE_STRCOLL 1 -EOF - -fi - - -for ac_hdr in unistd.h stdlib.h varargs.h stdarg.h string.h \ - sys/ptem.h sys/pte.h sys/stream.h sys/select.h \ - termcap.h termios.h termio.h sys/file.h locale.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1532: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1537 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1542: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - - - -echo $ac_n "checking for type of signal functions""... $ac_c" 1>&6 -echo "configure:1571: checking for type of signal functions" >&5 -if eval "test \"`echo '$''{'bash_cv_signal_vintage'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - - cat > conftest.$ac_ext <<EOF -#line 1577 "configure" -#include "confdefs.h" -#include <signal.h> -int main() { - - sigset_t ss; - struct sigaction sa; - sigemptyset(&ss); sigsuspend(&ss); - sigaction(SIGINT, &sa, (struct sigaction *) 0); - sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0); - -; return 0; } -EOF -if { (eval echo configure:1590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - bash_cv_signal_vintage=posix -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - - cat > conftest.$ac_ext <<EOF -#line 1599 "configure" -#include "confdefs.h" -#include <signal.h> -int main() { - - int mask = sigmask(SIGINT); - sigsetmask(mask); sigblock(mask); sigpause(mask); - -; return 0; } -EOF -if { (eval echo configure:1609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - bash_cv_signal_vintage=4.2bsd -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - - cat > conftest.$ac_ext <<EOF -#line 1618 "configure" -#include "confdefs.h" - - #include <signal.h> - RETSIGTYPE foo() { } -int main() { - - int mask = sigmask(SIGINT); - sigset(SIGINT, foo); sigrelse(SIGINT); - sighold(SIGINT); sigpause(SIGINT); - -; return 0; } -EOF -if { (eval echo configure:1631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - bash_cv_signal_vintage=svr3 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_signal_vintage=v7 - -fi -rm -f conftest* - -fi -rm -f conftest* - -fi -rm -f conftest* - -fi - -echo "$ac_t""$bash_cv_signal_vintage" 1>&6 -if test "$bash_cv_signal_vintage" = posix; then -cat >> confdefs.h <<\EOF -#define HAVE_POSIX_SIGNALS 1 -EOF - -elif test "$bash_cv_signal_vintage" = "4.2bsd"; then -cat >> confdefs.h <<\EOF -#define HAVE_BSD_SIGNALS 1 -EOF - -elif test "$bash_cv_signal_vintage" = svr3; then -cat >> confdefs.h <<\EOF -#define HAVE_USG_SIGHOLD 1 -EOF - -fi - - - -echo $ac_n "checking if signal handlers must be reinstalled when invoked""... $ac_c" 1>&6 -echo "configure:1672: checking if signal handlers must be reinstalled when invoked" >&5 -if eval "test \"`echo '$''{'bash_cv_must_reinstall_sighandlers'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - { echo "configure: error: cannot check signal handling if cross compiling -- defaulting to no" 1>&2; exit 1; } - bash_cv_must_reinstall_sighandlers=no - -else - cat > conftest.$ac_ext <<EOF -#line 1682 "configure" -#include "confdefs.h" - -#include <signal.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -typedef RETSIGTYPE sigfunc(); - -int nsigint; - -#ifdef HAVE_POSIX_SIGNALS -sigfunc * -set_signal_handler(sig, handler) - int sig; - sigfunc *handler; -{ - struct sigaction act, oact; - act.sa_handler = handler; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigemptyset (&oact.sa_mask); - sigaction (sig, &act, &oact); - return (oact.sa_handler); -} -#else -#define set_signal_handler(s, h) signal(s, h) -#endif - -RETSIGTYPE -sigint(s) -int s; -{ - nsigint++; -} - -main() -{ - nsigint = 0; - set_signal_handler(SIGINT, sigint); - kill((int)getpid(), SIGINT); - kill((int)getpid(), SIGINT); - exit(nsigint != 2); -} - -EOF -if { (eval echo configure:1729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - bash_cv_must_reinstall_sighandlers=no -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - bash_cv_must_reinstall_sighandlers=yes -fi -rm -fr conftest* -fi - -fi - -echo "$ac_t""$bash_cv_must_reinstall_sighandlers" 1>&6 -if test $bash_cv_must_reinstall_sighandlers = yes; then -cat >> confdefs.h <<\EOF -#define MUST_REINSTALL_SIGHANDLERS 1 -EOF - -fi - - - -echo $ac_n "checking for presence of POSIX-style sigsetjmp/siglongjmp""... $ac_c" 1>&6 -echo "configure:1754: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5 -if eval "test \"`echo '$''{'bash_cv_func_sigsetjmp'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - { echo "configure: error: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" 1>&2; exit 1; } - bash_cv_func_sigsetjmp=missing - -else - cat > conftest.$ac_ext <<EOF -#line 1764 "configure" -#include "confdefs.h" - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <sys/types.h> -#include <signal.h> -#include <setjmp.h> - -main() -{ -#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) -exit (1); -#else - -int code; -sigset_t set, oset; -sigjmp_buf xx; - -/* get the mask */ -sigemptyset(&set); -sigemptyset(&oset); -sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set); -sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset); - -/* save it */ -code = sigsetjmp(xx, 1); -if (code) - exit(0); /* could get sigmask and compare to oset here. */ - -/* change it */ -sigaddset(&set, SIGINT); -sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL); - -/* and siglongjmp */ -siglongjmp(xx, 10); -exit(1); -#endif -} -EOF -if { (eval echo configure:1805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - bash_cv_func_sigsetjmp=present -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - bash_cv_func_sigsetjmp=missing -fi -rm -fr conftest* -fi - -fi - -echo "$ac_t""$bash_cv_func_sigsetjmp" 1>&6 -if test $bash_cv_func_sigsetjmp = present; then -cat >> confdefs.h <<\EOF -#define HAVE_POSIX_SIGSETJMP 1 -EOF - -fi - -echo $ac_n "checking for lstat""... $ac_c" 1>&6 -echo "configure:1828: checking for lstat" >&5 -if eval "test \"`echo '$''{'bash_cv_func_lstat'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1833 "configure" -#include "confdefs.h" - -#include <sys/types.h> -#include <sys/stat.h> - -int main() { - lstat(".",(struct stat *)0); -; return 0; } -EOF -if { (eval echo configure:1843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - bash_cv_func_lstat=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_func_lstat=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_func_lstat" 1>&6 -if test $bash_cv_func_lstat = yes; then - cat >> confdefs.h <<\EOF -#define HAVE_LSTAT 1 -EOF - -fi - -echo $ac_n "checking whether programs are able to redeclare getpw functions""... $ac_c" 1>&6 -echo "configure:1864: checking whether programs are able to redeclare getpw functions" >&5 -if eval "test \"`echo '$''{'bash_cv_can_redecl_getpw'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1869 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <pwd.h> -extern struct passwd *getpwent(); -extern struct passwd *getpwuid(); -extern struct passwd *getpwnam(); -int main() { -struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root"); -; return 0; } -EOF -if { (eval echo configure:1880: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_can_redecl_getpw=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_can_redecl_getpw=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_can_redecl_getpw" 1>&6 -if test $bash_cv_can_redecl_getpw = no; then -cat >> confdefs.h <<\EOF -#define HAVE_GETPW_DECLS 1 -EOF - -fi - - -echo $ac_n "checking whether or not strcoll and strcmp differ""... $ac_c" 1>&6 -echo "configure:1902: checking whether or not strcoll and strcmp differ" >&5 -if eval "test \"`echo '$''{'bash_cv_func_strcoll_broken'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - { echo "configure: error: cannot check strcoll if cross compiling -- defaulting to no" 1>&2; exit 1; } - bash_cv_func_strcoll_broken=no - -else - cat > conftest.$ac_ext <<EOF -#line 1912 "configure" -#include "confdefs.h" - -#include <stdio.h> -#if defined (HAVE_LOCALE_H) -#include <locale.h> -#endif - -main(c, v) -int c; -char *v[]; -{ - int r1, r2; - char *deflocale, *defcoll; - -#ifdef HAVE_SETLOCALE - deflocale = setlocale(LC_ALL, ""); - defcoll = setlocale(LC_COLLATE, ""); -#endif - -#ifdef HAVE_STRCOLL - /* These two values are taken from tests/glob-test. */ - r1 = strcoll("abd", "aXd"); -#else - r1 = 0; -#endif - r2 = strcmp("abd", "aXd"); - - /* These two should both be greater than 0. It is permissible for - a system to return different values, as long as the sign is the - same. */ - - /* Exit with 1 (failure) if these two values are both > 0, since - this tests whether strcoll(3) is broken with respect to strcmp(3) - in the default locale. */ - exit (r1 > 0 && r2 > 0); -} - -EOF -if { (eval echo configure:1951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - bash_cv_func_strcoll_broken=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - bash_cv_func_strcoll_broken=no -fi -rm -fr conftest* -fi - -fi - -echo "$ac_t""$bash_cv_func_strcoll_broken" 1>&6 -if test $bash_cv_func_strcoll_broken = yes; then -cat >> confdefs.h <<\EOF -#define STRCOLL_BROKEN 1 -EOF - -fi - - -echo $ac_n "checking whether signal handlers are of type void""... $ac_c" 1>&6 -echo "configure:1975: checking whether signal handlers are of type void" >&5 -if eval "test \"`echo '$''{'bash_cv_void_sighandler'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1980 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <signal.h> -#ifdef signal -#undef signal -#endif -#ifdef __cplusplus -extern "C" -#endif -void (*signal ()) (); -int main() { -int i; -; return 0; } -EOF -if { (eval echo configure:1995: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_void_sighandler=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_void_sighandler=no -fi -rm -f conftest* -fi -echo "$ac_t""$bash_cv_void_sighandler" 1>&6 -if test $bash_cv_void_sighandler = yes; then -cat >> confdefs.h <<\EOF -#define VOID_SIGHANDLER 1 -EOF - -fi - -echo $ac_n "checking for TIOCGWINSZ in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:2015: checking for TIOCGWINSZ in sys/ioctl.h" >&5 -if eval "test \"`echo '$''{'bash_cv_tiocgwinsz_in_ioctl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2020 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <sys/ioctl.h> -int main() { -int x = TIOCGWINSZ; -; return 0; } -EOF -if { (eval echo configure:2028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_tiocgwinsz_in_ioctl=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_tiocgwinsz_in_ioctl=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_tiocgwinsz_in_ioctl" 1>&6 -if test $bash_cv_tiocgwinsz_in_ioctl = yes; then -cat >> confdefs.h <<\EOF -#define GWINSZ_IN_SYS_IOCTL 1 -EOF - -fi - -echo $ac_n "checking for TIOCSTAT in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:2049: checking for TIOCSTAT in sys/ioctl.h" >&5 -if eval "test \"`echo '$''{'bash_cv_tiocstat_in_ioctl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2054 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <sys/ioctl.h> -int main() { -int x = TIOCSTAT; -; return 0; } -EOF -if { (eval echo configure:2062: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_tiocstat_in_ioctl=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_tiocstat_in_ioctl=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_tiocstat_in_ioctl" 1>&6 -if test $bash_cv_tiocstat_in_ioctl = yes; then -cat >> confdefs.h <<\EOF -#define TIOCSTAT_IN_SYS_IOCTL 1 -EOF - -fi - -echo $ac_n "checking for FIONREAD in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:2083: checking for FIONREAD in sys/ioctl.h" >&5 -if eval "test \"`echo '$''{'bash_cv_fionread_in_ioctl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2088 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <sys/ioctl.h> -int main() { -int x = FIONREAD; -; return 0; } -EOF -if { (eval echo configure:2096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_fionread_in_ioctl=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_fionread_in_ioctl=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_fionread_in_ioctl" 1>&6 -if test $bash_cv_fionread_in_ioctl = yes; then -cat >> confdefs.h <<\EOF -#define FIONREAD_IN_SYS_IOCTL 1 -EOF - -fi - -echo $ac_n "checking for speed_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:2117: checking for speed_t in sys/types.h" >&5 -if eval "test \"`echo '$''{'bash_cv_speed_t_in_sys_types'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2122 "configure" -#include "confdefs.h" -#include <sys/types.h> -int main() { -speed_t x; -; return 0; } -EOF -if { (eval echo configure:2129: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_speed_t_in_sys_types=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_speed_t_in_sys_types=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_speed_t_in_sys_types" 1>&6 -if test $bash_cv_speed_t_in_sys_types = yes; then -cat >> confdefs.h <<\EOF -#define SPEED_T_IN_SYS_TYPES 1 -EOF - -fi - -echo $ac_n "checking for struct winsize in sys/ioctl.h and termios.h""... $ac_c" 1>&6 -echo "configure:2150: checking for struct winsize in sys/ioctl.h and termios.h" >&5 -if eval "test \"`echo '$''{'bash_cv_struct_winsize_header'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2155 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <sys/ioctl.h> -int main() { -struct winsize x; -; return 0; } -EOF -if { (eval echo configure:2163: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_struct_winsize_header=ioctl_h -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext <<EOF -#line 2171 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <termios.h> -int main() { -struct winsize x; -; return 0; } -EOF -if { (eval echo configure:2179: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_struct_winsize_header=termios_h -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_struct_winsize_header=other -fi -rm -f conftest* - -fi -rm -f conftest* -fi - -if test $bash_cv_struct_winsize_header = ioctl_h; then - echo "$ac_t""sys/ioctl.h" 1>&6 - cat >> confdefs.h <<\EOF -#define STRUCT_WINSIZE_IN_SYS_IOCTL 1 -EOF - -elif test $bash_cv_struct_winsize_header = termios_h; then - echo "$ac_t""termios.h" 1>&6 - cat >> confdefs.h <<\EOF -#define STRUCT_WINSIZE_IN_TERMIOS 1 -EOF - -else - echo "$ac_t""not found" 1>&6 -fi - - -echo $ac_n "checking if struct dirent has a d_ino member""... $ac_c" 1>&6 -echo "configure:2212: checking if struct dirent has a d_ino member" >&5 -if eval "test \"`echo '$''{'bash_cv_dirent_has_dino'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2217 "configure" -#include "confdefs.h" - -#include <stdio.h> -#include <sys/types.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif /* HAVE_UNISTD_H */ -#if defined(HAVE_DIRENT_H) -# include <dirent.h> -#else -# define dirent direct -# ifdef HAVE_SYS_NDIR_H -# include <sys/ndir.h> -# endif /* SYSNDIR */ -# ifdef HAVE_SYS_DIR_H -# include <sys/dir.h> -# endif /* SYSDIR */ -# ifdef HAVE_NDIR_H -# include <ndir.h> -# endif -#endif /* HAVE_DIRENT_H */ - -int main() { - -struct dirent d; int z; z = d.d_ino; - -; return 0; } -EOF -if { (eval echo configure:2246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_dirent_has_dino=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_dirent_has_dino=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_dirent_has_dino" 1>&6 -if test $bash_cv_dirent_has_dino = yes; then -cat >> confdefs.h <<\EOF -#define STRUCT_DIRENT_HAS_D_INO 1 -EOF - -fi - - -echo $ac_n "checking if struct dirent has a d_fileno member""... $ac_c" 1>&6 -echo "configure:2268: checking if struct dirent has a d_fileno member" >&5 -if eval "test \"`echo '$''{'bash_cv_dirent_has_d_fileno'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2273 "configure" -#include "confdefs.h" - -#include <stdio.h> -#include <sys/types.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif /* HAVE_UNISTD_H */ -#if defined(HAVE_DIRENT_H) -# include <dirent.h> -#else -# define dirent direct -# ifdef HAVE_SYS_NDIR_H -# include <sys/ndir.h> -# endif /* SYSNDIR */ -# ifdef HAVE_SYS_DIR_H -# include <sys/dir.h> -# endif /* SYSDIR */ -# ifdef HAVE_NDIR_H -# include <ndir.h> -# endif -#endif /* HAVE_DIRENT_H */ - -int main() { - -struct dirent d; int z; z = d.d_fileno; - -; return 0; } -EOF -if { (eval echo configure:2302: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_dirent_has_d_fileno=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_dirent_has_d_fileno=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_dirent_has_d_fileno" 1>&6 -if test $bash_cv_dirent_has_d_fileno = yes; then -cat >> confdefs.h <<\EOF -#define STRUCT_DIRENT_HAS_D_FILENO 1 -EOF - -fi - - -case "$host_os" in -aix*) prefer_curses=yes ;; -esac - -if test "X$bash_cv_termcap_lib" = "X"; then -_bash_needmsg=yes -else -echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6 -echo "configure:2331: checking which library has the termcap functions" >&5 -_bash_needmsg= -fi -if eval "test \"`echo '$''{'bash_cv_termcap_lib'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6 -echo "configure:2338: checking for tgetent in -ltermcap" >&5 -ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ltermcap $LIBS" -cat > conftest.$ac_ext <<EOF -#line 2346 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char tgetent(); - -int main() { -tgetent() -; return 0; } -EOF -if { (eval echo configure:2357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - bash_cv_termcap_lib=libtermcap -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6 -echo "configure:2376: checking for tgetent in -lcurses" >&5 -ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lcurses $LIBS" -cat > conftest.$ac_ext <<EOF -#line 2384 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char tgetent(); - -int main() { -tgetent() -; return 0; } -EOF -if { (eval echo configure:2395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - bash_cv_termcap_lib=libcurses -else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6 -echo "configure:2414: checking for tgetent in -lncurses" >&5 -ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lncurses $LIBS" -cat > conftest.$ac_ext <<EOF -#line 2422 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char tgetent(); - -int main() { -tgetent() -; return 0; } -EOF -if { (eval echo configure:2433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - bash_cv_termcap_lib=libncurses -else - echo "$ac_t""no" 1>&6 -bash_cv_termcap_lib=gnutermcap -fi - -fi - -fi - -fi - -if test "X$_bash_needmsg" = "Xyes"; then -echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6 -echo "configure:2462: checking which library has the termcap functions" >&5 -fi -echo "$ac_t""using $bash_cv_termcap_lib" 1>&6 -if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then -LDFLAGS="$LDFLAGS -L./lib/termcap" -TERMCAP_LIB="./lib/termcap/libtermcap.a" -TERMCAP_DEP="./lib/termcap/libtermcap.a" -elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then -TERMCAP_LIB=-ltermcap -TERMCAP_DEP= -elif test $bash_cv_termcap_lib = libncurses; then -TERMCAP_LIB=-lncurses -TERMCAP_DEP= -else -TERMCAP_LIB=-lcurses -TERMCAP_DEP= -fi - -if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then - TERMCAP_LIB=-ltermcap #default -fi - -case "$host_cpu" in -*cray*) LOCAL_CFLAGS=-DCRAY ;; -esac - -case "$host_os" in -isc*) LOCAL_CFLAGS=-Disc386 ;; -esac - -BUILD_DIR=`pwd` - - - - - - - - - - - - - - -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set) 2>&1 | grep ac_space` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -DEFS=-DHAVE_CONFIG_H - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12.2" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr `echo "Makefile doc/Makefile examples/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS <<EOF - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@CC@%$CC%g -s%@CPP@%$CPP%g -s%@CROSS_COMPILING_FLAG@%$CROSS_COMPILING_FLAG%g -s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@RANLIB@%$RANLIB%g -s%@BUILD_DIR@%$BUILD_DIR%g -s%@LOCAL_CFLAGS@%$LOCAL_CFLAGS%g -s%@LOCAL_LDFLAGS@%$LOCAL_LDFLAGS%g -s%@LOCAL_DEFS@%$LOCAL_DEFS%g -s%@LIBVERSION@%$LIBVERSION%g -s%@TERMCAP_LIB@%$TERMCAP_LIB%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <<EOF - -CONFIG_FILES=\${CONFIG_FILES-"Makefile doc/Makefile examples/Makefile"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <<EOF - CONFIG_HEADERS="config.h" -EOF -cat >> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. - -rm -f conftest.tail -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done - -EOF -cat >> $CONFIG_STATUS <<EOF - -EOF -cat >> $CONFIG_STATUS <<\EOF - -# Makefile uses this timestamp file to record whether config.h is up to date. -echo > stamp-h - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - diff --git a/readline/configure.in b/readline/configure.in deleted file mode 100644 index 15ccf1b..0000000 --- a/readline/configure.in +++ /dev/null @@ -1,151 +0,0 @@ -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 2.2, version 2.07, from autoconf version] AC_ACVERSION) -LIBVERSION=2.2 - -AC_INIT(readline.h) -AC_CONFIG_HEADER(config.h) - -dnl make sure we are using a recent autoconf version -AC_PREREQ(2.10) - -AC_CONFIG_AUX_DIR(./support) - -AC_CANONICAL_HOST - -dnl configure defaults -opt_curses=no -opt_shared=no - -dnl arguments to configure -AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval) - -if test "$opt_curses" = "yes"; then - prefer_curses=yes -fi - -# We want these before the checks, so the checks can modify their values. -test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 - -AC_PROG_CC -AC_MINIX - - -dnl BEGIN changes for CYGNUS cross-building for Cygwin - -dnl load up the cross-building cache file -- add more cases and cache -dnl files as necessary -if test "x$cross_compiling" = "xyes"; then - case "${host}" in - *-cygwin*) - cross_cache=${srcdir}/cross-build/cygwin.cache - if test -r "${cross_cache}"; then - echo "loading cross-build cache file ${cross_cache}" - . ${cross_cache} - fi - CFLAGS="$CFLAGS -I${srcdir}/../libtermcap" - unset cross_cache - ;; - *) echo "configure: cross-compiling for a non-cygwin target is not supported" >&2 - ;; - esac -fi - -if test "x$cross_compiling" = "xyes"; then - CROSS_COMPILING_FLAG=-DCROSS_COMPILING -else - CROSS_COMPILING_FLAG= -fi -AC_SUBST(CROSS_COMPILING_FLAG) - -if test -z "$CC_FOR_BUILD"; then - if test "x$cross_compiling" = "xno"; then - CC_FOR_BUILD='$(CC)' - else - CC_FOR_BUILD=gcc - fi -fi -AC_SUBST(CC_FOR_BUILD) - -dnl END changes for CYGNUS cross-building for Cygwin - - - -# 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_PROG_RANLIB - -AC_RETSIGTYPE - -AC_HEADER_STAT -AC_HEADER_DIRENT - -AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat) - -AC_FUNC_STRCOLL - -AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h \ - sys/ptem.h sys/pte.h sys/stream.h sys/select.h \ - termcap.h termios.h termio.h sys/file.h locale.h) - -BASH_SIGNAL_CHECK -BASH_REINSTALL_SIGHANDLERS - -BASH_FUNC_POSIX_SETJMP -BASH_FUNC_LSTAT -BASH_CHECK_GETPW_FUNCS -BASH_FUNC_STRCOLL - -BASH_TYPE_SIGHANDLER -BASH_HAVE_TIOCGWINSZ -BASH_HAVE_TIOCSTAT -BASH_HAVE_FIONREAD -BASH_MISC_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 - TERMCAP_LIB=-ltermcap #default -fi - -case "$host_cpu" in -*cray*) LOCAL_CFLAGS=-DCRAY ;; -esac - -case "$host_os" in -isc*) LOCAL_CFLAGS=-Disc386 ;; -esac - -BUILD_DIR=`pwd` -AC_SUBST(BUILD_DIR) - -AC_SUBST(CFLAGS) -AC_SUBST(LOCAL_CFLAGS) -AC_SUBST(LOCAL_LDFLAGS) -AC_SUBST(LOCAL_DEFS) - -AC_SUBST(host_cpu) -AC_SUBST(host_os) - -AC_SUBST(LIBVERSION) - -AC_SUBST(TERMCAP_LIB) - -AC_OUTPUT([Makefile doc/Makefile examples/Makefile], -[ -# Makefile uses this timestamp file to record whether config.h is up to date. -echo > stamp-h -]) diff --git a/readline/cross-build/.Sanitize b/readline/cross-build/.Sanitize deleted file mode 100644 index edee3d2..0000000 --- a/readline/cross-build/.Sanitize +++ /dev/null @@ -1,36 +0,0 @@ -# .Sanitize for readline/cross-build - -# Each directory to survive its way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this directory. - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Do-last:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -cygwin.cache - -Things-to-lose: - -# The lines between the "Do-last:" line and the end of the file -# are executed as a /bin/sh shell script after everything else is -# done. - -Do-last: - -# eof diff --git a/readline/cross-build/cygwin.cache b/readline/cross-build/cygwin.cache deleted file mode 100644 index 481a05d..0000000 --- a/readline/cross-build/cygwin.cache +++ /dev/null @@ -1,39 +0,0 @@ -# This file is a shell script that caches the results of configure -# tests for CYGWIN32 so they don't need to be done when cross-compiling. - -# AC_FUNC_GETPGRP should also define GETPGRP_VOID -ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void='yes'} -# AC_FUNC_SETVBUF_REVERSED should not define anything else -ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed='no'} -# on CYGWIN32, system calls do not restart -ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'} -bash_cv_sys_restartable_syscalls=${bash_cv_sys_restartable_syscalls='no'} - -# these may be necessary, but they are currently commented out -#ac_cv_c_bigendian=${ac_cv_c_bigendian='no'} -ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'} -ac_cv_sizeof_int=${ac_cv_sizeof_int='4'} -ac_cv_sizeof_long=${ac_cv_sizeof_long='4'} - -bash_cv_dup2_broken=${bash_cv_dup2_broken='no'} -bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'} -bash_cv_type_rlimit=${bash_cv_type_rlimit='long'} -bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist='no'} -bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist='no'} -bash_cv_sys_siglist=${bash_cv_sys_siglist='no'} -bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust='no'} -bash_cv_getenv_redef=${bash_cv_getenv_redef='yes'} -bash_cv_printf_declared=${bash_cv_printf_declared='yes'} -bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds='no'} -bash_cv_getcwd_calls_popen=${bash_cv_getcwd_calls_popen='no'} -bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers='no'} -bash_cv_job_control_missing=${bash_cv_job_control_missing='present'} -bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes='missing'} -bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp='present'} -bash_cv_mail_dir=${bash_cv_mail_dir='unknown'} -bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'} - -bash_cv_type_int32_t=${bash_cv_type_int32_t='int'} -bash_cv_type_u_int32_t=${bash_cv_type_u_int32_t='int'} - -# end of cross-build/cygwin32.cache diff --git a/readline/display.c b/readline/display.c deleted file mode 100644 index c627629..0000000 --- a/readline/display.c +++ /dev/null @@ -1,806 +0,0 @@ -/* display.c -- readline redisplay facility. */ - -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include <stdio.h> -#include <sys/types.h> - -/* System-specific feature definitions and include files. */ -#include "rldefs.h" - -/* Some standard library routines. */ -#include "readline.h" -#include "history.h" - -#if !defined (strrchr) -extern char *strrchr (); -#endif /* !strchr */ - -/* Global and pseudo-global variables and functions - imported from readline.c. */ -extern char *rl_prompt; -extern int readline_echoing_p; -extern char *term_clreol, *term_im, *term_ic, *term_ei, *term_DC; -/* Termcap variables. */ -extern char *term_up, *term_dc, *term_cr, *term_IC; -extern int screenheight, screenwidth, terminal_can_insert, term_xn; - -extern void _rl_output_some_chars (); -extern int _rl_output_character_function (); - -extern int _rl_convert_meta_chars_to_ascii; -extern int _rl_horizontal_scroll_mode; -extern int _rl_mark_modified_lines; -extern int _rl_prefer_visible_bell; - -/* Pseudo-global functions (local to the readline library) exported - by this file. */ -void _rl_move_cursor_relative (), _rl_output_some_chars (); -void _rl_move_vert (); - -static void update_line (), clear_to_eol (); -static void delete_chars (), insert_some_chars (); - -extern char *xmalloc (), *xrealloc (); - -/* **************************************************************** */ -/* */ -/* Display stuff */ -/* */ -/* **************************************************************** */ - -/* This is the stuff that is hard for me. I never seem to write good - display routines in C. Let's see how I do this time. */ - -/* (PWP) Well... Good for a simple line updater, but totally ignores - the problems of input lines longer than the screen width. - - update_line and the code that calls it makes a multiple line, - automatically wrapping line update. Carefull attention needs - to be paid to the vertical position variables. */ - -/* Keep two buffers; one which reflects the current contents of the - screen, and the other to draw what we think the new contents should - be. Then compare the buffers, and make whatever changes to the - screen itself that we should. Finally, make the buffer that we - just drew into be the one which reflects the current contents of the - screen, and place the cursor where it belongs. - - Commands that want to can fix the display themselves, and then let - this function know that the display has been fixed by setting the - RL_DISPLAY_FIXED variable. This is good for efficiency. */ - -/* What YOU turn on when you have handled all redisplay yourself. */ -int rl_display_fixed = 0; - -/* The stuff that gets printed out before the actual text of the line. - This is usually pointing to rl_prompt. */ -char *rl_display_prompt = (char *)NULL; - -/* Pseudo-global variables declared here. */ -/* The visible cursor position. If you print some text, adjust this. */ -int _rl_last_c_pos = 0; -int _rl_last_v_pos = 0; - -/* Number of lines currently on screen minus 1. */ -int _rl_vis_botlin = 0; - -/* Variables used only in this file. */ -/* The last left edge of text that was displayed. This is used when - doing horizontal scrolling. It shifts in thirds of a screenwidth. */ -static int last_lmargin = 0; - -/* The line display buffers. One is the line currently displayed on - the screen. The other is the line about to be displayed. */ -static char *visible_line = (char *)NULL; -static char *invisible_line = (char *)NULL; - -/* A buffer for `modeline' messages. */ -static char msg_buf[128]; - -/* Non-zero forces the redisplay even if we thought it was unnecessary. */ -static int forced_display = 0; - -/* Default and initial buffer size. Can grow. */ -static int line_size = 1024; - -/* Basic redisplay algorithm. */ -rl_redisplay () -{ - register int in, out, c, linenum; - register char *line = invisible_line; - char *prompt_this_line; - int c_pos = 0; - int inv_botlin = 0; /* Number of lines in newly drawn buffer. */ - - if (!readline_echoing_p) - return; - - if (!rl_display_prompt) - rl_display_prompt = ""; - - if (!invisible_line) - { - visible_line = (char *)xmalloc (line_size); - invisible_line = (char *)xmalloc (line_size); - line = invisible_line; - for (in = 0; in < line_size; in++) - { - visible_line[in] = 0; - invisible_line[in] = 1; - } - rl_on_new_line (); - } - - /* Draw the line into the buffer. */ - c_pos = -1; - - /* Mark the line as modified or not. We only do this for history - lines. */ - out = 0; - if (_rl_mark_modified_lines && current_history () && rl_undo_list) - { - line[out++] = '*'; - line[out] = '\0'; - } - - /* If someone thought that the redisplay was handled, but the currently - visible line has a different modification state than the one about - to become visible, then correct the caller's misconception. */ - if (visible_line[0] != invisible_line[0]) - rl_display_fixed = 0; - - prompt_this_line = strrchr (rl_display_prompt, '\n'); - if (!prompt_this_line) - prompt_this_line = rl_display_prompt; - else - { - prompt_this_line++; - if (forced_display) - _rl_output_some_chars - (rl_display_prompt, prompt_this_line - rl_display_prompt); - } - - strncpy (line + out, prompt_this_line, strlen (prompt_this_line)); - out += strlen (prompt_this_line); - line[out] = '\0'; - - for (in = 0; in < rl_end; in++) - { - c = (unsigned char)rl_line_buffer[in]; - - if (out + 8 >= line_size) /* XXX - 8 for \t */ - { - line_size *= 2; - visible_line = (char *)xrealloc (visible_line, line_size); - invisible_line = (char *)xrealloc (invisible_line, line_size); - line = invisible_line; - } - - if (in == rl_point) - c_pos = out; - - if (META_CHAR (c)) - { - if (_rl_convert_meta_chars_to_ascii) - { - sprintf (line + out, "\\%o", c); - out += 4; - } - else - line[out++] = c; - } -#define DISPLAY_TABS -#if defined (DISPLAY_TABS) - else if (c == '\t') - { - register int newout = (out | (int)7) + 1; - while (out < newout) - line[out++] = ' '; - } -#endif - else if (c < ' ') - { - line[out++] = '^'; - line[out++] = UNCTRL (c); /* XXX was c ^ 0x40 */ - } - else if (c == 127) - { - line[out++] = '^'; - line[out++] = '?'; - } - else - line[out++] = c; - } - line[out] = '\0'; - if (c_pos < 0) - c_pos = out; - - /* PWP: now is when things get a bit hairy. The visible and invisible - line buffers are really multiple lines, which would wrap every - screenwidth characters. Go through each in turn, finding - the changed region and updating it. The line order is top to bottom. */ - - /* If we can move the cursor up and down, then use multiple lines, - otherwise, let long lines display in a single terminal line, and - horizontally scroll it. */ - - if (!_rl_horizontal_scroll_mode && term_up && *term_up) - { - int total_screen_chars = (screenwidth * screenheight); - - if (!rl_display_fixed || forced_display) - { - forced_display = 0; - - /* If we have more than a screenful of material to display, then - only display a screenful. We should display the last screen, - not the first. I'll fix this in a minute. */ - if (out >= total_screen_chars) - out = total_screen_chars - 1; - - /* Number of screen lines to display. */ - inv_botlin = out / screenwidth; - - /* For each line in the buffer, do the updating display. */ - for (linenum = 0; linenum <= inv_botlin; linenum++) - update_line (linenum > _rl_vis_botlin ? "" - : &visible_line[linenum * screenwidth], - &invisible_line[linenum * screenwidth], - linenum); - - /* We may have deleted some lines. If so, clear the left over - blank ones at the bottom out. */ - if (_rl_vis_botlin > inv_botlin) - { - char *tt; - for (; linenum <= _rl_vis_botlin; linenum++) - { - tt = &visible_line[linenum * screenwidth]; - _rl_move_vert (linenum); - _rl_move_cursor_relative (0, tt); - clear_to_eol - ((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth); - } - } - _rl_vis_botlin = inv_botlin; - - /* Move the cursor where it should be. */ - _rl_move_vert (c_pos / screenwidth); - _rl_move_cursor_relative (c_pos % screenwidth, - &invisible_line[(c_pos / screenwidth) * screenwidth]); - } - } - else /* Do horizontal scrolling. */ - { - int lmargin; - - /* Always at top line. */ - _rl_last_v_pos = 0; - - /* If the display position of the cursor would be off the edge - of the screen, start the display of this line at an offset that - leaves the cursor on the screen. */ - if (c_pos - last_lmargin > screenwidth - 2) - lmargin = (c_pos / (screenwidth / 3) - 2) * (screenwidth / 3); - else if (c_pos - last_lmargin < 1) - lmargin = ((c_pos - 1) / (screenwidth / 3)) * (screenwidth / 3); - else - lmargin = last_lmargin; - - /* If the first character on the screen isn't the first character - in the display line, indicate this with a special character. */ - if (lmargin > 0) - line[lmargin] = '<'; - - if (lmargin + screenwidth < out) - line[lmargin + screenwidth - 1] = '>'; - - if (!rl_display_fixed || forced_display || lmargin != last_lmargin) - { - forced_display = 0; - update_line (&visible_line[last_lmargin], - &invisible_line[lmargin], 0); - - _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]); - last_lmargin = lmargin; - } - } - fflush (rl_outstream); - - /* Swap visible and non-visible lines. */ - { - char *temp = visible_line; - visible_line = invisible_line; - invisible_line = temp; - rl_display_fixed = 0; - } -} - -/* PWP: update_line() is based on finding the middle difference of each - line on the screen; vis: - - /old first difference - /beginning of line | /old last same /old EOL - v v v v -old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as -new: eddie> Oh, my little buggy says to me, as lurgid as - ^ ^ ^ ^ - \beginning of line | \new last same \new end of line - \new first difference - - All are character pointers for the sake of speed. Special cases for - no differences, as well as for end of line additions must be handeled. - - Could be made even smarter, but this works well enough */ -static void -update_line (old, new, current_line) - register char *old, *new; - int current_line; -{ - register char *ofd, *ols, *oe, *nfd, *nls, *ne; - int lendiff, wsatend; - - if (_rl_last_c_pos == screenwidth && term_xn && new[0]) - { - putc (new[0], rl_outstream); - _rl_last_c_pos = 1; - _rl_last_v_pos++; - if (old[0]) - old[0] = new[0]; - } - - /* Find first difference. */ - for (ofd = old, nfd = new; - (ofd - old < screenwidth) && *ofd && (*ofd == *nfd); - ofd++, nfd++) - ; - - /* Move to the end of the screen line. */ - for (oe = ofd; ((oe - old) < screenwidth) && *oe; oe++); - for (ne = nfd; ((ne - new) < screenwidth) && *ne; ne++); - - /* If no difference, continue to next line. */ - if (ofd == oe && nfd == ne) - return; - - wsatend = 1; /* flag for trailing whitespace */ - ols = oe - 1; /* find last same */ - nls = ne - 1; - while ((ols > ofd) && (nls > nfd) && (*ols == *nls)) - { - if (*ols != ' ') - wsatend = 0; - ols--; - nls--; - } - - if (wsatend) - { - ols = oe; - nls = ne; - } - else if (*ols != *nls) - { - if (*ols) /* don't step past the NUL */ - ols++; - if (*nls) - nls++; - } - - _rl_move_vert (current_line); - _rl_move_cursor_relative (ofd - old, old); - - /* if (len (new) > len (old)) */ - lendiff = (nls - nfd) - (ols - ofd); - - /* Insert (diff (len (old), len (new)) ch. */ - if (lendiff > 0) - { - if (terminal_can_insert) - { - /* Sometimes it is cheaper to print the characters rather than - use the terminal's capabilities. */ - if ((2 * (ne - nfd)) < lendiff && !term_IC) - { - _rl_output_some_chars (nfd, (ne - nfd)); - _rl_last_c_pos += (ne - nfd); - } - else - { - if (*ols) - { - insert_some_chars (nfd, lendiff); - _rl_last_c_pos += lendiff; - } - else - { - /* At the end of a line the characters do not have to - be "inserted". They can just be placed on the screen. */ - _rl_output_some_chars (nfd, lendiff); - _rl_last_c_pos += lendiff; - } - /* Copy (new) chars to screen from first diff to last match. */ - if (((nls - nfd) - lendiff) > 0) - { - _rl_output_some_chars (&nfd[lendiff], ((nls - nfd) - lendiff)); - _rl_last_c_pos += ((nls - nfd) - lendiff); - } - } - } - else - { /* cannot insert chars, write to EOL */ - _rl_output_some_chars (nfd, (ne - nfd)); - _rl_last_c_pos += (ne - nfd); - } - } - else /* Delete characters from line. */ - { - /* If possible and inexpensive to use terminal deletion, then do so. */ - if (term_dc && (2 * (ne - nfd)) >= (-lendiff)) - { - if (lendiff) - delete_chars (-lendiff); /* delete (diff) characters */ - - /* Copy (new) chars to screen from first diff to last match */ - if ((nls - nfd) > 0) - { - _rl_output_some_chars (nfd, (nls - nfd)); - _rl_last_c_pos += (nls - nfd); - } - } - /* Otherwise, print over the existing material. */ - else - { - _rl_output_some_chars (nfd, (ne - nfd)); - _rl_last_c_pos += (ne - nfd); - clear_to_eol ((oe - old) - (ne - new)); - } - } -} - -/* Tell the update routines that we have moved onto a new (empty) line. */ -rl_on_new_line () -{ - if (visible_line) - visible_line[0] = '\0'; - - _rl_last_c_pos = _rl_last_v_pos = 0; - _rl_vis_botlin = last_lmargin = 0; -} - -/* Actually update the display, period. */ -rl_forced_update_display () -{ - if (visible_line) - { - register char *temp = visible_line; - - while (*temp) *temp++ = '\0'; - } - rl_on_new_line (); - forced_display++; - rl_redisplay (); -} - -/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices. - DATA is the contents of the screen line of interest; i.e., where - the movement is being done. */ -void -_rl_move_cursor_relative (new, data) - int new; - char *data; -{ - register int i; - - /* It may be faster to output a CR, and then move forwards instead - of moving backwards. */ - if (new + 1 < _rl_last_c_pos - new) - { -#ifdef __MSDOS__ - putc('\r', rl_outstream); -#else - tputs (term_cr, 1, _rl_output_character_function); -#endif - _rl_last_c_pos = 0; - } - - if (_rl_last_c_pos == new) return; - - if (_rl_last_c_pos < new) - { - /* Move the cursor forward. We do it by printing the command - to move the cursor forward if there is one, else print that - portion of the output buffer again. Which is cheaper? */ - - /* The above comment is left here for posterity. It is faster - to print one character (non-control) than to print a control - sequence telling the terminal to move forward one character. - That kind of control is for people who don't know what the - data is underneath the cursor. */ -#if defined (HACK_TERMCAP_MOTION) - extern char *term_forward_char; - - if (term_forward_char) - for (i = _rl_last_c_pos; i < new; i++) - tputs (term_forward_char, 1, _rl_output_character_function); - else - for (i = _rl_last_c_pos; i < new; i++) - putc (data[i], rl_outstream); -#else - for (i = _rl_last_c_pos; i < new; i++) - putc (data[i], rl_outstream); -#endif /* HACK_TERMCAP_MOTION */ - } - else - backspace (_rl_last_c_pos - new); - _rl_last_c_pos = new; -} - -/* PWP: move the cursor up or down. */ -void -_rl_move_vert (to) - int to; -{ - register int delta, i; - - if (_rl_last_v_pos == to || to > screenheight) - return; - -#ifdef __GO32__ - { - int row, col; - ScreenGetCursor (&row, &col); - ScreenSetCursor ((row + to - _rl_last_v_pos), col); - } -#else /* __GO32__ */ - if ((delta = to - _rl_last_v_pos) > 0) - { - for (i = 0; i < delta; i++) - putc ('\n', rl_outstream); - tputs (term_cr, 1, _rl_output_character_function); - _rl_last_c_pos = 0; - } - else - { /* delta < 0 */ - if (term_up && *term_up) - for (i = 0; i < -delta; i++) - tputs (term_up, 1, _rl_output_character_function); - } -#endif /* !__GO32__ */ - _rl_last_v_pos = to; /* Now TO is here */ -} - -/* Physically print C on rl_outstream. This is for functions which know - how to optimize the display. */ -rl_show_char (c) - int c; -{ - if (META_CHAR (c) && _rl_convert_meta_chars_to_ascii) - { - fprintf (rl_outstream, "M-"); - c = UNMETA (c); - } - -#if defined (DISPLAY_TABS) - if (c < 32 && c != '\t') -#else - if (c < 32) -#endif /* !DISPLAY_TABS */ - { - - c += 64; - } - - putc (c, rl_outstream); - fflush (rl_outstream); -} - -int -rl_character_len (c, pos) - register int c, pos; -{ - if (META_CHAR (c)) - return (_rl_convert_meta_chars_to_ascii ? 4 : 1); - - if (c == '\t') - { -#if defined (DISPLAY_TABS) - return (((pos | (int)7) + 1) - pos); -#else - return (2); -#endif /* !DISPLAY_TABS */ - } - - if (isprint (c)) - return (1); - else - return (2); -} - -/* How to print things in the "echo-area". The prompt is treated as a - mini-modeline. */ - -#if defined (HAVE_VARARGS_H) -rl_message (va_alist) - va_dcl -{ - char *format; - va_list args; - - va_start (args); - format = va_arg (args, char *); - vsprintf (msg_buf, format, args); - va_end (args); - - rl_display_prompt = msg_buf; - rl_redisplay (); -} -#else /* !HAVE_VARARGS_H */ -rl_message (format, arg1, arg2) - char *format; -{ - sprintf (msg_buf, format, arg1, arg2); - rl_display_prompt = msg_buf; - rl_redisplay (); -} -#endif /* !HAVE_VARARGS_H */ - -/* How to clear things from the "echo-area". */ -rl_clear_message () -{ - rl_display_prompt = rl_prompt; - rl_redisplay (); -} - -rl_reset_line_state () -{ - rl_on_new_line (); - - rl_display_prompt = rl_prompt ? rl_prompt : ""; - forced_display = 1; -} - -/* Quick redisplay hack when erasing characters at the end of the line. */ -void -_rl_erase_at_end_of_line (l) - int l; -{ - register int i; - - backspace (l); - for (i = 0; i < l; i++) - putc (' ', rl_outstream); - backspace (l); - for (i = 0; i < l; i++) - visible_line[--_rl_last_c_pos] = '\0'; - rl_display_fixed++; -} - -/* Clear to the end of the line. COUNT is the minimum - number of character spaces to clear, */ -static void -clear_to_eol (count) - int count; -{ -#ifndef __GO32__ - if (term_clreol) - { - tputs (term_clreol, 1, _rl_output_character_function); - } - else -#endif /* !__GO32__ */ - { - register int i; - - /* Do one more character space. */ - count++; - - for (i = 0; i < count; i++) - putc (' ', rl_outstream); - - backspace (count); - } -} -/* Insert COUNT characters from STRING to the output stream. */ -static void -insert_some_chars (string, count) - char *string; - int count; -{ -#ifdef __GO32__ - int row, col, width; - char *row_start; - - ScreenGetCursor (&row, &col); - width = ScreenCols (); - row_start = ScreenPrimary + (row * width); - memcpy (row_start + col + count, row_start + col, width - col - count); - /* Place the text on the screen. */ - _rl_output_some_chars (string, count); -#else /* __GO32__ */ - /* If IC is defined, then we do not have to "enter" insert mode. */ - if (term_IC) - { - char *tgoto (), *buffer; - buffer = tgoto (term_IC, 0, count); - tputs (buffer, 1, _rl_output_character_function); - _rl_output_some_chars (string, count); - } - else - { - register int i; - - /* If we have to turn on insert-mode, then do so. */ - if (term_im && *term_im) - tputs (term_im, 1, _rl_output_character_function); - - /* If there is a special command for inserting characters, then - use that first to open up the space. */ - if (term_ic && *term_ic) - { - for (i = count; i--; ) - tputs (term_ic, 1, _rl_output_character_function); - } - - /* Print the text. */ - _rl_output_some_chars (string, count); - - /* If there is a string to turn off insert mode, we had best use - it now. */ - if (term_ei && *term_ei) - tputs (term_ei, 1, _rl_output_character_function); - } -#endif /* __GO32__ */ -} - -/* Delete COUNT characters from the display line. */ -static void -delete_chars (count) - int count; -{ -#if defined (__GO32__) - int row, col, width; - char *row_start; - - ScreenGetCursor (&row, &col); - width = ScreenCols (); - row_start = ScreenPrimary + (row * width); - memcpy (row_start + col, row_start + col + count, width - col - count); - memset (row_start + width - count, 0, count * 2); -#else /* !__GO32__ */ - if (count > screenwidth) - return; - - if (term_DC && *term_DC) - { - char *tgoto (), *buffer; - buffer = tgoto (term_DC, 0, count); - tputs (buffer, 1, _rl_output_character_function); - } - else - { - if (term_dc && *term_dc) - while (count--) - tputs (term_dc, 1, _rl_output_character_function); - } -#endif /* !__GO32__ */ -} diff --git a/readline/doc/.Sanitize b/readline/doc/.Sanitize deleted file mode 100644 index d74993d..0000000 --- a/readline/doc/.Sanitize +++ /dev/null @@ -1,47 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -ChangeLog -Makefile.in -hist.texinfo -hstech.texinfo -hsuser.texinfo -inc-hist.texi -readline.0 -readline.3 -rlman.texinfo -rltech.texinfo -rluser.texinfo -texi2dvi -texi2html - -Things-to-lose: - - -Do-last: - -# End of file. diff --git a/readline/doc/ChangeLog b/readline/doc/ChangeLog deleted file mode 100644 index 8049c5e..0000000 --- a/readline/doc/ChangeLog +++ /dev/null @@ -1,29 +0,0 @@ -Tue Dec 22 10:07:58 1998 Elena Zannoni <ezannoni@kwikemart.cygnus.com> - - * hsuser.texinfo (Bash History Builtins): comment out btindex - commands. - - * Import of Readline 2.2.1. - - New files: readline.0, readline.3, texi2dvi, texi2html. - -1998-12-17 Felix Lee <flee@cygnus.com> - - * inc-hist.texi: @node line "Using History" was wrong. - -Thu Jul 9 17:03:26 1998 Edith Epstein <eepstein@sophia.cygnus.com> - - * inc-hist.texi: one line change. - -Wed Sep 20 12:57:29 1995 Ian Lance Taylor <ian@cygnus.com> - - * Makefile.in (maintainer-clean): New synonym for realclean. - -Tue Feb 2 11:40:04 1993 Roland H. Pesch (pesch@fowanton.cygnus.com) - - * Makefile.in: configurable (and useable) Makefile template - * Makefile: removed, replaced with configurable Makefile.in - * texindex.c texinfo.tex: remove, replacing w/refs to tools - elsewhere in distribution tree - * configure.in: pro forma configure stub - * ChangeLog: new file diff --git a/readline/doc/Makefile.in b/readline/doc/Makefile.in deleted file mode 100644 index 5e0d2d5..0000000 --- a/readline/doc/Makefile.in +++ /dev/null @@ -1,94 +0,0 @@ -## Copyright (C) 1993 Free Software Foundation, Inc. - -# Makefile for Readline documentation. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -srcdir = . - -prefix = /usr/local - -infodir = $(prefix)/info - -SHELL = /bin/sh - -INSTALL = install -c -INSTALL_DATA = $(INSTALL) - -# where to find texinfo -TEXIDIR=$(srcdir)/../../texinfo - -# where to find makeinfo, preferably one designed for texinfo-2 -MAKEINFO=makeinfo - -# auxiliary program for sorting Texinfo indices -TEXINDEX=texindex - -# Don Knuth's TeX formatter -TEX=tex - -#### Host, target, and site specific Makefile fragments come in here. -### - -all: info dvi - -install: install-info - -info: history.info readline.info - -dvi: history.dvi readline.dvi - -install-info: info - -parent=`echo $(infodir)|sed -e 's@/[^/]*$$@@'`; \ - if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi - -if [ -d $(infodir) ] ; then true ; else mkdir $(infodir) ; fi - for i in *.info* ; do \ - $(INSTALL_DATA) $$i $(infodir)/$$i ; \ - done - -history.info: hist.texinfo hsuser.texinfo hstech.texinfo - $(MAKEINFO) -I $(srcdir) -o ./history.info $(srcdir)/hist.texinfo - -history.dvi: hist.texinfo hsuser.texinfo hstech.texinfo $(TEXIDIR)/texinfo.tex - TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) hist.texinfo - $(TEXINDEX) hist.?? - TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) hist.texinfo - -readline.info: rlman.texinfo rluser.texinfo rltech.texinfo - $(MAKEINFO) -I $(srcdir) -o ./readline.info $(srcdir)/rlman.texinfo - -readline.dvi: rlman.texinfo rluser.texinfo rltech.texinfo - TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) rlman.texinfo - $(TEXINDEX) rlman.?? - TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) rlman.texinfo - -distclean: clean - rm -f Makefile config.status - -mostlyclean: clean - -realclean: distclean - -clean: clean-info clean-dvi - -clean-info: - rm -f history.info* readline.info* - -clean-dvi: - rm -f hist.?? hist.??? - rm -f rlman.?? rlman.??? - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status diff --git a/readline/doc/hist.texinfo b/readline/doc/hist.texinfo deleted file mode 100644 index be8742f..0000000 --- a/readline/doc/hist.texinfo +++ /dev/null @@ -1,117 +0,0 @@ -\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 - -@ignore -last change: Thu Apr 2 14:38:22 EST 1998 -@end ignore - -@set EDITION 2.2 -@set VERSION 2.2 -@set UPDATED 2 April 1998 -@set UPDATE-MONTH April 1998 - -@dircategory Libraries -@direntry -* History: (history). The GNU history library API -@end direntry - -@ifinfo -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, 1991, 1993, 1995, 1996, 1998 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 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 @* -675 Massachusetts Avenue, @* -Cambridge, MA 02139 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 Foundation. - -@vskip 0pt plus 1filll -Copyright @copyright{} 1989, 1991 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 diff --git a/readline/doc/hstech.texinfo b/readline/doc/hstech.texinfo deleted file mode 100644 index 5410090..0000000 --- a/readline/doc/hstech.texinfo +++ /dev/null @@ -1,515 +0,0 @@ -@ignore -This file documents the user interface to the GNU History library. - -Copyright (C) 1988, 1991, 1994, 1996 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 GNU History Library. -It should be considered a technical guide. -For information on the interactive use of 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 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. - -@node History Storage -@section History Storage - -The history list is an array of history entries. A history entry is -declared as follows: - -@example -typedef struct _hist_entry @{ - char *line; - char *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 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; -@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 -present in GNU History. - -@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 () -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 () -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 (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, char *line, char *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 () -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 () -Stop stifling the history. This returns the previous amount the -history was stifled. The value is positive if the history was -stifled, negative if it wasn't. -@end deftypefun - -@deftypefun int history_is_stifled () -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 () -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 () -Returns the offset of the current history element. -@end deftypefun - -@deftypefun {HIST_ENTRY *} current_history () -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}. 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 () -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 position in the history list to @var{pos}, an absolute index -into the list. -@end deftypefun - -@deftypefun {HIST_ENTRY *} previous_history () -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 () -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 (char *string, int direction) -Search the history for @var{string}, starting at the current history -offset. If @var{direction} < 0, then the search is through previous entries, -else through subsequent. 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 (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} < 0, then the search is through previous -entries, else through subsequent. 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 (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 (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 errno if not. -@end deftypefun - -@deftypefun int read_history_range (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 (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}. Values -returned are as in @code{read_history ()}. -@end deftypefun - -@deftypefun int append_history (int nelements, char *filename) -Append the last @var{nelements} of the history list to @var{filename}. -@end deftypefun - -@deftypefun int history_truncate_file (char *filename, int nlines) -Truncate the history file @var{filename}, leaving only the last -@var{nlines} lines. -@end deftypefun - -@node History Expansion -@subsection History Expansion - -These functions implement @code{csh}-like 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 de-slashifying of 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 only 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 *} history_arg_extract (int first, int last, char *string) -Extract a string segment consisting of the @var{first} through @var{last} -arguments present in @var{string}. Arguments are broken up as in Bash. -@end deftypefun - -@deftypefun {char *} get_history_event (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 (char *string) -Return an array of tokens parsed out of @var{string}, much as the -shell might. The tokens are split on white space and on the -characters @code{()<>;&|$}, and shell quoting conventions are -obeyed. -@end deftypefun - -@node History Variables -@section History Variables - -This section describes the externally visible variables exported by -the 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 max_input_history -The maximum number of history entries. This must be changed using -@code{stifle_history ()}. -@end deftypevar - -@deftypevar char history_expansion_char -The character that starts a history event. The default is @samp{!}. -@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_no_expand_chars -The list of characters which inhibit history expansion if found immediately -following @var{history_expansion_char}. The default is whitespace 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 whitespace, @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 {Function *} 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 integer 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 NULL. -@end deftypevar - -@node History Programming Example -@section History Programming Example - -The following program demonstrates simple use of the GNU History Library. - -@smallexample -main () -@{ - 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 diff --git a/readline/doc/hsuser.texinfo b/readline/doc/hsuser.texinfo deleted file mode 100644 index 7c4582d..0000000 --- a/readline/doc/hsuser.texinfo +++ /dev/null @@ -1,398 +0,0 @@ -@ignore -This file documents the user interface to the GNU History library. - -Copyright (C) 1988, 1991, 1996 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 - -@ifset BashFeatures -This chapter describes how to use the GNU History Library interactively, -from a user's standpoint. It should be considered a user's guide. For -information on using the GNU History Library in other programs, -see the GNU Readline Library Manual. -@end ifset -@ifclear BashFeatures -This chapter describes how to use the GNU History Library interactively, -from a user's standpoint. It should be considered a user's guide. For -information on using the 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 @samp{-o history} option to the @code{set} builtin -is enabled (@pxref{The Set Builtin}), -the shell provides access to the @var{command history}, -the list of commands previously typed. The text of the last -@code{HISTSIZE} -commands (default 500) is saved in a history list. 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 -@code{HISTIGNORE} and @code{HISTCONTROL}. -When the shell starts up, the history is initialized from the -file named by the @code{HISTFILE} variable (default @file{~/.bash_history}). -@code{HISTFILE} is truncated, if necessary, to contain no more than -the number of lines specified by the value of the @code{HISTFILESIZE} -variable. When an interactive shell exits, the last -@code{HISTSIZE} lines are copied from the history list to @code{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 @code{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 @code{$HISTFILESIZE} -lines. If @code{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 can be used to display or modify the history -list and manipulate the history file. -When using the command-line editing, search commands -are available in each editing mode that provide access to the -history list. - -The shell allows control over which commands are saved on the history -list. The @code{HISTCONTROL} and @code{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. -@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 that allow you to manipulate the -history list and history file. - -@table @code - -@item fc -@comment 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 @samp{-l} flag is -given, the commands are listed on standard output. The @samp{-n} flag -suppresses the command numbers when listing. The @samp{-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 @code{FCEDIT} variable if set, or the value of the -@code{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 -@comment btindex history -@example -history [-c] [@var{n}] -history [-anrw] [@var{filename}] -history -ps @var{arg} -@end example - -Display the history list with line numbers. Lines prefixed with -with a @samp{*} have been modified. An argument of @var{n} says -to list only the last @var{n} lines. Options, if supplied, have -the following meanings: - -@table @code -@item -w -Write out the current history to the history file. - -@item -r -Read the current history file and append its contents to -the history list. - -@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 -c -Clear the history list. This may be combined -with the other options to replace the history list completely. - -@item -s -The @var{arg}s are added to the end of -the history list as a single entry. - -@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. -@end table - -When the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} option is -used, if @var{filename} -is given, then it is used as the history file. If not, then -the value of the @code{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 @samp{-p} option to the @code{history} builtin command -may be used to see what a history expansion will do before using it. -The @samp{-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. - -@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 diff --git a/readline/doc/inc-hist.texi b/readline/doc/inc-hist.texi deleted file mode 100644 index 9cdde40..0000000 --- a/readline/doc/inc-hist.texi +++ /dev/null @@ -1,159 +0,0 @@ -@ignore -This file is completely identical to hsuser.texinfo, except that it has the -reference to the programming manual removed. There are definately better ways -to do this! - -This file documents the user interface to the GNU History library. - -Copyright (C) 1988, 1991 Free Software Foundation, Inc. -Authored by Brian Fox. - -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 -@appendix Using History Interactively - -This chapter describes how to use the GNU History Library interactively, -from a user's standpoint. - -@menu -* History Interaction:: What it feels like using History as a user. -@end menu - -@node History Interaction -@section History Interaction -@cindex expansion - -The History library provides a history expansion feature similar -to the history expansion in @code{csh}. The following text describes the -syntax you use to manipulate history information. - -History expansion takes two parts. In the first part, determine -which line from the previous history will be used for substitution. -This line is called the @dfn{event}. -In the second part, select portions of that line for inclusion into the -current line. These portions are called @dfn{words}. -@value{GDBN} breaks the line into words in the same -way that the Bash shell does, so that several English (or Unix) words -surrounded by quotes are considered one word. - -@menu -* Event Designators:: How to specify which history line to use. -* Word Designators:: Specifying which words are of interest. -* Modifiers:: Modifying the results of susbstitution. -@end menu - -@node Event Designators -@subsection Event Designators -@cindex event designators - -An @dfn{event designator} is a reference to a command line entry in the -history list. - -@table @asis - -@item @code{!} -Start a history subsititution, except when followed by a space, tab, or -the end of the line... @key{=} or @key{(}. - -@item @code{!!} -Refer to the previous command. This is a synonym for @code{!-1}. - -@item @code{!n} -Refer to command line @var{n}. - -@item @code{!-n} -Refer to the command line @var{n} lines back. - -@item @code{!string} -Refer to the most recent command starting with @var{string}. - -@item @code{!?string}[@code{?}] -Refer to the most recent command containing @var{string}. - -@end table - -@node Word Designators -@subsection Word Designators - -A @key{:} separates the event designator from the @dfn{word designator}. -It can be omitted if the word designator begins with a @key{^}, @key{$}, -@key{*} or @key{%}. Words are numbered from the beginning of the line, -with the first word being denoted by a 0 (zero). - -@table @code - -@item 0 (zero) -The zero'th word. For many applications, this is the command word. - -@item 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 @code{?string?} search. - -@item x-y -A range of words; @code{-@var{y}} Abbreviates @code{0-@var{y}}. - -@item * -All of the words, excepting the zero'th. This is a synonym for @code{1-$}. -It is not an error to use @key{*} if there is just one word in the event. -The empty string is returned in that case. - -@end table - -@node Modifiers -@subsection Modifiers - -After the optional word designator, you can add a sequence of one or more -of the following @dfn{modifiers}, each preceded by a @key{:}. - -@table @code - -@item # -The entire command line typed so far. This means the current command, -not the previous command. -@c -@c FIXME: If it doesn't belong here, let's put it where it does. -@c -@c so it technically isn't a word designator and doesn't belong in -@c this section. - -@item h -Remove a trailing pathname component, leaving only the head. - -@item r -Remove a trailing suffix of the form @samp{.}@var{suffix}, leaving the basename. - -@item e -Remove all but the suffix. - -@item t -Remove all leading pathname components, leaving the tail. - -@item p -Print the new command but do not execute it. -@end table diff --git a/readline/doc/readline.0 b/readline/doc/readline.0 deleted file mode 100644 index c925d52..0000000 --- a/readline/doc/readline.0 +++ /dev/null @@ -1,1122 +0,0 @@ - - - -READLINE(3) READLINE(3) - - -NNAAMMEE - readline - get a line from a user with editing - -SSYYNNOOPPSSIISS - ##iinncclluuddee <<rreeaaddlliinnee..hh>> - ##iinncclluuddee <<hhiissttoorryy..hh>> - - cchhaarr **rreeaaddlliinnee ((pprroommpptt)) - cchhaarr **pprroommpptt;; - -CCOOPPYYRRIIGGHHTT - Readline is Copyright (C) 1989, 1991, 1993, 1995, 1996 by - the Free Software Foundation, Inc. - -DDEESSCCRRIIPPTTIIOONN - rreeaaddlliinnee will read a line from the terminal and return it, - using pprroommpptt as a prompt. If pprroommpptt is null, no prompt is - issued. The line returned is allocated with _m_a_l_l_o_c(3), so - the caller must free it when finished. The line returned - has the final newline removed, so only the text of the - line remains. - - rreeaaddlliinnee offers editing capabilities while the user is - entering the line. By default, the line editing commands - are similar to those of emacs. A vi-style line editing - interface is also available. - -RREETTUURRNN VVAALLUUEE - rreeaaddlliinnee returns the text of the line read. A blank line - returns the empty string. If EEOOFF is encountered while - reading a line, and the line is empty, NNUULLLL is returned. - If an EEOOFF is read with a non-empty line, it is treated as - a newline. - -NNOOTTAATTIIOONN - An emacs-style notation is used to denote keystrokes. - Control keys are denoted by C-_k_e_y, e.g., C-n means Con- - trol-N. Similarly, _m_e_t_a keys are denoted by M-_k_e_y, so M-x - means Meta-X. (On keyboards without a _m_e_t_a key, M-_x means - ESC _x, i.e., press the Escape key then the _x key. This - makes ESC the _m_e_t_a _p_r_e_f_i_x. The combination M-C-_x means - ESC-Control-_x, or press the Escape key then hold the Con- - trol key while pressing the _x key.) - - Readline commands may be given numeric _a_r_g_u_m_e_n_t_s, which - normally act as a repeat count. Sometimes, however, it is - the sign of the argument that is significant. Passing a - negative argument to a command that acts in the forward - direction (e.g., kkiillll--lliinnee) causes that command to act in - a backward direction. Commands whose behavior with argu- - ments deviates from this are noted. - - When a command is described as _k_i_l_l_i_n_g text, the text - deleted is saved for possible future retrieval (_y_a_n_k_i_n_g). - - - -GNU 1998 Feb 19 1 - - - - - -READLINE(3) READLINE(3) - - - The killed text is saved in a _k_i_l_l _r_i_n_g. Consecutive - kills cause the text to be accumulated into one unit, - which can be yanked all at once. Commands which do not - kill text separate the chunks of text on the kill ring. - -IINNIITTIIAALLIIZZAATTIIOONN FFIILLEE - Readline is customized by putting commands in an initial- - ization file (the _i_n_p_u_t_r_c file). The name of this file is - taken from the value of the IINNPPUUTTRRCC environment variable. - If that variable is unset, the default is _~_/_._i_n_p_u_t_r_c. - When a program which uses the readline library starts up, - the init file is read, and the key bindings and variables - are set. There are only a few basic constructs allowed in - the readline init file. Blank lines are ignored. Lines - beginning with a ## are comments. Lines beginning with a $$ - indicate conditional constructs. Other lines denote key - bindings and variable settings. Each program using this - library may add its own commands and bindings. - - For example, placing - - M-Control-u: universal-argument - or - C-Meta-u: universal-argument - into the _i_n_p_u_t_r_c would make M-C-u execute the readline - command _u_n_i_v_e_r_s_a_l_-_a_r_g_u_m_e_n_t. - - The following symbolic character names are recognized - while processing key bindings: _R_U_B_O_U_T, _D_E_L, _E_S_C, _L_F_D, _N_E_W_- - _L_I_N_E, _R_E_T, _R_E_T_U_R_N, _S_P_C, _S_P_A_C_E, and _T_A_B. In addition to - command names, readline allows keys to be bound to a - string that is inserted when the key is pressed (a _m_a_c_r_o). - - - KKeeyy BBiinnddiinnggss - The syntax for controlling key bindings in the _i_n_p_u_t_r_c - file is simple. All that is required is the name of the - command or the text of a macro and a key sequence to which - it should be bound. The name may be specified in one of - two ways: as a symbolic key name, possibly with _M_e_t_a_- or - _C_o_n_t_r_o_l_- prefixes, or as a key sequence. When using the - form kkeeyynnaammee:_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, _k_e_y_n_a_m_e is the name - of a key spelled out in English. For example: - - Control-u: universal-argument - Meta-Rubout: backward-kill-word - Control-o: ">&output" - - In the above example, _C_-_u is bound to the function uunniivveerr-- - ssaall--aarrgguummeenntt, _M_-_D_E_L is bound to the function bbaacckk-- - wwaarrdd--kkiillll--wwoorrdd, and _C_-_o is bound to run the macro - expressed on the right hand side (that is, to insert the - text _>_&_o_u_t_p_u_t into the line). - - - - -GNU 1998 Feb 19 2 - - - - - -READLINE(3) READLINE(3) - - - In the second form, ""kkeeyysseeqq"":_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, kkeeyy-- - sseeqq differs from kkeeyynnaammee above in that strings denoting an - entire key sequence may be specified by placing the - sequence within double quotes. Some GNU Emacs style key - escapes can be used, as in the following example. - - "\C-u": universal-argument - "\C-x\C-r": re-read-init-file - "\e[11~": "Function Key 1" - - In this example, _C_-_u is again bound to the function uunnii-- - vveerrssaall--aarrgguummeenntt. _C_-_x _C_-_r is bound to the function - rree--rreeaadd--iinniitt--ffiillee, and _E_S_C _[ _1 _1 _~ is bound to insert the - text FFuunnccttiioonn KKeeyy 11. The full set of GNU Emacs style - escape sequences is - \\CC-- control prefix - \\MM-- meta prefix - \\ee an escape character - \\\\ backslash - \\"" literal " - \\'' literal ' - - In addition to the GNU Emacs style escape sequences, a - second set of backslash escapes is available: - \\aa alert (bell) - \\bb backspace - \\dd delete - \\ff form feed - \\nn newline - \\rr carriage return - \\tt horizontal tab - \\vv vertical tab - \\_n_n_n the character whose ASCII code is the octal - value _n_n_n (one to three digits) - \\xx_n_n_n the character whose ASCII code is the hex- - adecimal value _n_n_n (one to three digits) - - When entering the text of a macro, single or double quotes - should be used to indicate a macro definition. Unquoted - text is assumed to be a function name. In the macro body, - the backslash escapes described above are expanded. Back- - slash will quote any other character in the macro text, - including " and '. - - BBaasshh allows the current readline key bindings to be dis- - played or modified with the bbiinndd builtin command. The - editing mode may be switched during interactive use by - using the --oo option to the sseett builtin command. Other - programs using this library provide similar mechanisms. - The _i_n_p_u_t_r_c file may be edited and re-read if a program - does not provide any other means to incorporate new bind- - ings. - - - - - -GNU 1998 Feb 19 3 - - - - - -READLINE(3) READLINE(3) - - - VVaarriiaabblleess - Readline has variables that can be used to further cus- - tomize its behavior. A variable may be set in the _i_n_p_u_t_r_c - file with a statement of the form - - sseett _v_a_r_i_a_b_l_e_-_n_a_m_e _v_a_l_u_e - - Except where noted, readline variables can take the values - OOnn or OOffff. The variables and their default values are: - - bbeellll--ssttyyllee ((aauuddiibbllee)) - Controls what happens when readline wants to ring - the terminal bell. If set to nnoonnee, readline never - rings the bell. If set to vviissiibbllee, readline uses a - visible bell if one is available. If set to aauuddii-- - bbllee, readline attempts to ring the terminal's bell. - ccoommmmeenntt--bbeeggiinn ((````##'''')) - The string that is inserted in vvii mode when the - iinnsseerrtt--ccoommmmeenntt command is executed. This command - is bound to MM--## in emacs mode and to ## in vi com- - mand mode. - ccoommpplleettiioonn--iiggnnoorree--ccaassee ((OOffff)) - If set to OOnn, readline performs filename matching - and completion in a case-insensitive fashion. - ccoommpplleettiioonn--qquueerryy--iitteemmss ((110000)) - This determines when the user is queried about - viewing the number of possible completions gener- - ated by the ppoossssiibbllee--ccoommpplleettiioonnss command. It may - be set to any integer value greater than or equal - to zero. If the number of possible completions is - greater than or equal to the value of this vari- - able, the user is asked whether or not he wishes to - view them; otherwise they are simply listed on the - terminal. - ccoonnvveerrtt--mmeettaa ((OOnn)) - If set to OOnn, readline will convert characters with - the eighth bit set to an ASCII key sequence by - stripping the eighth bit and prepending an escape - character (in effect, using escape as the _m_e_t_a _p_r_e_- - _f_i_x). - ddiissaabbllee--ccoommpplleettiioonn ((OOffff)) - If set to OOnn, readline will inhibit word comple- - tion. Completion characters will be inserted into - the line as if they had been mapped to sseellff--iinnsseerrtt. - eeddiittiinngg--mmooddee ((eemmaaccss)) - Controls whether readline begins with a set of key - bindings similar to _e_m_a_c_s or _v_i. eeddiittiinngg--mmooddee can - be set to either eemmaaccss or vvii. - eennaabbllee--kkeeyyppaadd ((OOffff)) - When set to OOnn, readline will try to enable the - application keypad when it is called. Some systems - need this to enable the arrow keys. - eexxppaanndd--ttiillddee ((OOffff)) - If set to oonn, tilde expansion is performed when - - - -GNU 1998 Feb 19 4 - - - - - -READLINE(3) READLINE(3) - - - readline attempts word completion. - hhoorriizzoonnttaall--ssccrroollll--mmooddee ((OOffff)) - When set to OOnn, makes readline use a single line - for display, scrolling the input horizontally on a - single screen line when it becomes longer than the - screen width rather than wrapping to a new line. - kkeeyymmaapp ((eemmaaccss)) - Set the current readline keymap. The set of legal - keymap names is _e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, - _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_m_o_v_e_, _v_i_-_c_o_m_m_a_n_d, and _v_i_-_i_n_s_e_r_t. - _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d; _e_m_a_c_s is equivalent - to _e_m_a_c_s_-_s_t_a_n_d_a_r_d. The default value is _e_m_a_c_s; the - value of eeddiittiinngg--mmooddee also affects the default - keymap. - mmaarrkk--ddiirreeccttoorriieess ((OOnn)) - If set to OOnn, complete<d directory names have a - slash appended. - mmaarrkk--mmooddiiffiieedd--lliinneess ((OOffff)) - If set to OOnn, history lines that have been modified - are displayed with a preceding asterisk (**). - mmeettaa--ffllaagg ((OOffff)) - If set to OOnn, readline will enable eight-bit input - (that is, it will not strip the high bit from the - characters it reads), regardless of what the termi- - nal claims it can support. - oouuttppuutt--mmeettaa ((OOffff)) - If set to OOnn, readline will display characters with - the eighth bit set directly rather than as a meta- - prefixed escape sequence. - pprriinntt--ccoommpplleettiioonnss--hhoorriizzoonnttaallllyy ((OOffff)) - If set to OOnn, readline will display completions - with matches sorted horizontally in alphabetical - order, rather than down the screen. - sshhooww--aallll--iiff--aammbbiigguuoouuss ((OOffff)) - This alters the default behavior of the completion - functions. If set to oonn, words which have more - than one possible completion cause the matches to - be listed immediately instead of ringing the bell. - vviissiibbllee--ssttaattss ((OOffff)) - If set to OOnn, a character denoting a file's type as - reported by ssttaatt(2) is appended to the filename - when listing possible completions. - - CCoonnddiittiioonnaall CCoonnssttrruuccttss - Readline implements a facility similar in spirit to the - conditional compilation features of the C preprocessor - which allows key bindings and variable settings to be per- - formed as the result of tests. There are four parser - directives used. - - $$iiff The $$iiff construct allows bindings to be made based - on the editing mode, the terminal being used, or - the application using readline. The text of the - test extends to the end of the line; no characters - - - -GNU 1998 Feb 19 5 - - - - - -READLINE(3) READLINE(3) - - - are required to isolate it. - - mmooddee The mmooddee== form of the $$iiff directive is used - to test whether readline is in emacs or vi - mode. This may be used in conjunction with - the sseett kkeeyymmaapp command, for instance, to set - bindings in the _e_m_a_c_s_-_s_t_a_n_d_a_r_d and _e_m_a_c_s_- - _c_t_l_x keymaps only if readline is starting - out in emacs mode. - - tteerrmm The tteerrmm== form may be used to include termi- - nal-specific key bindings, perhaps to bind - the key sequences output by the terminal's - function keys. The word on the right side - of the == is tested against the full name of - the terminal and the portion of the terminal - name before the first --. This allows _s_u_n to - match both _s_u_n and _s_u_n_-_c_m_d, for instance. - - aapppplliiccaattiioonn - The aapppplliiccaattiioonn construct is used to include - application-specific settings. Each program - using the readline library sets the _a_p_p_l_i_c_a_- - _t_i_o_n _n_a_m_e, and an initialization file can - test for a particular value. This could be - used to bind key sequences to functions use- - ful for a specific program. For instance, - the following command adds a key sequence - that quotes the current or previous word in - Bash: - - $$iiff bash - # Quote the current or previous word - "\C-xq": "\eb\"\ef\"" - $$eennddiiff - - $$eennddiiff This command, as seen in the previous example, ter- - minates an $$iiff command. - - $$eellssee Commands in this branch of the $$iiff directive are - executed if the test fails. - - $$iinncclluuddee - This directive takes a single filename as an argu- - ment and reads commands and bindings from that - file. For example, the following directive would - read _/_e_t_c_/_i_n_p_u_t_r_c: - - $$iinncclluuddee _/_e_t_c_/_i_n_p_u_t_r_c - -SSEEAARRCCHHIINNGG - Readline provides commands for searching through the com- - mand history for lines containing a specified string. - There are two search modes: _i_n_c_r_e_m_e_n_t_a_l and _n_o_n_- - - - -GNU 1998 Feb 19 6 - - - - - -READLINE(3) READLINE(3) - - - _i_n_c_r_e_m_e_n_t_a_l. - - Incremental searches begin before the user has finished - typing the search string. As each character of the search - string is typed, readline displays the next entry from the - history matching the string typed so far. An incremental - search requires only as many characters as needed to find - the desired history entry. The Escape character is used - to terminate an incremental search. Control-J will also - terminate the search. Control-G will abort an incremental - search and restore the original line. When the search is - terminated, the history entry containing the search string - becomes the current line. To find other matching entries - in the history list, type Control-S or Control-R as appro- - priate. This will search backward or forward in the his- - tory for the next line matching the search string typed so - far. Any other key sequence bound to a readline command - will terminate the search and execute that command. For - instance, a _n_e_w_l_i_n_e will terminate the search and accept - the line, thereby executing the command from the history - list. - - Non-incremental searches read the entire search string - before starting to search for matching history lines. The - search string may be typed by the user or be part of the - contents of the current line. - -EEDDIITTIINNGG CCOOMMMMAANNDDSS - The following is a list of the names of the commands and - the default key sequences to which they are bound. Com- - mand names without an accompanying key sequence are - unbound by default. - - CCoommmmaannddss ffoorr MMoovviinngg - bbeeggiinnnniinngg--ooff--lliinnee ((CC--aa)) - Move to the start of the current line. - eenndd--ooff--lliinnee ((CC--ee)) - Move to the end of the line. - ffoorrwwaarrdd--cchhaarr ((CC--ff)) - Move forward a character. - bbaacckkwwaarrdd--cchhaarr ((CC--bb)) - Move back a character. - ffoorrwwaarrdd--wwoorrdd ((MM--ff)) - Move forward to the end of the next word. Words - are composed of alphanumeric characters (letters - and digits). - bbaacckkwwaarrdd--wwoorrdd ((MM--bb)) - Move back to the start of this, or the previous, - word. Words are composed of alphanumeric charac- - ters (letters and digits). - cclleeaarr--ssccrreeeenn ((CC--ll)) - Clear the screen leaving the current line at the - top of the screen. With an argument, refresh the - current line without clearing the screen. - - - -GNU 1998 Feb 19 7 - - - - - -READLINE(3) READLINE(3) - - - rreeddrraaww--ccuurrrreenntt--lliinnee - Refresh the current line. - - CCoommmmaannddss ffoorr MMaanniippuullaattiinngg tthhee HHiissttoorryy - aacccceepptt--lliinnee ((NNeewwlliinnee,, RReettuurrnn)) - Accept the line regardless of where the cursor is. - If this line is non-empty, add it to the history - list. If the line is a modified history line, then - restore the history line to its original state. - pprreevviioouuss--hhiissttoorryy ((CC--pp)) - Fetch the previous command from the history list, - moving back in the list. - nneexxtt--hhiissttoorryy ((CC--nn)) - Fetch the next command from the history list, mov- - ing forward in the list. - bbeeggiinnnniinngg--ooff--hhiissttoorryy ((MM--<<)) - Move to the first line in the history. - eenndd--ooff--hhiissttoorryy ((MM-->>)) - Move to the end of the input history, i.e., the - line currently being entered. - rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((CC--rr)) - Search backward starting at the current line and - moving `up' through the history as necessary. This - is an incremental search. - ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((CC--ss)) - Search forward starting at the current line and - moving `down' through the history as necessary. - This is an incremental search. - nnoonn--iinnccrreemmeennttaall--rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((MM--pp)) - Search backward through the history starting at the - current line using a non-incremental search for a - string supplied by the user. - nnoonn--iinnccrreemmeennttaall--ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((MM--nn)) - Search forward through the history using a non- - incremental search for a string supplied by the - user. - hhiissttoorryy--sseeaarrcchh--ffoorrwwaarrdd - Search forward through the history for the string - of characters between the start of the current line - and the current cursor position (the _p_o_i_n_t). This - is a non-incremental search. - hhiissttoorryy--sseeaarrcchh--bbaacckkwwaarrdd - Search backward through the history for the string - of characters between the start of the current line - and the point. This is a non-incremental search. - yyaannkk--nntthh--aarrgg ((MM--CC--yy)) - Insert the first argument to the previous command - (usually the second word on the previous line) at - point (the current cursor position). With an argu- - ment _n, insert the _nth word from the previous com- - mand (the words in the previous command begin with - word 0). A negative argument inserts the _nth word - from the end of the previous command. - - - - -GNU 1998 Feb 19 8 - - - - - -READLINE(3) READLINE(3) - - - yyaannkk--llaasstt--aarrgg ((MM--..,, MM--__)) - Insert the last argument to the previous command - (the last word of the previous history entry). - With an argument, behave exactly like yyaannkk--nntthh--aarrgg. - Successive calls to yyaannkk--llaasstt--aarrgg move back through - the history list, inserting the last argument of - each line in turn. - - CCoommmmaannddss ffoorr CChhaannggiinngg TTeexxtt - ddeelleettee--cchhaarr ((CC--dd)) - Delete the character under the cursor. If point is - at the beginning of the line, there are no charac- - ters in the line, and the last character typed was - not bound to BBddeelleettee--cchhaarr, then return EEOOFF. - bbaacckkwwaarrdd--ddeelleettee--cchhaarr ((RRuubboouutt)) - Delete the character behind the cursor. When given - a numeric argument, save the deleted text on the - kill ring. - qquuootteedd--iinnsseerrtt ((CC--qq,, CC--vv)) - Add the next character that you type to the line - verbatim. This is how to insert characters like - CC--qq, for example. - ttaabb--iinnsseerrtt ((MM--TTAABB)) - Insert a tab character. - sseellff--iinnsseerrtt ((aa,, bb,, AA,, 11,, !!,, ......)) - Insert the character typed. - ttrraannssppoossee--cchhaarrss ((CC--tt)) - Drag the character before point forward over the - character at point. Point moves forward as well. - If point is at the end of the line, then transpose - the two characters before point. Negative argu- - ments don't work. - ttrraannssppoossee--wwoorrddss ((MM--tt)) - Drag the word behind the cursor past the word in - front of the cursor moving the cursor over that - word as well. - uuppccaassee--wwoorrdd ((MM--uu)) - Uppercase the current (or following) word. With a - negative argument, uppercase the previous word, but - do not move point. - ddoowwnnccaassee--wwoorrdd ((MM--ll)) - Lowercase the current (or following) word. With a - negative argument, lowercase the previous word, but - do not move point. - ccaappiittaalliizzee--wwoorrdd ((MM--cc)) - Capitalize the current (or following) word. With a - negative argument, capitalize the previous word, - but do not move point. - - KKiilllliinngg aanndd YYaannkkiinngg - kkiillll--lliinnee ((CC--kk)) - Kill the text from the current cursor position to - the end of the line. - - - - -GNU 1998 Feb 19 9 - - - - - -READLINE(3) READLINE(3) - - - bbaacckkwwaarrdd--kkiillll--lliinnee ((CC--xx RRuubboouutt)) - Kill backward to the beginning of the line. - uunniixx--lliinnee--ddiissccaarrdd ((CC--uu)) - Kill backward from point to the beginning of the - line. The killed text is saved on the kill-ring. - kkiillll--wwhhoollee--lliinnee - Kill all characters on the current line, no matter - where the cursor is. - kkiillll--wwoorrdd ((MM--dd)) - Kill from the cursor to the end of the current - word, or if between words, to the end of the next - word. Word boundaries are the same as those used - by ffoorrwwaarrdd--wwoorrdd. - bbaacckkwwaarrdd--kkiillll--wwoorrdd ((MM--RRuubboouutt)) - Kill the word behind the cursor. Word boundaries - are the same as those used by bbaacckkwwaarrdd--wwoorrdd. - uunniixx--wwoorrdd--rruubboouutt ((CC--ww)) - Kill the word behind the cursor, using white space - as a word boundary. The word boundaries are dif- - ferent from bbaacckkwwaarrdd--kkiillll--wwoorrdd. - ddeelleettee--hhoorriizzoonnttaall--ssppaaccee ((MM--\\)) - Delete all spaces and tabs around point. - kkiillll--rreeggiioonn - Kill the text between the point and _m_a_r_k (saved - cursor position). This text is referred to as the - _r_e_g_i_o_n. - ccooppyy--rreeggiioonn--aass--kkiillll - Copy the text in the region to the kill buffer. - ccooppyy--bbaacckkwwaarrdd--wwoorrdd - Copy the word before point to the kill buffer. The - word boundaries are the same as bbaacckkwwaarrdd--wwoorrdd. - ccooppyy--ffoorrwwaarrdd--wwoorrdd - Copy the word following point to the kill buffer. - The word boundaries are the same as ffoorrwwaarrdd--wwoorrdd. - yyaannkk ((CC--yy)) - Yank the top of the kill ring into the buffer at - the cursor. - yyaannkk--ppoopp ((MM--yy)) - Rotate the kill ring, and yank the new top. Only - works following yyaannkk or yyaannkk--ppoopp. - - NNuummeerriicc AArrgguummeennttss - ddiiggiitt--aarrgguummeenntt ((MM--00,, MM--11,, ......,, MM----)) - Add this digit to the argument already accumulat- - ing, or start a new argument. M-- starts a nega- - tive argument. - uunniivveerrssaall--aarrgguummeenntt - This is another way to specify an argument. If - this command is followed by one or more digits, - optionally with a leading minus sign, those digits - define the argument. If the command is followed by - digits, executing uunniivveerrssaall--aarrgguummeenntt again ends the - numeric argument, but is otherwise ignored. As a - special case, if this command is immediately - - - -GNU 1998 Feb 19 10 - - - - - -READLINE(3) READLINE(3) - - - followed by a character that is neither a digit or - minus sign, the argument count for the next command - is multiplied by four. The argument count is ini- - tially one, so executing this function the first - time makes the argument count four, a second time - makes the argument count sixteen, and so on. - - CCoommpplleettiinngg - ccoommpplleettee ((TTAABB)) - Attempt to perform completion on the text before - point. The actual completion performed is applica- - tion-specific. BBaasshh, for instance, attempts com- - pletion treating the text as a variable (if the - text begins with $$), username (if the text begins - with ~~), hostname (if the text begins with @@), or - command (including aliases and functions) in turn. - If none of these produces a match, filename comple- - tion is attempted. GGddbb, on the other hand, allows - completion of program functions and variables, and - only attempts filename completion under certain - circumstances. - ppoossssiibbllee--ccoommpplleettiioonnss ((MM--??)) - List the possible completions of the text before - point. - iinnsseerrtt--ccoommpplleettiioonnss ((MM--**)) - Insert all completions of the text before point - that would have been generated by ppoossssiibbllee--ccoommppllee-- - ttiioonnss. - mmeennuu--ccoommpplleettee - Similar to ccoommpplleettee, but replaces the word to be - completed with a single match from the list of pos- - sible completions. Repeated execution of mmeennuu--ccoomm-- - pplleettee steps through the list of possible comple- - tions, inserting each match in turn. At the end of - the list of completions, the bell is rung and the - original text is restored. An argument of _n moves - _n positions forward in the list of matches; a nega- - tive argument may be used to move backward through - the list. This command is intended to be bound to - TTAABB, but is unbound by default. - - KKeeyybbooaarrdd MMaaccrrooss - ssttaarrtt--kkbbdd--mmaaccrroo ((CC--xx (()) - Begin saving the characters typed into the current - keyboard macro. - eenndd--kkbbdd--mmaaccrroo ((CC--xx )))) - Stop saving the characters typed into the current - keyboard macro and store the definition. - ccaallll--llaasstt--kkbbdd--mmaaccrroo ((CC--xx ee)) - Re-execute the last keyboard macro defined, by mak- - ing the characters in the macro appear as if typed - at the keyboard. - - - - - -GNU 1998 Feb 19 11 - - - - - -READLINE(3) READLINE(3) - - - MMiisscceellllaanneeoouuss - rree--rreeaadd--iinniitt--ffiillee ((CC--xx CC--rr)) - Read in the contents of the _i_n_p_u_t_r_c file, and - incorporate any bindings or variable assignments - found there. - aabboorrtt ((CC--gg)) - Abort the current editing command and ring the ter- - minal's bell (subject to the setting of - bbeellll--ssttyyllee). - ddoo--uuppppeerrccaassee--vveerrssiioonn ((MM--aa,, MM--bb,, MM--_x,, ......)) - If the metafied character _x is lowercase, run the - command that is bound to the corresponding upper- - case character. - pprreeffiixx--mmeettaa ((EESSCC)) - Metafy the next character typed. EESSCC ff is equiva- - lent to MMeettaa--ff. - uunnddoo ((CC--__,, CC--xx CC--uu)) - Incremental undo, separately remembered for each - line. - rreevveerrtt--lliinnee ((MM--rr)) - Undo all changes made to this line. This is like - executing the uunnddoo command enough times to return - the line to its initial state. - ttiillddee--eexxppaanndd ((MM--~~)) - Perform tilde expansion on the current word. - sseett--mmaarrkk ((CC--@@,, MM--<<ssppaaccee>>)) - Set the mark to the current point. If a numeric - argument is supplied, the mark is set to that posi- - tion. - eexxcchhaannggee--ppooiinntt--aanndd--mmaarrkk ((CC--xx CC--xx)) - Swap the point with the mark. The current cursor - position is set to the saved position, and the old - cursor position is saved as the mark. - cchhaarraacctteerr--sseeaarrcchh ((CC--]])) - A character is read and point is moved to the next - occurrence of that character. A negative count - searches for previous occurrences. - cchhaarraacctteerr--sseeaarrcchh--bbaacckkwwaarrdd ((MM--CC--]])) - A character is read and point is moved to the pre- - vious occurrence of that character. A negative - count searches for subsequent occurrences. - iinnsseerrtt--ccoommmmeenntt ((MM--##)) - The value of the readline ccoommmmeenntt--bbeeggiinn variable is - inserted at the beginning of the current line, and - the line is accepted as if a newline had been - typed. This makes the current line a shell com- - ment. - dduummpp--ffuunnccttiioonnss - Print all of the functions and their key bindings - to the readline output stream. If a numeric argu- - ment is supplied, the output is formatted in such a - way that it can be made part of an _i_n_p_u_t_r_c file. - dduummpp--vvaarriiaabblleess - Print all of the settable variables and their - - - -GNU 1998 Feb 19 12 - - - - - -READLINE(3) READLINE(3) - - - values to the readline output stream. If a numeric - argument is supplied, the output is formatted in - such a way that it can be made part of an _i_n_p_u_t_r_c - file. - dduummpp--mmaaccrrooss - Print all of the readline key sequences bound to - macros and the strings they ouput. If a numeric - argument is supplied, the output is formatted in - such a way that it can be made part of an _i_n_p_u_t_r_c - file. - eemmaaccss--eeddiittiinngg--mmooddee ((CC--ee)) - When in vvii editing mode, this causes a switch to - eemmaaccss editing mode. - vvii--eeddiittiinngg--mmooddee ((MM--CC--jj)) - When in eemmaaccss editing mode, this causes a switch to - vvii editing mode. - -DDEEFFAAUULLTT KKEEYY BBIINNDDIINNGGSS - The following is a list of the default emacs and vi bind- - ings. Characters with the 8th bit set are written as - M-<character>, and are referred to as _m_e_t_a_f_i_e_d characters. - The printable ASCII characters not mentioned in the list - of emacs standard bindings are bound to the _s_e_l_f_-_i_n_s_e_r_t - function, which just inserts the given character into the - input line. In vi insertion mode, all characters not - specifically mentioned are bound to _s_e_l_f_-_i_n_s_e_r_t. Charac- - ters assigned to signal generation by _s_t_t_y(1) or the ter- - minal driver, such as C-Z or C-C, retain that function. - Upper and lower case _m_e_t_a_f_i_e_d characters are bound to the - same function in the emacs mode meta keymap. The remain- - ing characters are unbound, which causes readline to ring - the bell (subject to the setting of the bbeellll--ssttyyllee vari- - able). - - EEmmaaccss MMooddee - Emacs Standard bindings - - "C-@" set-mark - "C-A" beginning-of-line - "C-B" backward-char - "C-D" delete-char - "C-E" end-of-line - "C-F" forward-char - "C-G" abort - "C-H" backward-delete-char - "C-I" complete - "C-J" accept-line - "C-K" kill-line - "C-L" clear-screen - "C-M" accept-line - "C-N" next-history - "C-P" previous-history - "C-Q" quoted-insert - "C-R" reverse-search-history - - - -GNU 1998 Feb 19 13 - - - - - -READLINE(3) READLINE(3) - - - "C-S" forward-search-history - "C-T" transpose-chars - "C-U" unix-line-discard - "C-V" quoted-insert - "C-W" unix-word-rubout - "C-Y" yank - "C-]" character-search - "C-_" undo - " " to "/" self-insert - "0" to "9" self-insert - ":" to "~" self-insert - "C-?" backward-delete-char - - Emacs Meta bindings - - "M-C-G" abort - "M-C-H" backward-kill-word - "M-C-I" tab-insert - "M-C-J" vi-editing-mode - "M-C-M" vi-editing-mode - "M-C-R" revert-line - "M-C-Y" yank-nth-arg - "M-C-[" complete - "M-C-]" character-search-backward - "M-space" set-mark - "M-#" insert-comment - "M-&" tilde-expand - "M-*" insert-completions - "M--" digit-argument - "M-." yank-last-arg - "M-0" digit-argument - "M-1" digit-argument - "M-2" digit-argument - "M-3" digit-argument - "M-4" digit-argument - "M-5" digit-argument - "M-6" digit-argument - "M-7" digit-argument - "M-8" digit-argument - "M-9" digit-argument - "M-<" beginning-of-history - "M-=" possible-completions - "M->" end-of-history - "M-?" possible-completions - "M-B" backward-word - "M-C" capitalize-word - "M-D" kill-word - "M-F" forward-word - "M-L" downcase-word - "M-N" non-incremental-forward-search-history - "M-P" non-incremental-reverse-search-history - "M-R" revert-line - "M-T" transpose-words - "M-U" upcase-word - - - -GNU 1998 Feb 19 14 - - - - - -READLINE(3) READLINE(3) - - - "M-Y" yank-pop - "M-\" delete-horizontal-space - "M-~" tilde-expand - "M-C-?" backward-delete-word - "M-_" yank-last-arg - - Emacs Control-X bindings - - "C-XC-G" abort - "C-XC-R" re-read-init-file - "C-XC-U" undo - "C-XC-X" exchange-point-and-mark - "C-X(" start-kbd-macro - "C-X)" end-kbd-macro - "C-XE" call-last-kbd-macro - "C-XC-?" backward-kill-line - - - VVII MMooddee bbiinnddiinnggss - VI Insert Mode functions - - "C-D" vi-eof-maybe - "C-H" backward-delete-char - "C-I" complete - "C-J" accept-line - "C-M" accept-line - "C-R" reverse-search-history - "C-S" forward-search-history - "C-T" transpose-chars - "C-U" unix-line-discard - "C-V" quoted-insert - "C-W" unix-word-rubout - "C-Y" yank - "C-[" vi-movement-mode - "C-_" undo - " " to "~" self-insert - "C-?" backward-delete-char - - VI Command Mode functions - - "C-D" vi-eof-maybe - "C-E" emacs-editing-mode - "C-G" abort - "C-H" backward-char - "C-J" accept-line - "C-K" kill-line - "C-L" clear-screen - "C-M" accept-line - "C-N" next-history - "C-P" previous-history - "C-Q" quoted-insert - "C-R" reverse-search-history - "C-S" forward-search-history - "C-T" transpose-chars - - - -GNU 1998 Feb 19 15 - - - - - -READLINE(3) READLINE(3) - - - "C-U" unix-line-discard - "C-V" quoted-insert - "C-W" unix-word-rubout - "C-Y" yank - " " forward-char - "#" insert-comment - "$" end-of-line - "%" vi-match - "&" vi-tilde-expand - "*" vi-complete - "+" next-history - "," vi-char-search - "-" previous-history - "." vi-redo - "/" vi-search - "0" beginning-of-line - "1" to "9" vi-arg-digit - ";" vi-char-search - "=" vi-complete - "?" vi-search - "A" vi-append-eol - "B" vi-prev-word - "C" vi-change-to - "D" vi-delete-to - "E" vi-end-word - "F" vi-char-search - "G" vi-fetch-history - "I" vi-insert-beg - "N" vi-search-again - "P" vi-put - "R" vi-replace - "S" vi-subst - "T" vi-char-search - "U" revert-line - "W" vi-next-word - "X" backward-delete-char - "Y" vi-yank-to - "\" vi-complete - "^" vi-first-print - "_" vi-yank-arg - "`" vi-goto-mark - "a" vi-append-mode - "b" vi-prev-word - "c" vi-change-to - "d" vi-delete-to - "e" vi-end-word - "f" vi-char-search - "h" backward-char - "i" vi-insertion-mode - "j" next-history - "k" prev-history - "l" forward-char - "m" vi-set-mark - "n" vi-search-again - - - -GNU 1998 Feb 19 16 - - - - - -READLINE(3) READLINE(3) - - - "p" vi-put - "r" vi-change-char - "s" vi-subst - "t" vi-char-search - "u" undo - "w" vi-next-word - "x" vi-delete - "y" vi-yank-to - "|" vi-column - "~" vi-change-case - -SSEEEE AALLSSOO - _T_h_e _G_n_u _R_e_a_d_l_i_n_e _L_i_b_r_a_r_y, Brian Fox and Chet Ramey - _T_h_e _G_n_u _H_i_s_t_o_r_y _L_i_b_r_a_r_y, Brian Fox and Chet Ramey - _b_a_s_h(1) - -FFIILLEESS - _~_/_._i_n_p_u_t_r_c - Individual rreeaaddlliinnee initialization file - -AAUUTTHHOORRSS - Brian Fox, Free Software Foundation (primary author) - bfox@ai.MIT.Edu - - Chet Ramey, Case Western Reserve University - chet@ins.CWRU.Edu - -BBUUGG RREEPPOORRTTSS - If you find a bug in rreeaaddlliinnee,, 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 rreeaaddlliinnee - library that you have. - - Once you have determined that a bug actually exists, mail - a bug report to _b_u_g_-_r_e_a_d_l_i_n_e@_g_n_u_._o_r_g. If you have a fix, - you are welcome to mail that as well! Suggestions and - `philosophical' bug reports may be mailed to _b_u_g_-_r_e_a_d_- - _l_i_n_e@_g_n_u_._o_r_g or posted to the Usenet newsgroup - ggnnuu..bbaasshh..bbuugg. - - Comments and bug reports concerning this manual page - should be directed to _c_h_e_t_@_i_n_s_._C_W_R_U_._E_d_u. - -BBUUGGSS - It's too big and too slow. - - - - - - - - - - - - -GNU 1998 Feb 19 17 - - diff --git a/readline/doc/rlman.texinfo b/readline/doc/rlman.texinfo deleted file mode 100644 index dd6478a..0000000 --- a/readline/doc/rlman.texinfo +++ /dev/null @@ -1,115 +0,0 @@ -\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 - -@ignore -last change: Thu Apr 2 14:39:03 EST 1998 -@end ignore - -@set EDITION 2.2 -@set VERSION 2.2 -@set UPDATED 2 April 1998 -@set UPDATE-MONTH April 1998 - -@dircategory Libraries -@direntry -* Readline: (readline). The GNU readline library API -@end direntry - -@ifinfo -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, 1991, 1993, 1996, 1998 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 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 @* -675 Massachusetts Avenue, @* -Cambridge, MA 02139 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 Foundation. - -@vskip 0pt plus 1filll -Copyright @copyright{} 1989, 1991 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 diff --git a/readline/doc/rltech.texinfo b/readline/doc/rltech.texinfo deleted file mode 100644 index bce5087..0000000 --- a/readline/doc/rltech.texinfo +++ /dev/null @@ -1,1548 +0,0 @@ -@comment %**start of header (This is for running Texinfo on a region.) -@setfilename rltech.info -@comment %**end of header (This is for running Texinfo on a region.) -@setchapternewpage odd - -@ifinfo -This document describes the GNU Readline Library, a utility for aiding -in the consitency of user interface across discrete programs that need -to provide a command line interface. - -Copyright (C) 1988, 1994, 1996 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 Foundation. -@end ifinfo - -@node Programming with GNU Readline -@chapter Programming with GNU Readline - -This chapter describes the interface between the GNU Readline Library and -other programs. If you are a programmer, and you wish to include the -features found in GNU Readline -such as completion, line editing, and interactive history manipulation -in your own programs, this section is for you. - -@menu -* Basic Behavior:: Using the default behavior of Readline. -* Custom Functions:: Adding your own functions to Readline. -* Readline Variables:: Variables accessible to custom - functions. -* Readline Convenience Functions:: Functions which Readline supplies to - aid in writing your own -* Custom Completers:: Supplanting or supplementing Readline's - completion functions. -@end menu - -@node Basic Behavior -@section Basic Behavior - -Many programs provide a command line interface, such as @code{mail}, -@code{ftp}, and @code{sh}. For such programs, the default behaviour of -Readline is sufficient. This section describes how to use Readline in -the simplest way possible, perhaps to replace calls in your code to -@code{gets()} or @code{fgets ()}. - -@findex readline -@cindex readline, function -The function @code{readline ()} prints a prompt and then reads and returns -a single line of text from the user. The line @code{readline} -returns is allocated with @code{malloc ()}; you should @code{free ()} -the line when you are done with it. The declaration for @code{readline} -in ANSI C is - -@example -@code{char *readline (char *@var{prompt});} -@end example - -@noindent -So, one might say -@example -@code{char *line = readline ("Enter a line: ");} -@end example -@noindent -in order to read a line of text from the user. -The line returned has the final newline removed, so only the -text remains. - -If @code{readline} encounters an @code{EOF} while reading the line, and the -line is empty at that point, then @code{(char *)NULL} is returned. -Otherwise, the line is ended just as if a newline had been typed. - -If you want the user to be able to get at the line later, (with -@key{C-p} for example), you must call @code{add_history ()} to save the -line away in a @dfn{history} list of such lines. - -@example -@code{add_history (line)}; -@end example - -@noindent -For full details on the GNU History Library, see the associated manual. - -It is preferable to avoid saving empty lines on the history list, since -users rarely have a burning need to reuse a blank line. Here is -a function which usefully replaces the standard @code{gets ()} library -function, and has the advantage of no static buffer to overflow: - -@example -/* 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); -@} -@end example - -This function gives the user the default behaviour of @key{TAB} -completion: completion on file names. If you do not want Readline to -complete on filenames, you can change the binding of the @key{TAB} key -with @code{rl_bind_key ()}. - -@example -@code{int rl_bind_key (int @var{key}, int (*@var{function})());} -@end example - -@code{rl_bind_key ()} takes two arguments: @var{key} is the character that -you want to bind, and @var{function} is the address of the function to -call when @var{key} is pressed. Binding @key{TAB} to @code{rl_insert ()} -makes @key{TAB} insert itself. -@code{rl_bind_key ()} returns non-zero if @var{key} is not a valid -ASCII character code (between 0 and 255). - -Thus, to disable the default @key{TAB} behavior, the following suffices: -@example -@code{rl_bind_key ('\t', rl_insert);} -@end example - -This code should be executed once at the start of your program; you -might write a function called @code{initialize_readline ()} which -performs this and other desired initializations, such as installing -custom completers (@pxref{Custom Completers}). - -@node Custom Functions -@section Custom Functions - -Readline provides many functions for manipulating the text of -the line, but it isn't possible to anticipate the needs of all -programs. This section describes the various functions and variables -defined within the Readline library which allow a user program to add -customized functionality to Readline. - -@menu -* The Function Type:: C declarations to make code readable. -* Function Writing:: Variables and calling conventions. -@end menu - -@node The Function Type -@subsection The Function Type - -For readabilty, we declare a new type of object, called -@dfn{Function}. A @code{Function} is a C function which -returns an @code{int}. The type declaration for @code{Function} is: - -@noindent -@code{typedef int Function ();} - -The reason for declaring this new type is to make it easier to write -code describing pointers to C functions. Let us say we had a variable -called @var{func} which was a pointer to a function. Instead of the -classic C declaration - -@code{int (*)()func;} - -@noindent -we may write - -@code{Function *func;} - -@noindent -Similarly, there are - -@example -typedef void VFunction (); -typedef char *CPFunction (); @r{and} -typedef char **CPPFunction (); -@end example - -@noindent -for functions returning no value, @code{pointer to char}, and -@code{pointer to pointer to char}, respectively. - -@node Function Writing -@subsection Writing a New Function - -In order to write new functions for Readline, you need to know the -calling conventions for keyboard-invoked functions, and the names of the -variables that describe the current state of the line read so far. - -The calling sequence for a command @code{foo} looks like - -@example -@code{foo (int count, int key)} -@end example - -@noindent -where @var{count} is the numeric argument (or 1 if defaulted) and -@var{key} is the key that invoked this function. - -It is completely up to the function as to what should be done with the -numeric argument. Some functions use it as a repeat count, some -as a flag, and others to choose alternate behavior (refreshing the current -line as opposed to refreshing the screen, for example). Some choose to -ignore it. In general, if a -function uses the numeric argument as a repeat count, it should be able -to do something useful with both negative and positive arguments. -At the very least, it should be aware that it can be passed a -negative argument. - -@node Readline Variables -@section Readline Variables - -These variables are available to function writers. - -@deftypevar {char *} rl_line_buffer -This is the line gathered so far. You are welcome to modify the -contents of the line, but see @ref{Allowing Undoing}. -@end deftypevar - -@deftypevar int rl_point -The offset of the current cursor position in @code{rl_line_buffer} -(the @emph{point}). -@end deftypevar - -@deftypevar int rl_end -The number of characters present in @code{rl_line_buffer}. When -@code{rl_point} is at the end of the line, @code{rl_point} and -@code{rl_end} are equal. -@end deftypevar - -@deftypevar int rl_mark -The mark (saved position) in the current line. If set, the mark -and point define a @emph{region}. -@end deftypevar - -@deftypevar int rl_done -Setting this to a non-zero value causes Readline to return the current -line immediately. -@end deftypevar - -@deftypevar int rl_pending_input -Setting this to a value makes it the next keystroke read. This is a -way to stuff a single character into the input stream. -@end deftypevar - -@deftypevar {char *} rl_prompt -The prompt Readline uses. This is set from the argument to -@code{readline ()}, and should not be assigned to directly. -@end deftypevar - -@deftypevar {char *} rl_library_version -The version number of this revision of the library. -@end deftypevar - -@deftypevar {char *} rl_terminal_name -The terminal type, used for initialization. -@end deftypevar - -@deftypevar {char *} rl_readline_name -This variable is set to a unique name by each application using Readline. -The value allows conditional parsing of the inputrc file -(@pxref{Conditional Init Constructs}). -@end deftypevar - -@deftypevar {FILE *} rl_instream -The stdio stream from which Readline reads input. -@end deftypevar - -@deftypevar {FILE *} rl_outstream -The stdio stream to which Readline performs output. -@end deftypevar - -@deftypevar {Function *} rl_startup_hook -If non-zero, this is the address of a function to call just -before @code{readline} prints the first prompt. -@end deftypevar - -@deftypevar {Function *} rl_event_hook -If non-zero, this is the address of a function to call periodically -when readline is waiting for terminal input. -@end deftypevar - -@deftypevar {Function *} rl_getc_function -If non-zero, @code{readline} will call indirectly through this pointer -to get a character from the input stream. By default, it is set to -@code{rl_getc}, the default @code{readline} character input function -(@pxref{Utility Functions}). -@end deftypevar - -@deftypevar {VFunction *} rl_redisplay_function -If non-zero, @code{readline} will call indirectly through this pointer -to update the display with the current contents of the editing buffer. -By default, it is set to @code{rl_redisplay}, the default @code{readline} -redisplay function (@pxref{Redisplay}). -@end deftypevar - -@deftypevar {Keymap} rl_executing_keymap -This variable is set to the keymap (@pxref{Keymaps}) in which the -currently executing readline function was found. -@end deftypevar - -@deftypevar {Keymap} rl_binding_keymap -This variable is set to the keymap (@pxref{Keymaps}) in which the -last key binding occurred. -@end deftypevar - -@node Readline Convenience Functions -@section Readline Convenience Functions - -@menu -* Function Naming:: How to give a function you write a name. -* Keymaps:: Making keymaps. -* Binding Keys:: Changing Keymaps. -* Associating Function Names and Bindings:: Translate function names to - key sequences. -* Allowing Undoing:: How to make your functions undoable. -* Redisplay:: Functions to control line display. -* Modifying Text:: Functions to modify @code{rl_line_buffer}. -* Utility Functions:: Generally useful functions and hooks. -* Alternate Interface:: Using Readline in a `callback' fashion. -@end menu - -@node Function Naming -@subsection Naming a Function - -The user can dynamically change the bindings of keys while using -Readline. This is done by representing the function with a descriptive -name. The user is able to type the descriptive name when referring to -the function. Thus, in an init file, one might find - -@example -Meta-Rubout: backward-kill-word -@end example - -This binds the keystroke @key{Meta-Rubout} to the function -@emph{descriptively} named @code{backward-kill-word}. You, as the -programmer, should bind the functions you write to descriptive names as -well. Readline provides a function for doing that: - -@deftypefun int rl_add_defun (char *name, Function *function, int key) -Add @var{name} to the list of named functions. Make @var{function} be -the function that gets called. If @var{key} is not -1, then bind it to -@var{function} using @code{rl_bind_key ()}. -@end deftypefun - -Using this function alone is sufficient for most applications. It is -the recommended way to add a few functions to the default functions that -Readline has built in. If you need to do something other -than adding a function to Readline, you may need to use the -underlying functions described below. - -@node Keymaps -@subsection Selecting a Keymap - -Key bindings take place on a @dfn{keymap}. The keymap is the -association between the keys that the user types and the functions that -get run. You can make your own keymaps, copy existing keymaps, and tell -Readline which keymap to use. - -@deftypefun Keymap rl_make_bare_keymap () -Returns a new, empty keymap. The space for the keymap is allocated with -@code{malloc ()}; you should @code{free ()} it when you are done. -@end deftypefun - -@deftypefun Keymap rl_copy_keymap (Keymap map) -Return a new keymap which is a copy of @var{map}. -@end deftypefun - -@deftypefun Keymap rl_make_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. -@end deftypefun - -@deftypefun void rl_discard_keymap (Keymap keymap) -Free the storage associated with @var{keymap}. -@end deftypefun - -Readline has several internal keymaps. These functions allow you to -change which keymap is active. - -@deftypefun Keymap rl_get_keymap () -Returns the currently active keymap. -@end deftypefun - -@deftypefun void rl_set_keymap (Keymap keymap) -Makes @var{keymap} the currently active keymap. -@end deftypefun - -@deftypefun Keymap rl_get_keymap_by_name (char *name) -Return the keymap matching @var{name}. @var{name} is one which would -be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}). -@end deftypefun - -@deftypefun {char *} rl_get_keymap_name (Keymap keymap) -Return the name matching @var{keymap}. @var{name} is one which would -be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}). -@end deftypefun - -@node Binding Keys -@subsection Binding Keys - -You associate keys with functions through the keymap. Readline has -several internal keymaps: @code{emacs_standard_keymap}, -@code{emacs_meta_keymap}, @code{emacs_ctlx_keymap}, -@code{vi_movement_keymap}, and @code{vi_insertion_keymap}. -@code{emacs_standard_keymap} is the default, and the examples in -this manual assume that. - -These functions manage key bindings. - -@deftypefun int rl_bind_key (int key, Function *function) -Binds @var{key} to @var{function} in the currently active keymap. -Returns non-zero in the case of an invalid @var{key}. -@end deftypefun - -@deftypefun int rl_bind_key_in_map (int key, Function *function, Keymap map) -Bind @var{key} to @var{function} in @var{map}. Returns non-zero in the case -of an invalid @var{key}. -@end deftypefun - -@deftypefun int rl_unbind_key (int key) -Bind @var{key} to the null function in the currently active keymap. -Returns non-zero in case of error. -@end deftypefun - -@deftypefun int rl_unbind_key_in_map (int key, Keymap map) -Bind @var{key} to the null function in @var{map}. -Returns non-zero in case of error. -@end deftypefun - -@deftypefun int rl_unbind_function_in_map (Function *function, Keymap map) -Unbind all keys that execute @var{function} in @var{map}. -@end deftypefun - -@deftypefun int rl_unbind_command_in_map (char *command, Keymap map) -Unbind all keys that are bound to @var{command} in @var{map}. -@end deftypefun - -@deftypefun int rl_generic_bind (int type, char *keyseq, char *data, Keymap map) -Bind the key sequence represented by the string @var{keyseq} to the arbitrary -pointer @var{data}. @var{type} says what kind of data is pointed to by -@var{data}; this can be a function (@code{ISFUNC}), a macro -(@code{ISMACR}), or a keymap (@code{ISKMAP}). This makes new keymaps as -necessary. The initial keymap in which to do bindings is @var{map}. -@end deftypefun - -@deftypefun int rl_parse_and_bind (char *line) -Parse @var{line} as if it had been read from the @code{inputrc} file and -perform any key bindings and variable assignments found -(@pxref{Readline Init File}). -@end deftypefun - -@deftypefun int rl_read_init_file (char *filename) -Read keybindings and variable assignments from @var{filename} -(@pxref{Readline Init File}). -@end deftypefun - -@node Associating Function Names and Bindings -@subsection Associating Function Names and Bindings - -These functions allow you to find out what keys invoke named functions -and the functions invoked by a particular key sequence. - -@deftypefun {Function *} rl_named_function (char *name) -Return the function with name @var{name}. -@end deftypefun - -@deftypefun {Function *} rl_function_of_keyseq (char *keyseq, Keymap map, int *type) -Return the function invoked by @var{keyseq} in keymap @var{map}. -If @var{map} is NULL, the current keymap is used. If @var{type} is -not NULL, the type of the object is returned in it (one of @code{ISFUNC}, -@code{ISKMAP}, or @code{ISMACR}). -@end deftypefun - -@deftypefun {char **} rl_invoking_keyseqs (Function *function) -Return an array of strings representing the key sequences used to -invoke @var{function} in the current keymap. -@end deftypefun - -@deftypefun {char **} rl_invoking_keyseqs_in_map (Function *function, Keymap map) -Return an array of strings representing the key sequences used to -invoke @var{function} in the keymap @var{map}. -@end deftypefun - -@deftypefun void rl_function_dumper (int readable) -Print the readline function names and the key sequences currently -bound to them to @code{rl_outstream}. If @var{readable} is non-zero, -the list is formatted in such a way that it can be made part of an -@code{inputrc} file and re-read. -@end deftypefun - -@deftypefun void rl_list_funmap_names () -Print the names of all bindable Readline functions to @code{rl_outstream}. -@end deftypefun - -@node Allowing Undoing -@subsection Allowing Undoing - -Supporting the undo command is a painless thing, and makes your -functions much more useful. It is certainly easy to try -something if you know you can undo it. I could use an undo function for -the stock market. - -If your function simply inserts text once, or deletes text once, and -uses @code{rl_insert_text ()} or @code{rl_delete_text ()} to do it, then -undoing is already done for you automatically. - -If you do multiple insertions or multiple deletions, or any combination -of these operations, you should group them together into one operation. -This is done with @code{rl_begin_undo_group ()} and -@code{rl_end_undo_group ()}. - -The types of events that can be undone are: - -@example -enum undo_code @{ UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END @}; -@end example - -Notice that @code{UNDO_DELETE} means to insert some text, and -@code{UNDO_INSERT} means to delete some text. That is, the undo code -tells undo what to undo, not how to undo it. @code{UNDO_BEGIN} and -@code{UNDO_END} are tags added by @code{rl_begin_undo_group ()} and -@code{rl_end_undo_group ()}. - -@deftypefun int rl_begin_undo_group () -Begins saving undo information in a group construct. The undo -information usually comes from calls to @code{rl_insert_text ()} and -@code{rl_delete_text ()}, but could be the result of calls to -@code{rl_add_undo ()}. -@end deftypefun - -@deftypefun int rl_end_undo_group () -Closes the current undo group started with @code{rl_begin_undo_group -()}. There should be one call to @code{rl_end_undo_group ()} -for each call to @code{rl_begin_undo_group ()}. -@end deftypefun - -@deftypefun void rl_add_undo (enum undo_code what, int start, int end, char *text) -Remember how to undo an event (according to @var{what}). The affected -text runs from @var{start} to @var{end}, and encompasses @var{text}. -@end deftypefun - -@deftypefun void free_undo_list () -Free the existing undo list. -@end deftypefun - -@deftypefun int rl_do_undo () -Undo the first thing on the undo list. Returns @code{0} if there was -nothing to undo, non-zero if something was undone. -@end deftypefun - -Finally, if you neither insert nor delete text, but directly modify the -existing text (e.g., change its case), call @code{rl_modifying ()} -once, just before you modify the text. You must supply the indices of -the text range that you are going to modify. - -@deftypefun int rl_modifying (int start, int end) -Tell Readline to save the text between @var{start} and @var{end} as a -single undo unit. It is assumed that you will subsequently modify -that text. -@end deftypefun - -@node Redisplay -@subsection Redisplay - -@deftypefun void rl_redisplay () -Change what's displayed on the screen to reflect the current contents -of @code{rl_line_buffer}. -@end deftypefun - -@deftypefun int rl_forced_update_display () -Force the line to be updated and redisplayed, whether or not -Readline thinks the screen display is correct. -@end deftypefun - -@deftypefun int rl_on_new_line () -Tell the update routines that we have moved onto a new (empty) line, -usually after ouputting a newline. -@end deftypefun - -@deftypefun int rl_reset_line_state () -Reset the display state to a clean state and redisplay the current line -starting on a new line. -@end deftypefun - -@deftypefun int rl_message (va_alist) -The arguments are a string as would be supplied to @code{printf}. The -resulting string is displayed in the @dfn{echo area}. The echo area -is also used to display numeric arguments and search strings. -@end deftypefun - -@deftypefun int rl_clear_message () -Clear the message in the echo area. -@end deftypefun - -@node Modifying Text -@subsection Modifying Text - -@deftypefun int rl_insert_text (char *text) -Insert @var{text} into the line at the current cursor position. -@end deftypefun - -@deftypefun int rl_delete_text (int start, int end) -Delete the text between @var{start} and @var{end} in the current line. -@end deftypefun - -@deftypefun {char *} rl_copy_text (int start, int end) -Return a copy of the text between @var{start} and @var{end} in -the current line. -@end deftypefun - -@deftypefun int rl_kill_text (int start, int end) -Copy the text between @var{start} and @var{end} in the current line -to the kill ring, appending or prepending to the last kill if the -last command was a kill command. The text is deleted. -If @var{start} is less than @var{end}, -the text is appended, otherwise prepended. If the last command was -not a kill, a new kill ring slot is used. -@end deftypefun - -@node Utility Functions -@subsection Utility Functions - -@deftypefun int rl_read_key () -Return the next character available. This handles input inserted into -the input stream via @var{pending input} (@pxref{Readline Variables}) -and @code{rl_stuff_char ()}, macros, and characters read from the keyboard. -@end deftypefun - -@deftypefun int rl_getc (FILE *) -Return the next character available from the keyboard. -@end deftypefun - -@deftypefun int rl_stuff_char (int c) -Insert @var{c} into the Readline input stream. It will be "read" -before Readline attempts to read characters from the terminal with -@code{rl_read_key ()}. -@end deftypefun - -@deftypefun rl_extend_line_buffer (int len) -Ensure that @code{rl_line_buffer} has enough space to hold @var{len} -characters, possibly reallocating it if necessary. -@end deftypefun - -@deftypefun int rl_initialize () -Initialize or re-initialize Readline's internal state. -@end deftypefun - -@deftypefun int rl_reset_terminal (char *terminal_name) -Reinitialize Readline's idea of the terminal settings using -@var{terminal_name} as the terminal type (e.g., @code{vt100}). -@end deftypefun - -@deftypefun int alphabetic (int c) -Return 1 if @var{c} is an alphabetic character. -@end deftypefun - -@deftypefun int numeric (int c) -Return 1 if @var{c} is a numeric character. -@end deftypefun - -@deftypefun int ding () -Ring the terminal bell, obeying the setting of @code{bell-style}. -@end deftypefun - -The following are implemented as macros, defined in @code{chartypes.h}. - -@deftypefun int uppercase_p (int c) -Return 1 if @var{c} is an uppercase alphabetic character. -@end deftypefun - -@deftypefun int lowercase_p (int c) -Return 1 if @var{c} is a lowercase alphabetic character. -@end deftypefun - -@deftypefun int digit_p (int c) -Return 1 if @var{c} is a numeric character. -@end deftypefun - -@deftypefun int to_upper (int c) -If @var{c} is a lowercase alphabetic character, return the corresponding -uppercase character. -@end deftypefun - -@deftypefun int to_lower (int c) -If @var{c} is an uppercase alphabetic character, return the corresponding -lowercase character. -@end deftypefun - -@deftypefun int digit_value (int c) -If @var{c} is a number, return the value it represents. -@end deftypefun - -@node Alternate Interface -@subsection Alternate Interface - -An alternate interface is available to plain @code{readline()}. Some -applications need to interleave keyboard I/O with file, device, or -window system I/O, typically by using a main loop to @code{select()} -on various file descriptors. To accomodate this need, readline can -also be invoked as a `callback' function from an event loop. There -are functions available to make this easy. - -@deftypefun void rl_callback_handler_install (char *prompt, Vfunction *lhandler) -Set up the terminal for readline I/O and display the initial -expanded value of @var{prompt}. Save the value of @var{lhandler} to -use as a callback when a complete line of input has been entered. -@end deftypefun - -@deftypefun void rl_callback_read_char () -Whenever an application determines that keyboard input is available, it -should call @code{rl_callback_read_char()}, which will read the next -character from the current input source. If that character completes the -line, @code{rl_callback_read_char} will invoke the @var{lhandler} -function saved by @code{rl_callback_handler_install} to process the -line. @code{EOF} is indicated by calling @var{lhandler} with a -@code{NULL} line. -@end deftypefun - -@deftypefun void rl_callback_handler_remove () -Restore the terminal to its initial state and remove the line handler. -This may be called from within a callback as well as independently. -@end deftypefun - -@subsection An Example - -Here is a function which changes lowercase characters to their uppercase -equivalents, and uppercase characters to lowercase. If -this function was bound to @samp{M-c}, then typing @samp{M-c} would -change the case of the character under point. Typing @samp{M-1 0 M-c} -would change the case of the following 10 characters, leaving the cursor on -the last character changed. - -@example -/* Invert the case of the COUNT following characters. */ -int -invert_case_line (count, key) - int count, key; -@{ - register int start, end, i; - - start = rl_point; - - if (rl_point >= rl_end) - return (0); - - 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 = 0; - - if (start == end) - return (0); - - if (start > end) - @{ - int temp = start; - start = end; - end = temp; - @} - - /* Tell readline that we are modifying the line, so it will save - the undo information. */ - rl_modifying (start, end); - - for (i = start; i != end; i++) - @{ - if (uppercase_p (rl_line_buffer[i])) - rl_line_buffer[i] = to_lower (rl_line_buffer[i]); - else if (lowercase_p (rl_line_buffer[i])) - rl_line_buffer[i] = to_upper (rl_line_buffer[i]); - @} - /* Move point to on top of the last character changed. */ - rl_point = (direction == 1) ? end - 1 : start; - return (0); -@} -@end example - -@node Custom Completers -@section Custom Completers - -Typically, a program that reads commands from the user has a way of -disambiguating commands and data. If your program is one of these, then -it can provide completion for commands, data, or both. -The following sections describe how your program and Readline -cooperate to provide this service. - -@menu -* How Completing Works:: The logic used to do completion. -* Completion Functions:: Functions provided by Readline. -* Completion Variables:: Variables which control completion. -* A Short Completion Example:: An example of writing completer subroutines. -@end menu - -@node How Completing Works -@subsection How Completing Works - -In order to complete some text, the full list of possible completions -must be available. That is, it is not possible to accurately -expand a partial word without knowing all of the possible words -which make sense in that context. The Readline library provides -the user interface to completion, and two of the most common -completion functions: filename and username. For completing other types -of text, you must write your own completion function. This section -describes exactly what such functions must do, and provides an example. - -There are three major functions used to perform completion: - -@enumerate -@item -The user-interface function @code{rl_complete ()}. This function is -called with the same arguments as other Readline -functions intended for interactive use: @var{count} and -@var{invoking_key}. It isolates the word to be completed and calls -@code{completion_matches ()} to generate a list of possible completions. -It then either lists the possible completions, inserts the possible -completions, or actually performs the -completion, depending on which behavior is desired. - -@item -The internal function @code{completion_matches ()} uses your -@dfn{generator} function to generate the list of possible matches, and -then returns the array of these matches. You should place the address -of your generator function in @code{rl_completion_entry_function}. - -@item -The generator function is called repeatedly from -@code{completion_matches ()}, returning a string each time. The -arguments to the generator function are @var{text} and @var{state}. -@var{text} is the partial word to be completed. @var{state} is zero the -first time the function is called, allowing the generator to perform -any necessary initialization, and a positive non-zero integer for -each subsequent call. When the generator function returns -@code{(char *)NULL} this signals @code{completion_matches ()} that there are -no more possibilities left. Usually the generator function computes the -list of possible completions when @var{state} is zero, and returns them -one at a time on subsequent calls. Each string the generator function -returns as a match must be allocated with @code{malloc()}; Readline -frees the strings when it has finished with them. - -@end enumerate - -@deftypefun int rl_complete (int ignore, int invoking_key) -Complete the word at or before point. You have supplied the function -that does the initial simple matching selection algorithm (see -@code{completion_matches ()}). The default is to do filename completion. -@end deftypefun - -@deftypevar {Function *} rl_completion_entry_function -This is a pointer to the generator function for @code{completion_matches -()}. If the value of @code{rl_completion_entry_function} is -@code{(Function *)NULL} then the default filename generator function, -@code{filename_completion_function ()}, is used. -@end deftypevar - -@node Completion Functions -@subsection Completion Functions - -Here is the complete list of callable completion functions present in -Readline. - -@deftypefun int rl_complete_internal (int what_to_do) -Complete the word at or before point. @var{what_to_do} says what to do -with the completion. A value of @samp{?} means list the possible -completions. @samp{TAB} means do standard completion. @samp{*} means -insert all of the possible completions. @samp{!} means to display -all of the possible completions, if there is more than one, as well as -performing partial completion. -@end deftypefun - -@deftypefun int rl_complete (int ignore, int invoking_key) -Complete the word at or before point. You have supplied the function -that does the initial simple matching selection algorithm (see -@code{completion_matches ()} and @code{rl_completion_entry_function}). -The default is to do filename -completion. This calls @code{rl_complete_internal ()} with an -argument depending on @var{invoking_key}. -@end deftypefun - -@deftypefun int rl_possible_completions (int count, int invoking_key)) -List the possible completions. See description of @code{rl_complete -()}. This calls @code{rl_complete_internal ()} with an argument of -@samp{?}. -@end deftypefun - -@deftypefun int rl_insert_completions (int count, int invoking_key)) -Insert the list of possible completions into the line, deleting the -partially-completed word. See description of @code{rl_complete ()}. -This calls @code{rl_complete_internal ()} with an argument of @samp{*}. -@end deftypefun - -@deftypefun {char **} completion_matches (char *text, CPFunction *entry_func) -Returns an array of @code{(char *)} which is a list of completions for -@var{text}. If there are no completions, returns @code{(char **)NULL}. -The first entry in the returned array is the substitution for @var{text}. -The remaining entries are the possible completions. The array is -terminated with a @code{NULL} pointer. - -@var{entry_func} is a function of two args, and returns a -@code{(char *)}. The first argument is @var{text}. The second is a -state argument; it is zero on the first call, and non-zero on subsequent -calls. @var{entry_func} returns a @code{NULL} pointer to the caller -when there are no more matches. -@end deftypefun - -@deftypefun {char *} filename_completion_function (char *text, int state) -A generator function for filename completion in the general case. Note -that completion in Bash is a little different because of all -the pathnames that must be followed when looking up completions for a -command. The Bash source is a useful reference for writing custom -completion functions. -@end deftypefun - -@deftypefun {char *} username_completion_function (char *text, int state) -A completion generator for usernames. @var{text} contains a partial -username preceded by a random character (usually @samp{~}). As with all -completion generators, @var{state} is zero on the first call and non-zero -for subsequent calls. -@end deftypefun - -@node Completion Variables -@subsection Completion Variables - -@deftypevar {Function *} rl_completion_entry_function -A pointer to the generator function for @code{completion_matches ()}. -@code{NULL} means to use @code{filename_entry_function ()}, the default -filename completer. -@end deftypevar - -@deftypevar {CPPFunction *} rl_attempted_completion_function -A pointer to an alternative function to create matches. -The function is called with @var{text}, @var{start}, and @var{end}. -@var{start} and @var{end} are indices in @code{rl_line_buffer} saying -what the boundaries of @var{text} are. If this function exists and -returns @code{NULL}, or if this variable is set to @code{NULL}, then -@code{rl_complete ()} will call the value of -@code{rl_completion_entry_function} to generate matches, otherwise the -array of strings returned will be used. -@end deftypevar - -@deftypevar {CPFunction *} rl_filename_quoting_function -A pointer to a function that will quote a filename in an application- -specific fashion. This is called if filename completion is being -attempted and one of the characters in @code{rl_filename_quote_characters} -appears in a completed filename. The function is called with -@var{text}, @var{match_type}, and @var{quote_pointer}. The @var{text} -is the filename to be quoted. The @var{match_type} is either -@code{SINGLE_MATCH}, if there is only one completion match, or -@code{MULT_MATCH}. Some functions use this to decide whether or not to -insert a closing quote character. The @var{quote_pointer} is a pointer -to any opening quote character the user typed. Some functions choose -to reset this character. -@end deftypevar - -@deftypevar {CPFunction *} rl_filename_dequoting_function -A pointer to a function that will remove application-specific quoting -characters from a filename before completion is attempted, so those -characters do not interfere with matching the text against names in -the filesystem. It is called with @var{text}, the text of the word -to be dequoted, and @var{quote_char}, which is the quoting character -that delimits the filename (usually @samp{'} or @samp{"}). If -@var{quote_char} is zero, the filename was not in an embedded string. -@end deftypevar - -@deftypevar {Function *} rl_char_is_quoted_p -A pointer to a function to call that determines whether or not a specific -character in the line buffer is quoted, according to whatever quoting -mechanism the program calling readline uses. The function is called with -two arguments: @var{text}, the text of the line, and @var{index}, the -index of the character in the line. It is used to decide whether a -character found in @code{rl_completer_word_break_characters} should be -used to break words for the completer. -@end deftypevar - -@deftypevar int rl_completion_query_items -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. -@end deftypevar - -@deftypevar {char *} rl_basic_word_break_characters -The basic list of characters that signal a break between words for the -completer routine. The default value of this variable is the characters -which break words for completion in Bash, i.e., -@code{" \t\n\"\\'`@@$><=;|&@{("}. -@end deftypevar - -@deftypevar {char *} rl_basic_quote_characters -List of quote characters which can cause a word break. -@end deftypevar - -@deftypevar {char *} rl_completer_word_break_characters -The list of characters that signal a break between words for -@code{rl_complete_internal ()}. The default list is the value of -@code{rl_basic_word_break_characters}. -@end deftypevar - -@deftypevar {char *} rl_completer_quote_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 -@code{rl_completer_word_break_characters} are treated as any other character, -unless they also appear within this list. -@end deftypevar - -@deftypevar {char *} rl_filename_quote_characters -A list of characters that cause a filename to be quoted by the completer -when they appear in a completed filename. The default is the null string. -@end deftypevar - -@deftypevar {char *} rl_special_prefixes -The list of characters that are word break characters, but should be -left in @var{text} when it is passed to the completion function. -Programs can use this to help determine what kind of completing to do. -For instance, Bash sets this variable to "$@@" so that it can complete -shell variables and hostnames. -@end deftypevar - -@deftypevar {int} rl_completion_append_character -When a single completion alternative matches at the end of the command -line, this character is appended to the inserted completion text. The -default is a space character (@samp{ }). Setting this to the null -character (@samp{\0}) prevents anything being appended automatically. -This can be changed in custom completion functions to -provide the ``most sensible word separator character'' according to -an application-specific command line syntax specification. -@end deftypevar - -@deftypevar int rl_ignore_completion_duplicates -If non-zero, then disallow duplicates in the matches. Default is 1. -@end deftypevar - -@deftypevar int rl_filename_completion_desired -Non-zero means that the results of the matches are to be treated as -filenames. This is @emph{always} zero on entry, and can only be changed -within a completion entry generator function. If it is set to a non-zero -value, directory names have a slash appended and Readline attempts to -quote completed filenames if they contain any embedded word break -characters. -@end deftypevar - -@deftypevar int rl_filename_quoting_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 -completed filename contains any characters in -@code{rl_filename_quote_chars}. This is @emph{always} non-zero -on entry, and can only be changed within a completion entry generator -function. The quoting is effected via a call to the function pointed to -by @code{rl_filename_quoting_function}. -@end deftypevar - -@deftypevar int rl_inhibit_completion -If this variable is non-zero, completion is inhibit<ed. The completion -character will be inserted as any other bound to @code{self-insert}. -@end deftypevar - -@deftypevar {Function *} rl_ignore_some_completions_function -This function, if defined, is called by the completer when real filename -completion is done, after all the matching names have been generated. -It is passed a @code{NULL} terminated array of matches. -The first element (@code{matches[0]}) is the -maximal substring common to all matches. This function can -re-arrange the list of matches as required, but each element deleted -from the array must be freed. -@end deftypevar - -@deftypevar {Function *} rl_directory_completion_hook -This function, if defined, is allowed to modify the directory portion -of filenames Readline completes. It is called with the address of a -string (the current directory name) as an argument. It could be used -to expand symbolic links or shell variables in pathnames. -@end deftypevar - -@node A Short Completion Example -@subsection A Short Completion Example - -Here is a small application demonstrating the use of the GNU Readline -library. It is called @code{fileman}, and the source code resides in -@file{examples/fileman.c}. This sample application provides -completion of command names, line editing features, and access to the -history list. - -@page -@smallexample -/* 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. */ - -#include <stdio.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/stat.h> -#include <sys/errno.h> - -#include <readline/readline.h> -#include <readline/history.h> - -extern char *getwd (); -extern char *xmalloc (); - -/* The names of functions that actually do the manipulation. */ -int com_list (), com_view (), com_rename (), com_stat (), com_pwd (); -int com_delete (), com_help (), com_cd (), com_quit (); - -/* A structure which contains information on the commands this program - can understand. */ - -typedef struct @{ - char *name; /* User printable name of the function. */ - Function *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, (Function *)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) - int 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 (); -char **fileman_completion (); - -/* 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 = (CPPFunction *)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) - 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 = 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) - 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; - - sprintf (syscom, "more %s", arg); - 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 = getwd (dir); - 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); -@} -@end smallexample diff --git a/readline/doc/rluser.texinfo b/readline/doc/rluser.texinfo deleted file mode 100644 index b2fd060..0000000 --- a/readline/doc/rluser.texinfo +++ /dev/null @@ -1,1261 +0,0 @@ -@comment %**start of header (This is for running Texinfo on a region.) -@setfilename rluser.info -@comment %**end of header (This is for running Texinfo on a region.) -@setchapternewpage odd - -@ignore -This file documents the end user interface to the GNU command line -editing features. It is to be an appendix to manuals for programs which -use these features. There is a document entitled "readline.texinfo" -which contains both end-user and programmer documentation for the GNU -Readline Library. - -Copyright (C) 1988, 1991, 1993, 1996 Free Software Foundation, Inc. - -Authored by Brian Fox and Chet Ramey. - -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 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 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 - -@comment If you are including this manual as an appendix, then set the -@comment variable readline-appendix. - -@node Command Line Editing -@chapter Command Line Editing - -This chapter describes the basic features of the @sc{GNU} -command line editing interface. - -@menu -* Introduction and Notation:: Notation used in this text. -* Readline Interaction:: The minimum set of commands for editing a line. -* Readline Init File:: Customizing Readline from a user's view. -* Bindable Readline Commands:: A description of most of the Readline commands - available for binding -* Readline vi Mode:: A short description of how to make Readline - behave like the vi editor. -@end menu - -@node Introduction and Notation -@section Introduction to Line Editing - -The following paragraphs describe the notation used to represent -keystrokes. - -The text @key{C-k} is read as `Control-K' and describes the character -produced when the @key{k} key is pressed while the Control key -is depressed. - -The text @key{M-k} is read as `Meta-K' and describes the character -produced when the meta key (if you have one) is depressed, and the @key{k} -key is pressed. If you do not have a meta key, the identical keystroke -can be generated by typing @key{ESC} @i{first}, and then typing @key{k}. -Either process is known as @dfn{metafying} the @key{k} key. - -The text @key{M-C-k} is read as `Meta-Control-k' and describes the -character produced by @dfn{metafying} @key{C-k}. - -In addition, several keys have their own names. Specifically, -@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all -stand for themselves when seen in this text, or in an init file -(@pxref{Readline Init File}). - -@node Readline Interaction -@section Readline Interaction -@cindex interaction, readline - -Often during an interactive session you type in a long line of text, -only to notice that the first word on the line is misspelled. The -Readline library gives you a set of commands for manipulating the text -as you type it in, allowing you to just fix your typo, and not forcing -you to retype the majority of the line. Using these editing commands, -you move the cursor to the place that needs correction, and delete or -insert the text of the corrections. Then, when you are satisfied with -the line, you simply press @key{RETURN}. You do not have to be at the -end of the line to press @key{RETURN}; the entire line is accepted -regardless of the location of the cursor within the line. - -@menu -* Readline Bare Essentials:: The least you need to know about Readline. -* Readline Movement Commands:: Moving about the input line. -* Readline Killing Commands:: How to delete text, and how to get it back! -* Readline Arguments:: Giving numeric arguments to commands. -* Searching:: Searching through previous lines. - @end menu - -@node Readline Bare Essentials -@subsection Readline Bare Essentials -@cindex notation, readline -@cindex command editing -@cindex editing command lines - -In order to enter characters into the line, simply type them. The typed -character appears where the cursor was, and then the cursor moves one -space to the right. If you mistype a character, you can use your -erase character to back up and delete the mistyped character. - -Sometimes you may miss typing a character that you wanted to type, and -not notice your error until you have typed several other characters. In -that case, you can type @key{C-b} to move the cursor to the left, and then -correct your mistake. Afterwards, you can move the cursor to the right -with @key{C-f}. - -When you add text in the middle of a line, you will notice that characters -to the right of the cursor are `pushed over' to make room for the text -that you have inserted. Likewise, when you delete text behind the cursor, -characters to the right of the cursor are `pulled back' to fill in the -blank space created by the removal of the text. A list of the basic bare -essentials for editing the text of an input line follows. - -@table @asis -@item @key{C-b} -Move back one character. -@item @key{C-f} -Move forward one character. -@item @key{DEL} -Delete the character to the left of the cursor. -@item @key{C-d} -Delete the character underneath the cursor. -@item @w{Printing characters} -Insert the character into the line at the cursor. -@item @key{C-_} -Undo the last editing command. You can undo all the way back to an -empty line. -@end table - -@node Readline Movement Commands -@subsection Readline Movement Commands - - -The above table describes the most basic possible keystrokes that you need -in order to do editing of the input line. For your convenience, many -other commands have been added in addition to @key{C-b}, @key{C-f}, -@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly -about the line. - -@table @key -@item C-a -Move to the start of the line. -@item C-e -Move to the end of the line. -@item M-f -Move forward a word, where a word is composed of letters and digits. -@item M-b -Move backward a word. -@item C-l -Clear the screen, reprinting the current line at the top. -@end table - -Notice how @key{C-f} moves forward a character, while @key{M-f} moves -forward a word. It is a loose convention that control keystrokes -operate on characters while meta keystrokes operate on words. - -@node Readline Killing Commands -@subsection Readline Killing Commands - -@cindex killing text -@cindex yanking text - -@dfn{Killing} text means to delete the text from the line, but to save -it away for later use, usually by @dfn{yanking} (re-inserting) -it back into the line. -If the description for a command says that it `kills' text, then you can -be sure that you can get the text back in a different (or the same) -place later. - -When you use a kill command, the text is saved in a @dfn{kill-ring}. -Any number of consecutive kills save all of the killed text together, so -that when you yank it back, you get it all. The kill -ring is not line specific; the text that you killed on a previously -typed line is available to be yanked back later, when you are typing -another line. -@cindex kill ring - -Here is the list of commands for killing text. - -@table @key -@item C-k -Kill the text from the current cursor position to the end of the line. - -@item M-d -Kill from the cursor to the end of the current word, or if between -words, to the end of the next word. - -@item M-DEL -Kill from the cursor the start of the previous word, or if between -words, to the start of the previous word. - -@item C-w -Kill from the cursor to the previous whitespace. This is different than -@key{M-DEL} because the word boundaries differ. - -@end table - -Here is how to @dfn{yank} the text back into the line. Yanking -means to copy the most-recently-killed text from the kill buffer. - -@table @key -@item C-y -Yank the most recently killed text back into the buffer at the cursor. - -@item M-y -Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is @key{C-y} or @key{M-y}. -@end table - -@node Readline Arguments -@subsection Readline Arguments - -You can pass numeric arguments to Readline commands. Sometimes the -argument acts as a repeat count, other times it is the @i{sign} of the -argument that is significant. If you pass a negative argument to a -command which normally acts in a forward direction, that command will -act in a backward direction. For example, to kill text back to the -start of the line, you might type @samp{M-- C-k}. - -The general way to pass numeric arguments to a command is to type meta -digits before the command. If the first `digit' typed is a minus -sign (@key{-}), then the sign of the argument will be negative. Once -you have typed one meta digit to get the argument started, you can type -the remainder of the digits, and then the command. For example, to give -the @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}. - -@node Searching -@subsection Searching for Commands in the History - -Readline provides commands for searching through the command history -@ifset BashFeatures -(@pxref{Bash History Facilities}) -@end ifset -for lines containing a specified string. -There are two search modes: @var{incremental} and @var{non-incremental}. - -Incremental searches begin before the user has finished typing the -search string. -As each character of the search string is typed, Readline displays -the next entry from the history matching the string typed so far. -An incremental search requires only as many characters as needed to -find the desired history entry. -The @key{ESC} character is used to terminate an incremental search. -@key{C-j} will also terminate the search. -@key{C-g} will abort an incremental search and restore the original line. -When the search is terminated, the history entry containing the -search string becomes the current line. -To find other matching entries in the history list, type @key{C-s} or -@key{C-r} as appropriate. -This will search backward or forward in the history for the next -entry matching the search string typed so far. -Any other key sequence bound to a Readline command will terminate -the search and execute that command. -For instance, a @key{RET} will terminate the search and accept -the line, thereby executing the command from the history list. - -Non-incremental searches read the entire search string before starting -to search for matching history lines. The search string may be -typed by the user or be part of the contents of the current line. - -@node Readline Init File -@section Readline Init File -@cindex initialization file, readline - -Although the Readline library comes with a set of @code{emacs}-like -keybindings installed by default, it is possible to use a different set -of keybindings. -Any user can customize programs that use Readline by putting -commands in an @dfn{inputrc} file in his home directory. -The name of this -@ifset BashFeatures -file is taken from the value of the shell variable @code{INPUTRC}. If -@end ifset -@ifclear BashFeatures -file is taken from the value of the environment variable @code{INPUTRC}. If -@end ifclear -that variable is unset, the default is @file{~/.inputrc}. - -When a program which uses the Readline library starts up, the -init file is read, and the key bindings are set. - -In addition, the @code{C-x C-r} command re-reads this init file, thus -incorporating any changes that you might have made to it. - -@menu -* Readline Init File Syntax:: Syntax for the commands in the inputrc file. - -* Conditional Init Constructs:: Conditional key bindings in the inputrc file. - -* Sample Init File:: An example inputrc file. -@end menu - -@node Readline Init File Syntax -@subsection Readline Init File Syntax - -There are only a few basic constructs allowed in the -Readline init file. Blank lines are ignored. -Lines beginning with a @samp{#} are comments. -Lines beginning with a @samp{$} indicate conditional -constructs (@pxref{Conditional Init Constructs}). Other lines -denote variable settings and key bindings. - -@table @asis -@item Variable Settings -You can modify the run-time behavior of Readline by -altering the values of variables in Readline -using the @code{set} command within the init file. Here is how to -change from the default Emacs-like key binding to use -@code{vi} line editing commands: - -@example -set editing-mode vi -@end example - -A great deal of run-time behavior is changeable with the following -variables. - -@table @code - -@item bell-style -@vindex bell-style -Controls what happens when Readline wants to ring the terminal bell. -If set to @samp{none}, Readline never rings the bell. If set to -@samp{visible}, Readline uses a visible bell if one is available. -If set to @samp{audible} (the default), Readline attempts to ring -the terminal's bell. - -@item comment-begin -@vindex comment-begin -The string to insert at the beginning of the line when the -@code{insert-comment} command is executed. The default value -is @code{"#"}. - -@item completion-ignore-case -If set to @samp{on}, Readline performs filename matching and completion -in a case-insensitive fashion. -The default value is @samp{off}. - -@item completion-query-items -@vindex completion-query-items -The number of possible completions that determines when the user is -asked whether he wants to see the list of possibilities. If the -number of possible completions is greater than this value, -Readline will ask the user whether or not he wishes to view -them; otherwise, they are simply listed. The default limit is -@code{100}. - -@item convert-meta -@vindex convert-meta -If set to @samp{on}, Readline will convert characters with the -eighth bit set to an ASCII key sequence by stripping the eighth -bit and prepending an @key{ESC} character, converting them to a -meta-prefixed key sequence. The default value is @samp{on}. - -@item disable-completion -@vindex disable-completion -If set to @samp{On}, Readline will inhibit word completion. -Completion characters will be inserted into the line as if they had -been mapped to @code{self-insert}. The default is @samp{off}. - -@item editing-mode -@vindex editing-mode -The @code{editing-mode} variable controls which default set of -key bindings is used. By default, Readline starts up in Emacs editing -mode, where the keystrokes are most similar to Emacs. This variable can be -set to either @samp{emacs} or @samp{vi}. - -@item enable-keypad -@vindex enable-keypad -When set to @samp{on}, Readline will try to enable the application -keypad when it is called. Some systems need this to enable the -arrow keys. The default is @samp{off}. - -@item expand-tilde -@vindex expand-tilde -If set to @samp{on}, tilde expansion is performed when Readline -attempts word completion. The default is @samp{off}. - -@item horizontal-scroll-mode -@vindex horizontal-scroll-mode -This variable can be set to either @samp{on} or @samp{off}. Setting it -to @samp{on} means that the text of the lines being edited will scroll -horizontally on a single screen line when they are longer than the width -of the screen, instead of wrapping onto a new screen line. By default, -this variable is set to @samp{off}. - -@item keymap -@vindex keymap -Sets Readline's idea of the current keymap for key binding commands. -Acceptable @code{keymap} names are -@code{emacs}, -@code{emacs-standard}, -@code{emacs-meta}, -@code{emacs-ctlx}, -@code{vi}, -@code{vi-command}, and -@code{vi-insert}. -@code{vi} is equivalent to @code{vi-command}; @code{emacs} is -equivalent to @code{emacs-standard}. The default value is @code{emacs}. -The value of the @code{editing-mode} variable also affects the -default keymap. - -@item mark-directories -If set to @samp{on}, completed directory names have a slash -appended. The default is @samp{on}. - -@item mark-modified-lines -@vindex mark-modified-lines -This variable, when set to @samp{on}, causes Readline to display an -asterisk (@samp{*}) at the start of history lines which have been modified. -This variable is @samp{off} by default. - -@item input-meta -@vindex input-meta -@vindex meta-flag -If set to @samp{on}, Readline will enable eight-bit input (it -will not strip the eighth bit from the characters it reads), -regardless of what the terminal claims it can support. The -default value is @samp{off}. The name @code{meta-flag} is a -synonym for this variable. - -@item output-meta -@vindex output-meta -If set to @samp{on}, Readline will display characters with the -eighth bit set directly rather than as a meta-prefixed escape -sequence. The default is @samp{off}. - -@item print-completions-horizontally -If set to @samp{on}, Readline will display completions with matches -sorted horizontally in alphabetical order, rather than down the screen. -The default is @samp{off}. - -@item show-all-if-ambiguous -@vindex show-all-if-ambiguous -This alters the default behavior of the completion functions. If -set to @samp{on}, -words which have more than one possible completion cause the -matches to be listed immediately instead of ringing the bell. -The default value is @samp{off}. - -@item visible-stats -@vindex visible-stats -If set to @samp{on}, a character denoting a file's type -is appended to the filename when listing possible -completions. The default is @samp{off}. - -@end table - -@item Key Bindings -The syntax for controlling key bindings in the init file is -simple. First you have to know the name of the command that you -want to change. The following sections contain tables of the command -name, the default keybinding, if any, and a short description of what -the command does. - -Once you know the name of the command, simply place the name of the key -you wish to bind the command to, a colon, and then the name of the -command on a line in the init file. The name of the key -can be expressed in different ways, depending on which is most -comfortable for you. - -@table @asis -@item @w{@var{keyname}: @var{function-name} or @var{macro}} -@var{keyname} is the name of a key spelled out in English. For example: -@example -Control-u: universal-argument -Meta-Rubout: backward-kill-word -Control-o: "> output" -@end example - -In the above example, @key{C-u} is bound to the function -@code{universal-argument}, and @key{C-o} is bound to run the macro -expressed on the right hand side (that is, to insert the text -@samp{> output} into the line). - -@item @w{"@var{keyseq}": @var{function-name} or @var{macro}} -@var{keyseq} differs from @var{keyname} above in that strings -denoting an entire key sequence can be specified, by placing -the key sequence in double quotes. Some GNU Emacs style key -escapes can be used, as in the following example, but the -special character names are not recognized. - -@example -"\C-u": universal-argument -"\C-x\C-r": re-read-init-file -"\e[11~": "Function Key 1" -@end example - -In the above example, @key{C-u} is bound to the function -@code{universal-argument} (just as it was in the first example), -@samp{@key{C-x} @key{C-r}} is bound to the function @code{re-read-init-file}, -and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert -the text @samp{Function Key 1}. - -@end table - -The following GNU Emacs style escape sequences are available when -specifying key sequences: - -@table @code -@item @kbd{\C-} -control prefix -@item @kbd{\M-} -meta prefix -@item @kbd{\e} -an escape character -@item @kbd{\\} -backslash -@item @kbd{\"} -@key{"} -@item @kbd{\'} -@key{'} -@end table - -In addition to the GNU Emacs style escape sequences, a second -set of backslash escapes is available: - -@table @code -@item \a -alert (bell) -@item \b -backspace -@item \d -delete -@item \f -form feed -@item \n -newline -@item \r -carriage return -@item \t -horizontal tab -@item \v -vertical tab -@item \@var{nnn} -the character whose ASCII code is the octal value @var{nnn} -(one to three digits) -@item \x@var{nnn} -the character whose ASCII code is the hexadecimal value @var{nnn} -(one to three digits) -@end table - -When entering the text of a macro, single or double quotes must -be used to indicate a macro definition. -Unquoted text is assumed to be a function name. -In the macro body, the backslash escapes described above are expanded. -Backslash will quote any other character in the macro text, -including @samp{"} and @samp{'}. -For example, the following binding will make @samp{C-x \} -insert a single @samp{\} into the line: -@example -"\C-x\\": "\\" -@end example - -@end table - -@node Conditional Init Constructs -@subsection Conditional Init Constructs - -Readline implements a facility similar in spirit to the conditional -compilation features of the C preprocessor which allows key -bindings and variable settings to be performed as the result -of tests. There are four parser directives used. - -@table @code -@item $if -The @code{$if} construct allows bindings to be made based on the -editing mode, the terminal being used, or the application using -Readline. The text of the test extends to the end of the line; -no characters are required to isolate it. - -@table @code -@item mode -The @code{mode=} form of the @code{$if} directive is used to test -whether Readline is in @code{emacs} or @code{vi} mode. -This may be used in conjunction -with the @samp{set keymap} command, for instance, to set bindings in -the @code{emacs-standard} and @code{emacs-ctlx} keymaps only if -Readline is starting out in @code{emacs} mode. - -@item term -The @code{term=} form may be used to include terminal-specific -key bindings, perhaps to bind the key sequences output by the -terminal's function keys. The word on the right side of the -@samp{=} is tested against both the full name of the terminal and -the portion of the terminal name before the first @samp{-}. This -allows @code{sun} to match both @code{sun} and @code{sun-cmd}, -for instance. - -@item application -The @var{application} construct is used to include -application-specific settings. Each program using the Readline -library sets the @var{application name}, and you can test for it. -This could be used to bind key sequences to functions useful for -a specific program. For instance, the following command adds a -key sequence that quotes the current or previous word in Bash: -@example -$if Bash -# Quote the current or previous word -"\C-xq": "\eb\"\ef\"" -$endif -@end example -@end table - -@item $endif -This command, as seen in the previous example, terminates an -@code{$if} command. - -@item $else -Commands in this branch of the @code{$if} directive are executed if -the test fails. - -@item $include -This directive takes a single filename as an argument and reads commands -and bindings from that file. -@example -$include /etc/inputrc -@end example -@end table - -@node Sample Init File -@subsection Sample Init File - -Here is an example of an inputrc file. This illustrates key -binding, variable assignment, and conditional syntax. - -@example -@page -# This file controls the behaviour of line input editing for -# programs that use the Gnu Readline library. Existing programs -# include FTP, Bash, and Gdb. -# -# You can re-read the inputrc file with C-x C-r. -# Lines beginning with '#' are comments. -# -# First, include any systemwide bindings and variable assignments from -# /etc/Inputrc -$include /etc/Inputrc - -# -# Set various bindings for emacs mode. - -set editing-mode emacs - -$if mode=emacs - -Meta-Control-h: backward-kill-word Text after the function name is ignored - -# -# Arrow keys in keypad mode -# -#"\M-OD": backward-char -#"\M-OC": forward-char -#"\M-OA": previous-history -#"\M-OB": next-history -# -# Arrow keys in ANSI mode -# -"\M-[D": backward-char -"\M-[C": forward-char -"\M-[A": previous-history -"\M-[B": next-history -# -# Arrow keys in 8 bit keypad mode -# -#"\M-\C-OD": backward-char -#"\M-\C-OC": forward-char -#"\M-\C-OA": previous-history -#"\M-\C-OB": next-history -# -# Arrow keys in 8 bit ANSI mode -# -#"\M-\C-[D": backward-char -#"\M-\C-[C": forward-char -#"\M-\C-[A": previous-history -#"\M-\C-[B": next-history - -C-q: quoted-insert - -$endif - -# An old-style binding. This happens to be the default. -TAB: complete - -# Macros that are convenient for shell interaction -$if Bash -# edit the path -"\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f" -# prepare to type a quoted word -- insert open and close double quotes -# and move to just after the open quote -"\C-x\"": "\"\"\C-b" -# insert a backslash (testing backslash escapes in sequences and macros) -"\C-x\\": "\\" -# Quote the current or previous word -"\C-xq": "\eb\"\ef\"" -# Add a binding to refresh the line, which is unbound -"\C-xr": redraw-current-line -# Edit variable on current line. -"\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y=" -$endif - -# use a visible bell if one is available -set bell-style visible - -# don't strip characters to 7 bits when reading -set input-meta on - -# allow iso-latin1 characters to be inserted rather than converted to -# prefix-meta sequences -set convert-meta off - -# display characters with the eighth bit set directly rather than -# as meta-prefixed characters -set output-meta on - -# if there are more than 150 possible completions for a word, ask the -# user if he wants to see all of them -set completion-query-items 150 - -# For FTP -$if Ftp -"\C-xg": "get \M-?" -"\C-xt": "put \M-?" -"\M-.": yank-last-arg -$endif -@end example - -@node Bindable Readline Commands -@section Bindable Readline Commands - -@menu -* Commands For Moving:: Moving about the line. -* Commands For History:: Getting at previous lines. -* Commands For Text:: Commands for changing text. -* Commands For Killing:: Commands for killing and yanking. -* Numeric Arguments:: Specifying numeric arguments, repeat counts. -* Commands For Completion:: Getting Readline to do the typing for you. -* Keyboard Macros:: Saving and re-executing typed characters -* Miscellaneous Commands:: Other miscellaneous commands. -@end menu - -This section describes Readline commands that may be bound to key -sequences. - -@node Commands For Moving -@subsection Commands For Moving -@ftable @code -@item beginning-of-line (C-a) -Move to the start of the current line. - -@item end-of-line (C-e) -Move to the end of the line. - -@item forward-char (C-f) -Move forward a character. - -@item backward-char (C-b) -Move back a character. - -@item forward-word (M-f) -Move forward to the end of the next word. Words are composed of -letters and digits. - -@item backward-word (M-b) -Move back to the start of this, or the previous, word. Words are -composed of letters and digits. - -@item clear-screen (C-l) -Clear the screen and redraw the current line, -leaving the current line at the top of the screen. - -@item redraw-current-line () -Refresh the current line. By default, this is unbound. - -@end ftable - -@node Commands For History -@subsection Commands For Manipulating The History - -@ftable @code -@item accept-line (Newline, Return) -@ifset BashFeatures -Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list according to the setting of -the @code{HISTCONTROL} and @code{HISTIGNORE} variables. -If this line was a history line, then restore the history line to its -original state. -@end ifset -@ifclear BashFeatures -Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list. If this line was a history -line, then restore the history line to its original state. -@end ifclear - -@item previous-history (C-p) -Move `up' through the history list. - -@item next-history (C-n) -Move `down' through the history list. - -@item beginning-of-history (M-<) -Move to the first line in the history. - -@item end-of-history (M->) -Move to the end of the input history, i.e., the line currently -being entered. - -@item reverse-search-history (C-r) -Search backward starting at the current line and moving `up' through -the history as necessary. This is an incremental search. - -@item forward-search-history (C-s) -Search forward starting at the current line and moving `down' through -the the history as necessary. This is an incremental search. - -@item non-incremental-reverse-search-history (M-p) -Search backward starting at the current line and moving `up' -through the history as necessary using a non-incremental search -for a string supplied by the user. - -@item non-incremental-forward-search-history (M-n) -Search forward starting at the current line and moving `down' -through the the history as necessary using a non-incremental search -for a string supplied by the user. - -@item history-search-forward () -Search forward through the history for the string of characters -between the start of the current line and the current cursor -position (the @var{point}). This is a non-incremental search. By -default, this command is unbound. - -@item history-search-backward () -Search backward through the history for the string of characters -between the start of the current line and the point. This -is a non-incremental search. By default, this command is unbound. - -@item yank-nth-arg (M-C-y) -Insert the first argument to the previous command (usually -the second word on the previous line). With an argument @var{n}, -insert the @var{n}th word from the previous command (the words -in the previous command begin with word 0). A negative argument -inserts the @var{n}th word from the end of the previous command. - -@item yank-last-arg (M-., M-_) -Insert last argument to the previous command (the last word of the -previous history entry). With an -argument, behave exactly like @code{yank-nth-arg}. -Successive calls to @code{yank-last-arg} move back through the history -list, inserting the last argument of each line in turn. - -@end ftable - -@node Commands For Text -@subsection Commands For Changing Text - -@ftable @code -@item delete-char (C-d) -Delete the character under the cursor. If the cursor is at the -beginning of the line, there are no characters in the line, and -the last character typed was not bound to @code{delete-char}, then -return @code{EOF}. - -@item backward-delete-char (Rubout) -Delete the character behind the cursor. A numeric argument means -to kill the characters instead of deleting them. - -@item quoted-insert (C-q, C-v) -Add the next character typed to the line verbatim. This is -how to insert key sequences like @key{C-q}, for example. - -@ifclear BashFeatures -@item tab-insert (M-TAB) -Insert a tab character. -@end ifclear - -@item self-insert (a, b, A, 1, !, ...) -Insert yourself. - -@item transpose-chars (C-t) -Drag the character before the cursor forward over -the character at the cursor, moving the -cursor forward as well. If the insertion point -is at the end of the line, then this -transposes the last two characters of the line. -Negative arguments don't work. - -@item transpose-words (M-t) -Drag the word behind the cursor past the word in front of the cursor -moving the cursor over that word as well. - -@item upcase-word (M-u) -Uppercase the current (or following) word. With a negative argument, -uppercase the previous word, but do not move the cursor. - -@item downcase-word (M-l) -Lowercase the current (or following) word. With a negative argument, -lowercase the previous word, but do not move the cursor. - -@item capitalize-word (M-c) -Capitalize the current (or following) word. With a negative argument, -capitalize the previous word, but do not move the cursor. - -@end ftable - -@node Commands For Killing -@subsection Killing And Yanking - -@ftable @code - -@item kill-line (C-k) -Kill the text from the current cursor position to the end of the line. - -@item backward-kill-line (C-x Rubout) -Kill backward to the beginning of the line. - -@item unix-line-discard (C-u) -Kill backward from the cursor to the beginning of the current line. -The killed text is saved on the kill-ring. - -@item kill-whole-line () -Kill all characters on the current line, no matter where the -cursor is. By default, this is unbound. - -@item kill-word (M-d) -Kill from the cursor to the end of the current word, or if between -words, to the end of the next word. Word boundaries are the same -as @code{forward-word}. - -@item backward-kill-word (M-DEL) -Kill the word behind the cursor. Word boundaries are the same -as @code{backward-word}. - -@item unix-word-rubout (C-w) -Kill the word behind the cursor, using white space as a word -boundary. The killed text is saved on the kill-ring. - -@item delete-horizontal-space () -Delete all spaces and tabs around point. By default, this is unbound. - -@item kill-region () -Kill the text between the point and the @emph{mark} (saved -cursor position). This text is referred to as the @var{region}. -By default, this command is unbound. - -@item copy-region-as-kill () -Copy the text in the region to the kill buffer, so it can be yanked -right away. By default, this command is unbound. - -@item copy-backward-word () -Copy the word before point to the kill buffer. -The word boundaries are the same as @code{backward-word}. -By default, this command is unbound. - -@item copy-forward-word () -Copy the word following point to the kill buffer. -The word boundaries are the same as @code{forward-word}. -By default, this command is unbound. - -@item yank (C-y) -Yank the top of the kill ring into the buffer at the current -cursor position. - -@item yank-pop (M-y) -Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is yank or yank-pop. -@end ftable - -@node Numeric Arguments -@subsection Specifying Numeric Arguments -@ftable @code - -@item digit-argument (M-0, M-1, ... M--) -Add this digit to the argument already accumulating, or start a new -argument. @key{M--} starts a negative argument. - -@item universal-argument () -This is another way to specify an argument. -If this command is followed by one or more digits, optionally with a -leading minus sign, those digits define the argument. -If the command is followed by digits, executing @code{universal-argument} -again ends the numeric argument, but is otherwise ignored. -As a special case, if this command is immediately followed by a -character that is neither a digit or minus sign, the argument count -for the next command is multiplied by four. -The argument count is initially one, so executing this function the -first time makes the argument count four, a second time makes the -argument count sixteen, and so on. -By default, this is not bound to a key. -@end ftable - -@node Commands For Completion -@subsection Letting Readline Type For You - -@ftable @code -@item complete (TAB) -Attempt to do completion on the text before the cursor. This is -application-specific. Generally, if you are typing a filename -argument, you can do filename completion; if you are typing a command, -you can do command completion; if you are typing in a symbol to GDB, you -can do symbol name completion; if you are typing in a variable to Bash, -you can do variable name completion, and so on. -@ifset BashFeatures -Bash attempts completion treating the text as a variable (if the -text begins with @samp{$}), username (if the text begins with -@samp{~}), hostname (if the text begins with @samp{@@}), or -command (including aliases and functions) in turn. If none -of these produces a match, filename completion is attempted. -@end ifset - -@item possible-completions (M-?) -List the possible completions of the text before the cursor. - -@item insert-completions (M-*) -Insert all completions of the text before point that would have -been generated by @code{possible-completions}. - -@item menu-complete () -Similar to @code{complete}, but replaces the word to be completed -with a single match from the list of possible completions. -Repeated execution of @code{menu-complete} steps through the list -of possible completions, inserting each match in turn. -At the end of the list of completions, the bell is rung and the -original text is restored. -An argument of @var{n} moves @var{n} positions forward in the list -of matches; a negative argument may be used to move backward -through the list. -This command is intended to be bound to @code{TAB}, but is unbound -by default. - -@ifset BashFeatures -@item complete-filename (M-/) -Attempt filename completion on the text before point. - -@item possible-filename-completions (C-x /) -List the possible completions of the text before point, -treating it as a filename. - -@item complete-username (M-~) -Attempt completion on the text before point, treating -it as a username. - -@item possible-username-completions (C-x ~) -List the possible completions of the text before point, -treating it as a username. - -@item complete-variable (M-$) -Attempt completion on the text before point, treating -it as a shell variable. - -@item possible-variable-completions (C-x $) -List the possible completions of the text before point, -treating it as a shell variable. - -@item complete-hostname (M-@@) -Attempt completion on the text before point, treating -it as a hostname. - -@item possible-hostname-completions (C-x @@) -List the possible completions of the text before point, -treating it as a hostname. - -@item complete-command (M-!) -Attempt completion on the text before point, treating -it as a command name. Command completion attempts to -match the text against aliases, reserved words, shell -functions, shell builtins, and finally executable filenames, -in that order. - -@item possible-command-completions (C-x !) -List the possible completions of the text before point, -treating it as a command name. - -@item dynamic-complete-history (M-TAB) -Attempt completion on the text before point, comparing -the text against lines from the history list for possible -completion matches. - -@item complete-into-braces (M-@{) -Perform filename completion and return the list of possible completions -enclosed within braces so the list is available to the shell -(@pxref{Brace Expansion}). - -@end ifset -@end ftable - -@node Keyboard Macros -@subsection Keyboard Macros -@ftable @code - -@item start-kbd-macro (C-x () -Begin saving the characters typed into the current keyboard macro. - -@item end-kbd-macro (C-x )) -Stop saving the characters typed into the current keyboard macro -and save the definition. - -@item call-last-kbd-macro (C-x e) -Re-execute the last keyboard macro defined, by making the characters -in the macro appear as if typed at the keyboard. - -@end ftable - -@node Miscellaneous Commands -@subsection Some Miscellaneous Commands -@ftable @code - -@item re-read-init-file (C-x C-r) -Read in the contents of the inputrc file, and incorporate -any bindings or variable assignments found there. - -@item abort (C-g) -Abort the current editing command and -ring the terminal's bell (subject to the setting of -@code{bell-style}). - -@item do-uppercase-version (M-a, M-b, M-@var{x}, @dots{}) -If the metafied character @var{x} is lowercase, run the command -that is bound to the corresponding uppercase character. - -@item prefix-meta (ESC) -Make the next character typed be metafied. This is for keyboards -without a meta key. Typing @samp{ESC f} is equivalent to typing -@samp{M-f}. - -@item undo (C-_, C-x C-u) -Incremental undo, separately remembered for each line. - -@item revert-line (M-r) -Undo all changes made to this line. This is like executing the @code{undo} -command enough times to get back to the beginning. - -@item tilde-expand (M-~) -Perform tilde expansion on the current word. - -@item set-mark (C-@@) -Set the mark to the current point. If a -numeric argument is supplied, the mark is set to that position. - -@item exchange-point-and-mark (C-x C-x) -Swap the point with the mark. The current cursor position is set to -the saved position, and the old cursor position is saved as the mark. - -@item character-search (C-]) -A character is read and point is moved to the next occurrence of that -character. A negative count searches for previous occurrences. - -@item character-search-backward (M-C-]) -A character is read and point is moved to the previous occurrence -of that character. A negative count searches for subsequent -occurrences. - -@item insert-comment (M-#) -The value of the @code{comment-begin} -variable is inserted at the beginning of the current line, -and the line is accepted as if a newline had been typed. -@ifset BashFeatures -This makes the current line a shell comment. -@end ifset - -@item dump-functions () -Print all of the functions and their key bindings to the -Readline output stream. If a numeric argument is supplied, -the output is formatted in such a way that it can be made part -of an @var{inputrc} file. This command is unbound by default. - -@item dump-variables () -Print all of the settable variables and their values to the -Readline output stream. If a numeric argument is supplied, -the output is formatted in such a way that it can be made part -of an @var{inputrc} file. This command is unbound by default. - -@item dump-macros () -Print all of the Readline key sequences bound to macros and the -strings they ouput. If a numeric argument is supplied, -the output is formatted in such a way that it can be made part -of an @var{inputrc} file. This command is unbound by default. - -@ifset BashFeatures -@item glob-expand-word (C-x *) -The word before point is treated as a pattern for pathname expansion, -and the list of matching file names is inserted, replacing the word. - -@item glob-list-expansions (C-x g) -The list of expansions that would have been generated by -@code{glob-expand-word} is displayed, and the line is redrawn. - -@item display-shell-version (C-x C-v) -Display version information about the current instance of Bash. - -@item shell-expand-line (M-C-e) -Expand the line as the shell does. -This performs alias and history expansion as well as all of the shell -word expansions (@pxref{Shell Expansions}). - -@item history-expand-line (M-^) -Perform history expansion on the current line. - -@item magic-space () -Perform history expansion on the current line and insert a space -(@pxref{History Interaction}). - -@item alias-expand-line () -Perform alias expansion on the current line (@pxref{Aliases}). - -@item history-and-alias-expand-line () -Perform history and alias expansion on the current line. - -@item insert-last-argument (M-., M-_) -A synonym for @code{yank-last-arg}. - -@item operate-and-get-next (C-o) -Accept the current line for execution and fetch the next line -relative to the current line from the history for editing. Any -argument is ignored. - -@item emacs-editing-mode (C-e) -When in @code{vi} editing mode, this causes a switch back to -@code{emacs} editing mode, as if the command @samp{set -o emacs} had -been executed. - -@end ifset - -@end ftable - -@node Readline vi Mode -@section Readline vi Mode - -While the Readline library does not have a full set of @code{vi} -editing functions, it does contain enough to allow simple editing -of the line. The Readline @code{vi} mode behaves as specified in -the @sc{POSIX} 1003.2 standard. - -@ifset BashFeatures -In order to switch interactively between @code{emacs} and @code{vi} -editing modes, use the @samp{set -o emacs} and @samp{set -o vi} -commands (@pxref{The Set Builtin}). -@end ifset -@ifclear BashFeatures -In order to switch interactively between @code{emacs} and @code{vi} -editing modes, use the command M-C-j (toggle-editing-mode). -@end ifclear -The Readline default is @code{emacs} mode. - -When you enter a line in @code{vi} mode, you are already placed in -`insertion' mode, as if you had typed an @samp{i}. Pressing @key{ESC} -switches you into `command' mode, where you can edit the text of the -line with the standard @code{vi} movement keys, move to previous -history lines with @samp{k} and subsequent lines with @samp{j}, and -so forth. diff --git a/readline/emacs_keymap.c b/readline/emacs_keymap.c deleted file mode 100644 index 0b07fb3..0000000 --- a/readline/emacs_keymap.c +++ /dev/null @@ -1,472 +0,0 @@ -/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */ - -/* 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef 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, (Function *)0x0 }, /* Control-@ */ - { ISFUNC, rl_beg_of_line }, /* Control-a */ - { ISFUNC, rl_backward }, /* Control-b */ - { ISFUNC, (Function *)0x0 }, /* Control-c */ - { ISFUNC, rl_delete }, /* Control-d */ - { ISFUNC, rl_end_of_line }, /* Control-e */ - { ISFUNC, rl_forward }, /* 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, (Function *)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, (Function *)emacs_ctlx_keymap }, /* Control-x */ - { ISFUNC, rl_yank }, /* Control-y */ - { ISFUNC, (Function *)0x0 }, /* Control-z */ - { ISKMAP, (Function *)emacs_meta_keymap }, /* Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Control-] */ - { ISFUNC, (Function *)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 */ -}; - -KEYMAP_ENTRY_ARRAY emacs_meta_keymap = { - - /* Meta keys. Just like above, but the high bit is set. */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-@ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-a */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-b */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-c */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-d */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-e */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-f */ - { ISFUNC, rl_abort }, /* Meta-Control-g */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-h */ - { ISFUNC, rl_tab_insert }, /* Meta-Control-i */ - { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-k */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-l */ - { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-n */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-o */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-p */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-q */ - { ISFUNC, rl_revert_line }, /* Meta-Control-r */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-s */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-t */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-u */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-v */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-w */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-x */ - { ISFUNC, rl_yank_nth_arg }, /* Meta-Control-y */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-z */ - - { ISFUNC, (Function *)0x0 }, /* Meta-Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-] */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-^ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-_ */ - - /* The start of printing characters. */ - { ISFUNC, (Function *)0x0 }, /* Meta-SPACE */ - { ISFUNC, (Function *)0x0 }, /* Meta-! */ - { ISFUNC, (Function *)0x0 }, /* Meta-" */ - { ISFUNC, (Function *)0x0 }, /* Meta-# */ - { ISFUNC, (Function *)0x0 }, /* Meta-$ */ - { ISFUNC, (Function *)0x0 }, /* Meta-% */ - { ISFUNC, (Function *)0x0 }, /* Meta-& */ - { ISFUNC, (Function *)0x0 }, /* Meta-' */ - { ISFUNC, (Function *)0x0 }, /* Meta-( */ - { ISFUNC, (Function *)0x0 }, /* Meta-) */ - { ISFUNC, (Function *)0x0 }, /* Meta-* */ - { ISFUNC, (Function *)0x0 }, /* Meta-+ */ - { ISFUNC, (Function *)0x0 }, /* Meta-, */ - { ISFUNC, rl_digit_argument }, /* Meta-- */ - { ISFUNC, (Function *)0x0 }, /* Meta-. */ - { ISFUNC, (Function *)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, (Function *)0x0 }, /* Meta-: */ - { ISFUNC, (Function *)0x0 }, /* Meta-; */ - { ISFUNC, rl_beginning_of_history }, /* Meta-< */ - { ISFUNC, (Function *)0x0 }, /* Meta-= */ - { ISFUNC, rl_end_of_history }, /* Meta-> */ - { ISFUNC, rl_possible_completions }, /* Meta-? */ - { ISFUNC, (Function *)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_arrow_keys }, /* Meta-[ */ - { ISFUNC, (Function *)0x0 }, /* Meta-\ */ - { ISFUNC, (Function *)0x0 }, /* Meta-] */ - { ISFUNC, (Function *)0x0 }, /* Meta-^ */ - { ISFUNC, (Function *)0x0 }, /* Meta-_ */ - { ISFUNC, (Function *)0x0 }, /* Meta-` */ - - /* Lowercase alphabet. */ - { ISFUNC, (Function *)0x0 }, /* Meta-a */ - { ISFUNC, rl_backward_word }, /* Meta-b */ - { ISFUNC, rl_capitalize_word }, /* Meta-c */ - { ISFUNC, rl_kill_word }, /* Meta-d */ - { ISFUNC, (Function *)0x0 }, /* Meta-e */ - { ISFUNC, rl_forward_word }, /* Meta-f */ - { ISFUNC, (Function *)0x0 }, /* Meta-g */ - { ISFUNC, (Function *)0x0 }, /* Meta-h */ - { ISFUNC, (Function *)0x0 }, /* Meta-i */ - { ISFUNC, (Function *)0x0 }, /* Meta-j */ - { ISFUNC, (Function *)0x0 }, /* Meta-k */ - { ISFUNC, rl_downcase_word }, /* Meta-l */ - { ISFUNC, (Function *)0x0 }, /* Meta-m */ - { ISFUNC, (Function *)0x0 }, /* Meta-n */ - { ISFUNC, rl_arrow_keys }, /* Meta-o */ - { ISFUNC, (Function *)0x0 }, /* Meta-p */ - { ISFUNC, (Function *)0x0 }, /* Meta-q */ - { ISFUNC, rl_revert_line }, /* Meta-r */ - { ISFUNC, (Function *)0x0 }, /* Meta-s */ - { ISFUNC, rl_transpose_words }, /* Meta-t */ - { ISFUNC, rl_upcase_word }, /* Meta-u */ - { ISFUNC, (Function *)0x0 }, /* Meta-v */ - { ISFUNC, (Function *)0x0 }, /* Meta-w */ - { ISFUNC, (Function *)0x0 }, /* Meta-x */ - { ISFUNC, rl_yank_pop }, /* Meta-y */ - { ISFUNC, (Function *)0x0 }, /* Meta-z */ - - /* Final punctuation. */ - { ISFUNC, (Function *)0x0 }, /* Meta-{ */ - { ISFUNC, (Function *)0x0 }, /* Meta-| */ - { ISFUNC, (Function *)0x0 }, /* Meta-} */ - { ISFUNC, (Function *)0x0 }, /* Meta-~ */ - { ISFUNC, rl_backward_kill_word } /* Meta-rubout */ -}; - -KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = { - - /* Control keys. */ - { ISFUNC, (Function *)0x0 }, /* Control-@ */ - { ISFUNC, (Function *)0x0 }, /* Control-a */ - { ISFUNC, (Function *)0x0 }, /* Control-b */ - { ISFUNC, (Function *)0x0 }, /* Control-c */ - { ISFUNC, (Function *)0x0 }, /* Control-d */ - { ISFUNC, (Function *)0x0 }, /* Control-e */ - { ISFUNC, (Function *)0x0 }, /* Control-f */ - { ISFUNC, rl_abort }, /* Control-g */ - { ISFUNC, (Function *)0x0 }, /* Control-h */ - { ISFUNC, (Function *)0x0 }, /* Control-i */ - { ISFUNC, (Function *)0x0 }, /* Control-j */ - { ISFUNC, (Function *)0x0 }, /* Control-k */ - { ISFUNC, (Function *)0x0 }, /* Control-l */ - { ISFUNC, (Function *)0x0 }, /* Control-m */ - { ISFUNC, (Function *)0x0 }, /* Control-n */ - { ISFUNC, (Function *)0x0 }, /* Control-o */ - { ISFUNC, (Function *)0x0 }, /* Control-p */ - { ISFUNC, (Function *)0x0 }, /* Control-q */ - { ISFUNC, rl_re_read_init_file }, /* Control-r */ - { ISFUNC, (Function *)0x0 }, /* Control-s */ - { ISFUNC, (Function *)0x0 }, /* Control-t */ - { ISFUNC, rl_undo_command }, /* Control-u */ - { ISFUNC, (Function *)0x0 }, /* Control-v */ - { ISFUNC, (Function *)0x0 }, /* Control-w */ - { ISFUNC, (Function *)0x0 }, /* Control-x */ - { ISFUNC, (Function *)0x0 }, /* Control-y */ - { ISFUNC, (Function *)0x0 }, /* Control-z */ - { ISFUNC, (Function *)0x0 }, /* Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Control-] */ - { ISFUNC, (Function *)0x0 }, /* Control-^ */ - { ISFUNC, (Function *)0x0 }, /* Control-_ */ - - /* The start of printing characters. */ - { ISFUNC, (Function *)0x0 }, /* SPACE */ - { ISFUNC, (Function *)0x0 }, /* ! */ - { ISFUNC, (Function *)0x0 }, /* " */ - { ISFUNC, (Function *)0x0 }, /* # */ - { ISFUNC, (Function *)0x0 }, /* $ */ - { ISFUNC, (Function *)0x0 }, /* % */ - { ISFUNC, (Function *)0x0 }, /* & */ - { ISFUNC, (Function *)0x0 }, /* ' */ - { ISFUNC, rl_start_kbd_macro }, /* ( */ - { ISFUNC, rl_end_kbd_macro }, /* ) */ - { ISFUNC, (Function *)0x0 }, /* * */ - { ISFUNC, (Function *)0x0 }, /* + */ - { ISFUNC, (Function *)0x0 }, /* , */ - { ISFUNC, (Function *)0x0 }, /* - */ - { ISFUNC, (Function *)0x0 }, /* . */ - { ISFUNC, (Function *)0x0 }, /* / */ - - /* Regular digits. */ - { ISFUNC, (Function *)0x0 }, /* 0 */ - { ISFUNC, (Function *)0x0 }, /* 1 */ - { ISFUNC, (Function *)0x0 }, /* 2 */ - { ISFUNC, (Function *)0x0 }, /* 3 */ - { ISFUNC, (Function *)0x0 }, /* 4 */ - { ISFUNC, (Function *)0x0 }, /* 5 */ - { ISFUNC, (Function *)0x0 }, /* 6 */ - { ISFUNC, (Function *)0x0 }, /* 7 */ - { ISFUNC, (Function *)0x0 }, /* 8 */ - { ISFUNC, (Function *)0x0 }, /* 9 */ - - /* A little more punctuation. */ - { ISFUNC, (Function *)0x0 }, /* : */ - { ISFUNC, (Function *)0x0 }, /* ; */ - { ISFUNC, (Function *)0x0 }, /* < */ - { ISFUNC, (Function *)0x0 }, /* = */ - { ISFUNC, (Function *)0x0 }, /* > */ - { ISFUNC, (Function *)0x0 }, /* ? */ - { ISFUNC, (Function *)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, (Function *)0x0 }, /* [ */ - { ISFUNC, (Function *)0x0 }, /* \ */ - { ISFUNC, (Function *)0x0 }, /* ] */ - { ISFUNC, (Function *)0x0 }, /* ^ */ - { ISFUNC, (Function *)0x0 }, /* _ */ - { ISFUNC, (Function *)0x0 }, /* ` */ - - /* Lowercase alphabet. */ - { ISFUNC, (Function *)0x0 }, /* a */ - { ISFUNC, (Function *)0x0 }, /* b */ - { ISFUNC, (Function *)0x0 }, /* c */ - { ISFUNC, (Function *)0x0 }, /* d */ - { ISFUNC, rl_call_last_kbd_macro }, /* e */ - { ISFUNC, (Function *)0x0 }, /* f */ - { ISFUNC, (Function *)0x0 }, /* g */ - { ISFUNC, (Function *)0x0 }, /* h */ - { ISFUNC, (Function *)0x0 }, /* i */ - { ISFUNC, (Function *)0x0 }, /* j */ - { ISFUNC, (Function *)0x0 }, /* k */ - { ISFUNC, (Function *)0x0 }, /* l */ - { ISFUNC, (Function *)0x0 }, /* m */ - { ISFUNC, (Function *)0x0 }, /* n */ - { ISFUNC, (Function *)0x0 }, /* o */ - { ISFUNC, (Function *)0x0 }, /* p */ - { ISFUNC, (Function *)0x0 }, /* q */ - { ISFUNC, (Function *)0x0 }, /* r */ - { ISFUNC, (Function *)0x0 }, /* s */ - { ISFUNC, (Function *)0x0 }, /* t */ - { ISFUNC, (Function *)0x0 }, /* u */ - { ISFUNC, (Function *)0x0 }, /* v */ - { ISFUNC, (Function *)0x0 }, /* w */ - { ISFUNC, (Function *)0x0 }, /* x */ - { ISFUNC, (Function *)0x0 }, /* y */ - { ISFUNC, (Function *)0x0 }, /* z */ - - /* Final punctuation. */ - { ISFUNC, (Function *)0x0 }, /* { */ - { ISFUNC, (Function *)0x0 }, /* | */ - { ISFUNC, (Function *)0x0 }, /* } */ - { ISFUNC, (Function *)0x0 }, /* ~ */ - { ISFUNC, rl_backward_kill_line } /* RUBOUT */ -}; diff --git a/readline/examples/.Sanitize b/readline/examples/.Sanitize deleted file mode 100644 index a85109d..0000000 --- a/readline/examples/.Sanitize +++ /dev/null @@ -1,41 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -Inputrc -Makefile.in -fileman.c -histexamp.c -manexamp.c -rl.c -rltest.c - -Things-to-lose: - - -Do-last: - -# End of file. diff --git a/readline/examples/Inputrc b/readline/examples/Inputrc deleted file mode 100644 index db9510d..0000000 --- a/readline/examples/Inputrc +++ /dev/null @@ -1,58 +0,0 @@ -# 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. -# - -# 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 - -# 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-?" -$endif - -" ": self-insert diff --git a/readline/examples/fileman.c b/readline/examples/fileman.c deleted file mode 100644 index d1e72c5..0000000 --- a/readline/examples/fileman.c +++ /dev/null @@ -1,395 +0,0 @@ -/* 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. */ - -#include <stdio.h> -#include <readline/readline.h> -#include <readline/history.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/stat.h> -#include <sys/errno.h> - -/* The names of functions that actually do the manipulation. */ -int com_list (), com_view (), com_rename (), com_stat (), com_pwd (); -int com_delete (), com_help (), com_cd (), com_quit (); - -/* A structure which contains information on the commands this program - can understand. */ - -typedef struct { - char *name; /* User printable name of the function. */ - Function *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, (Function *)NULL, (char *)NULL } -}; - -/* 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 = 0; - -main (argc, argv) - int argc; - char **argv; -{ - progname = argv[0]; - - initialize_readline (); /* Bind our completer. */ - - /* Loop reading and executing lines until the user quits. */ - while (!done) - { - char *line; - - line = readline ("FileMan: "); - - if (!line) - { - done = 1; /* Encountered EOF at top level. */ - } - else - { - /* Remove leading and trailing whitespace from the line. - Then, if there is anything left, add it to the history list - and execute it. */ - stripwhite (line); - - if (*line) - { - add_history (line); - execute_line (line); - } - } - - if (line) - free (line); - } - exit (0); -} - -/* Execute a command line. */ -execute_line (line) - char *line; -{ - register int i; - COMMAND *find_command (), *command; - char *word; - - /* Isolate the command word. */ - i = 0; - while (line[i] && !whitespace (line[i])) - i++; - - word = line; - - if (line[i]) - line[i++] = '\0'; - - command = find_command (word); - - if (!command) - { - fprintf (stderr, "%s: No such command for FileMan.\n", word); - return; - } - - /* Get argument to command, if any. */ - while (whitespace (line[i])) - i++; - - word = line + i; - - /* Call the function. */ - (*(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. */ -stripwhite (string) - char *string; -{ - register int i = 0; - - while (whitespace (string[i])) - i++; - - if (i) - strcpy (string, string + i); - - i = strlen (string) - 1; - - while (i > 0 && whitespace (string[i])) - i--; - - string[++i] = '\0'; -} - -/* **************************************************************** */ -/* */ -/* Interface to Readline Completion */ -/* */ -/* **************************************************************** */ - -/* 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 () -{ - char **fileman_completion (); - - /* Allow conditional parsing of the ~/.inputrc file. */ - rl_readline_name = "FileMan"; - - /* Tell the completer that we want a crack first. */ - rl_attempted_completion_function = (Function *)fileman_completion; -} - -/* Attempt to complete on the contents of TEXT. START and END show the - region of TEXT that contains the word to complete. We can use the - entire line 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) - char *text; - int start, end; -{ - char **matches; - char *command_generator (); - - 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 = 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) - 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 (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); - system (syscom); -} - -com_view (arg) - char *arg; -{ - if (!valid_argument ("view", arg)) - return; - - sprintf (syscom, "cat %s | more", arg); - system (syscom); -} - -com_rename (arg) - char *arg; -{ - too_dangerous ("rename"); -} - -com_stat (arg) - char *arg; -{ - struct stat finfo; - - if (!valid_argument ("stat", arg)) - return; - - if (stat (arg, &finfo) == -1) - { - perror (arg); - return; - } - - printf ("Statistics for `%s':\n", arg); - - printf ("%s has %d link%s, and is %d bytes in length.\n", arg, - finfo.st_nlink, (finfo.st_nlink == 1) ? "" : "s", finfo.st_size); - printf (" Created on: %s", ctime (&finfo.st_ctime)); - printf (" Last access at: %s", ctime (&finfo.st_atime)); - printf ("Last modified at: %s", ctime (&finfo.st_mtime)); -} - -com_delete (arg) - char *arg; -{ - too_dangerous ("delete"); -} - -/* 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"); - } -} - -/* Change to the directory ARG. */ -com_cd (arg) - char *arg; -{ - if (chdir (arg) == -1) - perror (arg); - - com_pwd (""); -} - -/* Print out the current working directory. */ -com_pwd (ignore) - char *ignore; -{ - char dir[1024]; - - (void) getwd (dir); - - printf ("Current directory is %s\n", dir); -} - -/* The user wishes to quit using this program. Just set DONE non-zero. */ -com_quit (arg) - char *arg; -{ - done = 1; -} - -/* 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); -} - - -/* - * Local variables: - * compile-command: "cc -g -I../.. -L.. -o fileman fileman.c -lreadline -ltermcap" - * end: - */ diff --git a/readline/examples/histexamp.c b/readline/examples/histexamp.c deleted file mode 100644 index eceb66d..0000000 --- a/readline/examples/histexamp.c +++ /dev/null @@ -1,82 +0,0 @@ -main () -{ - 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"); - } - } - } -} diff --git a/readline/examples/manexamp.c b/readline/examples/manexamp.c deleted file mode 100644 index b7ec96a..0000000 --- a/readline/examples/manexamp.c +++ /dev/null @@ -1,96 +0,0 @@ -/* manexamp.c -- The examples which appear in the documentation are here. */ - -#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 * -do_gets () -{ - /* If the buffer has already been allocated, return the memory - to the free pool. */ - if (line_read != (char *)NULL) - { - 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 (uppercase_p (rl_line_buffer[start])) - rl_line_buffer[start] = to_lower (rl_line_buffer[start]); - else if (lowercase_p (rl_line_buffer[start])) - rl_line_buffer[start] = to_upper (rl_line_buffer[start]); - } - - /* Move point to on top of the last character changed. */ - rl_point = end - direction; -} - - diff --git a/readline/funmap.c b/readline/funmap.c deleted file mode 100644 index 7ac6a4d..0000000 --- a/readline/funmap.c +++ /dev/null @@ -1,270 +0,0 @@ -/* funmap.c -- attach names to functions. */ - -/* 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* #define STATIC_MALLOC */ -#if !defined (STATIC_MALLOC) -extern char *xmalloc (), *xrealloc (); -#else -static char *xmalloc (), *xrealloc (); -#endif /* STATIC_MALLOC */ - -#if !defined (BUFSIZ) -#include <stdio.h> -#endif /* BUFSIZ */ - -#include "readline.h" - -FUNMAP **funmap = (FUNMAP **)NULL; -static int funmap_size = 0; -static int funmap_entry = 0; - -/* 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-char", rl_backward }, - { "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 }, - { "clear-screen", rl_clear_screen }, - { "complete", rl_complete }, - { "delete-char", rl_delete }, - { "digit-argument", rl_digit_argument }, - { "do-lowercase-version", rl_do_lowercase_version }, - { "downcase-word", rl_downcase_word }, - { "dump-functions", rl_dump_functions }, - { "end-kbd-macro", rl_end_kbd_macro }, - { "end-of-history", rl_end_of_history }, - { "end-of-line", rl_end_of_line }, - { "forward-char", rl_forward }, - { "forward-search-history", rl_forward_search_history }, - { "forward-word", rl_forward_word }, - { "kill-line", rl_kill_line }, - { "kill-word", rl_kill_word }, - { "next-history", rl_get_next_history }, - { "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 }, - { "start-kbd-macro", rl_start_kbd_macro }, - { "tab-insert", rl_tab_insert }, - { "transpose-chars", rl_transpose_chars }, - { "transpose-words", rl_transpose_words }, - { "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-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-bWord", rl_vi_bWord }, - { "vi-bracktype", rl_vi_bracktype }, - { "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-comment", rl_vi_comment }, - { "vi-complete", rl_vi_complete }, - { "vi-delete", rl_vi_delete }, - { "vi-delete-to", rl_vi_delete_to }, - { "vi-dosearch", rl_vi_dosearch }, - { "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-first-print", rl_vi_first_print }, - { "vi-fword", rl_vi_fword }, - { "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-replace, ", rl_vi_replace }, - { "vi-search", rl_vi_search }, - { "vi-search-again", rl_vi_search_again }, - { "vi-subst", rl_vi_subst }, - { "vi-yank-arg", rl_vi_yank_arg }, - { "vi-yank-to", rl_vi_yank_to }, - -#endif /* VI_MODE */ - - {(char *)NULL, (Function *)NULL } -}; - -rl_add_funmap_entry (name, function) - char *name; - Function *function; -{ - if (funmap_entry + 2 >= funmap_size) - if (!funmap) - funmap = (FUNMAP **)xmalloc ((funmap_size = 80) * sizeof (FUNMAP *)); - else - funmap = - (FUNMAP **)xrealloc (funmap, (funmap_size += 80) * sizeof (FUNMAP *)); - - funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP)); - funmap[funmap_entry]->name = name; - funmap[funmap_entry]->function = function; - - funmap[++funmap_entry] = (FUNMAP *)NULL; -} - -static int funmap_initialized = 0; - -/* Make the funmap contain all of the default entries. */ -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; -} - -/* Stupid comparison routine for qsort () ing strings. */ -static int -qsort_string_compare (s1, s2) - register char **s1, **s2; -{ - return (strcmp (*s1, *s2)); -} - -/* 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. */ -char ** -rl_funmap_names () -{ - char **result = (char **)NULL; - int result_size, result_index; - - result_size = result_index = 0; - - /* Make sure that the function map has been initialized. */ - rl_initialize_funmap (); - - for (result_index = 0; funmap[result_index]; result_index++) - { - if (result_index + 2 > result_size) - { - if (!result) - result = (char **)xmalloc ((result_size = 20) * sizeof (char *)); - else - result = (char **) - xrealloc (result, (result_size += 20) * sizeof (char *)); - } - - result[result_index] = funmap[result_index]->name; - result[result_index + 1] = (char *)NULL; - } - - qsort (result, result_index, sizeof (char *), qsort_string_compare); - return (result); -} - -/* Things that mean `Control'. */ -char *possible_control_prefixes[] = { - "Control-", "C-", "CTRL-", (char *)NULL -}; - -char *possible_meta_prefixes[] = { - "Meta", "M-", (char *)NULL -}; - -#if defined (STATIC_MALLOC) - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)malloc (bytes); - else - temp = (char *)realloc (pointer, bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static void -memory_error_and_abort () -{ - fprintf (stderr, "history: Out of virtual memory!\n"); - abort (); -} -#endif /* STATIC_MALLOC */ diff --git a/readline/history.c b/readline/history.c deleted file mode 100644 index 828d717..0000000 --- a/readline/history.c +++ /dev/null @@ -1,1692 +0,0 @@ -/* History.c -- standalone history library */ - -/* Copyright (C) 1989, 1991 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 of the License, or - (at your option) any later version. - - The Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - 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., 675 Mass Ave, Cambridge, MA 02139, 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. */ - -/* Remove these declarations when we have a complete libgnu.a. */ -#if !defined (STATIC_MALLOC) -extern char *xmalloc (), *xrealloc (); -#else -static char *xmalloc (), *xrealloc (); -#endif - -#include "sysdep.h" -#include <stdio.h> -#include <errno.h> -#include <sys/types.h> -#ifndef NO_SYS_FILE -#include <sys/file.h> -#endif -#include <sys/stat.h> -#include <fcntl.h> - -#include "history.h" - -#ifndef savestring -#define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x)) -#endif - -#ifndef whitespace -#define whitespace(c) (((c) == ' ') || ((c) == '\t')) -#endif - -#ifndef digit -#define digit(c) ((c) >= '0' && (c) <= '9') -#endif - -#ifndef member -#define member(c, s) ((c) ? index ((s), (c)) : 0) -#endif - -/* **************************************************************** */ -/* */ -/* 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. */ -int history_stifled = 0; - -/* If HISTORY_STIFLED is non-zero, then this is the maximum number of - entries to remember. */ -int max_input_history; - -/* The current location of the interactive history pointer. Just makes - life easier for outside callers. */ -static int history_offset = 0; - -/* The number of strings currently stored in the input_history list. */ -int history_length = 0; - -/* The current number of slots allocated to the input_history. */ -static int history_size = 0; - -/* The number of slots to increase the_history by. */ -#define DEFAULT_HISTORY_GROW_SIZE 50 - -/* The character that represents the start of a history expansion - request. This is usually `!'. */ -char history_expansion_char = '!'; - -/* The character that invokes word substitution if found at the start of - a line. This is usually `^'. */ -char history_subst_char = '^'; - -/* During tokenization, if this character is seen as the first character - of a word, then it, and all subsequent characters upto a newline are - ignored. For a Bourne shell, this should be '#'. Bash special cases - the interactive comment character to not be a comment delimiter. */ -char history_comment_char = '\0'; - -/* The list of characters which inhibit the expansion of text if found - immediately following history_expansion_char. */ -char *history_no_expand_chars = " \t\n\r="; - -/* The logical `base' of the history array. It defaults to 1. */ -int history_base = 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; - - result = 0; - - for (i = 0; the_history && the_history[i]; i++) - result += strlen (the_history[i]->line); - - return (result); -} - -/* Place STRING at the end of the history list. The data field - is set to NULL. */ -void -add_history (string) - char *string; -{ - HIST_ENTRY *temp; - - if (history_stifled && (history_length == max_input_history)) - { - register int i; - - /* If the history is stifled, and history_length is zero, - and it equals max_input_history, we don't save items. */ - if (!history_length) - return; - - /* If there is something in the slot, then remove it. */ - if (the_history[0]) - { - free (the_history[0]->line); - free (the_history[0]); - } - - for (i = 0; i < history_length; i++) - the_history[i] = the_history[i + 1]; - - history_base++; - - } - else - { - if (!history_size) - { - the_history = (HIST_ENTRY **) - xmalloc ((history_size = DEFAULT_HISTORY_GROW_SIZE) - * sizeof (HIST_ENTRY *)); - history_length = 1; - - } - else - { - if (history_length == (history_size - 1)) - { - the_history = (HIST_ENTRY **) - xrealloc (the_history, - ((history_size += DEFAULT_HISTORY_GROW_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; - char *line; - char *data; -{ - HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); - HIST_ENTRY *old_value; - - if (which >= history_length) - return ((HIST_ENTRY *)NULL); - - old_value = the_history[which]; - - temp->line = savestring (line); - temp->data = data; - the_history[which] = temp; - - return (old_value); -} - -/* 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); -} - -/* 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. */ - -#define ANCHORED_SEARCH 1 -#define NON_ANCHORED_SEARCH 0 - -static int -history_search_internal (string, direction, anchored) - char *string; - int direction, anchored; -{ - register int i = history_offset; - register int reverse = (direction < 0); - register char *line; - register int index; - int string_len = strlen (string); - - /* Take care of trivial cases first. */ - - if (!history_length || ((i == history_length) && !reverse)) - return (-1); - - if (reverse && (i == history_length)) - i--; - - 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; - index = strlen (line); - - /* If STRING is longer than line, no match. */ - if (string_len > index) - goto next_line; - - /* Handle anchored searches first. */ - if (anchored == ANCHORED_SEARCH) - { - if (strncmp (string, line, string_len) == 0) - { - history_offset = i; - return (0); - } - - goto next_line; - } - - /* Do substring search. */ - if (reverse) - { - index -= string_len; - - while (index >= 0) - { - if (strncmp (string, line + index, string_len) == 0) - { - history_offset = i; - return (index); - } - index--; - } - } - else - { - register int limit = index - string_len + 1; - index = 0; - - while (index < limit) - { - if (strncmp (string, line + index, string_len) == 0) - { - history_offset = i; - return (index); - } - index++; - } - } - next_line: - if (reverse) - i--; - else - i++; - } -} - -/* Do a non-anchored search for STRING through the history in DIRECTION. */ -int -history_search (string, direction) - 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) - char *string; - int direction; -{ - return (history_search_internal (string, direction, ANCHORED_SEARCH)); -} - -/* 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; - - if (which >= history_length || !history_length) - return_value = (HIST_ENTRY *)NULL; - else - { - register int i; - 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; -{ - if (history_length > max) - { - register int i, j; - - /* This loses because we cannot free the data. */ - for (i = 0; i < (history_length - max); 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 = max; -} - -/* 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. */ -int -unstifle_history () -{ - int result = max_input_history; - if (history_stifled) - { - result = - result; - history_stifled = 0; - } - return (result); -} - -/* 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) - char *filename; -{ - char *return_val = filename ? savestring (filename) : (char *)NULL; - - if (!return_val) - { - char *home = (char *)getenv ("HOME"); - if (!home) home = "."; - return_val = (char *)xmalloc (2 + strlen (home) + strlen (".history")); - sprintf (return_val, "%s/.history", home); - } - 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) - 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) - char *filename; - int from, to; -{ - register int line_start, line_end; - char *input, *buffer = (char *)NULL; - int file, current_line; - struct stat finfo; - extern int errno; - - input = history_filename (filename); - file = open (input, O_RDONLY, 0666); - - if ((file < 0) || - (stat (input, &finfo) == -1)) - goto error_and_exit; - - buffer = (char *)xmalloc (finfo.st_size + 1); - - if (read (file, buffer, finfo.st_size) != finfo.st_size) - error_and_exit: - { - if (file >= 0) - close (file); - - if (buffer) - free (buffer); - - return (errno); - } - - close (file); - - /* Set TO to larger than end of file if negative. */ - if (to < 0) - to = finfo.st_size; - - /* Start at beginning of file, work to end. */ - line_start = line_end = current_line = 0; - - /* Skip lines until we are at FROM. */ - while (line_start < finfo.st_size && current_line < from) - { - for (line_end = line_start; line_end < finfo.st_size; line_end++) - if (buffer[line_end] == '\n') - { - current_line++; - line_start = line_end + 1; - if (current_line == from) - break; - } - } - - /* If there are lines left to gobble, then gobble them now. */ - for (line_end = line_start; line_end < finfo.st_size; line_end++) - if (buffer[line_end] == '\n') - { - buffer[line_end] = '\0'; - - if (buffer[line_start]) - add_history (buffer + line_start); - - current_line++; - - if (current_line >= to) - break; - - line_start = line_end + 1; - } - return (0); -} - -/* Truncate the history file FNAME, leaving only LINES trailing lines. - If FNAME is NULL, then use ~/.history. */ -history_truncate_file (fname, lines) - char *fname; - register int lines; -{ - register int i; - int file; - char *buffer = (char *)NULL, *filename; - struct stat finfo; - - filename = history_filename (fname); - if (stat (filename, &finfo) == -1) - goto truncate_exit; - - file = open (filename, O_RDONLY, 0666); - - if (file == -1) - goto truncate_exit; - - buffer = (char *)xmalloc (finfo.st_size + 1); - read (file, buffer, finfo.st_size); - close (file); - - /* Count backwards from the end of buffer until we have passed - LINES lines. */ - for (i = finfo.st_size; lines && i; i--) - { - if (buffer[i] == '\n') - lines--; - } - - /* If there are fewer lines in the file than we want to truncate to, - then we are all done. */ - if (!i) - goto truncate_exit; - - /* Otherwise, write from the start of this line until the end of the - buffer. */ - for (--i; i; i--) - if (buffer[i] == '\n') - { - i++; - break; - } - - file = open (filename, O_WRONLY | O_TRUNC | O_CREAT, 0666); - if (file == -1) - goto truncate_exit; - - write (file, buffer + i, finfo.st_size - i); - close (file); - - truncate_exit: - if (buffer) - free (buffer); - - free (filename); -} - -#define HISTORY_APPEND 0 -#define HISTORY_OVERWRITE 1 - -/* 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) - char *filename; - int nelements, overwrite; -{ - extern int errno; - register int i, j; - char *output = history_filename (filename); - int file, mode; - - if (overwrite) - mode = O_WRONLY | O_CREAT | O_TRUNC; - else - mode = O_WRONLY | O_APPEND; - - if ((file = open (output, mode, 0666)) == -1) - return (errno); - - 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). */ - { - register int j = 0; - int buffer_size = 0; - char *buffer; - - /* Calculate the total number of bytes to write. */ - for (i = history_length - nelements; i < history_length; i++) - buffer_size += 1 + strlen (the_history[i]->line); - - /* Allocate the buffer, and fill it. */ - buffer = (char *)xmalloc (buffer_size); - - for (i = history_length - nelements; i < history_length; i++) - { - strcpy (buffer + j, the_history[i]->line); - j += strlen (the_history[i]->line); - buffer[j++] = '\n'; - } - - write (file, buffer, buffer_size); - free (buffer); - } - - close (file); - return (0); -} - -/* 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; - 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) - char *filename; -{ - return (history_do_write (filename, history_length, HISTORY_OVERWRITE)); -} - -/* 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 () -{ - if ((history_offset == history_length) || !the_history) - return ((HIST_ENTRY *)NULL); - else - return (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 () -{ - if (!history_offset) - return ((HIST_ENTRY *)NULL); - else - return (the_history[--history_offset]); -} - -/* 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 () -{ - if (history_offset == history_length) - return ((HIST_ENTRY *)NULL); - else - return (the_history[++history_offset]); -} - -/* 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 which is logically at OFFSET in the history array. - OFFSET is relative to history_base. */ -HIST_ENTRY * -history_get (offset) - int offset; -{ - int index = offset - history_base; - - if (index >= history_length || - index < 0 || - !the_history) - return ((HIST_ENTRY *)NULL); - return (the_history[index]); -} - -/* 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) - char *string; - int dir, pos; -{ - int ret, 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; -} - -/* 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); -} - - -/* **************************************************************** */ -/* */ -/* History Expansion */ -/* */ -/* **************************************************************** */ - -/* Hairy history expansion on text, not tokens. This is of general - use, and thus belongs in this library. */ - -/* The last string searched for in a !?string? search. */ -static char *search_string = (char *)NULL; - -/* Return the event specified at TEXT + OFFSET modifying OFFSET to - point to after the event specifier. Just a pointer to the history - line is returned; NULL is returned in the event of a bad specifier. - You 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 `?'. - So you might call this function like: - line = get_history_event ("!echo:p", &index, 0); */ -char * -get_history_event (string, caller_index, delimiting_quote) - char *string; - int *caller_index; - int delimiting_quote; -{ - register int i = *caller_index; - int which, sign = 1; - HIST_ENTRY *entry; - - /* The event can be specified in a number of ways. - - !! the previous command - !n command line N - !-n current command-line minus N - !str the most recent command starting with STR - !?str[?] - the most recent command containing STR - - All values N are determined via HISTORY_BASE. */ - - if (string[i] != history_expansion_char) - return ((char *)NULL); - - /* Move on to the specification. */ - i++; - - /* Handle !! case. */ - if (string[i] == history_expansion_char) - { - i++; - which = history_base + (history_length - 1); - *caller_index = i; - goto get_which; - } - - /* Hack case of numeric line specification. */ - read_which: - if (string[i] == '-') - { - sign = -1; - i++; - } - - if (digit (string[i])) - { - int start = i; - - /* Get the extent of the digits. */ - for (; digit (string[i]); i++); - - /* Get the digit value. */ - sscanf (string + start, "%d", &which); - - *caller_index = i; - - if (sign < 0) - which = (history_length + history_base) - which; - - get_which: - if (entry = history_get (which)) - return (entry->line); - - return ((char *)NULL); - } - - /* This must be something to search for. If the spec begins with - a '?', then the string may be anywhere on the line. Otherwise, - the string must be found at the start of a line. */ - { - int index; - char *temp; - int substring_okay = 0; - - if (string[i] == '?') - { - substring_okay++; - i++; - } - - for (index = i; string[i]; i++) - if (whitespace (string[i]) || - string[i] == '\n' || - string[i] == ':' || - (substring_okay && string[i] == '?') || - string[i] == delimiting_quote) - break; - - temp = (char *)alloca (1 + (i - index)); - strncpy (temp, &string[index], (i - index)); - temp[i - index] = '\0'; - - if (string[i] == '?') - i++; - - *caller_index = i; - - search_again: - - index = history_search_internal - (temp, -1, substring_okay ? NON_ANCHORED_SEARCH : ANCHORED_SEARCH); - - if (index < 0) - search_lost: - { - history_offset = history_length; - return ((char *)NULL); - } - - if (index == 0) - { - search_won: - entry = current_history (); - history_offset = history_length; - - /* If this was a substring search, then remember the string that - we matched for word substitution. */ - if (substring_okay) - { - if (search_string) - free (search_string); - search_string = savestring (temp); - } - - return (entry->line); - } - - if (history_offset) - history_offset--; - else - goto search_lost; - - goto search_again; - } -} - -/* 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. - - If an error ocurred in expansion, then OUTPUT contains a descriptive - error message. */ -int -history_expand (string, output) - char *string; - char **output; -{ - register int j, l = strlen (string); - int i, word_spec_error = 0; - int cc, modified = 0; - char *word_spec, *event; - int starting_index, only_printing = 0, substitute_globally = 0; - - char *get_history_word_specifier (), *rindex (); - - /* The output string, and its length. */ - int len = 0; - char *result = (char *)NULL; - - /* Used in add_string; */ - char *temp, tt[2], tbl[3]; - - /* Prepare the buffer for printing error messages. */ - result = (char *)xmalloc (len = 255); - - result[0] = tt[1] = tbl[2] = '\0'; - tbl[0] = '\\'; - tbl[1] = history_expansion_char; - - /* Grovel the string. Only backslash can quote the history escape - character. We also handle arg specifiers. */ - - /* Before we grovel forever, see if the history_expansion_char appears - anywhere within the text. */ - - /* The quick substitution character is a history expansion all right. That - is to say, "^this^that^" is equivalent to "!!:s^this^that^", and in fact, - that is the substitution that we do. */ - if (string[0] == history_subst_char) - { - char *format_string = (char *)alloca (10 + strlen (string)); - - sprintf (format_string, "%c%c:s%s", - history_expansion_char, history_expansion_char, - string); - string = format_string; - l += 4; - goto grovel; - } - - /* If not quick substitution, still maybe have to do expansion. */ - - /* `!' followed by one of the characters in history_no_expand_chars - is NOT an expansion. */ - for (i = 0; string[i]; i++) - if (string[i] == history_expansion_char) - if (!string[i + 1] || member (string[i + 1], history_no_expand_chars)) - continue; - else - goto grovel; - - free (result); - *output = savestring (string); - return (0); - - grovel: - - for (i = j = 0; i < l; i++) - { - int tchar = string[i]; - if (tchar == history_expansion_char) - tchar = -3; - - switch (tchar) - { - case '\\': - if (string[i + 1] == history_expansion_char) - { - i++; - temp = tbl; - goto do_add; - } - else - goto add_char; - - /* case history_expansion_char: */ - case -3: - starting_index = i + 1; - cc = string[i + 1]; - - /* If the history_expansion_char is followed by one of the - characters in history_no_expand_chars, then it is not a - candidate for expansion of any kind. */ - if (member (cc, history_no_expand_chars)) - goto add_char; - - /* There is something that is listed as a `word specifier' in csh - documentation which means `the expanded text to this point'. - That is not a word specifier, it is an event specifier. */ - - if (cc == '#') - goto hack_pound_sign; - - /* If it is followed by something that starts a word specifier, - then !! is implied as the event specifier. */ - - if (member (cc, ":$*%^")) - { - char fake_s[3]; - int fake_i = 0; - i++; - fake_s[0] = fake_s[1] = history_expansion_char; - fake_s[2] = '\0'; - event = get_history_event (fake_s, &fake_i, 0); - } - else - { - int quoted_search_delimiter = 0; - - /* If the character before this `!' is a double or single - quote, then this expansion takes place inside of the - quoted string. If we have to search for some text ("!foo"), - allow the delimiter to end the search string. */ - if (i && (string[i - 1] == '\'' || string[i - 1] == '"')) - quoted_search_delimiter = string[i - 1]; - - event = get_history_event (string, &i, quoted_search_delimiter); - } - - if (!event) - event_not_found: - { - int l = 1 + (i - starting_index); - - temp = (char *)alloca (1 + l); - strncpy (temp, string + starting_index, l); - temp[l - 1] = 0; - sprintf (result, "%s: %s.", temp, - word_spec_error ? "Bad word specifier" : "Event not found"); - error_exit: - *output = result; - return (-1); - } - - /* If a word specifier is found, then do what that requires. */ - starting_index = i; - - word_spec = get_history_word_specifier (string, event, &i); - - /* There is no such thing as a `malformed word specifier'. However, - it is possible for a specifier that has no match. In that case, - we complain. */ - if (word_spec == (char *)-1) - bad_word_spec: - { - word_spec_error++; - goto event_not_found; - } - - /* If no word specifier, than the thing of interest was the event. */ - if (!word_spec) - temp = event; - else - { - temp = (char *)alloca (1 + strlen (word_spec)); - strcpy (temp, word_spec); - free (word_spec); - } - - /* Perhaps there are other modifiers involved. Do what they say. */ - - hack_specials: - - if (string[i] == ':') - { - char *tstr; - - switch (string[i + 1]) - { - /* :p means make this the last executed line. So we - return an error state after adding this line to the - history. */ - case 'p': - only_printing++; - goto next_special; - - /* :t discards all but the last part of the pathname. */ - case 't': - tstr = rindex (temp, '/'); - if (tstr) - temp = ++tstr; - goto next_special; - - /* :h discards the last part of a pathname. */ - case 'h': - tstr = rindex (temp, '/'); - if (tstr) - *tstr = '\0'; - goto next_special; - - /* :r discards the suffix. */ - case 'r': - tstr = rindex (temp, '.'); - if (tstr) - *tstr = '\0'; - goto next_special; - - /* :e discards everything but the suffix. */ - case 'e': - tstr = rindex (temp, '.'); - if (tstr) - temp = tstr; - goto next_special; - - /* :s/this/that substitutes `this' for `that'. */ - /* :gs/this/that substitutes `this' for `that' globally. */ - case 'g': - if (string[i + 2] == 's') - { - i++; - substitute_globally = 1; - goto substitute; - } - else - - case 's': - substitute: - { - char *this, *that, *new_event; - int delimiter = 0; - int si, l_this, l_that, l_temp = strlen (temp); - - if (i + 2 < strlen (string)) - delimiter = string[i + 2]; - - if (!delimiter) - break; - - i += 3; - - /* Get THIS. */ - for (si = i; string[si] && string[si] != delimiter; si++); - l_this = (si - i); - this = (char *)alloca (1 + l_this); - strncpy (this, string + i, l_this); - this[l_this] = '\0'; - - i = si; - if (string[si]) - i++; - - /* Get THAT. */ - for (si = i; string[si] && string[si] != delimiter; si++); - l_that = (si - i); - that = (char *)alloca (1 + l_that); - strncpy (that, string + i, l_that); - that[l_that] = '\0'; - - i = si; - if (string[si]) i++; - - /* Ignore impossible cases. */ - if (l_this > l_temp) - goto cant_substitute; - - /* Find the first occurrence of THIS in TEMP. */ - si = 0; - for (; (si + l_this) <= l_temp; si++) - if (strncmp (temp + si, this, l_this) == 0) - { - new_event = - (char *)alloca (1 + (l_that - l_this) + l_temp); - strncpy (new_event, temp, si); - strncpy (new_event + si, that, l_that); - strncpy (new_event + si + l_that, - temp + si + l_this, - l_temp - (si + l_this)); - new_event[(l_that - l_this) + l_temp] = '\0'; - temp = new_event; - - if (substitute_globally) - { - si += l_that; - l_temp = strlen (temp); - substitute_globally++; - continue; - } - - goto hack_specials; - } - - cant_substitute: - - if (substitute_globally > 1) - { - substitute_globally = 0; - goto hack_specials; - } - - goto event_not_found; - } - - /* :# is the line so far. Note that we have to - alloca () it since RESULT could be realloc ()'ed - below in add_string. */ - case '#': - hack_pound_sign: - if (result) - { - temp = (char *)alloca (1 + strlen (result)); - strcpy (temp, result); - } - else - temp = ""; - - next_special: - i += 2; - goto hack_specials; - } - - } - /* Believe it or not, we have to back the pointer up by one. */ - --i; - goto add_string; - - /* A regular character. Just add it to the output string. */ - default: - add_char: - tt[0] = string[i]; - temp = tt; - goto do_add; - - add_string: - modified++; - - do_add: - j += strlen (temp); - while (j > len) - result = (char *)xrealloc (result, (len += 255)); - - strcpy (result + (j - strlen (temp)), temp); - } - } - - *output = result; - - if (only_printing) - { - add_history (result); - return (-1); - } - - return (modified != 0); -} - -/* Return a consed string which is the word specified in SPEC, and found - in FROM. NULL is returned if there is no spec. -1 is returned if - the word specified cannot be found. CALLER_INDEX is the offset in - SPEC to start looking; it is updated to point to just after the last - character parsed. */ -char * -get_history_word_specifier (spec, from, caller_index) - char *spec, *from; - int *caller_index; -{ - register int i = *caller_index; - int first, last; - int expecting_word_spec = 0; - char *history_arg_extract (); - - /* The range of words to return doesn't exist yet. */ - first = last = 0; - - /* If we found a colon, then this *must* be a word specification. If - it isn't, then it is an error. */ - if (spec[i] == ':') - i++, expecting_word_spec++; - - /* Handle special cases first. */ - - /* `%' is the word last searched for. */ - if (spec[i] == '%') - { - *caller_index = i + 1; - if (search_string) - return (savestring (search_string)); - else - return (savestring ("")); - } - - /* `*' matches all of the arguments, but not the command. */ - if (spec[i] == '*') - { - char *star_result; - - *caller_index = i + 1; - star_result = history_arg_extract (1, '$', from); - - if (!star_result) - star_result = savestring (""); - - return (star_result); - } - - /* `$' is last arg. */ - if (spec[i] == '$') - { - *caller_index = i + 1; - return (history_arg_extract ('$', '$', from)); - } - - /* Try to get FIRST and LAST figured out. */ - if (spec[i] == '-' || spec[i] == '^') - { - first = 1; - goto get_last; - } - - get_first: - if (digit (spec[i]) && expecting_word_spec) - { - sscanf (spec + i, "%d", &first); - for (; digit (spec[i]); i++); - } - else - return ((char *)NULL); - - get_last: - if (spec[i] == '^') - { - i++; - last = 1; - goto get_args; - } - - if (spec[i] != '-') - { - last = first; - goto get_args; - } - - i++; - - if (digit (spec[i])) - { - sscanf (spec + i, "%d", &last); - for (; digit (spec[i]); i++); - } - else - if (spec[i] == '$') - { - i++; - last = '$'; - } - - get_args: - { - char *result = (char *)NULL; - - *caller_index = i; - - if (last >= first) - result = history_arg_extract (first, last, from); - - if (result) - return (result); - else - return ((char *)-1); - } -} - -/* Extract the args specified, starting at FIRST, and ending at LAST. - The args are taken from STRING. If either FIRST or LAST is < 0, - then make that arg count from the right (subtract from the number of - tokens, so that FIRST = -1 means the next to last token on the line). */ -char * -history_arg_extract (first, last, string) - int first, last; - char *string; -{ - register int i, len; - char *result = (char *)NULL; - int size = 0, offset = 0; - - char **history_tokenize (), **list; - - if (!(list = history_tokenize (string))) - return ((char *)NULL); - - for (len = 0; list[len]; len++); - - if (last < 0) - last = len + last - 1; - - if (first < 0) - first = len + first - 1; - - if (last == '$') - last = len - 1; - - if (first == '$') - first = len - 1; - - last++; - - if (first > len || last > len || first < 0 || last < 0) - result = ((char *)NULL); - else - { - for (i = first; i < last; i++) - { - int l = strlen (list[i]); - - if (!result) - result = (char *)xmalloc ((size = (2 + l))); - else - result = (char *)xrealloc (result, (size += (2 + l))); - strcpy (result + offset, list[i]); - offset += l; - if (i + 1 < last) - { - strcpy (result + offset, " "); - offset++; - } - } - } - - for (i = 0; i < len; i++) - free (list[i]); - - free (list); - - return (result); -} - -#define slashify_in_quotes "\\`\"$" - -/* Return an array of tokens, much as the shell might. The tokens are - parsed out of STRING. */ -char ** -history_tokenize (string) - char *string; -{ - char **result = (char **)NULL; - register int i, start, result_index, size; - int len; - - i = result_index = size = 0; - - /* Get a token, and stuff it into RESULT. The tokens are split - exactly where the shell would split them. */ - get_token: - - /* Skip leading whitespace. */ - for (; string[i] && whitespace(string[i]); i++); - - start = i; - - if (!string[i] || string[i] == history_comment_char) - return (result); - - if (member (string[i], "()\n")) { - i++; - goto got_token; - } - - if (member (string[i], "<>;&|")) { - int peek = string[i + 1]; - - if (peek == string[i]) { - if (peek == '<') { - if (string[1 + 2] == '-') - i++; - i += 2; - goto got_token; - } - - if (member (peek, ">:&|")) { - i += 2; - goto got_token; - } - } else { - if ((peek == '&' && - (string[i] == '>' || string[i] == '<')) || - ((peek == '>') && - (string[i] == '&'))) { - i += 2; - goto got_token; - } - } - i++; - goto got_token; - } - - /* Get word from string + i; */ - { - int delimiter = 0; - - if (member (string[i], "\"'`")) - delimiter = string[i++]; - - for (;string[i]; i++) { - - if (string[i] == '\\') { - - if (string[i + 1] == '\n') { - i++; - continue; - } else { - if (delimiter != '\'') - if ((delimiter != '"') || - (member (string[i], slashify_in_quotes))) { - i++; - continue; - } - } - } - - if (delimiter && string[i] == delimiter) { - delimiter = 0; - continue; - } - - if (!delimiter && (member (string[i], " \t\n;&()|<>"))) - goto got_token; - - if (!delimiter && member (string[i], "\"'`")) { - delimiter = string[i]; - continue; - } - } - got_token: - - len = i - start; - if (result_index + 2 >= size) { - if (!size) - result = (char **)xmalloc ((size = 10) * (sizeof (char *))); - else - result = - (char **)xrealloc (result, ((size += 10) * (sizeof (char *)))); - } - result[result_index] = (char *)xmalloc (1 + len); - strncpy (result[result_index], string + start, len); - result[result_index][len] = '\0'; - result_index++; - result[result_index] = (char *)NULL; - } - if (string[i]) - goto get_token; - - return (result); -} - -#if defined (STATIC_MALLOC) - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)xmalloc (bytes); - else - temp = (char *)realloc (pointer, bytes); - - if (!temp) - memory_error_and_abort (); - - return (temp); -} - -static void -memory_error_and_abort () -{ - fprintf (stderr, "history: Out of virtual memory!\n"); - abort (); -} -#endif /* STATIC_MALLOC */ - - -/* **************************************************************** */ -/* */ -/* Test Code */ -/* */ -/* **************************************************************** */ -#ifdef TEST -main () -{ - char line[1024], *t; - int done = 0; - - line[0] = 0; - - while (!done) - { - fprintf (stdout, "history%% "); - t = gets (line); - - if (!t) - strcpy (line, "quit"); - - if (line[0]) - { - char *expansion; - int result; - - using_history (); - - result = history_expand (line, &expansion); - strcpy (line, expansion); - free (expansion); - if (result) - fprintf (stderr, "%s\n", line); - - if (result < 0) - continue; - - add_history (line); - } - - if (strcmp (line, "quit") == 0) done = 1; - if (strcmp (line, "save") == 0) write_history (0); - if (strcmp (line, "read") == 0) read_history (0); - if (strcmp (line, "list") == 0) - { - register HIST_ENTRY **the_list = history_list (); - register int i; - - if (the_list) - for (i = 0; the_list[i]; i++) - fprintf (stdout, "%d: %s\n", i + history_base, the_list[i]->line); - } - if (strncmp (line, "delete", strlen ("delete")) == 0) - { - int which; - if ((sscanf (line + strlen ("delete"), "%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"); - } - } - } -} - -#endif /* TEST */ - -/* -* Local variables: -* compile-command: "gcc -g -DTEST -o history history.c" -* end: -*/ diff --git a/readline/history.h b/readline/history.h deleted file mode 100644 index 0bac209..0000000 --- a/readline/history.h +++ /dev/null @@ -1,108 +0,0 @@ -/* History.h -- the names of functions that you can call in history. */ - -typedef struct _hist_entry { - char *line; - char *data; -} HIST_ENTRY; - -/* For convenience only. You set this when interpreting history commands. - It is the logical offset of the first history element. */ -extern int history_base; - -/* Begin a session in which the history functions might be used. This - just initializes the interactive variables. */ -extern void using_history (); - -/* Place STRING at the end of the history list. - The associated data field (if any) is set to NULL. */ -extern void add_history (); - -/* Returns the number which says what history element we are now - looking at. */ -extern int where_history (); - -/* Set the position in the history list to POS. */ -int history_set_pos (); - -/* 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 (); - -/* 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 (); - -/* Stifle the history list, remembering only MAX number of entries. */ -extern void stifle_history (); - -/* 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 (); - -/* 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 (); - -/* Append the current history to FILENAME. If FILENAME is NULL, - then append the history list to ~/.history. Values returned - are as in read_history (). */ -extern int write_history (); - - -/* 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 (); - -/* 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 (); - -/* 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 (); - -/* 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 (); - -/* 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 (); - -/* 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 (); - -/* 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. - - If an error ocurred in expansion, then OUTPUT contains a descriptive - error message. */ -extern int history_expand (); - -/* 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 (); - - diff --git a/readline/isearch.c b/readline/isearch.c deleted file mode 100644 index 9b44c93..0000000 --- a/readline/isearch.c +++ /dev/null @@ -1,378 +0,0 @@ -/* **************************************************************** */ -/* */ -/* I-Search and Searching */ -/* */ -/* **************************************************************** */ - -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include <stdio.h> - -#if defined (__GNUC__) -# define alloca __builtin_alloca -#else -# if defined (sparc) || defined (HAVE_ALLOCA_H) -# include <alloca.h> -# endif -#endif - -#include "readline.h" -#include "history.h" - -extern Keymap _rl_keymap; -extern HIST_ENTRY *saved_line_for_history; -extern int rl_line_buffer_len; -extern int rl_point, rl_end; -extern char *rl_prompt, *rl_line_buffer; - -/* Remove these declarations when we have a complete libgnu.a. */ -extern char *xmalloc (), *xrealloc (); - -static void rl_search_history (); - -/* Search backwards through the history looking for a string which is typed - interactively. Start with the current line. */ -rl_reverse_search_history (sign, key) - int sign; - int key; -{ - rl_search_history (-sign, key); -} - -/* Search forwards through the history looking for a string which is typed - interactively. Start with the current line. */ -rl_forward_search_history (sign, key) - int sign; - int key; -{ - 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 = (char *)NULL; - - message = - (char *)xmalloc (1 + (search_string ? strlen (search_string) : 0) + 30); - - *message = '\0'; - -#if defined (NOTDEF) - if (where != -1) - sprintf (message, "[%d]", where + history_base); -#endif /* NOTDEF */ - - strcat (message, "("); - - if (reverse_p) - strcat (message, "reverse-"); - - strcat (message, "i-search)`"); - - if (search_string) - strcat (message, search_string); - - strcat (message, "': "); - rl_message ("%s", message, 0); - free (message); - rl_redisplay (); -} - -/* 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 void -rl_search_history (direction, invoking_key) - int direction; - int 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; - - /* The length of LINES. */ - int hlen; - - /* Where we get LINES from. */ - HIST_ENTRY **hlist = history_list (); - - register int i = 0; - int orig_point = rl_point; - int orig_line = where_history (); - int last_found_line = orig_line; - int c, done = 0; - - /* The line currently being searched. */ - char *sline; - - /* Offset in that line. */ - int index; - - /* Non-zero if we are doing a reverse search. */ - int reverse = (direction < 0); - - /* Create an arrary of pointers to the lines that we want to search. */ - maybe_replace_line (); - 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 **)alloca ((1 + (hlen = i)) * sizeof (char *)); - for (i = 0; i < hlen; i++) - lines[i] = hlist[i]->line; - - if (saved_line_for_history) - lines[i] = saved_line_for_history->line; - else - /* So I have to type it in this way instead. */ - { - char *alloced_line; - - /* Keep that MIPS alloca () happy. */ - alloced_line = (char *)alloca (1 + strlen (rl_line_buffer)); - lines[i] = alloced_line; - strcpy (lines[i], &rl_line_buffer[0]); - } - - hlen++; - - /* The line where we start the search. */ - i = orig_line; - - /* Initialize search parameters. */ - search_string = (char *)xmalloc (search_string_size = 128); - *search_string = '\0'; - search_string_index = 0; - - /* Normalize DIRECTION into 1 or -1. */ - if (direction >= 0) - direction = 1; - else - direction = -1; - - rl_display_search (search_string, reverse, -1); - - sline = rl_line_buffer; - index = rl_point; - - while (!done) - { - c = rl_read_key (); - - /* Hack C to Do What I Mean. */ - { - Function *f = (Function *)NULL; - - if (_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; - } - } - - switch (c) - { - case ESC: - done = 1; - continue; - - /* case invoking_key: */ - case -1: - goto search_again; - - /* switch directions */ - case -2: - direction = -direction; - reverse = (direction < 0); - - goto do_search; - - case CTRL ('G'): - strcpy (rl_line_buffer, lines[orig_line]); - rl_point = orig_point; - rl_end = strlen (rl_line_buffer); - rl_clear_message (); - return; - - default: - if (c < 32 || c > 126) - { - rl_execute_next (c); - done = 1; - continue; - } - else - { - if (search_string_index + 2 >= search_string_size) - search_string = (char *)xrealloc - (search_string, (search_string_size += 128)); - search_string[search_string_index++] = c; - search_string[search_string_index] = '\0'; - goto do_search; - - search_again: - - if (!search_string_index) - continue; - else - { - if (reverse) - --index; - else - if (index != strlen (sline)) - ++index; - else - ding (); - } - do_search: - - while (1) - { - if (reverse) - { - while (index >= 0) - if (strncmp - (search_string, sline + index, search_string_index) - == 0) - goto string_found; - else - index--; - } - else - { - register int limit = - (strlen (sline) - search_string_index) + 1; - - while (index < limit) - { - if (strncmp (search_string, - sline + index, - search_string_index) == 0) - goto string_found; - index++; - } - } - - next_line: - i += direction; - - /* At limit for direction? */ - if ((reverse && i < 0) || - (!reverse && i == hlen)) - goto search_failed; - - sline = lines[i]; - if (reverse) - index = strlen (sline); - else - index = 0; - - /* If the search string is longer than the current - line, no match. */ - if (search_string_index > (int)strlen (sline)) - goto next_line; - - /* Start actually searching. */ - if (reverse) - index -= search_string_index; - } - - search_failed: - /* We cannot find the search string. Ding the bell. */ - ding (); - i = last_found_line; - break; - - string_found: - /* 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. */ - { - int line_len; - - line_len = strlen (lines[i]); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strcpy (rl_line_buffer, lines[i]); - rl_point = index; - rl_end = line_len; - last_found_line = i; - rl_display_search - (search_string, reverse, (i == orig_line) ? -1 : i); - } - } - } - continue; - } - - /* 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 - INDEX is -1, then that shows that the string searched for was not - found. We use this to determine where to place rl_point. */ - { - int now = last_found_line; - - /* First put back the original state. */ - strcpy (rl_line_buffer, lines[orig_line]); - - /* Free the search string. */ - free (search_string); - - if (now < orig_line) - rl_get_previous_history (orig_line - now); - else - rl_get_next_history (now - orig_line); - - /* If the index of the "matched" string is less than zero, then the - final search string was never matched, so put point somewhere - reasonable. */ - if (index < 0) - index = strlen (rl_line_buffer); - - rl_point = index; - rl_clear_message (); - } -} diff --git a/readline/keymaps.c b/readline/keymaps.c deleted file mode 100644 index e4c3884..0000000 --- a/readline/keymaps.c +++ /dev/null @@ -1,177 +0,0 @@ -/* 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "keymaps.h" -#include "emacs_keymap.c" - -#ifdef VI_MODE -#include "vi_keymap.c" -#endif - -/* Remove these declarations when we have a complete libgnu.a. */ -/* #define STATIC_MALLOC */ -#if !defined (STATIC_MALLOC) -extern char *xmalloc (), *xrealloc (); -#else -static char *xmalloc (), *xrealloc (); -#endif /* STATIC_MALLOC */ - -/* **************************************************************** */ -/* */ -/* 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 (128 * sizeof (KEYMAP_ENTRY)); - - for (i = 0; i < 128; i++) - { - keymap[i].type = ISFUNC; - keymap[i].function = (Function *)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 < 128; 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 () -{ - extern rl_insert (), rl_rubout (); - register int i; - Keymap newmap; - - newmap = rl_make_bare_keymap (); - - /* All printing characters are self-inserting. */ - for (i = ' '; i < 126; i++) - newmap[i].function = rl_insert; - - newmap[TAB].function = rl_insert; - newmap[RUBOUT].function = rl_rubout; - newmap[CTRL('H')].function = rl_rubout; - - return (newmap); -} - -/* Free the storage associated with MAP. */ -rl_discard_keymap (map) - Keymap (map); -{ - int i; - - if (!map) - return; - - for (i = 0; i < 128; 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; - } - } -} - -#ifdef STATIC_MALLOC - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)malloc (bytes); - else - temp = (char *)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 (); -} -#endif /* STATIC_MALLOC */ diff --git a/readline/keymaps.h b/readline/keymaps.h deleted file mode 100644 index 5fd0cba..0000000 --- a/readline/keymaps.h +++ /dev/null @@ -1,86 +0,0 @@ -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _KEYMAPS_H_ -#define _KEYMAPS_H_ - -#include <readline/chardefs.h> - -#ifndef __FUNCTION_DEF -typedef int Function (); -#define __FUNCTION_DEF -#endif - -/* A keymap contains one entry for each key in the ASCII set. - Each entry consists of a type and a pointer. - POINTER is the address of a function to run, or the - address of a keymap to indirect through. - TYPE says which kind of thing POINTER is. */ -typedef struct _keymap_entry { - char type; - Function *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). */ -#define KEYMAP_SIZE 256 - -/* I wanted to make the above structure contain a union of: - union { Function *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. */ -Keymap rl_make_bare_keymap (); - -/* Return a new keymap which is a copy of MAP. */ -Keymap rl_copy_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. */ -Keymap rl_make_keymap (); - -/* Return the keymap corresponding to a given name. Names look like - `emacs' or `emacs-meta' or `vi-insert'. */ -Keymap rl_get_keymap_by_name (); - -/* Return the current keymap. */ -Keymap rl_get_keymap (); - -/* Set the current keymap to MAP. */ -void rl_set_keymap (); - -#endif /* _KEYMAPS_H_ */ diff --git a/readline/parens.c b/readline/parens.c deleted file mode 100644 index 2c96012..0000000 --- a/readline/parens.c +++ /dev/null @@ -1,115 +0,0 @@ -/* parens.c -- Implemenation of matching parenthesis 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include <stdio.h> -#include <sys/types.h> -#include <sys/time.h> -#include "readline.h" - -/* Non-zero means try to blink the matching open parenthesis when the - close parenthesis is inserted. */ -#if defined (FD_SET) -int rl_blink_matching_paren = 1; -#else /* !FD_SET */ -int rl_blink_matching_paren = 0; -#endif /* !FD_SET */ - -static int find_matching_open (); - -rl_insert_close (count, invoking_key) - int count, invoking_key; -{ - extern int rl_explicit_arg; - - if (rl_explicit_arg || !rl_blink_matching_paren) - rl_insert (count, invoking_key); - else - { -#if defined (FD_SET) - int orig_point, match_point, ready; - struct timeval timer; - fd_set readfds; - - rl_insert (1, invoking_key); - rl_redisplay (); - 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; - - FD_ZERO (&readfds); - FD_SET (fileno (rl_instream), &readfds); - timer.tv_sec = 1; - timer.tv_usec = 500; - - orig_point = rl_point; - rl_point = match_point; - rl_redisplay (); - ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer); - rl_point = orig_point; -#else /* !FD_SET */ - rl_insert (count, invoking_key); -#endif /* !FD_SET */ - } -} - -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 ((string[i] == '\'') || (string[i] == '"')) - delimiter = rl_line_buffer[i]; - else if (!delimiter && (string[i] == closer)) - level++; - else if (!delimiter && (string[i] == opener)) - level--; - - if (!level) - break; - } - return (i); -} - - - diff --git a/readline/readline.c b/readline/readline.c deleted file mode 100644 index 3d28df8..0000000 --- a/readline/readline.c +++ /dev/null @@ -1,3288 +0,0 @@ -/* readline.c -- a general facility for reading lines of input - with emacs style editing and completion. */ - -/* Copyright 1987, 1989, 1991, 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "sysdep.h" -#include <stdio.h> -#include <fcntl.h> -#ifndef NO_SYS_FILE -#include <sys/file.h> -#endif -#include <signal.h> - -/* This is needed to include support for TIOCGWINSZ and window resizing. */ -#if defined (OSF1) || defined (BSD386) || defined (_386BSD) || defined (AIX) -# include <sys/ioctl.h> -#endif /* OSF1 */ - -#if defined (HAVE_UNISTD_H) -# include <unistd.h> -#endif - -#include <errno.h> -/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ -#if !defined (errno) -extern int errno; -#endif /* !errno */ - -extern char * getenv (); - -#include <setjmp.h> -#include <sys/stat.h> - -/* System-specific feature definitions and include files. */ -#include "rldefs.h" - -/* Some standard library routines. */ -#include "readline.h" -#include "history.h" - -/* 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. */ - -/* Functions imported from other files in the library. */ -extern char *tgetstr (); -extern void rl_prep_terminal (), rl_deprep_terminal (); -extern void rl_vi_set_last (); -extern Function *rl_function_of_keyseq (); -extern char *tilde_expand (); - -/* External redisplay functions and variables from display.c */ -extern void rl_redisplay (); -extern void _rl_move_vert (); - -extern void _rl_erase_at_end_of_line (); -extern void _rl_move_cursor_relative (); - -extern int _rl_vis_botlin; -extern int _rl_last_c_pos; -extern int rl_display_fixed; - -/* Variables imported from complete.c. */ -extern char *rl_completer_word_break_characters; -extern char *rl_basic_word_break_characters; -extern Function *rl_symbolic_link_hook; -extern int rl_completion_query_items; -extern int rl_complete_with_tilde_expansion; - -/* Forward declarations used in this file. */ -void rl_dispatch (); -void free_history_entry (); -int _rl_output_character_function (); -void _rl_set_screen_size (); -void free_undo_list (), rl_add_undo (); - -#if !defined (__GO32__) -static void readline_default_bindings (); -#endif /* !__GO32__ */ - -#if defined (__GO32__) -# include <sys/pc.h> -# undef HANDLE_SIGNALS -#endif /* __GO32__ */ - -#if defined (STATIC_MALLOC) -static char *xmalloc (), *xrealloc (); -#else -extern char *xmalloc (), *xrealloc (); -#endif /* STATIC_MALLOC */ - - -/* **************************************************************** */ -/* */ -/* Line editing input utility */ -/* */ -/* **************************************************************** */ - -static char *LibraryVersion = "2.0 (Cygnus)"; - -/* 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; - -/* Non-zero if the previous command was a kill command. */ -static int 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 = 0; - -/* If non-zero, this program is running in an EMACS buffer. */ -static char *running_in_emacs = (char *)NULL; - -/* 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. */ -Function *rl_last_func = (Function *)NULL; - -/* Top level environment for readline_internal (). */ -static jmp_buf readline_top_level; - -/* The streams we interact with. */ -static FILE *in_stream, *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. */ -int readline_echoing_p = 1; - -/* Current prompt. */ -char *rl_prompt; - -/* 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 () prints the first prompt. */ -Function *rl_startup_hook = (Function *)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. */ -char *rl_terminal_name = (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; - -/* Non-zero means to use a visible bell if one is available rather than - simply ringing the terminal bell. */ -int _rl_prefer_visible_bell = 0; - -/* Line buffer and maintenence. */ -char *rl_line_buffer = (char *)NULL; -int rl_line_buffer_len = 0; -#define DEFAULT_BUFFER_SIZE 256 - - -/* **************************************************************** */ -/* */ -/* `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 save keys that we dispatch on in a kbd macro. */ -static int defining_kbd_macro = 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 tells rl_delete_text and rl_insert_text to not add to - the undo list. */ -static int doing_an_undo = 0; - -/* **************************************************************** */ -/* */ -/* Top Level Functions */ -/* */ -/* **************************************************************** */ - -/* Non-zero means treat 0200 bit in terminal input as Meta bit. */ -int _rl_meta_flag = 0; /* Forward declaration */ - -/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means - none. A return value of NULL means that EOF was encountered. */ -char * -readline (prompt) - char *prompt; -{ - char *readline_internal (); - char *value; - - rl_prompt = prompt; - - /* If we are at EOF return a NULL string. */ - if (rl_pending_input == EOF) - { - rl_pending_input = 0; - return ((char *)NULL); - } - - rl_initialize (); - rl_prep_terminal (_rl_meta_flag); - -#if defined (HANDLE_SIGNALS) - rl_set_signals (); -#endif - - value = readline_internal (); - rl_deprep_terminal (); - -#if defined (HANDLE_SIGNALS) - rl_clear_signals (); -#endif - - return (value); -} - -/* 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. */ -char * -readline_internal () -{ - int lastc, c, eof_found; - - in_stream = rl_instream; - out_stream = rl_outstream; - - lastc = -1; - eof_found = 0; - - if (rl_startup_hook) - (*rl_startup_hook) (); - - if (!readline_echoing_p) - { - if (rl_prompt) - { - fprintf (out_stream, "%s", rl_prompt); - fflush (out_stream); - } - } - else - { - rl_on_new_line (); - rl_redisplay (); -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_vi_insertion_mode (); -#endif /* VI_MODE */ - } - - while (!rl_done) - { - int lk = last_command_was_kill; - int code; - - code = setjmp (readline_top_level); - - if (code) - rl_redisplay (); - - if (!rl_pending_input) - { - /* Then initialize the argument and number of keys read. */ - rl_init_argument (); - rl_key_sequence_length = 0; - } - - c = rl_read_key (); - - /* 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) - { - eof_found = 1; - break; - } - - lastc = c; - rl_dispatch (c, _rl_keymap); - - /* If there was no change in 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) - { - if (lk == last_command_was_kill) - 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_done) - rl_redisplay (); - } - - /* Restore the original of this history line, iff the line that we - are editing was originally in the history, AND the line has changed. */ - { - HIST_ENTRY *entry = current_history (); - - if (entry && rl_undo_list) - { - char *temp = savestring (the_line); - rl_revert_line (); - entry = replace_history_entry (where_history (), the_line, - (HIST_ENTRY *)NULL); - 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) - free_undo_list (); - - if (eof_found) - return (char *)NULL; - else - return (savestring (the_line)); -} - -/* **************************************************************** */ -/* */ -/* Character Input Buffering */ -/* */ -/* **************************************************************** */ - -static int pop_index = 0, push_index = 0, ibuffer_len = 511; -static unsigned char ibuffer[512]; - -/* Non-null means it is a pointer to a function to run while waiting for - character input. */ -Function *rl_event_hook = (Function *)NULL; - -#define any_typein (push_index != pop_index) - -/* Add KEY to the buffer of characters to be read. */ -rl_stuff_char (key) - int key; -{ - if (key == EOF) - { - key = NEWLINE; - rl_pending_input = EOF; - } - ibuffer[push_index++] = key; - if (push_index >= ibuffer_len) - push_index = 0; -} - -/* Return the amount of space available in the - buffer for stuffing characters. */ -int -ibuffer_space () -{ - if (pop_index > push_index) - return (pop_index - push_index); - 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. */ -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. */ -void -rl_gather_tyi () -{ -#if defined (__GO32__) - char input; - - if (isatty (0)) - { - int i = rl_getc (); - - if (i != EOF) - rl_stuff_char (i); - } - else if (kbhit () && ibuffer_space ()) - rl_stuff_char (getkey ()); -#else /* !__GO32__ */ - - int tty = fileno (in_stream); - register int tem, result = -1; - int chars_avail; - char input; - -#if defined (FIONREAD) - result = ioctl (tty, FIONREAD, &chars_avail); -#endif - -#if defined (O_NDELAY) - if (result == -1) - { - int flags; - - flags = fcntl (tty, F_GETFL, 0); - - fcntl (tty, F_SETFL, (flags | O_NDELAY)); - chars_avail = read (tty, &input, 1); - - fcntl (tty, F_SETFL, flags); - if (chars_avail == -1 && errno == EAGAIN) - return; - } -#endif /* O_NDELAY */ - - /* If there's nothing available, don't waste time trying to read - something. */ - if (chars_avail == 0) - return; - - 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 (in_stream)); - } - else - { - if (chars_avail) - rl_stuff_char (input); - } -#endif /* !__GO32__ */ -} - -static int next_macro_key (); -/* 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_pending_input = 0; - } - else - { - /* If input is coming from a macro, then use that. */ - if (c = 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)) - { - (*rl_event_hook) (); - rl_gather_tyi (); - } - } - else - { - if (!rl_get_char (&c)) - c = rl_getc (in_stream); - } - } - - return (c); -} - -/* Found later in this file. */ -static void add_macro_char (), with_macro_input (); - -/* 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. */ -void -rl_dispatch (key, map) - register int key; - Keymap map; -{ -#if defined (VI_MODE) - extern int _rl_vi_last_command, _rl_vi_last_repeat, _rl_vi_last_arg_sign; -#endif - - if (defining_kbd_macro) - add_macro_char (key); - - if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii) - { - if (map[ESC].type == ISKMAP) - { -#if defined (CRAY) - map = (Keymap)((int)map[ESC].function); -#else - map = (Keymap)map[ESC].function; -#endif - key = UNMETA (key); - rl_key_sequence_length += 2; - rl_dispatch (key, map); - } - else - ding (); - return; - } - - switch (map[key].type) - { - case ISFUNC: - { - Function *func = map[key].function; - - if (func != (Function *)NULL) - { - /* Special case rl_do_lowercase_version (). */ - if (func == rl_do_lowercase_version) - { - rl_dispatch (to_lower (key), map); - return; - } - - (*map[key].function)(rl_numeric_arg * rl_arg_sign, key); - - /* 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) - rl_last_func = map[key].function; - } - else - { - rl_abort (); - return; - } - } - break; - - case ISKMAP: - if (map[key].function != (Function *)NULL) - { - int newkey; - - rl_key_sequence_length++; - newkey = rl_read_key (); -#if defined (CRAY) - /* If you cast map[key].function to type (Keymap) on a Cray, - the compiler takes the value of may[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. */ - rl_dispatch (newkey, (Keymap)((int)map[key].function)); -#else - rl_dispatch (newkey, (Keymap)map[key].function); -#endif /* !CRAY */ - } - else - { - rl_abort (); - return; - } - break; - - case ISMACR: - if (map[key].function != (Function *)NULL) - { - char *macro; - - macro = savestring ((char *)map[key].function); - with_macro_input (macro); - return; - } - break; - } -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap && - rl_vi_textmod_command (key)) - { - _rl_vi_last_command = key; - _rl_vi_last_repeat = rl_numeric_arg; - _rl_vi_last_arg_sign = rl_arg_sign; - } -#endif -} - - -/* **************************************************************** */ -/* */ -/* 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. */ -static char *executing_macro = (char *)NULL; - -/* The offset in the above string to the next character to be read. */ -static int executing_macro_index = 0; - -/* 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 = 0; - -/* The index at which characters are being added to current_macro. */ -static int current_macro_index = 0; - -/* 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 index; -}; - -/* The list of saved macros. */ -struct saved_macro *macro_list = (struct saved_macro *)NULL; - -/* Forward declarations of static functions. Thank you C. */ -static void push_executing_macro (), pop_executing_macro (); - -/* This one has to be declared earlier in the file. */ -/* static void add_macro_char (); */ - -/* Set up to read subsequent input from STRING. - STRING is free ()'ed when we are done with it. */ -static void -with_macro_input (string) - char *string; -{ - push_executing_macro (); - executing_macro = string; - executing_macro_index = 0; -} - -/* Return the next character available from a macro, or 0 if - there are no macro characters. */ -static int -next_macro_key () -{ - if (!executing_macro) - return (0); - - if (!executing_macro[executing_macro_index]) - { - pop_executing_macro (); - return (next_macro_key ()); - } - - return (executing_macro[executing_macro_index++]); -} - -/* Save the currently executing macro on a stack of saved macros. */ -static void -push_executing_macro () -{ - struct saved_macro *saver; - - saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro)); - saver->next = macro_list; - saver->index = executing_macro_index; - saver->string = executing_macro; - - macro_list = saver; -} - -/* Discard the current macro, replacing it with the one - on the top of the stack of saved macros. */ -static void -pop_executing_macro () -{ - if (executing_macro) - free (executing_macro); - - executing_macro = (char *)NULL; - executing_macro_index = 0; - - if (macro_list) - { - struct saved_macro *disposer = macro_list; - executing_macro = macro_list->string; - executing_macro_index = macro_list->index; - macro_list = macro_list->next; - free (disposer); - } -} - -/* Add a character to the macro being built. */ -static void -add_macro_char (c) - int c; -{ - if (current_macro_index + 1 >= current_macro_size) - { - if (!current_macro) - 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'; -} - -/* 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. */ -rl_start_kbd_macro (ignore1, ignore2) - int ignore1, ignore2; -{ - if (defining_kbd_macro) - rl_abort (); - - if (rl_explicit_arg) - { - if (current_macro) - with_macro_input (savestring (current_macro)); - } - else - current_macro_index = 0; - - defining_kbd_macro = 1; -} - -/* 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. */ -rl_end_kbd_macro (count, ignore) - int count, ignore; -{ - if (!defining_kbd_macro) - rl_abort (); - - current_macro_index -= (rl_key_sequence_length - 1); - current_macro[current_macro_index] = '\0'; - - defining_kbd_macro = 0; - - rl_call_last_kbd_macro (--count, 0); -} - -/* Execute the most recently defined keyboard macro. - COUNT says how many times to execute it. */ -rl_call_last_kbd_macro (count, ignore) - int count, ignore; -{ - if (!current_macro) - rl_abort (); - - if (defining_kbd_macro) - { - ding (); /* no recursive macros */ - current_macro[--current_macro_index] = '\0'; /* erase this char */ - return 0; - } - - while (count--) - with_macro_input (savestring (current_macro)); -} - -void -_rl_kill_kbd_macro () -{ - if (current_macro) - { - free (current_macro); - current_macro = (char *) NULL; - } - current_macro_size = current_macro_index = 0; - - if (executing_macro) - { - free (executing_macro); - executing_macro = (char *) NULL; - } - executing_macro_index = 0; - - defining_kbd_macro = 0; -} - - -/* **************************************************************** */ -/* */ -/* Initializations */ -/* */ -/* **************************************************************** */ - -/* Initliaze readline (and terminal if not already). */ -rl_initialize () -{ - /* If we have never been called before, initialize the - terminal and data structures. */ - if (!rl_initialized) - { - readline_initialize_everything (); - rl_initialized++; - } - - /* Initalize the current line information. */ - rl_point = rl_end = 0; - the_line = rl_line_buffer; - the_line[0] = 0; - - /* We aren't done yet. We haven't even gotten started yet! */ - rl_done = 0; - - /* Tell the history routines what is going on. */ - 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 = (Function *)NULL; - - /* Parsing of key-bindings begins in an enabled state. */ - _rl_parsing_conditionalized_out = 0; -} - -/* Initialize the entire state of the world. */ -readline_initialize_everything () -{ - /* Find out if we are running in Emacs. */ - running_in_emacs = getenv ("EMACS"); - - /* 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 in_stream and out_stream immediately. These values may change, - but they may also be used before readline_internal () is called. */ - in_stream = rl_instream; - out_stream = rl_outstream; - - /* Allocate data structures. */ - if (!rl_line_buffer) - rl_line_buffer = - (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE); - - /* Initialize the terminal interface. */ - init_terminal_io ((char *)NULL); - -#if !defined (__GO32__) - /* Bind tty characters to readline functions. */ - readline_default_bindings (); -#endif /* !__GO32__ */ - - /* Initialize the function names. */ - rl_initialize_funmap (); - - /* Read in the init file. */ - rl_read_init_file ((char *)NULL); - - /* 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. */ -#if !defined (__GO32__) -static void -readline_default_bindings () -{ - rltty_set_default_bindings (_rl_keymap); -} -#endif /* !__GO32__ */ - - -/* **************************************************************** */ -/* */ -/* Numeric Arguments */ -/* */ -/* **************************************************************** */ - -/* Handle C-u style numeric args, as well as M--, and M-digits. */ - -/* Add the current digit to the argument in progress. */ -rl_digit_argument (ignore, key) - int ignore, key; -{ - rl_pending_input = key; - rl_digit_loop (); -} - -/* What to do when you abort reading an argument. */ -rl_discard_argument () -{ - ding (); - rl_clear_message (); - rl_init_argument (); -} - -/* Create a default argument. */ -rl_init_argument () -{ - rl_numeric_arg = rl_arg_sign = 1; - rl_explicit_arg = 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. */ -rl_universal_argument () -{ - rl_numeric_arg *= 4; - rl_digit_loop (); -} - -rl_digit_loop () -{ - int key, c; - while (1) - { - rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg); - key = c = rl_read_key (); - - if (_rl_keymap[c].type == ISFUNC && - _rl_keymap[c].function == rl_universal_argument) - { - rl_numeric_arg *= 4; - continue; - } - c = UNMETA (c); - if (numeric (c)) - { - if (rl_explicit_arg) - rl_numeric_arg = (rl_numeric_arg * 10) + (c - '0'); - else - rl_numeric_arg = (c - '0'); - rl_explicit_arg = 1; - } - else - { - if (c == '-' && !rl_explicit_arg) - { - rl_numeric_arg = 1; - rl_arg_sign = -1; - } - else - { - rl_clear_message (); - rl_dispatch (key, _rl_keymap); - return; - } - } - } -} - -/* **************************************************************** */ -/* */ -/* Terminal and Termcap */ -/* */ -/* **************************************************************** */ - -static char *term_buffer = (char *)NULL; -static char *term_string_buffer = (char *)NULL; - -/* Non-zero means this terminal can't really do anything. */ -int dumb_term = 0; -/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC. - Unfortunately, PC is a global variable used by the termcap library. */ -#undef PC - -#if !defined (__linux__) -char PC; -char *BC, *UP; -#endif /* __linux__ */ - -/* Some strings to control terminal actions. These are output by tputs (). */ -char *term_goto, *term_clreol, *term_cr, *term_clrpag, *term_backspace; - -int screenwidth, screenheight; - -/* Non-zero if we determine that the terminal can do character insertion. */ -int terminal_can_insert = 0; - -/* How to insert characters. */ -char *term_im, *term_ei, *term_ic, *term_ip, *term_IC; - -/* How to delete characters. */ -char *term_dc, *term_DC; - -#if defined (HACK_TERMCAP_MOTION) -char *term_forward_char; -#endif /* HACK_TERMCAP_MOTION */ - -/* How to go up a line. */ -char *term_up; - -/* True if we have funny auto-line-wrap ("am" and "xn"). */ -int term_xn; - -/* A visible bell, if the terminal can be made to flash the screen. */ -char *visible_bell; - -/* Non-zero means that this terminal has a meta key. */ -int term_has_meta; - -/* The string to write to turn on the meta key, if this term has one. */ -char *term_mm; - -/* The string to write to turn off the meta key, if this term has one. */ -char *term_mo; - -/* The key sequences output by the arrow keys, if this terminal has any. */ -char *term_ku, *term_kd, *term_kr, *term_kl; - -/* Re-initialize the terminal considering that the TERM/TERMCAP variable - has changed. */ -rl_reset_terminal (terminal_name) - char *terminal_name; -{ - init_terminal_io (terminal_name); -} - -/* Set 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_set_screen_size (tty, ignore_env) - int tty, ignore_env; -{ -#if defined (TIOCGWINSZ) && !defined (TIOCGWINSZ_BROKEN) - struct winsize window_size; -#endif /* TIOCGWINSZ */ - -#if defined (TIOCGWINSZ) && !defined (TIOCGWINSZ_BROKEN) - if (ioctl (tty, TIOCGWINSZ, &window_size) == 0) - { - screenwidth = (int) window_size.ws_col; - screenheight = (int) window_size.ws_row; - } -#endif /* TIOCGWINSZ */ - - /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV - is unset. */ - if (screenwidth <= 0) - { - char *sw; - - if (!ignore_env && (sw = getenv ("COLUMNS"))) - screenwidth = atoi (sw); - - if (screenwidth <= 0 && term_string_buffer) - screenwidth = tgetnum ("co"); - } - - /* Environment variable LINES overrides setting of "li" if IGNORE_ENV - is unset. */ - if (screenheight <= 0) - { - char *sh; - - if (!ignore_env && (sh = getenv ("LINES"))) - screenheight = atoi (sh); - - if (screenheight <= 0 && term_string_buffer) - screenheight = tgetnum ("li"); - } - - /* If all else fails, default to 80x24 terminal. */ - if (screenwidth <= 0) - screenwidth = 80; - - if (screenheight <= 0) - screenheight = 24; - -#if defined (SHELL) - /* If we're being compiled as part of bash, set the environment - variables $LINES and $COLUMNS to new values. */ - set_lines_and_columns (screenheight, screenwidth); -#endif - - /* If we don't have xn (most modern terminals do), - don't use the last column. */ - if (!term_xn) - screenwidth--; -} - -init_terminal_io (terminal_name) - char *terminal_name; -{ -#if defined (__GO32__) - screenwidth = ScreenCols (); - screenheight = ScreenRows (); - term_cr = "\r"; - term_im = term_ei = term_ic = term_IC = (char *)NULL; - term_up = term_dc = term_DC = visible_bell = (char *)NULL; - - /* Does the __GO32__ have a meta key? I don't know. */ - term_has_meta = 0; - term_mm = term_mo = (char *)NULL; - - /* It probably has arrow keys, but I don't know what they are. */ - term_ku = term_kd = term_kr = term_kl = (char *)NULL; - -#if defined (HACK_TERMCAP_MOTION) - term_forward_char = (char *)NULL; -#endif /* HACK_TERMCAP_MOTION */ - terminal_can_insert = term_xn = 0; - return; -#else /* !__GO32__ */ - - char *term, *buffer; - int tty; - - term = terminal_name ? terminal_name : getenv ("TERM"); - - if (!term_string_buffer) - term_string_buffer = (char *)xmalloc (2048); - - if (!term_buffer) - term_buffer = (char *)xmalloc (2048); - - buffer = term_string_buffer; - - term_clrpag = term_cr = term_clreol = (char *)NULL; - - if (!term) - term = "dumb"; - - if (tgetent (term_buffer, term) <= 0) - { - dumb_term = 1; - screenwidth = 79; - screenheight = 24; - term_cr = "\r"; - term_im = term_ei = term_ic = term_IC = (char *)NULL; - term_up = term_dc = term_DC = visible_bell = (char *)NULL; - term_ku = term_kd = term_kl = term_kr = (char *)NULL; -#if defined (HACK_TERMCAP_MOTION) - term_forward_char = (char *)NULL; -#endif - terminal_can_insert = term_xn = 0; - return; - } - - BC = tgetstr ("pc", &buffer); - PC = buffer ? *buffer : 0; - - term_backspace = tgetstr ("le", &buffer); - - term_cr = tgetstr ("cr", &buffer); - term_clreol = tgetstr ("ce", &buffer); - term_clrpag = tgetstr ("cl", &buffer); - - if (!term_cr) - term_cr = "\r"; - -#if defined (HACK_TERMCAP_MOTION) - term_forward_char = tgetstr ("nd", &buffer); -#endif /* HACK_TERMCAP_MOTION */ - - if (rl_instream) - tty = fileno (rl_instream); - else - tty = 0; - - screenwidth = screenheight = 0; - - term_xn = tgetflag ("am") && tgetflag ("xn"); - - _rl_set_screen_size (tty, 0); - - term_im = tgetstr ("im", &buffer); - term_ei = tgetstr ("ei", &buffer); - term_IC = tgetstr ("IC", &buffer); - term_ic = tgetstr ("ic", &buffer); - - /* "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... */ - terminal_can_insert = (term_IC || term_im || term_ic); - - term_up = tgetstr ("up", &buffer); - term_dc = tgetstr ("dc", &buffer); - term_DC = tgetstr ("DC", &buffer); - - visible_bell = tgetstr ("vb", &buffer); - - /* Check to see if this terminal has a meta key. */ - term_has_meta = (tgetflag ("km") || tgetflag ("MT")); - if (term_has_meta) - { - term_mm = tgetstr ("mm", &buffer); - term_mo = tgetstr ("mo", &buffer); - } - else - { - term_mm = (char *)NULL; - term_mo = (char *)NULL; - } - - /* Attempt to find and bind the arrow keys. Do not override already - bound keys in an overzealous attempt, however. */ - term_ku = tgetstr ("ku", &buffer); - term_kd = tgetstr ("kd", &buffer); - term_kr = tgetstr ("kr", &buffer); - term_kl = tgetstr ("kl", &buffer); - - if (term_ku) - { - Function *func; - - func = rl_function_of_keyseq (term_ku, _rl_keymap, (int *)NULL); - - if (!func || func == rl_do_lowercase_version) - rl_set_key (term_ku, rl_get_previous_history, _rl_keymap); - } - - if (term_kd) - { - Function *func; - - func = rl_function_of_keyseq (term_kd, _rl_keymap, (int *)NULL); - - if (!func || func == rl_do_lowercase_version) - rl_set_key (term_kd, rl_get_next_history, _rl_keymap); - } - - if (term_kr) - { - Function *func; - - func = rl_function_of_keyseq (term_kr, _rl_keymap, (int *)NULL); - - if (!func || func == rl_do_lowercase_version) - rl_set_key (term_kr, rl_forward, _rl_keymap); - } - - if (term_kl) - { - Function *func; - - func = rl_function_of_keyseq (term_kl, _rl_keymap, (int *)NULL); - - if (!func || func == rl_do_lowercase_version) - rl_set_key (term_kl, rl_backward, _rl_keymap); - } -#endif /* !__GO32__ */ - return 0; -} - -/* A function for the use of tputs () */ -int -_rl_output_character_function (c) - int c; -{ - return putc (c, out_stream); -} - -/* Write COUNT characters from STRING to the output stream. */ -void -_rl_output_some_chars (string, count) - char *string; - int count; -{ - fwrite (string, 1, count, out_stream); -} - -/* Move the cursor back. */ -backspace (count) - int count; -{ - register int i; - -#if !defined (__GO32__) - if (term_backspace) - for (i = 0; i < count; i++) - tputs (term_backspace, 1, _rl_output_character_function); - else -#endif /* !__GO32__ */ - for (i = 0; i < count; i++) - putc ('\b', out_stream); -} - -/* Move to the start of the next line. */ -crlf () -{ -#if defined (NEW_TTY_DRIVER) - tputs (term_cr, 1, _rl_output_character_function); -#endif /* NEW_TTY_DRIVER */ - putc ('\n', out_stream); -} - - -/* **************************************************************** */ -/* */ -/* 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 allow_pathname_alphabetic_chars = 0; -char *pathname_alphabetic_chars = "/-_=~.#$"; - -int -alphabetic (c) - int c; -{ - if (pure_alphabetic (c) || (numeric (c))) - return (1); - - if (allow_pathname_alphabetic_chars) - return (strchr (pathname_alphabetic_chars, c) != NULL); - else - return (0); -} - -/* Return non-zero if C is a numeric character. */ -int -numeric (c) - int c; -{ - return (c >= '0' && c <= '9'); -} - -/* Ring the terminal bell. */ -int -ding () -{ - if (readline_echoing_p) - { -#if !defined (__GO32__) - if (_rl_prefer_visible_bell && visible_bell) - tputs (visible_bell, 1, _rl_output_character_function); - else -#endif /* !__GO32__ */ - { - fprintf (stderr, "\007"); - fflush (stderr); - } - } - return (-1); -} - -/* How to abort things. */ -rl_abort () -{ - ding (); - rl_clear_message (); - rl_init_argument (); - rl_pending_input = 0; - - defining_kbd_macro = 0; - while (executing_macro) - pop_executing_macro (); - - rl_last_func = (Function *)NULL; - longjmp (readline_top_level, 1); -} - -/* 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) - { - int t = from; - from = to; - to = t; - } - - length = to - from; - copy = (char *)xmalloc (1 + length); - strncpy (copy, the_line + 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 = - (char *)xrealloc - (rl_line_buffer, rl_line_buffer_len += DEFAULT_BUFFER_SIZE); - - the_line = rl_line_buffer; -} - - -/* **************************************************************** */ -/* */ -/* Insert and Delete */ -/* */ -/* **************************************************************** */ - -/* Insert a string of text into the line at point. This is the only - way that you should do insertion. rl_insert () calls this - function. */ -rl_insert_text (string) - char *string; -{ - register int i, l = strlen (string); - - if (rl_end + l >= rl_line_buffer_len) - rl_extend_line_buffer (rl_end + l); - - for (i = rl_end; i >= rl_point; i--) - the_line[i + l] = the_line[i]; - strncpy (the_line + rl_point, string, l); - - /* Remember how to undo this if we aren't undoing something. */ - if (!doing_an_undo) - { - /* If possible and desirable, concatenate the undos. */ - if ((strlen (string) == 1) && - rl_undo_list && - (rl_undo_list->what == UNDO_INSERT) && - (rl_undo_list->end == rl_point) && - (rl_undo_list->end - rl_undo_list->start < 20)) - rl_undo_list->end++; - else - rl_add_undo (UNDO_INSERT, rl_point, rl_point + l, (char *)NULL); - } - rl_point += l; - rl_end += l; - the_line[rl_end] = '\0'; -} - -/* Delete the string between FROM and TO. FROM is - inclusive, TO is not. */ -rl_delete_text (from, to) - int from, to; -{ - register char *text; - - /* Fix it if the caller is confused. */ - if (from > to) - { - int t = from; - from = to; - to = t; - } - text = rl_copy_text (from, to); - strncpy (the_line + from, the_line + to, rl_end - to); - - /* Remember how to undo this delete. */ - if (!doing_an_undo) - rl_add_undo (UNDO_DELETE, from, to, text); - else - free (text); - - rl_end -= (to - from); - the_line[rl_end] = '\0'; -} - - -/* **************************************************************** */ -/* */ -/* Readline character functions */ -/* */ -/* **************************************************************** */ - -/* This is not a gap editor, just a stupid line input routine. No hair - is involved in writing any of the functions, and none should be. */ - -/* Note that: - - rl_end is the place in the string that we would place '\0'; - i.e., it is always safe to place '\0' there. - - rl_point is the place in the string where the cursor is. Sometimes - this is the same as rl_end. - - Any command that is called interactively receives two arguments. - The first is a count: the numeric arg pased to this command. - The second is the key which invoked this command. -*/ - - -/* **************************************************************** */ -/* */ -/* Movement Commands */ -/* */ -/* **************************************************************** */ - -/* Note that if you `optimize' the display for these functions, you cannot - use said functions in other functions which do not do optimizing display. - I.e., you will have to update the data base for rl_redisplay, and you - might as well let rl_redisplay do that job. */ - -/* Move forward COUNT characters. */ -rl_forward (count) - int count; -{ - if (count < 0) - rl_backward (-count); - else - while (count) - { -#if defined (VI_MODE) - if (rl_point >= (rl_end - (rl_editing_mode == vi_mode))) -#else - if (rl_point == rl_end) -#endif /* VI_MODE */ - { - ding (); - return 0; - } - else - rl_point++; - --count; - } - return 0; -} - -/* Move backward COUNT characters. */ -rl_backward (count) - int count; -{ - if (count < 0) - rl_forward (-count); - else - while (count) - { - if (!rl_point) - { - ding (); - return 0; - } - else - --rl_point; - --count; - } - return 0; -} - -/* Move to the beginning of the line. */ -rl_beg_of_line () -{ - rl_point = 0; - return 0; -} - -/* Move to the end of the line. */ -rl_end_of_line () -{ - rl_point = rl_end; - return 0; -} - -/* Move forward a word. We do what Emacs does. */ -rl_forward_word (count) - int count; -{ - int c; - - if (count < 0) - { - rl_backward_word (-count); - return 0; - } - - while (count) - { - if (rl_point == rl_end) - return 0; - - /* If we are not in a word, move forward until we are in one. - Then, move forward until we hit a non-alphabetic character. */ - c = the_line[rl_point]; - if (!alphabetic (c)) - { - while (++rl_point < rl_end) - { - c = the_line[rl_point]; - if (alphabetic (c)) break; - } - } - if (rl_point == rl_end) return; - while (++rl_point < rl_end) - { - c = the_line[rl_point]; - if (!alphabetic (c)) break; - } - --count; - } - return 0; -} - -/* Move backward a word. We do what Emacs does. */ -rl_backward_word (count) - int count; -{ - int c; - - if (count < 0) - { - rl_forward_word (-count); - return 0; - } - - while (count) - { - if (!rl_point) - return 0; - - /* Like rl_forward_word (), except that we look at the characters - just before point. */ - - c = the_line[rl_point - 1]; - if (!alphabetic (c)) - { - while (--rl_point) - { - c = the_line[rl_point - 1]; - if (alphabetic (c)) break; - } - } - - while (rl_point) - { - c = the_line[rl_point - 1]; - if (!alphabetic (c)) - break; - else --rl_point; - } - --count; - } - return 0; -} - -/* Clear the current line. Numeric argument to C-l does this. */ -rl_refresh_line () -{ - int curr_line = _rl_last_c_pos / screenwidth; - - _rl_move_vert (curr_line); - _rl_move_cursor_relative (0, the_line); /* XXX is this right */ - -#if defined (__GO32__) - { - int row, col, width, row_start; - - ScreenGetCursor (&row, &col); - width = ScreenCols (); - row_start = ScreenPrimary + (row * width); - memset (row_start + col, 0, (width - col) * 2); - } -#else /* !__GO32__ */ - if (term_clreol) - tputs (term_clreol, 1, _rl_output_character_function); -#endif /* !__GO32__ */ - - rl_forced_update_display (); - rl_display_fixed = 1; - - return 0; -} - -/* C-l typed to a line without quoting clears the screen, and then reprints - the prompt and the current input line. Given a numeric arg, redraw only - the current line. */ -rl_clear_screen () -{ - if (rl_explicit_arg) - { - rl_refresh_line (); - return 0; - } - -#if !defined (__GO32__) - if (term_clrpag) - tputs (term_clrpag, 1, _rl_output_character_function); - else -#endif /* !__GO32__ */ - crlf (); - - rl_forced_update_display (); - rl_display_fixed = 1; - - return 0; -} - -rl_arrow_keys (count, c) - int count, c; -{ - int ch; - - ch = rl_read_key (); - - switch (to_upper (ch)) - { - case 'A': - rl_get_previous_history (count); - break; - - case 'B': - rl_get_next_history (count); - break; - - case 'C': - rl_forward (count); - break; - - case 'D': - rl_backward (count); - break; - - default: - ding (); - } - return 0; -} - - -/* **************************************************************** */ -/* */ -/* Text commands */ -/* */ -/* **************************************************************** */ - -/* Insert the character C at the current location, moving point forward. */ -rl_insert (count, c) - int count, c; -{ - register int i; - char *string; - - if (count <= 0) - return 0; - - /* If we can optimize, then do it. But don't let people crash - readline because of extra large arguments. */ - if (count > 1 && count < 1024) - { - string = (char *)alloca (1 + count); - - for (i = 0; i < count; i++) - string[i] = c; - - string[i] = '\0'; - rl_insert_text (string); - return 0; - } - - if (count > 1024) - { - int decreaser; - - string = (char *)alloca (1024 + 1); - - for (i = 0; i < 1024; i++) - string[i] = c; - - while (count) - { - decreaser = (count > 1024 ? 1024 : count); - string[decreaser] = '\0'; - rl_insert_text (string); - count -= decreaser; - } - return 0; - } - - /* We are inserting a single character. - If there is pending input, then make a string of all of the - pending characters that are bound to rl_insert, and insert - them all. */ - if (any_typein) - { - int key = 0, t; - - i = 0; - string = (char *)alloca (ibuffer_len + 1); - string[i++] = 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); - } - else - { - /* Inserting a single character. */ - string = (char *)alloca (2); - - string[1] = '\0'; - string[0] = c; - rl_insert_text (string); - } - return 0; -} - -/* Insert the next typed character verbatim. */ -rl_quoted_insert (count) - int count; -{ - int c; - - c = rl_read_key (); - return (rl_insert (count, c)); - -} - -/* Insert a tab character. */ -rl_tab_insert (count) - int count; -{ - return (rl_insert (count, '\t')); -} - -/* What to do when a NEWLINE is pressed. We accept the whole line. - KEY is the key that invoked this command. I guess it could have - meaning in the future. */ -rl_newline (count, key) - int count, key; -{ - rl_done = 1; - -#if defined (VI_MODE) - { - extern int _rl_vi_doing_insert; - if (_rl_vi_doing_insert) - { - rl_end_undo_group (); - _rl_vi_doing_insert = 0; - } - } - rl_vi_set_last (); - -#endif /* VI_MODE */ - - if (readline_echoing_p) - { - _rl_move_vert (_rl_vis_botlin); - _rl_vis_botlin = 0; - crlf (); - fflush (out_stream); - rl_display_fixed++; - } - return 0; -} - -rl_clean_up_for_exit () -{ - if (readline_echoing_p) - { - _rl_move_vert (_rl_vis_botlin); - _rl_vis_botlin = 0; - fflush (out_stream); - rl_restart_output (); - } - return 0; -} - -/* What to do for some uppercase characters, like meta characters, - and some characters appearing in emacs_ctlx_keymap. This function - is just a stub, you bind keys to it and the code in rl_dispatch () - is special cased. */ -rl_do_lowercase_version (ignore1, ignore2) - int ignore1, ignore2; -{ - return 0; -} - -/* Rubout the character behind point. */ -rl_rubout (count) - int count; -{ - if (count < 0) - { - rl_delete (-count); - return 0; - } - - if (!rl_point) - { - ding (); - return -1; - } - - if (count > 1 || rl_explicit_arg) - { - int orig_point = rl_point; - rl_backward (count); - rl_kill_text (orig_point, rl_point); - } - else - { - int c = the_line[--rl_point]; - rl_delete_text (rl_point, rl_point + 1); - - if (rl_point == rl_end && isprint (c) && _rl_last_c_pos) - { - int l; - l = rl_character_len (c, rl_point); - _rl_erase_at_end_of_line (l); - } - } - return 0; -} - -/* Delete the character under the cursor. Given a numeric argument, - kill that many characters instead. */ -rl_delete (count, invoking_key) - int count, invoking_key; -{ - if (count < 0) - { - return (rl_rubout (-count)); - } - - if (rl_point == rl_end) - { - ding (); - return -1; - } - - if (count > 1 || rl_explicit_arg) - { - int orig_point = rl_point; - rl_forward (count); - rl_kill_text (orig_point, rl_point); - rl_point = orig_point; - return 0; - } - else - return (rl_delete_text (rl_point, rl_point + 1)); - -} - -/* Delete all spaces and tabs around point. */ -rl_delete_horizontal_space (count, ignore) - int count, ignore; -{ - int start = rl_point; - - while (rl_point && whitespace (the_line[rl_point - 1])) - rl_point--; - - start = rl_point; - - while (rl_point < rl_end && whitespace (the_line[rl_point])) - rl_point++; - - if (start != rl_point) - { - rl_delete_text (start, rl_point); - rl_point = start; - } - return 0; -} - - -/* **************************************************************** */ -/* */ -/* Kill commands */ -/* */ -/* **************************************************************** */ - -/* 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. */ -rl_unix_word_rubout () -{ - if (!rl_point) - ding (); - else - { - int orig_point = rl_point; - - while (rl_point && whitespace (the_line[rl_point - 1])) - rl_point--; - - while (rl_point && !whitespace (the_line[rl_point - 1])) - rl_point--; - - rl_kill_text (rl_point, orig_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. */ -rl_unix_line_discard () -{ - if (!rl_point) - ding (); - else - { - rl_kill_text (rl_point, 0); - rl_point = 0; - } - return 0; -} - - -/* **************************************************************** */ -/* */ -/* Commands For Typos */ -/* */ -/* **************************************************************** */ - -/* Random and interesting things in here. */ - -/* **************************************************************** */ -/* */ -/* Changing Case */ -/* */ -/* **************************************************************** */ - -/* The three kinds of things that we know how to do. */ -#define UpCase 1 -#define DownCase 2 -#define CapCase 3 - -static int rl_change_case (); - -/* Uppercase the word at point. */ -rl_upcase_word (count) - int count; -{ - return (rl_change_case (count, UpCase)); -} - -/* Lowercase the word at point. */ -rl_downcase_word (count) - int count; -{ - return (rl_change_case (count, DownCase)); -} - -/* Upcase the first letter, downcase the rest. */ -rl_capitalize_word (count) - int count; -{ - return (rl_change_case (count, CapCase)); -} - -/* The meaty function. - Change the case of COUNT words, performing OP on them. - OP is one of UpCase, DownCase, or CapCase. - If a negative argument is given, leave point where it started, - otherwise, leave it where it moves to. */ -static int -rl_change_case (count, op) - int count, op; -{ - register int start = rl_point, end; - int state = 0; - - rl_forward_word (count); - end = rl_point; - - if (count < 0) - { - int temp = start; - start = end; - end = temp; - } - - /* We are going to modify some text, so let's prepare to undo it. */ - rl_modifying (start, end); - - for (; start < end; start++) - { - switch (op) - { - case UpCase: - the_line[start] = to_upper (the_line[start]); - break; - - case DownCase: - the_line[start] = to_lower (the_line[start]); - break; - - case CapCase: - if (state == 0) - { - the_line[start] = to_upper (the_line[start]); - state = 1; - } - else - { - the_line[start] = to_lower (the_line[start]); - } - if (!pure_alphabetic (the_line[start])) - state = 0; - break; - - default: - abort (); - return -1; - } - } - rl_point = end; - return 0; -} - -/* **************************************************************** */ -/* */ -/* Transposition */ -/* */ -/* **************************************************************** */ - -/* Transpose the words at point. */ -rl_transpose_words (count) - int count; -{ - char *word1, *word2; - int w1_beg, w1_end, w2_beg, w2_end; - int orig_point = rl_point; - - if (!count) - return 0; - - /* Find the two words. */ - rl_forward_word (count); - w2_end = rl_point; - rl_backward_word (1); - w2_beg = rl_point; - rl_backward_word (count); - w1_beg = rl_point; - rl_forward_word (1); - w1_end = rl_point; - - /* Do some check to make sure that there really are two words. */ - if ((w1_beg == w2_beg) || (w2_beg < w1_end)) - { - ding (); - rl_point = orig_point; - return -1; - } - - /* Get the text of the words. */ - word1 = rl_copy_text (w1_beg, w1_end); - word2 = rl_copy_text (w2_beg, w2_end); - - /* We are about to do many insertions and deletions. Remember them - as one operation. */ - rl_begin_undo_group (); - - /* Do the stuff at word2 first, so that we don't have to worry - about word1 moving. */ - rl_point = w2_beg; - rl_delete_text (w2_beg, w2_end); - rl_insert_text (word1); - - rl_point = w1_beg; - rl_delete_text (w1_beg, w1_end); - rl_insert_text (word2); - - /* This is exactly correct since the text before this point has not - changed in length. */ - rl_point = w2_end; - - /* I think that does it. */ - rl_end_undo_group (); - free (word1); - free (word2); - - return 0; -} - -/* Transpose the characters at point. If point is at the end of the line, - then transpose the characters before point. */ -rl_transpose_chars (count) - int count; -{ - char dummy[2]; - - if (!count) - return 0; - - if (!rl_point || rl_end < 2) - { - ding (); - return -1; - } - - rl_begin_undo_group (); - - if (rl_point == rl_end) - { - --rl_point; - count = 1; - } - rl_point--; - - dummy[0] = the_line[rl_point]; - dummy[1] = '\0'; - - rl_delete_text (rl_point, rl_point + 1); - - rl_point += count; - if (rl_point > rl_end) - rl_point = rl_end; - else if (rl_point < 0) - rl_point = 0; - rl_insert_text (dummy); - - rl_end_undo_group (); - return 0; -} - -/* **************************************************************** */ -/* */ -/* Undo, and Undoing */ -/* */ -/* **************************************************************** */ - -/* The current undo list for THE_LINE. */ -UNDO_LIST *rl_undo_list = (UNDO_LIST *)NULL; - -/* 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 -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 = 0; - -undo_thing: - if (!rl_undo_list) - return (0); - - doing_an_undo = 1; - - switch (rl_undo_list->what) { - - /* Undoing deletes means inserting some text. */ - case UNDO_DELETE: - rl_point = rl_undo_list->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 (rl_undo_list->start, rl_undo_list->end); - rl_point = rl_undo_list->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 -#if 0 - abort (); -#else - ding (); -#endif - break; - } - - doing_an_undo = 0; - - release = rl_undo_list; - rl_undo_list = rl_undo_list->next; - free (release); - - if (waiting_for_begin) - goto undo_thing; - - return (1); -} - -/* Begin a group. Subsequent undos are undone as an atomic operation. */ -rl_begin_undo_group () -{ - rl_add_undo (UNDO_BEGIN, 0, 0, 0); - return 0; -} - -/* End an undo group started with rl_begin_undo_group (). */ -rl_end_undo_group () -{ - rl_add_undo (UNDO_END, 0, 0, 0); - return 0; -} - -/* Save an undo entry for the text from START to END. */ -rl_modifying (start, end) - int start, end; -{ - if (start > end) - { - int t = start; - start = end; - end = t; - } - - 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. */ -rl_revert_line () -{ - if (!rl_undo_list) - ding (); - else - { - while (rl_undo_list) - rl_do_undo (); - } - return 0; -} - -/* Do some undoing of things that were done. */ -rl_undo_command (count) - int count; -{ - if (count < 0) - return 0; /* Nothing to do. */ - - while (count) - { - if (rl_do_undo ()) - count--; - else - { - ding (); - break; - } - } - return 0; -} - -/* **************************************************************** */ -/* */ -/* History Utilities */ -/* */ -/* **************************************************************** */ - -/* We already have a history library, and that is what we use to control - the history features of readline. However, 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 *saved_line_for_history = (HIST_ENTRY *)NULL; - -/* Set the history pointer back to the last entry in the history. */ -start_using_history () -{ - using_history (); - if (saved_line_for_history) - free_history_entry (saved_line_for_history); - - saved_line_for_history = (HIST_ENTRY *)NULL; - return 0; -} - -/* Free the contents (and containing structure) of a HIST_ENTRY. */ -void -free_history_entry (entry) - HIST_ENTRY *entry; -{ - if (!entry) - return; - if (entry->line) - free (entry->line); - free (entry); -} - -/* Perhaps put back the current line if it has changed. */ -maybe_replace_line () -{ - HIST_ENTRY *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 (), the_line, rl_undo_list); - free (temp->line); - free (temp); - } - return 0; -} - -/* Put back the saved_line_for_history if there is one. */ -maybe_unsave_line () -{ - if (saved_line_for_history) - { - int line_len; - - line_len = strlen (saved_line_for_history->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strcpy (the_line, saved_line_for_history->line); - rl_undo_list = (UNDO_LIST *)saved_line_for_history->data; - free_history_entry (saved_line_for_history); - saved_line_for_history = (HIST_ENTRY *)NULL; - rl_end = rl_point = strlen (the_line); - } - else - ding (); - return 0; -} - -/* Save the current line in saved_line_for_history. */ -maybe_save_line () -{ - if (!saved_line_for_history) - { - saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); - saved_line_for_history->line = savestring (the_line); - saved_line_for_history->data = (char *)rl_undo_list; - } - return 0; -} - -/* **************************************************************** */ -/* */ -/* History Commands */ -/* */ -/* **************************************************************** */ - -/* Meta-< goes to the start of the history. */ -rl_beginning_of_history () -{ - return (rl_get_previous_history (1 + where_history ())); -} - -/* Meta-> goes to the end of the history. (The current line). */ -rl_end_of_history () -{ - maybe_replace_line (); - using_history (); - maybe_unsave_line (); - return 0; -} - -/* Move down to the next history line. */ -rl_get_next_history (count) - int count; -{ - HIST_ENTRY *temp = (HIST_ENTRY *)NULL; - - if (count < 0) - return (rl_get_previous_history (-count)); - - if (!count) - return 0; - - maybe_replace_line (); - - while (count) - { - temp = next_history (); - if (!temp) - break; - --count; - } - - if (!temp) - maybe_unsave_line (); - else - { - int line_len; - - line_len = strlen (temp->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strcpy (the_line, temp->line); - rl_undo_list = (UNDO_LIST *)temp->data; - rl_end = rl_point = strlen (the_line); -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_point = 0; -#endif /* VI_MODE */ - } - return 0; -} - -/* Get the previous item out of our interactive history, making it the current - line. If there is no previous history, just ding. */ -rl_get_previous_history (count) - int count; -{ - HIST_ENTRY *old_temp = (HIST_ENTRY *)NULL; - HIST_ENTRY *temp = (HIST_ENTRY *)NULL; - - if (count < 0) - return (rl_get_next_history (-count)); - - if (!count) - return 0; - - /* If we don't have a line saved, then save this one. */ - maybe_save_line (); - - /* If the current line has changed, save the changes. */ - maybe_replace_line (); - - while (count) - { - temp = previous_history (); - if (!temp) - break; - else - 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) - ding (); - else - { - int line_len; - - line_len = strlen (temp->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strcpy (the_line, temp->line); - rl_undo_list = (UNDO_LIST *)temp->data; - rl_end = rl_point = line_len; - -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_point = 0; -#endif /* VI_MODE */ - } - return 0; -} - -/* Make C be the next command to be executed. */ -rl_execute_next (c) - int c; -{ - rl_pending_input = c; - return 0; -} - -/* **************************************************************** */ -/* */ -/* The Mark and the Region. */ -/* */ -/* **************************************************************** */ - -/* Set the mark at POSITION. */ -rl_set_mark (position) - int position; -{ - if (position > rl_end) - return -1; - - rl_mark = position; - return 0; -} - -/* Exchange the position of mark and point. */ -rl_exchange_mark_and_point () -{ - if (rl_mark > rl_end) - rl_mark = -1; - - if (rl_mark == -1) - { - ding (); - return -1; - } - else - { - int temp = rl_point; - - rl_point = rl_mark; - rl_mark = temp; - } - return 0; -} - - -/* **************************************************************** */ -/* */ -/* 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. */ -int rl_max_kills = DEFAULT_MAX_KILLS; - -/* Where to store killed text. */ -char **rl_kill_ring = (char **)NULL; - -/* Where we are in the kill ring. */ -int rl_kill_index = 0; - -/* How many slots we have in the kill ring. */ -int rl_kill_ring_length = 0; - -/* How to say that you only want to save a certain amount - of kill material. */ -rl_set_retained_kills (num) - int num; -{ - 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. */ -rl_kill_text (from, to) - int from, to; -{ - int slot; - char *text = rl_copy_text (from, to); - - /* Is there anything to kill? */ - if (from == to) - { - free (text); - last_command_was_kill++; - return 0; - } - - /* Delete the copied text from the line. */ - rl_delete_text (from, to); - - /* First, find the slot to work with. */ - if (!last_command_was_kill) - { - /* Get a new slot. */ - if (!rl_kill_ring) - { - /* If we don't have any defined, then make one. */ - rl_kill_ring = (char **) - xmalloc (((rl_kill_ring_length = 1) + 1) * sizeof (char *)); - slot = 1; - } - 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 - { - rl_kill_ring = - (char **) - xrealloc (rl_kill_ring, - ((slot = (rl_kill_ring_length += 1)) + 1) - * sizeof (char *)); - } - } - slot--; - } - else - { - slot = rl_kill_ring_length - 1; - } - - /* If the last command was a kill, prepend or append. */ - if (last_command_was_kill && rl_editing_mode != vi_mode) - { - char *old = rl_kill_ring[slot]; - char *new = (char *)xmalloc (1 + strlen (old) + strlen (text)); - - if (from < to) - { - 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; - 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. */ -rl_kill_word (count) - int count; -{ - int orig_point = rl_point; - - if (count < 0) - return (rl_backward_kill_word (-count)); - else - { - rl_forward_word (count); - - if (rl_point != orig_point) - rl_kill_text (orig_point, rl_point); - - rl_point = orig_point; - } - return 0; -} - -/* Rubout the word before point, placing it on the kill ring. */ -rl_backward_kill_word (count) - int count; -{ - int orig_point = rl_point; - - if (count < 0) - return (rl_kill_word (-count)); - else - { - rl_backward_word (count); - - if (rl_point != orig_point) - rl_kill_text (orig_point, rl_point); - } -} - -/* Kill from here to the end of the line. If DIRECTION is negative, kill - back to the line start instead. */ -rl_kill_line (direction) - int direction; -{ - int orig_point = rl_point; - - if (direction < 0) - return (rl_backward_kill_line (1)); - else - { - rl_end_of_line (); - if (orig_point != rl_point) - rl_kill_text (orig_point, rl_point); - rl_point = orig_point; - } - return 0; -} - -/* Kill backwards to the start of the line. If DIRECTION is negative, kill - forwards to the line end instead. */ -rl_backward_kill_line (direction) - int direction; -{ - int orig_point = rl_point; - - if (direction < 0) - return (rl_kill_line (1)); - else - { - if (!rl_point) - ding (); - else - { - rl_beg_of_line (); - rl_kill_text (orig_point, rl_point); - } - } - return 0; -} - -/* Yank back the last killed text. This ignores arguments. */ -rl_yank () -{ - if (!rl_kill_ring) - { - rl_abort (); - return -1; - } - - rl_set_mark (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. */ -rl_yank_pop () -{ - int l; - - if (((rl_last_func != rl_yank_pop) && (rl_last_func != rl_yank)) || - !rl_kill_ring) - { - rl_abort (); - return -1; - } - - l = strlen (rl_kill_ring[rl_kill_index]); - if (((rl_point - l) >= 0) && - (strncmp (the_line + (rl_point - l), - rl_kill_ring[rl_kill_index], l) == 0)) - { - rl_delete_text ((rl_point - l), rl_point); - rl_point -= l; - rl_kill_index--; - if (rl_kill_index < 0) - rl_kill_index = rl_kill_ring_length - 1; - rl_yank (); - return 0; - } - else - { - rl_abort (); - return -1; - } -} - -/* Yank the COUNTth argument from the previous history line. */ -rl_yank_nth_arg (count, ignore) - int count; -{ - register HIST_ENTRY *entry = previous_history (); - char *arg; - - if (entry) - next_history (); - else - { - ding (); - return -1; - } - - arg = history_arg_extract (count, count, entry->line); - if (!arg || !*arg) - { - ding (); - return -1; - } - - rl_begin_undo_group (); - -#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_point++; -#endif /* VI_MODE */ - -#if 0 - if (rl_point && the_line[rl_point - 1] != ' ') - rl_insert_text (" "); -#endif - - rl_insert_text (arg); - free (arg); - - rl_end_undo_group (); - return 0; -} - -/* How to toggle back and forth between editing modes. */ -rl_vi_editing_mode () -{ -#if defined (VI_MODE) - rl_editing_mode = vi_mode; - rl_vi_insertion_mode (); - return 0; -#endif /* VI_MODE */ -} - -rl_emacs_editing_mode () -{ - rl_editing_mode = emacs_mode; - _rl_keymap = emacs_standard_keymap; - return 0; -} - - -/* **************************************************************** */ -/* */ -/* USG (System V) Support */ -/* */ -/* **************************************************************** */ - -int -rl_getc (stream) - FILE *stream; -{ - int result; - unsigned char c; - -#if defined (__GO32__) - if (isatty (0)) - return (getkey ()); -#endif /* __GO32__ */ - - 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 (EWOULDBLOCK) - if (errno == EWOULDBLOCK) - { - int flags; - - if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0) - return (EOF); - if (flags & O_NDELAY) - { - flags &= ~O_NDELAY; - fcntl (fileno (stream), F_SETFL, flags); - continue; - } - continue; - } -#endif /* EWOULDBLOCK */ - -#if defined (_POSIX_VERSION) && defined (EAGAIN) && defined (O_NONBLOCK) - if (errno == EAGAIN) - { - int flags; - - if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0) - return (EOF); - if (flags & O_NONBLOCK) - { - flags &= ~O_NONBLOCK; - fcntl (fileno (stream), F_SETFL, flags); - continue; - } - } -#endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */ - -#if !defined (__GO32__) - /* 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); -#endif /* !__GO32__ */ - } -} - -char * -_rl_savestring (str) - char *str; -{ - char *copy = (char*) xmalloc (strlen (str) + 1); - strcpy (copy, str); - return copy; -} - -#if defined (STATIC_MALLOC) - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)malloc (bytes); - else - temp = (char *)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 (); -} -#endif /* STATIC_MALLOC */ - - -/* **************************************************************** */ -/* */ -/* Testing Readline */ -/* */ -/* **************************************************************** */ - -#if defined (TEST) - -main () -{ - HIST_ENTRY **history_list (); - char *temp = (char *)NULL; - char *prompt = "readline% "; - int 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 = history_list (); - register int i; - if (list) - { - for (i = 0; list[i]; i++) - { - fprintf (stderr, "%d: %s\r\n", i, list[i]->line); - free (list[i]->line); - } - free (list); - } - } - free (temp); - } -} - -#endif /* TEST */ - - -/* - * Local variables: - * compile-command: "gcc -g -traditional -I. -I.. -DTEST -o readline readline.c keymaps.o funmap.o history.o -ltermcap" - * end: - */ diff --git a/readline/readline.h b/readline/readline.h deleted file mode 100644 index f890c0e..0000000 --- a/readline/readline.h +++ /dev/null @@ -1,200 +0,0 @@ -/* Readline.h -- the names of functions callable from within readline. */ - -#include "sysdep.h" - -#if !defined (_READLINE_H_) -#define _READLINE_H_ - -#include "keymaps.h" - -#if !defined (__FUNCTION_DEF) -typedef int Function (); -#define __FUNCTION_DEF -#endif /* __FUNCTION_DEF */ - -/* The functions for manipulating the text of the line within readline. -Most of these functions are bound to keys by default. */ -extern int - rl_beg_of_line (), rl_backward (), rl_delete (), rl_end_of_line (), - rl_forward (), ding (), rl_backward (), rl_newline (), rl_kill_line (), - rl_clear_screen (), rl_get_next_history (), rl_get_previous_history (), - rl_quoted_insert (), rl_reverse_search_history (), rl_transpose_chars (), - rl_unix_line_discard (), rl_quoted_insert (), rl_unix_word_rubout (), - rl_yank (), rl_rubout (), rl_backward_word (), rl_kill_word (), - rl_forward_word (), rl_tab_insert (), rl_yank_pop (), rl_yank_nth_arg (), - rl_backward_kill_word (), rl_backward_kill_line (), rl_transpose_words (), - rl_complete (), rl_possible_completions (), rl_do_lowercase_version (), - rl_digit_argument (), rl_universal_argument (), rl_abort (), - rl_undo_command (), rl_revert_line (), rl_beginning_of_history (), - rl_end_of_history (), rl_forward_search_history (), rl_insert (), - rl_upcase_word (), rl_downcase_word (), rl_capitalize_word (), - rl_restart_output (), rl_re_read_init_file (), rl_dump_functions (); - -/* These are *both* defined even when VI_MODE is not. */ -extern int rl_vi_editing_mode (), rl_emacs_editing_mode (); - -#if defined (VI_MODE) -/* Things for vi mode. */ -extern int - rl_vi_movement_mode (), rl_vi_insertion_mode (), rl_vi_arg_digit (), - rl_vi_prev_word (), rl_vi_next_word (), rl_vi_char_search (), - rl_vi_eof_maybe (), rl_vi_append_mode (), rl_vi_put (), - rl_vi_append_eol (), rl_vi_insert_beg (), rl_vi_delete (), rl_vi_comment (), - rl_vi_first_print (), rl_vi_fword (), rl_vi_fWord (), rl_vi_bword (), - rl_vi_bWord (), rl_vi_eword (), rl_vi_eWord (), rl_vi_end_word (), - rl_vi_change_case (), rl_vi_match (), rl_vi_bracktype (), - rl_vi_change_char (), rl_vi_yank_arg (), rl_vi_search (), - rl_vi_search_again (), rl_vi_dosearch (), rl_vi_subst (), - rl_vi_overstrike (), rl_vi_overstrike_delete (), rl_vi_replace(), - rl_vi_column (), rl_vi_delete_to (), rl_vi_change_to (), rl_vi_yank_to (), - rl_vi_complete (), rl_vi_fetch_history (); -#endif /* VI_MODE */ - -/* Keyboard macro commands. */ -extern int -rl_start_kbd_macro (), rl_end_kbd_macro (), rl_call_last_kbd_macro (); - -extern int rl_arrow_keys(), rl_refresh_line (); - -/* 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 { - char *name; - Function *function; -} FUNMAP; - -extern FUNMAP **funmap; - -/* **************************************************************** */ -/* */ -/* Well Published Variables */ -/* */ -/* **************************************************************** */ - -/* The name of the calling program. You should initialize this to - whatever was in argv[0]. It is used when parsing conditionals. */ -extern char *rl_readline_name; - -/* The line buffer that is in use. */ -extern char *rl_line_buffer; - -/* The location of point, and end. */ -extern int rl_point, rl_end; - -/* The name of the terminal to use. */ -extern char *rl_terminal_name; - -/* The input and output streams. */ -extern FILE *rl_instream, *rl_outstream; - -/* 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 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 char *rl_completer_word_break_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 char *rl_special_prefixes; - -/* Pointer to the generator function for completion_matches (). - NULL means to use filename_entry_function (), the default filename - completer. */ -extern Function *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 Function *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 Function *rl_attempted_completion_function; - -/* If non-zero, then this is the address of a function to call just - before readline_internal () prints the first prompt. */ -extern Function *rl_startup_hook; - -/* 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. */ -extern Function *rl_symbolic_link_hook; - -/* Non-zero means that modified history lines are preceded - with an asterisk. */ -extern int rl_show_star; - - -/* **************************************************************** */ -/* */ -/* Tilde Variables That Can be Externally Set */ -/* */ -/* **************************************************************** */ - -/* 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 Function *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; - -/* **************************************************************** */ -/* */ -/* Well Published Functions */ -/* */ -/* **************************************************************** */ - -/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */ -extern char *readline (); - -/* Return an array of strings which are the result of repeatadly calling - FUNC with TEXT. */ -extern char **completion_matches (); - -/* rl_add_defun (char *name, Function *function, int key) - Add NAME to the list of named functions. Make FUNCTION - be the function that gets called. - If KEY is not -1, then bind it. */ -extern int rl_add_defun (); - -#endif /* _READLINE_H_ */ diff --git a/readline/rldefs.h b/readline/rldefs.h deleted file mode 100644 index 3b7a623..0000000 --- a/readline/rldefs.h +++ /dev/null @@ -1,274 +0,0 @@ -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (_RLDEFS_H) -#define _RLDEFS_H - -#if defined (__GNUC__) -# undef alloca -# define alloca __builtin_alloca -#else -# if defined (sparc) || defined (HAVE_ALLOCA_H) -# include <alloca.h> -# endif -#endif - - -#define NEW_TTY_DRIVER -#define HAVE_BSD_SIGNALS -/* #define USE_XON_XOFF */ - -#if defined(__MSDOS__) || defined(_WIN32) -#define NO_SYS_FILE -#define SIGALRM 1234 -#undef NEW_TTY_DRIVER -#undef HAVE_BSD_SIGNALS -#define MINIMAL -#endif - -#if defined (__linux__) -# include <termcap.h> -#endif /* __linux__ */ - -/* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */ -/* CYGNUS LOCAL accept __hpux as well as hpux for HP compiler in ANSI mode. */ -#if defined (USG) && !(defined (hpux) || defined (__hpux)) -# undef HAVE_BSD_SIGNALS -#endif - -#define ScreenCols() 80 -#define ScreenRows() 24 -#define ScreenSetCursor() abort(); -#define ScreenGetCursor() abort(); - -/* System V machines use termio. */ -#if !defined (_POSIX_VERSION) -/* CYGNUS LOCAL accept __hpux as well as hpux for HP compiler in ANSI mode. - Add __osf__ to list of machines to force use of termio.h */ -# if defined (USG) || defined (hpux) || defined (__hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (__osf__) -# undef NEW_TTY_DRIVER -# define TERMIO_TTY_DRIVER -# include <termio.h> -# if !defined (TCOON) -# define TCOON 1 -# endif -# endif /* USG || hpux || Xenix || sgi || DUGX || __osf__ */ -#endif /* !_POSIX_VERSION */ - -/* Posix systems use termios and the Posix signal functions. */ -#if defined (_POSIX_VERSION) -# if !defined (TERMIOS_MISSING) -# undef NEW_TTY_DRIVER -# define TERMIOS_TTY_DRIVER -# include <termios.h> -# endif /* !TERMIOS_MISSING */ -# define HAVE_POSIX_SIGNALS -# if !defined (O_NDELAY) -# define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */ -# endif /* O_NDELAY */ -#endif /* _POSIX_VERSION */ - -/* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */ -#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) -# if defined (USGr3) -# if !defined (HAVE_USG_SIGHOLD) -# define HAVE_USG_SIGHOLD -# endif /* !HAVE_USG_SIGHOLD */ -# endif /* USGr3 */ -#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */ - -/* Other (BSD) machines use sgtty. */ -#if defined (NEW_TTY_DRIVER) -# include <sgtty.h> -#endif - -/* 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 (_POSIX_VERSION) -# define _POSIX_VDISABLE 0 -# else /* !_POSIX_VERSION */ -# define _POSIX_VDISABLE -1 -# endif /* !_POSIX_VERSION */ -#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */ - -#if 1 -# define D_NAMLEN(d) strlen ((d)->d_name) -#else /* !1 */ - -#if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3)) -# if !defined (HAVE_DIRENT_H) -# define HAVE_DIRENT_H -# endif /* !HAVE_DIRENT_H */ -#endif /* !SHELL && (_POSIX_VERSION || USGr3) */ - -#if defined (HAVE_DIRENT_H) -# include <dirent.h> -# if !defined (direct) -# define direct dirent -# endif /* !direct */ -# define D_NAMLEN(d) strlen ((d)->d_name) -#else /* !HAVE_DIRENT_H */ -# define D_NAMLEN(d) ((d)->d_namlen) -# if defined (USG) -# if defined (Xenix) -# include <sys/ndir.h> -# else /* !Xenix (but USG...) */ -# include "ndir.h" -# endif /* !Xenix */ -# else /* !USG */ -# include <sys/dir.h> -# endif /* !USG */ -#endif /* !HAVE_DIRENT_H */ -#endif /* !1 */ - -#if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux) -# if defined (_AIX) - /* AIX 4.x seems to reference struct uio within a prototype - in stream.h, but doesn't cause the uio include file to - be included. */ -# include <sys/uio.h> -# endif -# include <sys/stream.h> -# if defined (HAVE_SYS_PTEM_H) -# include <sys/ptem.h> -# endif /* HAVE_SYS_PTEM_H */ -# if defined (HAVE_SYS_PTE_H) -# include <sys/pte.h> -# endif /* HAVE_SYS_PTE_H */ -#endif /* USG && TIOCGWINSZ && !Linux */ - -/* 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 -/* Posix macro to check file in statbuf for file-ness. - This requires that <sys/stat.h> be included before this test. */ -#if defined (S_IFREG) && !defined (S_ISREG) -#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) -#endif - -#if !defined (strchr) && !defined (__STDC__) -extern char *strchr (), *strrchr (); -#endif /* !strchr && !__STDC__ */ - -#if defined (HAVE_VARARGS_H) -# include <varargs.h> -#endif /* HAVE_VARARGS_H */ - -/* 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 - -#if defined(_WIN32) || defined(__MSDOS__) -#undef HANDLE_SIGNALS -#endif - - -#if !defined (emacs_mode) -# define no_mode -1 -# define vi_mode 0 -# define emacs_mode 1 -#endif - -/* Define some macros for dealing with assorted signalling disciplines. - - These macros provide a way to use signal blocking and disabling - without smothering your code in a pile of #ifdef's. - - SIGNALS_UNBLOCK; Stop blocking all signals. - - { - SIGNALS_DECLARE_SAVED (name); Declare a variable to save the - signal blocking state. - ... - SIGNALS_BLOCK (SIGSTOP, name); Block a signal, and save the previous - state for restoration later. - ... - SIGNALS_RESTORE (name); Restore previous signals. - } - -*/ - -#ifdef HAVE_POSIX_SIGNALS - /* POSIX signals */ - -#define SIGNALS_UNBLOCK \ - do { sigset_t set; \ - sigemptyset (&set); \ - sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); \ - } while (0) - -#define SIGNALS_DECLARE_SAVED(name) sigset_t name - -#define SIGNALS_BLOCK(SIG, saved) \ - do { sigset_t set; \ - sigemptyset (&set); \ - sigaddset (&set, SIG); \ - sigprocmask (SIG_BLOCK, &set, &saved); \ - } while (0) - -#define SIGNALS_RESTORE(saved) \ - sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL) - - -#else /* HAVE_POSIX_SIGNALS */ -#ifdef HAVE_BSD_SIGNALS - /* BSD signals */ - -#define SIGNALS_UNBLOCK sigsetmask (0) -#define SIGNALS_DECLARE_SAVED(name) int name -#define SIGNALS_BLOCK(SIG, saved) saved = sigblock (sigmask (SIG)) -#define SIGNALS_RESTORE(saved) sigsetmask (saved) - - -#else /* HAVE_BSD_SIGNALS */ - /* None of the Above */ - -#define SIGNALS_UNBLOCK /* nothing */ -#define SIGNALS_DECLARE_SAVED(name) /* nothing */ -#define SIGNALS_BLOCK(SIG, saved) /* nothing */ -#define SIGNALS_RESTORE(saved) /* nothing */ - - -#endif /* HAVE_BSD_SIGNALS */ -#endif /* HAVE_POSIX_SIGNALS */ - -#if !defined (strchr) -extern char *strchr (); -#endif -#if !defined (strrchr) -extern char *strrchr (); -#endif -#ifdef __STDC__ -#include <stddef.h> -extern size_t strlen (const char *s); -#endif /* __STDC__ */ - -/* End of signal handling definitions. */ -#endif /* !_RLDEFS_H */ diff --git a/readline/rltty.c b/readline/rltty.c deleted file mode 100644 index a324419..0000000 --- a/readline/rltty.c +++ /dev/null @@ -1,669 +0,0 @@ -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "sysdep.h" -#include <signal.h> -#include <errno.h> -#include <stdio.h> -#ifndef NO_SYS_FILE -#include <sys/file.h> -#endif - -#if defined (HAVE_UNISTD_H) -# include <unistd.h> -#endif /* HAVE_UNISTD_H */ - -#include "rldefs.h" -#include "readline.h" - -#if !defined (errno) -extern int errno; -#endif /* !errno */ - -extern int readline_echoing_p; -extern int _rl_eof_char; - -#if defined (__GO32__) -# include <sys/pc.h> -# undef HANDLE_SIGNALS -#endif /* __GO32__ */ - -/* **************************************************************** */ -/* */ -/* 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 = 0; - -/* 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) - 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; -} - -/* **************************************************************** */ -/* */ -/* Controlling the Meta Key */ -/* */ -/* **************************************************************** */ - -extern int term_has_meta; -extern char *term_mm; -extern char *term_mo; - -static void -outchar (c) - int c; -{ - putc (c, rl_outstream); -} - -/* Turn on/off the meta key depending on ON. */ -static void -control_meta_key (on) - int on; -{ - if (term_has_meta) - { - if (on && term_mm) - tputs (term_mm, 1, outchar); - else if (!on && term_mo) - tputs (term_mo, 1, outchar); - } -} - -/* **************************************************************** */ -/* */ -/* Saving and Restoring the TTY */ -/* */ -/* **************************************************************** */ - -/* Non-zero means that the terminal is in a prepped state. */ -static int terminal_prepped = 0; - -/* If non-zero, means that this process has called tcflow(fd, TCOOFF) - and output is suspended. */ -#if defined (__ksr1__) -static int ksrflow = 0; -#endif -#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 int -get_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; -{ - tiop->flags = tiop->lflag = 0; - - ioctl (tty, TIOCGETP, &(tiop->sgttyb)); - tiop->flags |= SGTTY_SET; - -#if defined (TIOCLGET) - ioctl (tty, TIOCLGET, &(tiop->lflag)); - tiop->flags |= LFLAG_SET; -#endif - -#if defined (TIOCGETC) - ioctl (tty, TIOCGETC, &(tiop->tchars)); - tiop->flags |= TCHARS_SET; -#endif - -#if defined (TIOCGLTC) - ioctl (tty, TIOCGLTC, &(tiop->ltchars)); - tiop->flags |= LTCHARS_SET; -#endif - - return 0; -} - -set_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; -{ - if (tiop->flags & SGTTY_SET) - { - ioctl (tty, TIOCSETN, &(tiop->sgttyb)); - tiop->flags &= ~SGTTY_SET; - } - -#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, otio, tiop) - int meta_flag; - TIOTYPE otio, *tiop; -{ -#if !defined (__GO32__) - readline_echoing_p = (otio.sgttyb.sg_flags & ECHO); - - /* Copy the original settings to the structure we're going to use for - our settings. */ - tiop->sgttyb = otio.sgttyb; - tiop->lflag = otio.lflag; -#if defined (TIOCGETC) - tiop->tchars = otio.tchars; -#endif -#if defined (TIOCGLTC) - tiop->ltchars = otio.ltchars; -#endif - tiop->flags = otio.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 (((otio.sgttyb.sg_flags & ANYP) == ANYP) || - ((otio.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 (otio.tchars.t_startc != -1) - rl_bind_key (otio.tchars.t_startc, rl_restart_output); -# endif /* USE_XON_XOFF */ - - /* If there is an EOF char, bind _rl_eof_char to it. */ - if (otio.tchars.t_eofc != -1) - _rl_eof_char = otio.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 */ -#endif /* !__GO32__ */ -} -#endif /* defined (NEW_TTY_DRIVER) */ - -#if !defined (NEW_TTY_DRIVER) && !defined(__GO32__) - -#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)) -# define SETATTR(tty, tiop) (tcsetattr (tty, TCSANOW, tiop)) -#else -# define TIOTYPE struct termio -# define DRAIN_OUTPUT(fd) -# define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop)) -# define SETATTR(tty, tiop) (ioctl (tty, TCSETA, tiop)) -#endif /* !TERMIOS_TTY_DRIVER */ - -static TIOTYPE otio; - -static int -get_tty_settings (tty, tiop) - int tty; - TIOTYPE *tiop; -{ - while (GETATTR (tty, tiop) < 0) - { - if (errno != EINTR) - return -1; - errno = 0; - } - 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; - } - -#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 - - return 0; -} - -static void -prepare_terminal_settings (meta_flag, otio, tiop) - int meta_flag; - TIOTYPE otio, *tiop; -{ - readline_echoing_p = (otio.c_lflag & ECHO); - - tiop->c_lflag &= ~(ICANON | ECHO); - - if ((unsigned char) otio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE) - _rl_eof_char = otio.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; - - /* 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 /* !defined (NEW_TTY_DRIVER) && !defined(__GO32__) */ - -/* Put the terminal in CBREAK mode so that we can detect key presses. */ -void -rl_prep_terminal (meta_flag) - int meta_flag; -{ -#if !defined (__GO32__) - int tty = fileno (rl_instream); - TIOTYPE tio; - - if (terminal_prepped) - return; - - /* Try to keep this function from being INTerrupted. */ - block_sigint (); - - if (get_tty_settings (tty, &tio) < 0) - { - release_sigint (); - return; - } - - otio = tio; - - prepare_terminal_settings (meta_flag, otio, &tio); - - if (set_tty_settings (tty, &tio) < 0) - { - release_sigint (); - return; - } - - control_meta_key (1); - terminal_prepped = 1; - - release_sigint (); -#endif /* !__GO32__ */ -} - -/* Restore the terminal's normal settings and modes. */ -void -rl_deprep_terminal () -{ -#if !defined (__GO32__) - int tty = fileno (rl_instream); - - if (!terminal_prepped) - return; - - /* Try to keep this function from being INTerrupted. */ - block_sigint (); - - if (set_tty_settings (tty, &otio) < 0) - { - release_sigint (); - return; - } -#ifdef NEW_TTY_DRIVER - readline_echoing_p = 1; -#endif - - control_meta_key (0); - terminal_prepped = 0; - - release_sigint (); -#endif /* !__GO32__ */ -} - -/* **************************************************************** */ -/* */ -/* Bogus Flow Control */ -/* */ -/* **************************************************************** */ - -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 */ -} - -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 */ -} - -/* **************************************************************** */ -/* */ -/* Default Key Bindings */ -/* */ -/* **************************************************************** */ -#if !defined (__GO32__) -void -rltty_set_default_bindings (kmap) - Keymap kmap; -{ - TIOTYPE ttybuff; - int tty = fileno (rl_instream); - -#if defined (NEW_TTY_DRIVER) - - if (get_tty_settings (tty, &ttybuff) == 0) - { - if (ttybuff.flags & SGTTY_SET) - { - int erase, kill; - - erase = ttybuff.sgttyb.sg_erase; - kill = ttybuff.sgttyb.sg_kill; - - if (erase != -1 && kmap[erase].type == ISFUNC) - kmap[erase].function = rl_rubout; - - if (kill != -1 && kmap[kill].type == ISFUNC) - kmap[kill].function = rl_unix_line_discard; - } - -# if defined (TIOCGLTC) - - if (ttybuff.flags & LTCHARS_SET) - { - int werase, nextc; - - werase = ttybuff.ltchars.t_werasc; - nextc = ttybuff.ltchars.t_lnextc; - - if (werase != -1 && kmap[werase].type == ISFUNC) - kmap[werase].function = rl_unix_word_rubout; - - if (nextc != -1 && kmap[nextc].type == ISFUNC) - kmap[nextc].function = rl_quoted_insert; - } - } -# endif /* TIOCGLTC */ - -#else /* !NEW_TTY_DRIVER */ - - if (get_tty_settings (tty, &ttybuff) == 0) - { - unsigned char erase, kill; - - erase = ttybuff.c_cc[VERASE]; - kill = ttybuff.c_cc[VKILL]; - - if (erase != (unsigned char)_POSIX_VDISABLE && - kmap[erase].type == ISFUNC) - kmap[erase].function = rl_rubout; - - if (kill != (unsigned char)_POSIX_VDISABLE && - kmap[kill].type == ISFUNC) - kmap[kill].function = rl_unix_line_discard; - -# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER) - { - unsigned char nextc; - - nextc = ttybuff.c_cc[VLNEXT]; - - if (nextc != (unsigned char)_POSIX_VDISABLE && - kmap[nextc].type == ISFUNC) - kmap[nextc].function = rl_quoted_insert; - } -# endif /* VLNEXT && TERMIOS_TTY_DRIVER */ - -# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER) - { - unsigned char werase; - - werase = ttybuff.c_cc[VWERASE]; - - if (werase != (unsigned char)_POSIX_VDISABLE && - kmap[werase].type == ISFUNC) - kmap[werase].function = rl_unix_word_rubout; - } -# endif /* VWERASE && TERMIOS_TTY_DRIVER */ - } -#endif /* !NEW_TTY_DRIVER */ -} -#endif /* !__GO32__ */ diff --git a/readline/search.c b/readline/search.c deleted file mode 100644 index ea98c6f..0000000 --- a/readline/search.c +++ /dev/null @@ -1,271 +0,0 @@ -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include <stdio.h> - -#if defined (__GNUC__) -# define alloca __builtin_alloca -#else -# if defined (sparc) || defined (HAVE_ALLOCA_H) -# include <alloca.h> -# endif -#endif - -#include "readline.h" -#include "history.h" - -extern char *xmalloc (), *xrealloc (); - -/* Variables imported from readline.c */ -extern int rl_point, rl_end, rl_line_buffer_len; -extern Keymap _rl_keymap; -extern char *rl_prompt; -extern char *rl_line_buffer; -extern HIST_ENTRY *saved_line_for_history; - -static char *noninc_search_string = (char *) NULL; -static int noninc_history_pos = 0; - -/* 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; - - old = where_history (); - history_set_pos (pos); - - if (*string == '^') - ret = history_search_prefix (string + 1, dir); - else - ret = history_search (string, dir); - - 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) - { - ding (); - return; - } - - pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir); - if (pos == -1) - { - /* Search failed, current history position unchanged. */ - maybe_unsave_line (); - rl_clear_message (); - rl_point = 0; - ding (); - return; - } - - noninc_history_pos = pos; - - oldpos = where_history (); - history_set_pos (noninc_history_pos); - entry = current_history (); - history_set_pos (oldpos); - - { - int line_len; - - line_len = strlen (entry->line); - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - strcpy (rl_line_buffer, entry->line); - } - - rl_undo_list = (UNDO_LIST *)entry->data; - rl_end = strlen (rl_line_buffer); - rl_point = 0; - rl_clear_message (); - - if (saved_line_for_history) - free_history_entry (saved_line_for_history); - saved_line_for_history = (HIST_ENTRY *)NULL; -} - -/* 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, c, pmtlen; - char *p; - - maybe_save_line (); - saved_point = rl_point; - - /* Use the line buffer to read the search string. */ - rl_line_buffer[0] = 0; - rl_end = rl_point = 0; - - pmtlen = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; - p = (char *)alloca (2 + pmtlen); - if (pmtlen) - strcpy (p, rl_prompt); - p[pmtlen] = pchar ? pchar : ':'; - p[pmtlen + 1] = '\0'; - - rl_message (p, 0, 0); - - /* Read the search string. */ - while (c = rl_read_key ()) - { - switch (c) - { - case CTRL('H'): - case RUBOUT: - if (rl_point == 0) - { - maybe_unsave_line (); - rl_clear_message (); - rl_point = saved_point; - return; - } - /* FALLTHROUGH */ - - case CTRL('W'): - case CTRL('U'): - rl_dispatch (c, _rl_keymap); - break; - - case RETURN: - case NEWLINE: - goto dosearch; - /* NOTREACHED */ - break; - - case CTRL('C'): - case CTRL('G'): - maybe_unsave_line (); - rl_clear_message (); - rl_point = saved_point; - ding (); - return; - - default: - rl_insert (1, c); - break; - } - rl_redisplay (); - } - - dosearch: - /* 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) - { - ding (); - return; - } - } - else - { - /* We want to start the search from the current history position. */ - noninc_history_pos = where_history (); - if (noninc_search_string) - free (noninc_search_string); - noninc_search_string = savestring (rl_line_buffer); - } - - noninc_dosearch (noninc_search_string, dir); -} - -/* Search forward through the history list for a string. If the vi-mode - code calls this, KEY will be `?'. */ -rl_noninc_forward_search (count, key) - int count, key; -{ - if (key == '?') - noninc_search (1, '?'); - else - noninc_search (1, 0); -} - -/* Reverse search the history list for a string. If the vi-mode code - calls this, KEY will be `/'. */ -rl_noninc_reverse_search (count, key) - int count, key; -{ - if (key == '/') - noninc_search (-1, '/'); - else - noninc_search (-1, 0); -} - -/* Search forward through the history list for the last string searched - for. If there is no saved search string, abort. */ -rl_noninc_forward_search_again (count, key) - int count, key; -{ - if (!noninc_search_string) - { - ding (); - return (-1); - } - noninc_dosearch (noninc_search_string, 1); -} - -/* Reverse search in the history list for the last string searched - for. If there is no saved search string, abort. */ -rl_noninc_reverse_search_again (count, key) - int count, key; -{ - if (!noninc_search_string) - { - ding (); - return (-1); - } - noninc_dosearch (noninc_search_string, -1); -} diff --git a/readline/shell.c b/readline/shell.c deleted file mode 100644 index 553f3c1..0000000 --- a/readline/shell.c +++ /dev/null @@ -1,138 +0,0 @@ -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define READLINE_LIBRARY - -#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 /* 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 */ - -extern char *xmalloc (), *xrealloc (); - -#if !defined (SHELL) - -#ifdef savestring -#undef savestring -#endif - -/* Backwards compatibility, now that savestring has been removed from - all `public' readline header files. */ -char * -savestring (s) - char *s; -{ - return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s))); -} - -/* Does shell-like quoting using single quotes. */ -char * -single_quote (string) - char *string; -{ - register int c; - char *result, *r, *s; - - result = (char *)xmalloc (3 + (3 * 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 -set_lines_and_columns (lines, cols) - int lines, cols; -{ - char *b; - -#if defined (HAVE_PUTENV) - b = xmalloc (24); - sprintf (b, "LINES=%d", lines); - putenv (b); - b = xmalloc (24); - sprintf (b, "COLUMNS=%d", cols); - putenv (b); -#else /* !HAVE_PUTENV */ -# if defined (HAVE_SETENV) - b = xmalloc (8); - sprintf (b, "%d", lines); - setenv ("LINES", b, 1); - b = xmalloc (8); - sprintf (b, "%d", cols); - setenv ("COLUMNS", b, 1); -# endif /* HAVE_SETENV */ -#endif /* !HAVE_PUTENV */ -} - -char * -get_env_value (varname) - char *varname; -{ - return ((char *)getenv (varname)); -} - -#else /* SHELL */ -extern char *get_string_value (); - -char * -get_env_value (varname) - char *varname; -{ - return get_string_value (varname); -} -#endif /* SHELL */ diff --git a/readline/signals.c b/readline/signals.c deleted file mode 100644 index 35a64b6..0000000 --- a/readline/signals.c +++ /dev/null @@ -1,248 +0,0 @@ -/* 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include <stdio.h> -#include <sys/types.h> -#include <fcntl.h> -#if !defined (NO_SYS_FILE) -# include <sys/file.h> -#endif /* !NO_SYS_FILE */ -#include <signal.h> - -/* This is needed to include support for TIOCGWINSZ and window resizing. */ -#if defined (OSF1) || defined (BSD386) || defined (_386BSD) || defined (__BSD_4_4__) || defined (AIX) -# include <sys/ioctl.h> -#endif /* OSF1 || BSD386 || _386BSD || __BSD_4_4__ || AIX */ - -#include <errno.h> -/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ -#if !defined (errno) -extern int errno; -#endif /* !errno */ - -/* System-specific feature definitions and include files. */ -#include "rldefs.h" - -/* Some standard library routines. */ -#include "readline.h" -#include "history.h" - -static void cr (); - -extern int readline_echoing_p; -extern int rl_pending_input; - -extern int _rl_meta_flag; - -#ifdef __STDC__ -extern void _rl_output_character_function (int); -#else -extern void _rl_output_character_function (); -#endif - -extern void free_undo_list (); - -#if defined (VOID_SIGHANDLER) -# define sighandler void -#else -# define sighandler int -#endif /* VOID_SIGHANDLER */ - -/* This typedef is equivalant to the one for Function; it allows us - to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */ -typedef sighandler SigHandler (); - -/* **************************************************************** */ -/* */ -/* Signal Handling */ -/* */ -/* **************************************************************** */ - -#if defined (HANDLE_SIGNALS) - -#if defined (SIGWINCH) -static SigHandler *old_sigwinch = (SigHandler *)NULL; - -static sighandler -rl_handle_sigwinch (sig) - int sig; -{ - if (readline_echoing_p) - { - _rl_set_screen_size (fileno (rl_instream), 1); - - cr (); /* was crlf () */ - rl_forced_update_display (); - } - - if (old_sigwinch && - old_sigwinch != (SigHandler *)SIG_IGN && - old_sigwinch != (SigHandler *)SIG_DFL) - (*old_sigwinch) (sig); -#if !defined (VOID_SIGHANDLER) - return (0); -#endif /* VOID_SIGHANDLER */ -} -#endif /* SIGWINCH */ - -/* Interrupt handling. */ -static SigHandler - *old_int = (SigHandler *)NULL, - *old_tstp = (SigHandler *)NULL, - *old_ttou = (SigHandler *)NULL, - *old_ttin = (SigHandler *)NULL, - *old_cont = (SigHandler *)NULL, - *old_alrm = (SigHandler *)NULL; - -/* Handle an interrupt character. */ -static sighandler -rl_signal_handler (sig) - int sig; -{ -#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) - signal (sig, SIG_IGN); -#endif /* !HAVE_BSD_SIGNALS */ - - switch (sig) - { - case SIGINT: - { - register HIST_ENTRY *entry; - - free_undo_list (); - - entry = current_history (); - if (entry) - entry->data = (char *)NULL; - } - _rl_kill_kbd_macro (); - rl_clear_message (); - rl_init_argument (); - -#if defined (SIGTSTP) - case SIGTSTP: - case SIGTTOU: - case SIGTTIN: -#endif /* SIGTSTP */ - case SIGALRM: - rl_clean_up_for_exit (); - rl_deprep_terminal (); - rl_clear_signals (); - rl_pending_input = 0; - - kill (getpid (), sig); - - SIGNALS_UNBLOCK; - - rl_prep_terminal (_rl_meta_flag); - rl_set_signals (); - } - -#if !defined (VOID_SIGHANDLER) - return (0); -#endif /* !VOID_SIGHANDLER */ -} - -#if defined (HAVE_POSIX_SIGNALS) -static SigHandler * -rl_set_sighandler (sig, handler) - int sig; - SigHandler *handler; -{ - struct sigaction act, oact; - - act.sa_handler = handler; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigemptyset (&oact.sa_mask); - sigaction (sig, &act, &oact); - return (oact.sa_handler); -} - -#else /* !HAVE_POSIX_SIGNALS */ -# define rl_set_sighandler(sig, handler) (SigHandler *)signal (sig, handler) -#endif /* !HAVE_POSIX_SIGNALS */ - -rl_set_signals () -{ - old_int = (SigHandler *)rl_set_sighandler (SIGINT, rl_signal_handler); - if (old_int == (SigHandler *)SIG_IGN) - signal (SIGINT, SIG_IGN); - - old_alrm = (SigHandler *)rl_set_sighandler (SIGALRM, rl_signal_handler); - if (old_alrm == (SigHandler *)SIG_IGN) - signal (SIGALRM, SIG_IGN); - -#if defined (SIGTSTP) - old_tstp = (SigHandler *)rl_set_sighandler (SIGTSTP, rl_signal_handler); - if (old_tstp == (SigHandler *)SIG_IGN) - signal (SIGTSTP, SIG_IGN); -#endif -#if defined (SIGTTOU) - old_ttou = (SigHandler *)rl_set_sighandler (SIGTTOU, rl_signal_handler); - old_ttin = (SigHandler *)rl_set_sighandler (SIGTTIN, rl_signal_handler); - - if (old_tstp == (SigHandler *)SIG_IGN) - { - signal (SIGTTOU, SIG_IGN); - signal (SIGTTIN, SIG_IGN); - } -#endif - -#if defined (SIGWINCH) - old_sigwinch = - (SigHandler *) rl_set_sighandler (SIGWINCH, rl_handle_sigwinch); -#endif -} - -rl_clear_signals () -{ - rl_set_sighandler (SIGINT, old_int); - rl_set_sighandler (SIGALRM, old_alrm); - -#if defined (SIGTSTP) - signal (SIGTSTP, old_tstp); -#endif - -#if defined (SIGTTOU) - signal (SIGTTOU, old_ttou); - signal (SIGTTIN, old_ttin); -#endif - -#if defined (SIGWINCH) - signal (SIGWINCH, old_sigwinch); -#endif -} - -/* Move to the start of the current line. */ -static void -cr () -{ - extern char *term_cr; - - if (term_cr) - tputs (term_cr, 1, _rl_output_character_function); -} -#endif /* HANDLE_SIGNALS */ diff --git a/readline/support/.Sanitize b/readline/support/.Sanitize deleted file mode 100644 index 02fab17..0000000 --- a/readline/support/.Sanitize +++ /dev/null @@ -1,39 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -config.guess -config.sub -install.sh -mkdirs -mkdist - -Things-to-lose: - - -Do-last: - -# End of file. diff --git a/readline/support/install.sh b/readline/support/install.sh deleted file mode 100755 index ea88212..0000000 --- a/readline/support/install.sh +++ /dev/null @@ -1,235 +0,0 @@ -#!/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 $ -# -# 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 diff --git a/readline/support/mkdirs b/readline/support/mkdirs deleted file mode 100755 index b79d971..0000000 --- a/readline/support/mkdirs +++ /dev/null @@ -1,32 +0,0 @@ -#! /bin/sh -# -# mkdirs - a work-alike for `mkdir -p' -# -# Chet Ramey -# chet@po.cwru.edu - -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 diff --git a/readline/tilde.c b/readline/tilde.c deleted file mode 100644 index 22890f4..0000000 --- a/readline/tilde.c +++ /dev/null @@ -1,396 +0,0 @@ -/* 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if defined (__GNUC__) -# undef alloca -# define alloca __builtin_alloca -#else /* !__GNUC__ */ -# if defined (_AIX) - #pragma alloca -# else /* !_AIX */ -# if defined (HAVE_ALLOCA_H) -# include <alloca.h> -# endif /* HAVE_ALLOCA_H */ -# endif /* !AIX */ -#endif /* !__GNUC__ */ - -#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 <tilde/tilde.h> -#include <pwd.h> - -#if !defined (sgi) && !defined (isc386) -extern struct passwd *getpwnam (), *getpwuid (); -#endif /* !sgi */ - -#if !defined (savestring) -extern char *xmalloc (); -# ifndef strcpy -extern char *strcpy (); -# endif -#define savestring(x) strcpy (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 defined (TEST) || defined (STATIC_MALLOC) -static char *xmalloc (), *xrealloc (); -#else -extern char *xmalloc (), *xrealloc (); -#endif /* TEST || STATIC_MALLOC */ - -/* 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 char *default_prefixes[] = - { " ~", "\t~", (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 char *default_suffixes[] = - { " ", "\n", (char *)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. */ -Function *tilde_expansion_failure_hook = (Function *)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 = 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 = default_suffixes; - -/* 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) - char *string; - int *len; -{ - register int i, j, string_len; - register char **prefixes = tilde_additional_prefixes; - - string_len = strlen (string); - *len = 0; - - if (!*string || *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) - char *string; -{ - register int i, j, string_len; - register char **suffixes = tilde_additional_suffixes; - - string_len = strlen (string); - - for (i = 0; i < string_len; i++) - { - if (string[i] == '/' || !string[i]) - 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) - char *string; -{ - char *result, *tilde_expand_word (); - int result_size, result_index; - - result_size = result_index = 0; - result = (char *)NULL; - - /* 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); - 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); -} - -/* Do the work of tilde expansion on FILENAME. FILENAME starts with a - tilde. If there is no expansion, call tilde_expansion_failure_hook. */ -char * -tilde_expand_word (filename) - char *filename; -{ - char *dirname; - - dirname = filename ? savestring (filename) : (char *)NULL; - - if (dirname && *dirname == '~') - { - char *temp_name; - if (!dirname[1] || dirname[1] == '/') - { - /* Prepend $HOME to the rest of the string. */ - char *temp_home = (char *)getenv ("HOME"); - - /* If there is no HOME variable, look up the directory in - the password database. */ - if (!temp_home) - { - struct passwd *entry; - - entry = getpwuid (getuid ()); - if (entry) - temp_home = entry->pw_dir; - } - - temp_name = (char *)alloca (1 + strlen (&dirname[1]) - + (temp_home ? strlen (temp_home) : 0)); - temp_name[0] = '\0'; - if (temp_home) - strcpy (temp_name, temp_home); - strcat (temp_name, &dirname[1]); - free (dirname); - dirname = savestring (temp_name); - } - else - { - struct passwd *user_entry; - char *username = (char *)alloca (257); - int i, c; - - for (i = 1; c = dirname[i]; i++) - { - if (c == '/') - break; - else - username[i - 1] = c; - } - username[i - 1] = '\0'; - - if (!(user_entry = getpwnam (username))) - { - /* 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) - { - char *expansion; - - expansion = - (char *)(*tilde_expansion_failure_hook) (username); - - if (expansion) - { - temp_name = (char *)alloca (1 + strlen (expansion) - + strlen (&dirname[i])); - strcpy (temp_name, expansion); - strcat (temp_name, &dirname[i]); - free (expansion); - goto return_name; - } - } - /* We shouldn't report errors. */ - } - else - { - temp_name = (char *)alloca (1 + strlen (user_entry->pw_dir) - + strlen (&dirname[i])); - strcpy (temp_name, user_entry->pw_dir); - strcat (temp_name, &dirname[i]); - return_name: - free (dirname); - dirname = savestring (temp_name); - } - 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 char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)malloc (bytes); - else - temp = (char *)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 */ diff --git a/readline/tilde.h b/readline/tilde.h deleted file mode 100644 index 4f808fe..0000000 --- a/readline/tilde.h +++ /dev/null @@ -1,33 +0,0 @@ -/* tilde.h: Externally available variables and function in libtilde.a. */ - -/* Function pointers can be declared as (Function *)foo. */ -#if !defined (__FUNCTION_DEF) -# define __FUNCTION_DEF -typedef int Function (); -typedef void VFunction (); -typedef char *CPFunction (); -typedef char **CPPFunction (); -#endif /* _FUNCTION_DEF */ - -/* 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 Function *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 (); - -/* 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 (); diff --git a/readline/vi_keymap.c b/readline/vi_keymap.c deleted file mode 100644 index 5464dad..0000000 --- a/readline/vi_keymap.c +++ /dev/null @@ -1,474 +0,0 @@ -/* vi_keymap.c -- the keymap for vi_mode in readline (). */ - -/* 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef BUFSIZ -#include <stdio.h> -#endif /* BUFSIZ */ - -#include "readline.h" - -extern KEYMAP_ENTRY_ARRAY vi_escape_keymap; - -/* The keymap arrays for handling vi mode. */ -KEYMAP_ENTRY_ARRAY vi_movement_keymap = { - - /* The regular control keys come first. */ - { ISFUNC, (Function *)0x0 }, /* Control-@ */ - { ISFUNC, (Function *)0x0 }, /* Control-a */ - { ISFUNC, (Function *)0x0 }, /* Control-b */ - { ISFUNC, (Function *)0x0 }, /* Control-c */ - { ISFUNC, rl_vi_eof_maybe }, /* Control-d */ - { ISFUNC, rl_emacs_editing_mode }, /* Control-e */ - { ISFUNC, (Function *)0x0 }, /* Control-f */ - { ISFUNC, rl_abort }, /* Control-g */ - { ISFUNC, rl_rubout }, /* Control-h */ - { ISFUNC, (Function *)0x0 }, /* 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, (Function *)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 */ - { ISFUNC, (Function *)0x0 }, /* Control-x */ - { ISFUNC, rl_yank }, /* Control-y */ - { ISFUNC, (Function *)0x0 }, /* Control-z */ - - { ISKMAP, (Function *)vi_escape_keymap }, /* Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Control-] */ - { ISFUNC, (Function *)0x0 }, /* Control-^ */ - { ISFUNC, rl_undo_command }, /* Control-_ */ - - /* The start of printing characters. */ - { ISFUNC, rl_forward }, /* SPACE */ - { ISFUNC, (Function *)0x0 }, /* ! */ - { ISFUNC, (Function *)0x0 }, /* " */ - { ISFUNC, rl_vi_comment }, /* # */ - { ISFUNC, rl_end_of_line }, /* $ */ - { ISFUNC, rl_vi_match }, /* % */ - { ISFUNC, (Function *)0x0 }, /* & */ - { ISFUNC, (Function *)0x0 }, /* ' */ - { ISFUNC, (Function *)0x0 }, /* ( */ - { ISFUNC, (Function *)0x0 }, /* ) */ - { ISFUNC, rl_vi_complete }, /* * */ - { ISFUNC, rl_get_next_history}, /* + */ - { ISFUNC, rl_vi_char_search }, /* , */ - { ISFUNC, rl_get_previous_history }, /* - */ - { ISFUNC, (Function *)0x0 }, /* . */ - { ISFUNC, rl_vi_search }, /* / */ - - /* Regular digits. */ - { ISFUNC, rl_vi_arg_digit }, /* 0 */ - { ISFUNC, rl_vi_arg_digit }, /* 1 */ - { ISFUNC, rl_vi_arg_digit }, /* 2 */ - { ISFUNC, rl_vi_arg_digit }, /* 3 */ - { ISFUNC, rl_vi_arg_digit }, /* 4 */ - { ISFUNC, rl_vi_arg_digit }, /* 5 */ - { ISFUNC, rl_vi_arg_digit }, /* 6 */ - { ISFUNC, rl_vi_arg_digit }, /* 7 */ - { ISFUNC, rl_vi_arg_digit }, /* 8 */ - { ISFUNC, rl_vi_arg_digit }, /* 9 */ - - /* A little more punctuation. */ - { ISFUNC, (Function *)0x0 }, /* : */ - { ISFUNC, rl_vi_char_search }, /* ; */ - { ISFUNC, (Function *)0x0 }, /* < */ - { ISFUNC, rl_vi_complete }, /* = */ - { ISFUNC, (Function *)0x0 }, /* > */ - { ISFUNC, rl_vi_search }, /* ? */ - { ISFUNC, (Function *)0x0 }, /* @ */ - - /* Uppercase alphabet. */ - { ISFUNC, rl_vi_append_eol }, /* A */ - { ISFUNC, rl_vi_prev_word}, /* B */ - { ISFUNC, rl_vi_change_to }, /* C */ - { ISFUNC, rl_vi_delete_to }, /* D */ - { ISFUNC, rl_vi_end_word }, /* E */ - { ISFUNC, rl_vi_char_search }, /* F */ - { ISFUNC, rl_vi_fetch_history }, /* G */ - { ISFUNC, (Function *)0x0 }, /* H */ - { ISFUNC, rl_vi_insert_beg }, /* I */ - { ISFUNC, (Function *)0x0 }, /* J */ - { ISFUNC, (Function *)0x0 }, /* K */ - { ISFUNC, (Function *)0x0 }, /* L */ - { ISFUNC, (Function *)0x0 }, /* M */ - { ISFUNC, rl_vi_search_again }, /* N */ - { ISFUNC, (Function *)0x0 }, /* O */ - { ISFUNC, rl_vi_put }, /* P */ - { ISFUNC, (Function *)0x0 }, /* Q */ - { ISFUNC, rl_vi_replace }, /* R */ - { ISFUNC, rl_vi_subst }, /* S */ - { ISFUNC, rl_vi_char_search }, /* T */ - { ISFUNC, rl_revert_line }, /* U */ - { ISFUNC, (Function *)0x0 }, /* V */ - { ISFUNC, rl_vi_next_word }, /* W */ - { ISFUNC, rl_rubout }, /* X */ - { ISFUNC, rl_vi_yank_to }, /* Y */ - { ISFUNC, (Function *)0x0 }, /* Z */ - - /* Some more punctuation. */ - { ISFUNC, (Function *)0x0 }, /* [ */ - { ISFUNC, rl_vi_complete }, /* \ */ - { ISFUNC, (Function *)0x0 }, /* ] */ - { ISFUNC, rl_vi_first_print }, /* ^ */ - { ISFUNC, rl_vi_yank_arg }, /* _ */ - { ISFUNC, (Function *)0x0 }, /* ` */ - - /* Lowercase alphabet. */ - { ISFUNC, rl_vi_append_mode }, /* a */ - { ISFUNC, rl_vi_prev_word }, /* b */ - { ISFUNC, rl_vi_change_to }, /* c */ - { ISFUNC, rl_vi_delete_to }, /* d */ - { ISFUNC, rl_vi_end_word }, /* e */ - { ISFUNC, rl_vi_char_search }, /* f */ - { ISFUNC, (Function *)0x0 }, /* g */ - { ISFUNC, rl_backward }, /* h */ - { ISFUNC, rl_vi_insertion_mode }, /* i */ - { ISFUNC, rl_get_next_history }, /* j */ - { ISFUNC, rl_get_previous_history }, /* k */ - { ISFUNC, rl_forward }, /* l */ - { ISFUNC, (Function *)0x0 }, /* m */ - { ISFUNC, rl_vi_search_again }, /* n */ - { ISFUNC, (Function *)0x0 }, /* o */ - { ISFUNC, rl_vi_put }, /* p */ - { ISFUNC, (Function *)0x0 }, /* q */ - { ISFUNC, rl_vi_change_char }, /* r */ - { ISFUNC, rl_vi_subst }, /* s */ - { ISFUNC, rl_vi_char_search }, /* t */ - { ISFUNC, rl_undo_command }, /* u */ - { ISFUNC, (Function *)0x0 }, /* v */ - { ISFUNC, rl_vi_next_word }, /* w */ - { ISFUNC, rl_vi_delete }, /* x */ - { ISFUNC, rl_vi_yank_to }, /* y */ - { ISFUNC, (Function *)0x0 }, /* z */ - - /* Final punctuation. */ - { ISFUNC, (Function *)0x0 }, /* { */ - { ISFUNC, rl_vi_column }, /* | */ - { ISFUNC, (Function *)0x0 }, /* } */ - { ISFUNC, rl_vi_change_case }, /* ~ */ - { ISFUNC, rl_backward } /* RUBOUT */ -}; - - -KEYMAP_ENTRY_ARRAY vi_insertion_keymap = { - - /* The regular control keys come first. */ - { ISFUNC, (Function *)0x0 }, /* Control-@ */ - { ISFUNC, rl_insert }, /* Control-a */ - { ISFUNC, rl_insert }, /* Control-b */ - { ISFUNC, rl_insert }, /* Control-c */ - { ISFUNC, rl_vi_eof_maybe }, /* Control-d */ - { ISFUNC, rl_insert }, /* Control-e */ - { ISFUNC, rl_insert }, /* Control-f */ - { ISFUNC, rl_insert }, /* Control-g */ - { ISFUNC, rl_rubout }, /* Control-h */ - { ISFUNC, rl_complete }, /* Control-i */ - { ISFUNC, rl_newline }, /* Control-j */ - { ISFUNC, rl_insert }, /* Control-k */ - { ISFUNC, rl_insert }, /* Control-l */ - { ISFUNC, rl_newline }, /* Control-m */ - { ISFUNC, rl_insert }, /* Control-n */ - { ISFUNC, rl_insert }, /* Control-o */ - { ISFUNC, rl_insert }, /* Control-p */ - { ISFUNC, rl_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 */ - { ISFUNC, rl_insert }, /* Control-x */ - { ISFUNC, rl_yank }, /* Control-y */ - { ISFUNC, rl_insert }, /* Control-z */ - - { ISFUNC, rl_vi_movement_mode }, /* Control-[ */ - { ISFUNC, rl_insert }, /* Control-\ */ - { ISFUNC, rl_insert }, /* Control-] */ - { ISFUNC, rl_insert }, /* 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 */ -}; - -KEYMAP_ENTRY_ARRAY vi_escape_keymap = { - - /* The regular control keys come first. */ - { ISFUNC, (Function *)0x0 }, /* Control-@ */ - { ISFUNC, (Function *)0x0 }, /* Control-a */ - { ISFUNC, (Function *)0x0 }, /* Control-b */ - { ISFUNC, (Function *)0x0 }, /* Control-c */ - { ISFUNC, (Function *)0x0 }, /* Control-d */ - { ISFUNC, (Function *)0x0 }, /* Control-e */ - { ISFUNC, (Function *)0x0 }, /* Control-f */ - { ISFUNC, (Function *)0x0 }, /* Control-g */ - { ISFUNC, (Function *)0x0 }, /* Control-h */ - { ISFUNC, rl_tab_insert}, /* Control-i */ - { ISFUNC, rl_emacs_editing_mode}, /* Control-j */ - { ISFUNC, rl_kill_line }, /* Control-k */ - { ISFUNC, (Function *)0x0 }, /* Control-l */ - { ISFUNC, rl_emacs_editing_mode}, /* Control-m */ - { ISFUNC, (Function *)0x0 }, /* Control-n */ - { ISFUNC, (Function *)0x0 }, /* Control-o */ - { ISFUNC, (Function *)0x0 }, /* Control-p */ - { ISFUNC, (Function *)0x0 }, /* Control-q */ - { ISFUNC, (Function *)0x0 }, /* Control-r */ - { ISFUNC, (Function *)0x0 }, /* Control-s */ - { ISFUNC, (Function *)0x0 }, /* Control-t */ - { ISFUNC, (Function *)0x0 }, /* Control-u */ - { ISFUNC, (Function *)0x0 }, /* Control-v */ - { ISFUNC, (Function *)0x0 }, /* Control-w */ - { ISFUNC, (Function *)0x0 }, /* Control-x */ - { ISFUNC, (Function *)0x0 }, /* Control-y */ - { ISFUNC, (Function *)0x0 }, /* Control-z */ - - { ISFUNC, rl_vi_movement_mode }, /* Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Control-] */ - { ISFUNC, (Function *)0x0 }, /* Control-^ */ - { ISFUNC, rl_undo_command }, /* Control-_ */ - - /* The start of printing characters. */ - { ISFUNC, (Function *)0x0 }, /* SPACE */ - { ISFUNC, (Function *)0x0 }, /* ! */ - { ISFUNC, (Function *)0x0 }, /* " */ - { ISFUNC, (Function *)0x0 }, /* # */ - { ISFUNC, (Function *)0x0 }, /* $ */ - { ISFUNC, (Function *)0x0 }, /* % */ - { ISFUNC, (Function *)0x0 }, /* & */ - { ISFUNC, (Function *)0x0 }, /* ' */ - { ISFUNC, (Function *)0x0 }, /* ( */ - { ISFUNC, (Function *)0x0 }, /* ) */ - { ISFUNC, (Function *)0x0 }, /* * */ - { ISFUNC, (Function *)0x0 }, /* + */ - { ISFUNC, (Function *)0x0 }, /* , */ - { ISFUNC, (Function *)0x0 }, /* - */ - { ISFUNC, (Function *)0x0 }, /* . */ - { ISFUNC, (Function *)0x0 }, /* / */ - - /* Regular digits. */ - { ISFUNC, rl_vi_arg_digit }, /* 0 */ - { ISFUNC, rl_vi_arg_digit }, /* 1 */ - { ISFUNC, rl_vi_arg_digit }, /* 2 */ - { ISFUNC, rl_vi_arg_digit }, /* 3 */ - { ISFUNC, rl_vi_arg_digit }, /* 4 */ - { ISFUNC, rl_vi_arg_digit }, /* 5 */ - { ISFUNC, rl_vi_arg_digit }, /* 6 */ - { ISFUNC, rl_vi_arg_digit }, /* 7 */ - { ISFUNC, rl_vi_arg_digit }, /* 8 */ - { ISFUNC, rl_vi_arg_digit }, /* 9 */ - - /* A little more punctuation. */ - { ISFUNC, (Function *)0x0 }, /* : */ - { ISFUNC, (Function *)0x0 }, /* ; */ - { ISFUNC, (Function *)0x0 }, /* < */ - { ISFUNC, (Function *)0x0 }, /* = */ - { ISFUNC, (Function *)0x0 }, /* > */ - { ISFUNC, (Function *)0x0 }, /* ? */ - { ISFUNC, (Function *)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, (Function *)0x0 }, /* [ */ - { ISFUNC, (Function *)0x0 }, /* \ */ - { ISFUNC, (Function *)0x0 }, /* ] */ - { ISFUNC, (Function *)0x0 }, /* ^ */ - { ISFUNC, (Function *)0x0 }, /* _ */ - { ISFUNC, (Function *)0x0 }, /* ` */ - - /* Lowercase alphabet. */ - { ISFUNC, (Function *)0x0 }, /* a */ - { ISFUNC, (Function *)0x0 }, /* b */ - { ISFUNC, (Function *)0x0 }, /* c */ - { ISFUNC, (Function *)0x0 }, /* d */ - { ISFUNC, (Function *)0x0 }, /* e */ - { ISFUNC, (Function *)0x0 }, /* f */ - { ISFUNC, (Function *)0x0 }, /* g */ - { ISFUNC, (Function *)0x0 }, /* h */ - { ISFUNC, (Function *)0x0 }, /* i */ - { ISFUNC, (Function *)0x0 }, /* j */ - { ISFUNC, (Function *)0x0 }, /* k */ - { ISFUNC, (Function *)0x0 }, /* l */ - { ISFUNC, (Function *)0x0 }, /* m */ - { ISFUNC, (Function *)0x0 }, /* n */ - { ISFUNC, (Function *)0x0 }, /* o */ - { ISFUNC, (Function *)0x0 }, /* p */ - { ISFUNC, (Function *)0x0 }, /* q */ - { ISFUNC, (Function *)0x0 }, /* r */ - { ISFUNC, (Function *)0x0 }, /* s */ - { ISFUNC, (Function *)0x0 }, /* t */ - { ISFUNC, (Function *)0x0 }, /* u */ - { ISFUNC, (Function *)0x0 }, /* v */ - { ISFUNC, (Function *)0x0 }, /* w */ - { ISFUNC, (Function *)0x0 }, /* x */ - { ISFUNC, (Function *)0x0 }, /* y */ - { ISFUNC, (Function *)0x0 }, /* z */ - - /* Final punctuation. */ - { ISFUNC, (Function *)0x0 }, /* { */ - { ISFUNC, (Function *)0x0 }, /* | */ - { ISFUNC, (Function *)0x0 }, /* } */ - { ISFUNC, (Function *)0x0 }, /* ~ */ - { ISFUNC, rl_backward_kill_word } /* RUBOUT */ -}; diff --git a/readline/vi_mode.c b/readline/vi_mode.c deleted file mode 100644 index bdc8107..0000000 --- a/readline/vi_mode.c +++ /dev/null @@ -1,1223 +0,0 @@ -/* vi_mode.c -- A vi emulation mode for Bash. - Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */ - -/* Copyright (C) 1988, 1991 Free Software Foundation, Inc. - - This file is part of the GNU 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 1, 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, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* **************************************************************** */ -/* */ -/* VI Emulation Mode */ -/* */ -/* **************************************************************** */ -#if defined (VI_MODE) - -#include <stdio.h> - -#if defined (__GNUC__) -# define alloca __builtin_alloca -#else -# if defined (sparc) || defined (HAVE_ALLOCA_H) -# include <alloca.h> -# endif -#endif - -/* Some standard library routines. */ -#include "readline.h" -#include "history.h" - -#ifndef digit -#define digit(c) ((c) >= '0' && (c) <= '9') -#endif - -#ifndef isletter -#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z')) -#endif - -#ifndef digit_value -#define digit_value(c) ((c) - '0') -#endif - -#ifndef member -#define member(c, s) ((c) ? index ((s), (c)) : 0) -#endif - -#ifndef isident -#define isident(c) ((isletter(c) || digit(c) || c == '_')) -#endif - -#ifndef exchange -#define exchange(x, y) {int temp = x; x = y; y = temp;} -#endif - -/* Variables imported from readline.c */ -extern int rl_point, rl_end, rl_mark, rl_done; -extern FILE *rl_instream; -extern int rl_line_buffer_len, rl_explicit_arg, rl_numeric_arg; -extern Keymap keymap; -extern char *rl_prompt; -extern char *rl_line_buffer; -extern int rl_arg_sign; - -extern char *xmalloc (), *xrealloc (); -extern void rl_extend_line_buffer (); - -/* Last string searched for from `/' or `?'. */ -static char *vi_last_search = (char *)NULL; -static int vi_histpos; - -/* Non-zero means enter insertion mode. */ -int vi_doing_insert = 0; - -/* String inserted into the line by rl_vi_comment (). */ -char *rl_vi_comment_begin = (char *)NULL; - -/* *** UNCLEAN *** */ -/* Command keys which do movement for xxx_to commands. */ -static char *vi_motion = " hl^$0ftFt;,%wbeWBE|"; - -/* Keymap used for vi replace characters. Created dynamically since - rarely used. */ -static Keymap vi_replace_map = (Keymap)NULL; - -/* The number of characters inserted in the last replace operation. */ -static int vi_replace_count = 0; - -/* Yank the nth arg from the previous line into this line at point. */ -rl_vi_yank_arg (count) - int count; -{ - /* Readline thinks that the first word on a line is the 0th, while vi - thinks the first word on a line is the 1st. Compensate. */ - if (rl_explicit_arg) - rl_yank_nth_arg (count - 1, 0); - else - rl_yank_nth_arg ('$', 0); -} - -/* With an argument, move back that many history lines, else move to the - beginning of history. */ -rl_vi_fetch_history (count, c) - int count, c; -{ - extern int rl_explicit_arg; - int current = where_history (); - - /* Giving an argument of n means we want the nth command in the history - file. The command number is interpreted the same way that the bash - `history' command does it -- that is, giving an argument count of 450 - to this command would get the command listed as number 450 in the - output of `history'. */ - if (rl_explicit_arg) - { - int wanted = history_base + current - count; - if (wanted <= 0) - rl_beginning_of_history (0, 0); - else - rl_get_previous_history (wanted); - } - else - rl_beginning_of_history (count, 0); -} - -/* Search again for the last thing searched for. */ -rl_vi_search_again (ignore, key) - int ignore, key; -{ - switch (key) - { - case 'n': - rl_vi_dosearch (vi_last_search, -1); - break; - - case 'N': - rl_vi_dosearch (vi_last_search, 1); - break; - } -} - -/* Do a vi style search. */ -rl_vi_search (count, key) - int count, key; -{ - int dir, c, save_pos; - char *p; - - switch (key) - { - case '?': - dir = 1; - break; - - case '/': - dir = -1; - break; - - default: - ding (); - return; - } - - vi_histpos = where_history (); - maybe_save_line (); - save_pos = rl_point; - - /* Reuse the line input buffer to read the search string. */ - rl_line_buffer[0] = 0; - rl_end = rl_point = 0; - p = (char *)alloca (2 + (rl_prompt ? strlen (rl_prompt) : 0)); - - sprintf (p, "%s%c", rl_prompt ? rl_prompt : "", key); - - rl_message (p, 0, 0); - - while (c = rl_read_key ()) - { - switch (c) - { - case CTRL('H'): - case RUBOUT: - if (rl_point == 0) - { - maybe_unsave_line (); - rl_clear_message (); - rl_point = save_pos; - return; - } - - case CTRL('W'): - case CTRL('U'): - rl_dispatch (c, keymap); - break; - - case ESC: - case RETURN: - case NEWLINE: - goto dosearch; - break; - - case CTRL('C'): - maybe_unsave_line (); - rl_clear_message (); - rl_point = 0; - ding (); - return; - - default: - rl_insert (1, c); - break; - } - rl_redisplay (); - } - dosearch: - if (vi_last_search) - free (vi_last_search); - - vi_last_search = savestring (rl_line_buffer); - rl_vi_dosearch (rl_line_buffer, dir); -} - -/* 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. If the first character of STRING - is `^', the string must match a prefix of a history line, otherwise - a full substring match is performed. */ -static int -vi_history_search_pos (string, dir, pos) - char *string; - int dir, pos; -{ - int ret, old = where_history (); - - history_set_pos (pos); - - if (*string == '^') - ret = history_search_prefix (string + 1, dir); - else - ret = history_search (string, dir); - - if (ret == -1) - { - history_set_pos (old); - return (-1); - } - - ret = where_history (); - history_set_pos (old); - return ret; -} - -rl_vi_dosearch (string, dir) - char *string; - int dir; -{ - int old, save = vi_histpos; - HIST_ENTRY *h; - - if (string == 0 || *string == 0 || vi_histpos < 0) - { - ding (); - return; - } - - if ((save = vi_history_search_pos (string, dir, vi_histpos + dir)) == -1) - { - maybe_unsave_line (); - rl_clear_message (); - rl_point = 0; - ding (); - return; - } - - vi_histpos = save; - - old = where_history (); - history_set_pos (vi_histpos); - h = current_history (); - history_set_pos (old); - - { - int line_len = strlen (h->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - strcpy (rl_line_buffer, h->line); - } - - rl_undo_list = (UNDO_LIST *)h->data; - rl_end = strlen (rl_line_buffer); - rl_point = 0; - rl_clear_message (); -} - -/* Completion, from vi's point of view. */ -rl_vi_complete (ignore, key) - int ignore, key; -{ - if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point]))) - { - if (!whitespace (rl_line_buffer[rl_point + 1])) - rl_vi_end_word (1, 'E'); - rl_point++; - } - - if (key == '*') - rl_complete_internal ('*'); /* Expansion and replacement. */ - else if (key == '=') - rl_complete_internal ('?'); /* List possible completions. */ - else if (key == '\\') - rl_complete_internal (TAB); /* Standard Readline completion. */ - else - rl_complete (0, key); -} - -/* Previous word in vi mode. */ -rl_vi_prev_word (count, key) - int count, key; -{ - if (count < 0) - { - rl_vi_next_word (-count, key); - return; - } - - if (rl_point == 0) - { - ding (); - return; - } - - if (uppercase_p (key)) - rl_vi_bWord (count); - else - rl_vi_bword (count); -} - -/* Next word in vi mode. */ -rl_vi_next_word (count, key) - int count; -{ - if (count < 0) - { - rl_vi_prev_word (-count, key); - return; - } - - if (rl_point >= (rl_end - 1)) - { - ding (); - return; - } - - if (uppercase_p (key)) - rl_vi_fWord (count); - else - rl_vi_fword (count); -} - -/* Move to the end of the ?next? word. */ -rl_vi_end_word (count, key) - int count, key; -{ - if (count < 0) - { - ding (); - return; - } - - if (uppercase_p (key)) - rl_vi_eWord (count); - else - rl_vi_eword (count); -} - -/* Move forward a word the way that 'W' does. */ -rl_vi_fWord (count) - int count; -{ - while (count-- && rl_point < (rl_end - 1)) - { - /* Skip until whitespace. */ - while (!whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end) - rl_point++; - - /* Now skip whitespace. */ - while (whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end) - rl_point++; - } -} - -rl_vi_bWord (count) - int count; -{ - while (count-- && rl_point > 0) - { - /* If we are at the start of a word, move back to whitespace so - we will go back to the start of the previous word. */ - if (!whitespace (rl_line_buffer[rl_point]) && - whitespace (rl_line_buffer[rl_point - 1])) - rl_point--; - - while (rl_point > 0 && whitespace (rl_line_buffer[rl_point])) - rl_point--; - - if (rl_point > 0) - { - while (--rl_point >= 0 && !whitespace (rl_line_buffer[rl_point])); - rl_point++; - } - } -} - -rl_vi_eWord (count) - int count; -{ - while (count-- && rl_point < (rl_end - 1)) - { - if (!whitespace (rl_line_buffer[rl_point])) - rl_point++; - - /* Move to the next non-whitespace character (to the start of the - next word). */ - while (++rl_point < rl_end && whitespace (rl_line_buffer[rl_point])); - - if (rl_point && rl_point < rl_end) - { - /* Skip whitespace. */ - while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) - rl_point++; - - /* Skip until whitespace. */ - while (rl_point < rl_end && !whitespace (rl_line_buffer[rl_point])) - rl_point++; - - /* Move back to the last character of the word. */ - rl_point--; - } - } -} - -rl_vi_fword (count) - int count; -{ - while (count-- && rl_point < (rl_end - 1)) - { - /* Move to white space (really non-identifer). */ - if (isident (rl_line_buffer[rl_point])) - { - while (isident (rl_line_buffer[rl_point]) && rl_point < rl_end) - rl_point++; - } - else /* if (!whitespace (rl_line_buffer[rl_point])) */ - { - while (!isident (rl_line_buffer[rl_point]) && - !whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end) - rl_point++; - } - - /* Move past whitespace. */ - while (whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end) - rl_point++; - } -} - -rl_vi_bword (count) - int count; -{ - while (count-- && rl_point > 0) - { - int last_is_ident; - - /* If we are at the start of a word, move back to whitespace - so we will go back to the start of the previous word. */ - if (!whitespace (rl_line_buffer[rl_point]) && - whitespace (rl_line_buffer[rl_point - 1])) - rl_point--; - - /* If this character and the previous character are `opposite', move - back so we don't get messed up by the rl_point++ down there in - the while loop. Without this code, words like `l;' screw up the - function. */ - last_is_ident = isident (rl_line_buffer[rl_point - 1]); - if ((isident (rl_line_buffer[rl_point]) && !last_is_ident) || - (!isident (rl_line_buffer[rl_point]) && last_is_ident)) - rl_point--; - - while (rl_point > 0 && whitespace (rl_line_buffer[rl_point])) - rl_point--; - - if (rl_point > 0) - { - if (isident (rl_line_buffer[rl_point])) - while (--rl_point >= 0 && isident (rl_line_buffer[rl_point])); - else - while (--rl_point >= 0 && !isident (rl_line_buffer[rl_point]) && - !whitespace (rl_line_buffer[rl_point])); - rl_point++; - } - } -} - -rl_vi_eword (count) - int count; -{ - while (count-- && rl_point < rl_end - 1) - { - if (!whitespace (rl_line_buffer[rl_point])) - rl_point++; - - while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) - rl_point++; - - if (rl_point < rl_end) - { - if (isident (rl_line_buffer[rl_point])) - while (++rl_point < rl_end && isident (rl_line_buffer[rl_point])); - else - while (++rl_point < rl_end && !isident (rl_line_buffer[rl_point]) - && !whitespace (rl_line_buffer[rl_point])); - } - rl_point--; - } -} - -rl_vi_insert_beg () -{ - rl_beg_of_line (); - rl_vi_insertion_mode (); - return 0; -} - -rl_vi_append_mode () -{ - if (rl_point < rl_end) - rl_point += 1; - rl_vi_insertion_mode (); - return 0; -} - -rl_vi_append_eol () -{ - rl_end_of_line (); - rl_vi_append_mode (); - return 0; -} - -/* What to do in the case of C-d. */ -rl_vi_eof_maybe (count, c) - int count, c; -{ - rl_newline (1, '\n'); -} - -/* Insertion mode stuff. */ - -/* Switching from one mode to the other really just involves - switching keymaps. */ -rl_vi_insertion_mode () -{ - keymap = vi_insertion_keymap; -} - -rl_vi_movement_mode () -{ - if (rl_point > 0) - rl_backward (1); - - keymap = vi_movement_keymap; - vi_done_inserting (); -} - -vi_done_inserting () -{ - if (vi_doing_insert) - { - rl_end_undo_group (); - vi_doing_insert = 0; - } -} - -rl_vi_arg_digit (count, c) - int count, c; -{ - if (c == '0' && rl_numeric_arg == 1 && !rl_explicit_arg) - rl_beg_of_line (); - else - rl_digit_argument (count, c); -} - -rl_vi_change_case (count, ignore) - int count, ignore; -{ - char c = 0; - - /* Don't try this on an empty line. */ - if (rl_point >= rl_end) - return; - - while (count-- && rl_point < rl_end) - { - if (uppercase_p (rl_line_buffer[rl_point])) - c = to_lower (rl_line_buffer[rl_point]); - else if (lowercase_p (rl_line_buffer[rl_point])) - c = to_upper (rl_line_buffer[rl_point]); - - /* Vi is kind of strange here. */ - if (c) - { - rl_begin_undo_group (); - rl_delete (1, c); - rl_insert (1, c); - rl_end_undo_group (); - rl_vi_check (); - } - else - rl_forward (1); - } -} - -rl_vi_put (count, key) - int count, key; -{ - if (!uppercase_p (key) && (rl_point + 1 <= rl_end)) - rl_point++; - - rl_yank (); - rl_backward (1); -} - -rl_vi_check () -{ - if (rl_point && rl_point == rl_end) - rl_point--; -} - -rl_vi_column (count) -{ - if (count > rl_end) - rl_end_of_line (); - else - rl_point = count - 1; -} - -int -rl_vi_domove (key, nextkey) - int key, *nextkey; -{ - int c, save; - int old_end, added_blank; - - added_blank = 0; - - rl_mark = rl_point; - c = rl_read_key (); - *nextkey = c; - - if (!member (c, vi_motion)) - { - if (digit (c)) - { - save = rl_numeric_arg; - rl_numeric_arg = digit_value (c); - rl_digit_loop1 (); - rl_numeric_arg *= save; - c = rl_read_key (); /* real command */ - *nextkey = c; - } - else if ((key == 'd' && c == 'd') || - (key == 'y' && c == 'y') || - (key == 'c' && c == 'c')) - { - rl_mark = rl_end; - rl_beg_of_line (); - return (0); - } - else - return (-1); - } - - /* Append a blank character temporarily so that the motion routines - work right at the end of the line. */ - old_end = rl_end; - rl_line_buffer[rl_end++] = ' '; /* This looks pretty bogus to me??? */ - rl_line_buffer[rl_end] = '\0'; - added_blank++; - - rl_dispatch (c, keymap); - - /* Remove the blank that we added. */ - rl_end = old_end; - rl_line_buffer[rl_end] = '\0'; - if (rl_point > rl_end) - rl_point = rl_end - 1; - - /* No change in position means the command failed. */ - if (rl_mark == rl_point) - return (-1); - - /* rl_vi_f[wW]ord () leaves the cursor on the first character of the next - word. If we are not at the end of the line, and we are on a - non-whitespace character, move back one (presumably to whitespace). */ - if ((c == 'w' || c == 'W') && (rl_point < rl_end) && - !whitespace (rl_line_buffer[rl_point])) - rl_point--; - - /* If cw or cW, back up to the end of a word, so the behaviour of ce - or cE is the actual result. Brute-force, no subtlety. Do the same - thing for dw or dW. */ - if (key == 'c' && (to_upper (c) == 'W')) - { - while (rl_point && whitespace (rl_line_buffer[rl_point])) - rl_point--; - } - - if (rl_mark < rl_point) - exchange (rl_point, rl_mark); - - return (0); -} - -/* A simplified loop for vi. Don't dispatch key at end. - Don't recognize minus sign? */ -rl_digit_loop1 () -{ - int key, c; - - while (1) - { - rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg, 0); - key = c = rl_read_key (); - - if (keymap[c].type == ISFUNC && - keymap[c].function == rl_universal_argument) - { - rl_numeric_arg *= 4; - continue; - } - - c = UNMETA (c); - if (numeric (c)) - { - if (rl_explicit_arg) - rl_numeric_arg = (rl_numeric_arg * 10) + digit_value (c); - else - rl_numeric_arg = digit_value (c); - rl_explicit_arg = 1; - } - else - { - rl_clear_message (); - rl_stuff_char (key); - break; - } - } -} - -rl_vi_delete_to (count, key) - int count, key; -{ - int c; - - if (uppercase_p (key)) - rl_stuff_char ('$'); - - if (rl_vi_domove (key, &c)) - { - ding (); - return; - } - - if ((c != 'l') && (c != '|') && (c != 'h') && rl_mark < rl_end) - rl_mark++; - - rl_kill_text (rl_point, rl_mark); -} - -rl_vi_change_to (count, key) - int count, key; -{ - int c; - - if (uppercase_p (key)) - rl_stuff_char ('$'); - - if (rl_vi_domove (key, &c)) - { - ding (); - return; - } - - if ((c != 'l') && (c != '|') && (c != 'h') && rl_mark < rl_end) - rl_mark++; - - rl_begin_undo_group (); - vi_doing_insert = 1; - rl_kill_text (rl_point, rl_mark); - rl_vi_insertion_mode (); -} - -rl_vi_yank_to (count, key) - int count, key; -{ - int c, save = rl_point; - - if (uppercase_p (key)) - rl_stuff_char ('$'); - - if (rl_vi_domove (key, &c)) - { - ding (); - return; - } - - if ((c != 'l') && (c != '|') && (c != 'h') && rl_mark < rl_end) - rl_mark++; - - rl_begin_undo_group (); - rl_kill_text (rl_point, rl_mark); - rl_end_undo_group (); - rl_do_undo (); - rl_point = save; -} - -rl_vi_delete (count) -{ - int end; - - if (rl_end == 0) - { - ding (); - return; - } - - end = rl_point + count; - - if (end >= rl_end) - end = rl_end; - - rl_kill_text (rl_point, end); - - if (rl_point > 0 && rl_point == rl_end) - rl_backward (1); -} - -/* Turn the current line into a comment in shell history. - A K*rn shell style function. */ -rl_vi_comment () -{ - rl_beg_of_line (); - - if (rl_vi_comment_begin != (char *)NULL) - rl_insert_text (rl_vi_comment_begin); - else - rl_insert_text (": "); /* Default. */ - - rl_redisplay (); - rl_newline (1, '\010'); -} - -rl_vi_first_print () -{ - rl_back_to_indent (); -} - -rl_back_to_indent (ignore1, ignore2) - int ignore1, ignore2; -{ - rl_beg_of_line (); - while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) - rl_point++; -} - -/* 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 */ - -rl_vi_char_search (count, key) - int count, key; -{ - static char target; - static int orig_dir, dir; - int pos; - - if (key == ';' || key == ',') - dir = (key == ';' ? orig_dir : -orig_dir); - else - { - target = rl_getc (rl_instream); - - switch (key) - { - case 't': - orig_dir = dir = FTO; - break; - - case 'T': - orig_dir = dir = BTO; - break; - - case 'f': - orig_dir = dir = FFIND; - break; - - case 'F': - orig_dir = dir = BFIND; - break; - } - } - - pos = rl_point; - - while (count--) - { - if (dir < 0) - { - if (pos == 0) - { - ding (); - return; - } - - pos--; - do - { - if (rl_line_buffer[pos] == target) - { - if (dir == BTO) - rl_point = pos + 1; - else - rl_point = pos; - break; - } - } - while (pos--); - - if (pos < 0) - { - ding (); - return; - } - } - else - { /* dir > 0 */ - if (pos >= rl_end) - { - ding (); - return; - } - - pos++; - do - { - if (rl_line_buffer[pos] == target) - { - if (dir == FTO) - rl_point = pos - 1; - else - rl_point = pos; - break; - } - } - while (++pos < rl_end); - - if (pos >= (rl_end - 1)) - { - ding (); - return; - } - } - } -} - -/* Match brackets */ -rl_vi_match () -{ - int count = 1, brack, pos; - - pos = rl_point; - if ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0) - { - while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0 && - rl_point < rl_end - 1) - rl_forward (1); - - if (brack <= 0) - { - rl_point = pos; - ding (); - return; - } - } - - pos = rl_point; - - if (brack < 0) - { - while (count) - { - if (--pos >= 0) - { - int b = rl_vi_bracktype (rl_line_buffer[pos]); - if (b == -brack) - count--; - else if (b == brack) - count++; - } - else - { - ding (); - return; - } - } - } - else - { /* brack > 0 */ - while (count) - { - if (++pos < rl_end) - { - int b = rl_vi_bracktype (rl_line_buffer[pos]); - if (b == -brack) - count--; - else if (b == brack) - count++; - } - else - { - ding (); - return; - } - } - } - rl_point = pos; -} - -int -rl_vi_bracktype (c) - int c; -{ - switch (c) - { - case '(': return 1; - case ')': return -1; - case '[': return 2; - case ']': return -2; - case '{': return 3; - case '}': return -3; - default: return 0; - } -} - -rl_vi_change_char (count, key) - int count, key; -{ - int c; - - c = rl_getc (rl_instream); - - if (c == '\033' || c == CTRL ('C')) - return; - - while (count-- && rl_point < rl_end) - { - rl_begin_undo_group (); - - rl_delete (1, c); - rl_insert (1, c); - if (count == 0) - rl_backward (1); - - rl_end_undo_group (); - } -} - -rl_vi_subst (count, key) - int count, key; -{ - rl_begin_undo_group (); - vi_doing_insert = 1; - - if (uppercase_p (key)) - { - rl_beg_of_line (); - rl_kill_line (1); - } - else - rl_delete (count, key); - - rl_vi_insertion_mode (); -} - -rl_vi_overstrike (count, key) - int count, key; -{ - int i; - - if (vi_doing_insert == 0) - { - vi_doing_insert = 1; - rl_begin_undo_group (); - } - - for (i = 0; i < count; i++) - { - vi_replace_count++; - rl_begin_undo_group (); - - if (rl_point < rl_end) - { - rl_delete (1, key); - rl_insert (1, key); - } - else - rl_insert (1, key); - - rl_end_undo_group (); - } -} - -rl_vi_overstrike_delete (count) - int count; -{ - int i, s; - - for (i = 0; i < count; i++) - { - if (vi_replace_count == 0) - { - ding (); - break; - } - s = rl_point; - - if (rl_do_undo ()) - vi_replace_count--; - - if (rl_point == s) - rl_backward (1); - } - - if (vi_replace_count == 0 && vi_doing_insert) - { - rl_end_undo_group (); - rl_do_undo (); - vi_doing_insert = 0; - } -} - -rl_vi_replace (count, key) - int count, key; -{ - int i; - - vi_replace_count = 0; - - if (!vi_replace_map) - { - vi_replace_map = rl_make_bare_keymap (); - - for (i = ' '; i < 127; i++) - vi_replace_map[i].function = rl_vi_overstrike; - - vi_replace_map[RUBOUT].function = rl_vi_overstrike_delete; - vi_replace_map[ESC].function = rl_vi_movement_mode; - vi_replace_map[RETURN].function = rl_newline; - vi_replace_map[NEWLINE].function = rl_newline; - - /* If the normal vi insertion keymap has ^H bound to erase, do the - same here. Probably should remove the assignment to RUBOUT up - there, but I don't think it will make a difference in real life. */ - if (vi_insertion_keymap[CTRL ('H')].type == ISFUNC && - vi_insertion_keymap[CTRL ('H')].function == rl_rubout) - vi_replace_map[CTRL ('H')].function = rl_vi_overstrike_delete; - - } - keymap = vi_replace_map; -} - -/* - * Try to complete the word we are standing on or the word that ends with - * the previous character. A space matches everything. - * Word delimiters are space and ;. - */ -rl_vi_possible_completions() -{ - int save_pos = rl_point; - - if (!index (" ;", rl_line_buffer[rl_point])) - { - while (!index(" ;", rl_line_buffer[++rl_point])) - ; - } - else if (rl_line_buffer[rl_point-1] == ';') - { - ding (); - return (0); - } - - rl_possible_completions (); - rl_point = save_pos; - - return (0); -} - -#endif /* VI_MODE */ diff --git a/readline/xmalloc.c b/readline/xmalloc.c deleted file mode 100644 index 0ed49dd..0000000 --- a/readline/xmalloc.c +++ /dev/null @@ -1,76 +0,0 @@ -/* xmalloc.c -- safe versions of malloc and realloc */ - -/* Copyright (C) 1991 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if defined (ALREADY_HAVE_XMALLOC) -#else -#include <stdio.h> - -#if defined (HAVE_STDLIB_H) -# include <stdlib.h> -#endif /* HAVE_STDLIB_H */ - -static void memory_error_and_abort (); - -/* **************************************************************** */ -/* */ -/* Memory Allocation and Deallocation. */ -/* */ -/* **************************************************************** */ - -/* Return a pointer to free()able block of memory large enough - to hold BYTES number of bytes. If the memory cannot be allocated, - print an error message and abort. */ -char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort ("xmalloc"); - return (temp); -} - -char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)malloc (bytes); - else - temp = (char *)realloc (pointer, bytes); - - if (!temp) - memory_error_and_abort ("xrealloc"); - return (temp); -} - -static void -memory_error_and_abort (fname) - char *fname; -{ - fprintf (stderr, "%s: Out of virtual memory!\n", fname); - abort (); -} -#endif /* !ALREADY_HAVE_XMALLOC */ |