summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-05-09 20:36:08 +0000
committerache <ache@FreeBSD.org>1994-05-09 20:36:08 +0000
commit5ffff78a1ac63d71c5fd5b7b42f98b23104e8517 (patch)
tree7d4aef8f293a311c0fa8931aa76f7c175c67f392 /gnu
parent67b1642fa35ed0bcf8be79195874cd2b01e563e7 (diff)
downloadFreeBSD-src-5ffff78a1ac63d71c5fd5b7b42f98b23104e8517.zip
FreeBSD-src-5ffff78a1ac63d71c5fd5b7b42f98b23104e8517.tar.gz
Merge with much improved version from gdb4.11
Diffstat (limited to 'gnu')
-rw-r--r--gnu/lib/libreadline/COPYING368
-rw-r--r--gnu/lib/libreadline/ChangeLog381
-rw-r--r--gnu/lib/libreadline/Makefile6
-rw-r--r--gnu/lib/libreadline/README.FreeBSD2
-rw-r--r--gnu/lib/libreadline/doc/ChangeLog8
-rw-r--r--gnu/lib/libreadline/doc/hist.texinfo2
-rw-r--r--gnu/lib/libreadline/doc/inc-hist.texi155
-rw-r--r--gnu/lib/libreadline/doc/rlman.texinfo18
-rw-r--r--gnu/lib/libreadline/doc/rltech.texinfo30
-rw-r--r--gnu/lib/libreadline/doc/rluser.texinfo255
-rw-r--r--gnu/lib/libreadline/emacs_keymap.c28
-rw-r--r--gnu/lib/libreadline/examples/Inputrc58
-rw-r--r--gnu/lib/libreadline/examples/fileman.c53
-rw-r--r--gnu/lib/libreadline/funmap.c213
-rw-r--r--gnu/lib/libreadline/history.c145
-rw-r--r--gnu/lib/libreadline/keymaps.c41
-rw-r--r--gnu/lib/libreadline/readline.c1753
-rw-r--r--gnu/lib/libreadline/readline/history.h1
-rw-r--r--gnu/lib/libreadline/readline/readline.h93
-rw-r--r--gnu/lib/libreadline/sysdep.h37
-rw-r--r--gnu/lib/libreadline/vi_keymap.c34
-rw-r--r--gnu/lib/libreadline/vi_mode.c595
22 files changed, 3118 insertions, 1158 deletions
diff --git a/gnu/lib/libreadline/COPYING b/gnu/lib/libreadline/COPYING
index 1bb82d1..a43ea21 100644
--- a/gnu/lib/libreadline/COPYING
+++ b/gnu/lib/libreadline/COPYING
@@ -1,46 +1,40 @@
-
GNU GENERAL PUBLIC LICENSE
- Version 1, February 1989
+ Version 2, June 1991
- Copyright (C) 1989 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
+ Copyright (C) 1989, 1991 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
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. 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.
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
When we speak of free software, we are referring to freedom, not
-price. 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.
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
- For example, if you distribute copies of a such a program, whether
+ For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
-source code. And you must tell them their rights.
+source code. And you must show them these terms so they know their
+rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
@@ -53,122 +47,209 @@ want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- 0. This License 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.
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
- 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
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
- received the program in object code or executable form 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.
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these
-terms and conditions. You may not impose any further restrictions on the
-recipients' exercise of the rights granted herein.
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
- 7. The Free Software Foundation may publish revised and/or new versions
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
-Each version is given a distinguishing version number. If the Program
-specifies a version number of the license which applies to it and "any
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
-the license, you may choose any version ever published by the Free Software
+this 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
+ 10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
+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
@@ -176,7 +257,7 @@ of promoting the sharing and reuse of software generally.
NO WARRANTY
- 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
@@ -186,7 +267,7 @@ 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
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
@@ -201,22 +282,21 @@ POSSIBILITY OF SUCH DAMAGES.
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.
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
- To do so, attach the following notices to the program. It is safest to
-attach them to the start of each source file to most effectively convey
-the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
+ 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>
+ 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.
+ 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
@@ -232,26 +312,28 @@ 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 version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
-The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
+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:
+necessary. Here is 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.
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
-That's all there is to it!
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/gnu/lib/libreadline/ChangeLog b/gnu/lib/libreadline/ChangeLog
index 67c5df8..c238e0a 100644
--- a/gnu/lib/libreadline/ChangeLog
+++ b/gnu/lib/libreadline/ChangeLog
@@ -1,3 +1,384 @@
+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
diff --git a/gnu/lib/libreadline/Makefile b/gnu/lib/libreadline/Makefile
index f19a4e0..927ff75 100644
--- a/gnu/lib/libreadline/Makefile
+++ b/gnu/lib/libreadline/Makefile
@@ -1,9 +1,11 @@
-# $Id: Makefile,v 1.1.1.1 1994/05/09 15:59:08 ache Exp $
+# $Id: Makefile,v 1.1 1993/12/28 07:54:51 ache Exp $
SHLIB_MAJOR=1
SHLIB_MINOR=0
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/readline -DVOID_SIGHANDLER -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp
+CFLAGS+= -I${.CURDIR} -I${.CURDIR}/readline -DVOID_SIGHANDLER \
+ -DHAVE_UNISTD_H -DSTATIC_MALLOC \
+ -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp
LIB= readline
SRCS+= readline.c history.c funmap.c keymaps.c
diff --git a/gnu/lib/libreadline/README.FreeBSD b/gnu/lib/libreadline/README.FreeBSD
index 7c917b0..5defcc4 100644
--- a/gnu/lib/libreadline/README.FreeBSD
+++ b/gnu/lib/libreadline/README.FreeBSD
@@ -11,4 +11,6 @@ Workaround for this implemented via TIOCGWINSZ/TIOCSWINSZ
with same winsize structure: it does nothing expect polling
process from background. Look tcsh_hack.readme for details.
+Here is megred version with readline comes from gdb4.11
+
ache@astral.msk.su
diff --git a/gnu/lib/libreadline/doc/ChangeLog b/gnu/lib/libreadline/doc/ChangeLog
new file mode 100644
index 0000000..5f1f5061
--- /dev/null
+++ b/gnu/lib/libreadline/doc/ChangeLog
@@ -0,0 +1,8 @@
+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/gnu/lib/libreadline/doc/hist.texinfo b/gnu/lib/libreadline/doc/hist.texinfo
index d110374..6292738 100644
--- a/gnu/lib/libreadline/doc/hist.texinfo
+++ b/gnu/lib/libreadline/doc/hist.texinfo
@@ -3,7 +3,7 @@
@setfilename history.info
@settitle GNU Readline Library
@comment %**end of header (This is for running Texinfo on a region.)
-@synindex fn vr
+@synindex vr fn
@setchapternewpage odd
@ifinfo
diff --git a/gnu/lib/libreadline/doc/inc-hist.texi b/gnu/lib/libreadline/doc/inc-hist.texi
new file mode 100644
index 0000000..539e372
--- /dev/null
+++ b/gnu/lib/libreadline/doc/inc-hist.texi
@@ -0,0 +1,155 @@
+@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 that is similar
+to the history expansion in Csh. The following text describes the sytax
+that you use to manipulate the history information.
+
+History expansion takes place in two parts. The first is to determine
+which line from the previous history 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 previous history is called the
+@dfn{event}, and the portions of that line that are acted upon are
+called @dfn{words}. The line is broken into words in the same fashion
+that the Bash shell does, so that several English (or Unix) words
+surrounded by quotes are considered as 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 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 specification from the 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 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, so it really isn't a word designator, and doesn't
+belong in 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/gnu/lib/libreadline/doc/rlman.texinfo b/gnu/lib/libreadline/doc/rlman.texinfo
index 9ac246d..f2e7fb6 100644
--- a/gnu/lib/libreadline/doc/rlman.texinfo
+++ b/gnu/lib/libreadline/doc/rlman.texinfo
@@ -3,12 +3,12 @@
@setfilename readline.info
@settitle GNU Readline Library
@comment %**end of header (This is for running Texinfo on a region.)
-@synindex fn vr
+@synindex vr fn
@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
+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 Free Software Foundation, Inc.
@@ -44,7 +44,7 @@ by the Foundation.
@center April 1991
@page
-This document describes the GNU Readline Library, a utility for aiding
+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.
@@ -74,7 +74,7 @@ Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
@node Top
@top GNU Readline Library
-This document describes the GNU Readline Library, a utility for aiding
+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.
@@ -91,13 +91,13 @@ to provide a command line interface.
@include rltech.texinfo
@node Concept Index
-@appendix Concept Index
+@unnumbered Concept Index
@printindex cp
@node Function and Variable Index
-@appendix Function and Variable Index
-@printindex vr
-@contents
+@unnumbered Function and Variable Index
+@printindex fn
+@contents
@bye
diff --git a/gnu/lib/libreadline/doc/rltech.texinfo b/gnu/lib/libreadline/doc/rltech.texinfo
index f52288e..2048b7c 100644
--- a/gnu/lib/libreadline/doc/rltech.texinfo
+++ b/gnu/lib/libreadline/doc/rltech.texinfo
@@ -1,6 +1,5 @@
@comment %**start of header (This is for running Texinfo on a region.)
@setfilename rltech.info
-@synindex fn vr
@comment %**end of header (This is for running Texinfo on a region.)
@setchapternewpage odd
@@ -132,7 +131,7 @@ with @code{rl_bind_key ()}.
@findex rl_bind_key ()
@example
-@code{int rl_bind_key (int @var{key}, (int (*)())@var{function});}
+@code{int rl_bind_key (int @var{key}, int (*@var{function})());}
@end example
@code{rl_bind_key ()} takes 2 arguments; @var{key} is the character that
@@ -423,10 +422,10 @@ invert_case_line (count, key)
@section Custom Completers
Typically, a program that reads commands from the user has a way of
-disambiguating between commands and data. If your program is one of
-these, then it can provide completion for either commands, or data, or
-both commands and data. The following sections describe how your
-program and Readline cooperate to provide this service to end users.
+disambiguating commands and data. If your program is one of these, then
+it can provide completion for either commands, or data, or both commands
+and data. The following sections describe how your program and Readline
+cooperate to provide this service to end users.
@menu
* How Completing Works:: The logic used to do completion.
@@ -455,7 +454,7 @@ There are three major functions used to perform completion:
The user-interface function @code{rl_complete ()}. This function is
called interactively with the same calling conventions as other
functions in readline intended for interactive use; i.e. @var{count},
-and @code{invoking-key}. It isolates the word to be completed and calls
+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 or actually performs the
completion, depending on which behaviour is desired.
@@ -576,7 +575,7 @@ she wants to see them all. The default value is 100.
@defvar {char *rl_basic_word_break_characters}
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 Bash shell, i.e. " \t\n\"\\'`@@$><=".
+in the Bash shell, i.e. " \t\n\"\\'`@@$><=;|&@{(".
@end defvar
@defvar {char *rl_completer_word_break_characters}
@@ -603,12 +602,12 @@ within a completion entry generator function.
@defvar {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 pointers to @code{(char *)}
-known as @var{matches} in the code. The 1st element (@code{matches[0]})
-is the maximal substring that is common to all matches. This function
-can re-arrange the list of matches as required, but each deleted
-element of the array must be @code{free()}'d.
+completion is done, after all the matching names have been generated.
+It is passed a @code{NULL} terminated array of @code{(char *)} known as
+@var{matches} in the code. The 1st element (@code{matches[0]}) is the
+maximal substring that is common to all matches. This function can
+re-arrange the list of matches as required, but each deleted element of
+the array must be @code{free()}'d.
@end defvar
@node A Short Completion Example
@@ -868,6 +867,9 @@ static char syscom[1024];
com_list (arg)
char *arg;
@{
+ if (!arg)
+ arg = "*";
+
sprintf (syscom, "ls -FClg %s", arg);
system (syscom);
@}
diff --git a/gnu/lib/libreadline/doc/rluser.texinfo b/gnu/lib/libreadline/doc/rluser.texinfo
index ea20205..67fe64e 100644
--- a/gnu/lib/libreadline/doc/rluser.texinfo
+++ b/gnu/lib/libreadline/doc/rluser.texinfo
@@ -1,9 +1,3 @@
-@comment %**start of header (This is for running Texinfo on a region.)
-@setfilename rluser.info
-@synindex fn vr
-@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 feautres. It is to be an appendix to manuals for programs which
@@ -35,7 +29,7 @@ into another language, under the above conditions for modified versions.
@end ignore
@node Command Line Editing
-@chapter Command Line Editing
+@appendix Command Line Editing
This text describes GNU's command line editing interface.
@@ -48,7 +42,8 @@ This text describes GNU's command line editing interface.
@node Introduction and Notation
@section Introduction to Line Editing
-In this tex a the following notation is used to describe keystrokes.
+The following paragraphs describe the notation we use to represent
+keystrokes.
The text @key{C-k} is read as `Control-K' and describes the character
produced when the Control key is depressed and the @key{k} key is struck.
@@ -156,10 +151,6 @@ operate on characters while meta keystrokes operate on words.
@node Readline Killing Commands
@subsection Readline Killing Commands
-The act of @dfn{cutting} text means to delete the text from the line, and
-to save away the deleted text for later use, just as if you had cut the
-text out of the line with a pair of scissors. There is a
-
@dfn{Killing} text means to delete the text from the line, but to save
it away for later use, usually by @dfn{yanking} it back into the line.
If the description for a command says that it `kills' text, then you can
@@ -177,7 +168,8 @@ 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 fromthe cursor the start ofthe previous word, or if between words, to the start of the previous word.
+Kill from the cursor to 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
@@ -234,6 +226,9 @@ file is @file{~/.inputrc}.
When a program which uses the Readline library starts up, the
@file{~/.inputrc} file is read, and the keybindings are set.
+In addition, the @key{C-x C-r} command re-reads this init file, thus
+incorporating any changes that you might have made to it.
+
@menu
* Readline Init Syntax:: Syntax for the commands in @file{~/.inputrc}.
* Readline Vi Mode:: Switching to @code{vi} mode in Readline.
@@ -242,38 +237,99 @@ When a program which uses the Readline library starts up, the
@node Readline Init Syntax
@subsection Readline Init Syntax
-You can start up with a vi-like editing mode by placing
+There are only four constructs allowed in the @file{~/.inputrc}
+file:
+
+@table @asis
+@item Variable Settings
+You can change the state of a few variables in Readline. You do this by
+using the @code{set} command within the init file. Here is how you
+would specify that you wish to use Vi line editing commands:
@example
-@code{set editing-mode vi}
+set editing-mode vi
@end example
-in your @file{~/.inputrc} file.
+Right now, there are only a few variables which can be set; so few in
+fact, that we just iterate them here:
-You can have Readline use a single line for display, scrolling the input
-between the two edges of the screen by placing
-
-@example
-@code{set horizontal-scroll-mode On}
-@end example
+@table @code
-in your @file{~/.inputrc} file.
+@item editing-mode
+@vindex editing-mode
+The @code{editing-mode} variable controls which editing mode you are
+using. By default, GNU Readline starts up in Emacs editing mode, where
+the keystrokes are most similar to Emacs. This variable can either be
+set to @code{emacs} or @code{vi}.
+
+@item horizontal-scroll-mode
+@vindex horizontal-scroll-mode
+This variable can either be set to @code{On} or @code{Off}. Setting it
+to @code{On} means that the text of the lines that you edit will scroll
+horizontally on a single screen line when they are larger than the width
+of the screen, instead of wrapping onto a new screen line. By default,
+this variable is set to @code{Off}.
+
+@item mark-modified-lines
+@vindex mark-modified-lines
+This variable when set to @code{On}, says to display an asterisk
+(@samp{*}) at the starts of history lines which have been modified.
+This variable is off by default.
+
+@item prefer-visible-bell
+@vindex prefer-visible-bell
+If this variable is set to @code{On} it means to use a visible bell if
+one is available, rather than simply ringing the terminal bell. By
+default, the value is @code{Off}.
+@end table
+@item Key Bindings
The syntax for controlling keybindings in the @file{~/.inputrc} file is
simple. First you have to know the @i{name} of the command that you
-want to change. The following pages contain tables of the command name, the
-default keybinding, and a short description of what the command does.
+want to change. The following pages contain tables of the command name,
+the default keybinding, 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 @file{~/.inputrc} file. Here is an example:
+command on a line in the @file{~/.inputrc} 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
-# This is a comment line.
-Meta-Rubout: backward-kill-word
-Control-u: universal-argument
+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. Simply place the key sequence
+in double quotes. GNU Emacs style key escapes can be used, as in the
+following example:
+
+@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),
+@key{C-x C-r} is bound to the function @code{re-read-init-file}, and
+@key{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}.
+
+@end table
+@end table
+
@menu
* Commands For Moving:: Moving about the line.
* Commands For History:: Getting at previous lines.
@@ -286,159 +342,159 @@ Control-u: universal-argument
@node Commands For Moving
@subsubsection Commands For Moving
-@table @code
-@item beginning-of-line (C-a)
+@ftable @code
+@item beginning-of-line (@key{C-a})
Move to the start of the current line.
-@item end-of-line (C-e)
+@item end-of-line (@key{C-e})
Move to the end of the line.
-@item forward-char (C-f)
+@item forward-char (@key{C-f})
Move forward a character.
-@item backward-char (C-b)
+@item backward-char (@key{C-b})
Move back a character.
-@item forward-word (M-f)
+@item forward-word (@key{M-f})
Move forward to the end of the next word.
-@item backward-word (M-b)
+@item backward-word (@key{M-b})
Move back to the start of this, or the previous, word.
-@item clear-screen (C-l)
+@item clear-screen (@key{C-l})
Clear the screen leaving the current line at the top of the screen.
-@end table
+@end ftable
@node Commands For History
@subsubsection Commands For Manipulating The History
-@table @code
+@ftable @code
@item accept-line (Newline, Return)
Accept the line regardless of where the cursor is. If this line is
-non-empty, add it too the history list. If this line was a history
+non-empty, add it to the history list. If this line was a history
line, then restore the history line to its original state.
-@item previous-history (C-p)
+@item previous-history (@key{C-p})
Move `up' through the history list.
-@item next-history (C-n)
+@item next-history (@key{C-n})
Move `down' through the history list.
-@item beginning-of-history (M-<)
+@item beginning-of-history (@key{M-<})
Move to the first line in the history.
-@item end-of-history (M->)
+@item end-of-history (@key{M->})
Move to the end of the input history, i.e., the line you are entering!
-@item reverse-search-history (C-r)
+@item reverse-search-history (@key{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)
+@item forward-search-history (@key{C-s})
Search forward starting at the current line and moving `down' through
the the history as neccessary.
-@end table
+@end ftable
@node Commands For Text
@subsubsection Commands For Changing Text
-@table @code
-@item delete-char (C-d)
+@ftable @code
+@item delete-char (@key{C-d})
Delete the character under the cursor. If the cursor is at the
beginning of the line, and there are no characters in the line, and
-the last character typed was not C-d, then return EOF.
+the last character typed was not @key{C-d}, then return EOF.
@item backward-delete-char (Rubout)
Delete the character behind the cursor. A numeric arg says to kill
the characters instead of deleting them.
-@item quoted-insert (C-q, C-v)
+@item quoted-insert (@key{C-q}, @key{C-v})
Add the next character that you type to the line verbatim. This is
-how to insert things like C-q for example.
+how to insert things like @key{C-q} for example.
-@item tab-insert (M-TAB)
+@item tab-insert (@key{M-TAB})
Insert a tab character.
@item self-insert (a, b, A, 1, !, ...)
Insert yourself.
-@item transpose-chars (C-t)
+@item transpose-chars (@key{C-t})
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 args don't work.
-@item transpose-words (M-t)
+@item transpose-words (@key{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,
-do the previous word, but do not move point.
+@item upcase-word (@key{M-u})
+Uppercase all letters in the current (or following) word. With a
+negative argument, do the previous word, but do not move point.
-@item downcase-word (M-l)
-Lowercase the current (or following) word. With a negative argument,
-do the previous word, but do not move point.
+@item downcase-word (@key{M-l})
+Lowercase all letters in the current (or following) word. With a
+negative argument, do the previous word, but do not move point.
-@item capitalize-word (M-c)
-Uppercase the current (or following) word. With a negative argument,
-do the previous word, but do not move point.
+@item capitalize-word (@key{M-c})
+Uppercase the first letter in the current (or following) word. With a
+negative argument, do the previous word, but do not move point.
-@end table
+@end ftable
@node Commands For Killing
@subsubsection Killing And Yanking
-@table @code
+@ftable @code
-@item kill-line (C-k)
+@item kill-line (@key{C-k})
Kill the text from the current cursor position to the end of the line.
@item backward-kill-line ()
Kill backward to the beginning of the line. This is normally unbound.
-@item kill-word (M-d)
+@item kill-word (@key{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 backward-kill-word (M-DEL)
+@item backward-kill-word (@key{M-DEL})
Kill the word behind the cursor.
-@item unix-line-discard (C-u)
-Do what C-u used to do in Unix line input. We save the killed text on
+@item unix-line-discard (@key{C-u})
+Do what @key{C-u} used to do in Unix line input. We save the killed text on
the kill-ring, though.
-@item unix-word-rubout (C-w)
-Do what C-w used to do in Unix line input. The killed text is saved
+@item unix-word-rubout (@key{C-w})
+Do what @key{C-w} used to do in Unix line input. The killed text is saved
on the kill-ring. This is different than backward-kill-word because
the word boundaries differ.
-@item yank (C-y)
+@item yank (@key{C-y})
Yank the top of the kill ring into the buffer at point.
-@item yank-pop (M-y)
+@item yank-pop (@key{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 table
+@end ftable
@node Numeric Arguments
@subsubsection Specifying Numeric Arguments
-@table @code
+@ftable @code
-@item digit-argument (M-0, M-1, ... M--)
+@item digit-argument (@key{M-0}, @key{M-1}, ... @key{M--})
Add this digit to the argument already accumulating, or start a new
-argument. M-- starts a negative argument.
+argument. @key{M--} starts a negative argument.
@item universal-argument ()
-Do what C-u does in emacs. By default, this is not bound.
-@end table
+Do what @key{C-u} does in emacs. By default, this is not bound.
+@end ftable
@node Commands For Completion
@subsubsection Letting Readline Type For You
-@table @code
+@ftable @code
@item complete (TAB)
Attempt to do completion on the text before point. This is
implementation defined. Generally, if you are typing a filename
@@ -449,41 +505,54 @@ you can do variable name completion...
@item possible-completions (M-?)
List the possible completions of the text before point.
-@end table
+@end ftable
@node Miscellaneous Commands
@subsubsection Some Miscellaneous Commands
-@table @code
+@ftable @code
+
+@item re-read-init-file (@key{C-x} @key{C-r})
+Read in the contents of your @file{~/.inputrc} file, and incorporate
+any bindings found there.
-@item abort (C-g)
-Ding! Stops things.
+@item abort (@key{C-g})
+Stop running the current editing command.
-@item do-uppercase-version (M-a, M-b, ...)
+@ignore
+@c I have no idea what this means, and can't figure it out by
+@c experiment, and can't find it in the readline source.
+@c pesch@cygnus.com, 20may1993.
+@item do-uppercase-version (@key{M-a}, @key{M-b}, ...)
Run the command that is bound to your uppercase brother.
+@end ignore
@item prefix-meta (ESC)
-Make the next character that you type be metafied. This is for
-people without a meta key. @key{ESC-f} is equivalent to @key{M-f}.
+Make the next character that you type be metafied. This is for people
+without a meta key. Typing @key{ESC f} is equivalent to typing
+@key{M-f}.
-@item undo (C-_)
+@item undo (@key{C-_})
Incremental undo, separately remembered for each line.
-@item revert-line (M-r)
+@item revert-line (@key{M-r})
Undo all changes made to this line. This is like typing the `undo'
command enough times to get back to the beginning.
-@end table
+@end ftable
@node Readline Vi Mode
@subsection Readline Vi Mode
+@cindex @code{vi} style command editing
+@kindex toggle-editing-mode
While the Readline library does not have a full set of Vi editing
functions, it does contain enough to allow simple editing of the line.
In order to switch interactively between Emacs and Vi editing modes, use
-the command M-C-j (toggle-editing-mode).
+the command @key{M-C-j} (toggle-editing-mode).
When you enter a line in Vi mode, you are already placed in `insertion'
mode, as if you had typed an `i'. Pressing @key{ESC} switches you into
`edit' mode, where you can edit the text of the line with the standard
Vi movement keys, move to previous history lines with `k', and following
lines with `j', and so forth.
+
diff --git a/gnu/lib/libreadline/emacs_keymap.c b/gnu/lib/libreadline/emacs_keymap.c
index 0b07fb3..37f93de 100644
--- a/gnu/lib/libreadline/emacs_keymap.c
+++ b/gnu/lib/libreadline/emacs_keymap.c
@@ -1,29 +1,23 @@
/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1988, 1989, 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 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.
- 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.
+ 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"
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* An array of function pointers, one for each possible key.
If the type byte is ISKMAP, then the pointer is the address of
diff --git a/gnu/lib/libreadline/examples/Inputrc b/gnu/lib/libreadline/examples/Inputrc
new file mode 100644
index 0000000..db9510d
--- /dev/null
+++ b/gnu/lib/libreadline/examples/Inputrc
@@ -0,0 +1,58 @@
+# 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/gnu/lib/libreadline/examples/fileman.c b/gnu/lib/libreadline/examples/fileman.c
index 92f3942..0adc2a1 100644
--- a/gnu/lib/libreadline/examples/fileman.c
+++ b/gnu/lib/libreadline/examples/fileman.c
@@ -244,7 +244,14 @@ static char syscom[1024];
com_list (arg)
char *arg;
{
+ if (!arg)
+ arg = "*";
+
+#ifdef __GO32__
+ sprintf (syscom, "ls -lp %s", arg);
+#else
sprintf (syscom, "ls -FClg %s", arg);
+#endif
system (syscom);
}
@@ -390,3 +397,49 @@ valid_argument (caller, arg)
* compile-command: "cc -g -I../.. -L.. -o fileman fileman.c -lreadline -ltermcap"
* end:
*/
+
+#ifdef __GO32__
+/* **************************************************************** */
+/* */
+/* xmalloc and xrealloc () */
+/* */
+/* **************************************************************** */
+
+static void memory_error_and_abort ();
+
+char *
+xmalloc (bytes)
+ int bytes;
+{
+ char *temp = (char *)malloc (bytes);
+
+ if (!temp)
+ memory_error_and_abort ();
+ return (temp);
+}
+
+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, "xmalloc: Out of virtual memory!\n");
+ abort ();
+}
+#endif
diff --git a/gnu/lib/libreadline/funmap.c b/gnu/lib/libreadline/funmap.c
index 77fad75..d48d299 100644
--- a/gnu/lib/libreadline/funmap.c
+++ b/gnu/lib/libreadline/funmap.c
@@ -1,34 +1,33 @@
/* funmap.c -- attach names to functions. */
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1988, 1989, 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 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.
- 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.
+ 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. */
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
+/* #define STATIC_MALLOC */
+#if !defined (STATIC_MALLOC)
extern char *xmalloc (), *xrealloc ();
#else
static char *xmalloc (), *xrealloc ();
-#endif
+#endif /* STATIC_MALLOC */
-#ifndef BUFSIZ
+#include "sysdep.h"
#include <stdio.h>
-#endif /* BUFSIZ */
#include "readline.h"
@@ -36,94 +35,103 @@ 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 },
- { "redraw-current-line", rl_refresh_line},
- { "beginning-of-line", rl_beg_of_line },
{ "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 },
- { "accept-line", rl_newline },
+ { "forward-search-history", rl_forward_search_history },
+ { "forward-word", rl_forward_word },
{ "kill-line", rl_kill_line },
- { "clear-screen", rl_clear_screen },
+ { "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 },
- { "forward-search-history", rl_forward_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-pop", rl_yank_pop },
{ "yank-nth-arg", rl_yank_nth_arg },
- { "backward-delete-char", rl_rubout },
- { "backward-word", rl_backward_word },
- { "kill-word", rl_kill_word },
- { "forward-word", rl_forward_word },
- { "tab-insert", rl_tab_insert },
- { "backward-kill-word", rl_backward_kill_word },
- { "backward-kill-line", rl_backward_kill_line },
- { "transpose-words", rl_transpose_words },
- { "digit-argument", rl_digit_argument },
- { "complete", rl_complete },
- { "possible-completions", rl_possible_completions },
- { "do-lowercase-version", rl_do_lowercase_version },
- { "digit-argument", rl_digit_argument },
- { "universal-argument", rl_universal_argument },
- { "abort", rl_abort },
- { "undo", rl_undo_command },
- { "upcase-word", rl_upcase_word },
- { "downcase-word", rl_downcase_word },
- { "capitalize-word", rl_capitalize_word },
- { "revert-line", rl_revert_line },
- { "beginning-of-history", rl_beginning_of_history },
- { "end-of-history", rl_end_of_history },
- { "self-insert", rl_insert },
- { "start-kbd-macro", rl_start_kbd_macro },
- { "end-kbd-macro", rl_end_kbd_macro },
- { "re-read-init-file", rl_re_read_init_file },
-#ifdef VI_MODE
- { "vi-movement-mode", rl_vi_movement_mode },
- { "vi-insertion-mode", rl_vi_insertion_mode },
+ { "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-prev-word", rl_vi_prev_word },
- { "vi-next-word", rl_vi_next_word },
+ { "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-append-mode", rl_vi_append_mode },
- { "vi-put", rl_vi_put },
- { "vi-append-eol", rl_vi_append_eol },
- { "vi-insert-beg", rl_vi_insert_beg },
- { "vi-delete", rl_vi_delete },
- { "vi-comment", rl_vi_comment },
+ { "vi-eword", rl_vi_eword },
+ { "vi-fWord", rl_vi_fWord },
{ "vi-first-print", rl_vi_first_print },
{ "vi-fword", rl_vi_fword },
- { "vi-fWord", rl_vi_fWord },
- { "vi-bword", rl_vi_bword },
- { "vi-bWord", rl_vi_bWord },
- { "vi-eword", rl_vi_eword },
- { "vi-eWord", rl_vi_eWord },
- { "vi-end-word", rl_vi_end_word },
- { "vi-change-case", rl_vi_change_case },
+ { "vi-insert-beg", rl_vi_insert_beg },
+ { "vi-insertion-mode", rl_vi_insertion_mode },
{ "vi-match", rl_vi_match },
- { "vi-bracktype", rl_vi_bracktype },
- { "vi-change-char", rl_vi_change_char },
- { "vi-yank-arg", rl_vi_yank_arg },
- { "vi-search", rl_vi_search },
- { "vi-search-again", rl_vi_search_again },
- { "vi-dosearch", rl_vi_dosearch },
- { "vi-subst", rl_vi_subst },
+ { "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-column", rl_vi_column },
- { "vi-delete-to", rl_vi_delete_to },
- { "vi-change-to", rl_vi_change_to },
+ { "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 },
- { "vi-complete", rl_vi_complete },
+
#endif /* VI_MODE */
{(char *)NULL, (Function *)NULL }
@@ -161,6 +169,48 @@ rl_initialize_funmap ()
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'. */
@@ -172,7 +222,7 @@ char *possible_meta_prefixes[] = {
"Meta", "M-", (char *)NULL
};
-#ifdef STATIC_MALLOC
+#if defined (STATIC_MALLOC)
/* **************************************************************** */
/* */
@@ -198,7 +248,12 @@ xrealloc (pointer, bytes)
char *pointer;
int bytes;
{
- char *temp = (char *)realloc (pointer, bytes);
+ char *temp;
+
+ if (!pointer)
+ temp = (char *)malloc (bytes);
+ else
+ temp = (char *)realloc (pointer, bytes);
if (!temp)
memory_error_and_abort ();
diff --git a/gnu/lib/libreadline/history.c b/gnu/lib/libreadline/history.c
index 97df610..115a8af 100644
--- a/gnu/lib/libreadline/history.c
+++ b/gnu/lib/libreadline/history.c
@@ -1,53 +1,44 @@
/* History.c -- standalone history library */
-/* Copyright (C) 1989 Free Software Foundation, Inc.
+/* 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 1, or (at your option)
- any later version.
+ 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.
+ 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. */
+ 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. */
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
+#if !defined (STATIC_MALLOC)
extern char *xmalloc (), *xrealloc ();
#else
static char *xmalloc (), *xrealloc ();
#endif
+#include "sysdep.h"
#include <stdio.h>
-#include <sys/types.h>
+#include <errno.h>
+#ifndef NO_SYS_FILE
#include <sys/file.h>
+#endif
#include <sys/stat.h>
#include <fcntl.h>
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#if defined (sparc) && defined (sun)
-#include <alloca.h>
-#else
-extern char *alloca ();
-#endif
-#endif
-
#include "history.h"
#ifndef savestring
@@ -132,6 +123,8 @@ history_total_bytes ()
{
register int i, result;
+ result = 0;
+
for (i = 0; the_history && the_history[i]; i++)
result += strlen (the_history[i]->line);
@@ -232,15 +225,22 @@ where_history ()
}
/* 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. */
-int
-history_search (string, direction)
+ 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;
+ int direction, anchored;
{
register int i = history_offset;
register int reverse = (direction < 0);
@@ -272,7 +272,19 @@ history_search (string, direction)
if (string_len > index)
goto next_line;
- /* Do the actual search. */
+ /* 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;
@@ -289,7 +301,7 @@ history_search (string, direction)
}
else
{
- register int limit = (string_len - index) + 1;
+ register int limit = index - string_len + 1;
index = 0;
while (index < limit)
@@ -310,6 +322,24 @@ history_search (string, direction)
}
}
+/* 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. */
@@ -340,6 +370,8 @@ void
stifle_history (max)
int max;
{
+ if (max < 0)
+ max = 0;
if (history_length > max)
{
register int i, j;
@@ -416,7 +448,7 @@ read_history_range (filename, from, to)
{
register int line_start, line_end;
char *input, *buffer = (char *)NULL;
- int file, current_line, done;
+ int file, current_line;
struct stat finfo;
extern int errno;
@@ -497,7 +529,7 @@ history_truncate_file (fname, lines)
if (stat (filename, &finfo) == -1)
goto truncate_exit;
- file = open (filename, O_RDONLY, 066);
+ file = open (filename, O_RDONLY, 0666);
if (file == -1)
goto truncate_exit;
@@ -554,10 +586,9 @@ history_do_write (filename, nelements, overwrite)
int nelements, overwrite;
{
extern int errno;
- register int i;
+ register int i, j;
char *output = history_filename (filename);
int file, mode;
- char cr = '\n';
if (overwrite)
mode = O_WRONLY | O_CREAT | O_TRUNC;
@@ -570,13 +601,30 @@ history_do_write (filename, nelements, overwrite)
if (nelements > history_length)
nelements = history_length;
- for (i = history_length - nelements; i < history_length; i++)
- {
- if (write (file, the_history[i]->line, strlen (the_history[i]->line)) < 0)
- break;
- if (write (file, &cr, 1) < 0)
- break;
- }
+ /* 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);
@@ -815,7 +863,8 @@ get_history_event (string, caller_index, delimiting_quote)
search_again:
- index = history_search (temp, -1);
+ index = history_search_internal
+ (temp, -1, substring_okay ? NON_ANCHORED_SEARCH : ANCHORED_SEARCH);
if (index < 0)
search_lost:
@@ -824,9 +873,7 @@ get_history_event (string, caller_index, delimiting_quote)
return ((char *)NULL);
}
- if (index == 0 || substring_okay ||
- (strncmp (temp, the_history[history_offset]->line,
- strlen (temp)) == 0))
+ if (index == 0)
{
search_won:
entry = current_history ();
diff --git a/gnu/lib/libreadline/keymaps.c b/gnu/lib/libreadline/keymaps.c
index 5e8ee24..fe3edd02 100644
--- a/gnu/lib/libreadline/keymaps.c
+++ b/gnu/lib/libreadline/keymaps.c
@@ -1,24 +1,27 @@
/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1988, 1989, 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 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.
- 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.
+ 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. */
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include "sysdep.h"
+#include <stdio.h>
+#include "readline.h"
#include "keymaps.h"
#include "emacs_keymap.c"
@@ -27,12 +30,12 @@
#endif
/* Remove these declarations when we have a complete libgnu.a. */
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
+/* #define STATIC_MALLOC */
+#if !defined (STATIC_MALLOC)
extern char *xmalloc (), *xrealloc ();
#else
static char *xmalloc (), *xrealloc ();
-#endif
+#endif /* STATIC_MALLOC */
/* **************************************************************** */
/* */
@@ -86,8 +89,7 @@ rl_copy_keymap (map)
Keymap
rl_make_keymap ()
{
- extern rl_insert (), rl_rubout (), rl_do_lowercase_version ();
- extern rl_digit_argument ();
+ extern rl_insert (), rl_rubout ();
register int i;
Keymap newmap;
@@ -157,7 +159,12 @@ xrealloc (pointer, bytes)
char *pointer;
int bytes;
{
- char *temp = (char *)realloc (pointer, bytes);
+ char *temp;
+
+ if (!pointer)
+ temp = (char *)malloc (bytes);
+ else
+ temp = (char *)realloc (pointer, bytes);
if (!temp)
memory_error_and_abort ();
diff --git a/gnu/lib/libreadline/readline.c b/gnu/lib/libreadline/readline.c
index 7222e37..8529c08 100644
--- a/gnu/lib/libreadline/readline.c
+++ b/gnu/lib/libreadline/readline.c
@@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input
- with emacs style editing and completion. */
+ with emacs style editing and completion. */
-/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
+/* Copyright 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
This file contains the Readline Library (the Library), a set of
routines for providing Emacs style line input to programs that ask
@@ -9,50 +9,48 @@
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 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.
+ 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. */
+ 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. */
/* Remove these declarations when we have a complete libgnu.a. */
-#define STATIC_MALLOC
-#ifndef STATIC_MALLOC
+/* #define STATIC_MALLOC */
+#if !defined (STATIC_MALLOC)
extern char *xmalloc (), *xrealloc ();
#else
static char *xmalloc (), *xrealloc ();
-#endif
+#endif /* STATIC_MALLOC */
+#include "sysdep.h"
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
+#ifndef NO_SYS_FILE
#include <sys/file.h>
-#include <signal.h>
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else
-#if defined (sparc) && defined (sun)
-#include <alloca.h>
-#endif
#endif
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
#if defined (HAVE_UNISTD_H)
-#include <unistd.h>
+# include <unistd.h>
#endif
#define NEW_TTY_DRIVER
#define HAVE_BSD_SIGNALS
+/* #define USE_XON_XOFF */
+
+#ifdef __MSDOS__
+#undef NEW_TTY_DRIVER
+#undef HAVE_BSD_SIGNALS
+#endif
/* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */
#if defined (USG) && !defined (hpux)
@@ -61,69 +59,135 @@ static char *xmalloc (), *xrealloc ();
/* System V machines use termio. */
#if !defined (_POSIX_VERSION)
-#if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX)
-#undef NEW_TTY_DRIVER
-#include <termio.h>
-
-#if !defined (TCOON)
-#define TCOON 1
-#endif
-
-#endif /* USG | hpux | Xenix sgi | DUGX */
+# if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (__H3050R) || defined (__H3050RX)
+# undef NEW_TTY_DRIVER
+# define TERMIO_TTY_DRIVER
+# include <termio.h>
+# if !defined (TCOON)
+# define TCOON 1
+# endif
+# endif /* USG || hpux || Xenix || sgi || DUGX */
#endif /* !_POSIX_VERSION */
-/* Posix systems use termios. */
+/* Posix systems use termios and the Posix signal functions. */
#if defined (_POSIX_VERSION)
-#undef NEW_TTY_DRIVER
-#include <termios.h>
-#if !defined (O_NDELAY)
-#define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */
-#endif /* O_NDELAY */
-#endif
+# 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 */
/* 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 */
+
+/* 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 */
+
+/* End of signal handling definitions. */
+
+
#include <errno.h>
extern int errno;
#include <setjmp.h>
#include <sys/stat.h>
+/* Posix macro to check file in statbuf for directory-ness. */
+#if defined (S_IFDIR) && !defined (S_ISDIR)
+#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
+#endif
+
+#ifndef __MSDOS__
/* These next are for filename completion. Perhaps this belongs
in a different place. */
#include <pwd.h>
-#if defined (USG)
+#endif /* __MSDOS__ */
+
+#if defined (USG) && !defined (isc386) && !defined (sgi)
struct passwd *getpwuid (), *getpwent ();
#endif
/* #define HACK_TERMCAP_MOTION */
-#if !defined (USG)
-#include <sys/dir.h>
-#else /* USG */
-#if defined (Xenix)
-#include <sys/ndir.h>
-#else
-#ifdef hpux
-#include <ndir.h>
-#else
-#include <dirent.h>
-#define direct dirent
-#define d_namlen d_reclen
-#endif /* hpux */
-#endif /* xenix */
-#endif /* USG */
-
-#if defined (USG) && defined (TIOCGWINSZ)
-#include <sys/stream.h>
-# if defined (USGr4) || defined (USGr3)
-# include <sys/ptem.h>
-# endif /* USGr4 */
-#endif /* USG && TIOCGWINSZ */
-
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
@@ -141,7 +205,6 @@ struct passwd *getpwuid (), *getpwent ();
#endif
#ifndef member
-char *index ();
#define member(c, s) ((c) ? index ((s), (c)) : 0)
#endif
@@ -153,15 +216,17 @@ char *index ();
#define exchange(x, y) {int temp = x; x = y; y = temp;}
#endif
+extern char *tilde_expand ();
+
static update_line ();
static delete_chars ();
-static insert_some_chars ();
+static void insert_some_chars ();
-#ifdef VOID_SIGHANDLER
-#define sighandler void
+#if defined (VOID_SIGHANDLER)
+# define sighandler void
#else
-#define sighandler int
-#endif
+# 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); */
@@ -170,6 +235,11 @@ typedef sighandler SigHandler ();
/* If on, then readline handles signals in a way that doesn't screw. */
#define HANDLE_SIGNALS
+#ifdef __GO32__
+#include <sys/pc.h>
+#undef HANDLE_SIGNALS
+#endif
+
/* **************************************************************** */
/* */
@@ -181,6 +251,7 @@ typedef sighandler SigHandler ();
By default, it is the standard emacs keymap. */
Keymap keymap = emacs_standard_keymap;
+#define no_mode -1
#define vi_mode 0
#define emacs_mode 1
@@ -197,7 +268,7 @@ int rl_numeric_arg = 1;
int rl_explicit_arg = 0;
/* Temporary value used while generating the argument. */
-static int arg_sign = 1;
+int rl_arg_sign = 1;
/* Non-zero means we have been called at least once before. */
static int rl_initialized = 0;
@@ -227,7 +298,7 @@ static jmp_buf readline_top_level;
static FILE *in_stream, *out_stream;
/* The names of the streams that we do input and output to. */
-FILE *rl_instream = stdin, *rl_outstream = stdout;
+FILE *rl_instream, *rl_outstream;
/* Non-zero means echo characters as they are read. */
int readline_echoing_p = 1;
@@ -262,7 +333,7 @@ char *rl_terminal_name = (char *)NULL;
/* Line buffer and maintenence. */
char *rl_line_buffer = (char *)NULL;
-static int rl_line_buffer_len = 0;
+int rl_line_buffer_len = 0;
#define DEFAULT_BUFFER_SIZE 256
@@ -282,11 +353,11 @@ static int defining_kbd_macro = 0;
/* XXX this prevents to got editing mode from tcsh */
static void wait_foreground(void)
{
- struct winsize w;
- int tty = fileno (rl_instream);
+ struct winsize w;
+ int tty = fileno (rl_instream);
- if (ioctl (tty, TIOCGWINSZ, &w) == 0)
- (void) ioctl (tty, TIOCSWINSZ, &w);
+ if (ioctl (tty, TIOCGWINSZ, &w) == 0)
+ (void) ioctl (tty, TIOCSWINSZ, &w);
}
/* **************************************************************** */
@@ -295,13 +366,15 @@ static void wait_foreground(void)
/* */
/* **************************************************************** */
+static void rl_prep_terminal (), rl_deprep_terminal ();
+static void clear_to_eol (), rl_generic_bind ();
+
/* 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;
{
- static rl_prep_terminal (), rl_deprep_terminal ();
char *readline_internal ();
char *value;
@@ -317,14 +390,14 @@ readline (prompt)
rl_initialize ();
rl_prep_terminal ();
-#ifdef HANDLE_SIGNALS
+#if defined (HANDLE_SIGNALS)
rl_set_signals ();
#endif
value = readline_internal ();
rl_deprep_terminal ();
-#ifdef HANDLE_SIGNALS
+#if defined (HANDLE_SIGNALS)
rl_clear_signals ();
#endif
@@ -339,8 +412,11 @@ readline_internal ()
{
int lastc, c, eof_found;
- in_stream = rl_instream; out_stream = rl_outstream;
- lastc = eof_found = 0;
+ in_stream = rl_instream;
+ out_stream = rl_outstream;
+
+ lastc = -1;
+ eof_found = 0;
if (rl_startup_hook)
(*rl_startup_hook) ();
@@ -357,7 +433,7 @@ readline_internal ()
{
rl_on_new_line ();
rl_redisplay ();
-#ifdef VI_MODE
+#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_vi_insertion_mode ();
#endif /* VI_MODE */
@@ -404,12 +480,12 @@ readline_internal ()
last_command_was_kill = 0;
}
-#ifdef VI_MODE
+#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 && keymap == vi_movement_keymap)
rl_vi_check ();
-#endif
+#endif /* VI_MODE */
if (!rl_done)
rl_redisplay ();
@@ -451,15 +527,16 @@ readline_internal ()
/* */
/* **************************************************************** */
-#ifdef SIGWINCH
+#if defined (SIGWINCH)
static SigHandler *old_sigwinch = (SigHandler *)NULL;
static sighandler
-rl_handle_sigwinch (sig, code, scp)
- int sig, code;
- struct sigcontext *scp;
+rl_handle_sigwinch (sig)
+ int sig;
{
- char *term = rl_terminal_name;
+ char *term;
+
+ term = rl_terminal_name;
if (readline_echoing_p)
{
@@ -468,41 +545,43 @@ rl_handle_sigwinch (sig, code, scp)
if (!term)
term = "dumb";
rl_reset_terminal (term);
-#ifdef NEVER
+#if defined (NOTDEF)
crlf ();
rl_forced_update_display ();
-#endif
+#endif /* NOTDEF */
}
if (old_sigwinch &&
old_sigwinch != (SigHandler *)SIG_IGN &&
old_sigwinch != (SigHandler *)SIG_DFL)
- (*old_sigwinch)(sig, code, scp);
+ (*old_sigwinch) (sig);
+#if !defined (VOID_SIGHANDLER)
+ return (0);
+#endif /* VOID_SIGHANDLER */
}
#endif /* SIGWINCH */
-#ifdef HANDLE_SIGNALS
+#if defined (HANDLE_SIGNALS)
/* Interrupt handling. */
-static SigHandler *old_int = (SigHandler *)NULL,
- *old_tstp = (SigHandler *)NULL,
- *old_ttou = (SigHandler *)NULL,
- *old_ttin = (SigHandler *)NULL,
- *old_cont = (SigHandler *)NULL;
+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, code, scp)
- int sig, code;
- struct sigcontext *scp;
+rl_signal_handler (sig)
+ int sig;
{
- static rl_prep_terminal (), rl_deprep_terminal ();
-
-#if !defined (HAVE_BSD_SIGNALS) || defined (hpux)
+#if !defined (HAVE_BSD_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 || hpux */
+#endif /* !HAVE_BSD_SIGNALS */
switch (sig)
{
@@ -511,12 +590,12 @@ rl_signal_handler (sig, code, scp)
rl_clear_message ();
rl_init_argument ();
-#ifdef SIGTSTP
+#if defined (SIGTSTP)
case SIGTSTP:
case SIGTTOU:
case SIGTTIN:
-#endif
-
+#endif /* SIGTSTP */
+ case SIGALRM:
rl_clean_up_for_exit ();
rl_deprep_terminal ();
rl_clear_signals ();
@@ -524,22 +603,15 @@ rl_signal_handler (sig, code, scp)
kill (getpid (), sig);
-#if defined (_POSIX_VERSION)
- {
- sigset_t set;
-
- sigemptyset (&set);
- sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
- }
-#else
-#if defined (HAVE_BSD_SIGNALS)
- sigsetmask (0);
-#endif /* HAVE_BSD_SIGNALS */
-#endif /* _POSIX_VERSION */
+ SIGNALS_UNBLOCK;
rl_prep_terminal ();
rl_set_signals ();
}
+
+#if !defined (VOID_SIGHANDLER)
+ return (0);
+#endif /* !VOID_SIGHANDLER */
}
rl_set_signals ()
@@ -548,12 +620,16 @@ rl_set_signals ()
if (old_int == (SigHandler *)SIG_IGN)
signal (SIGINT, SIG_IGN);
-#ifdef SIGTSTP
+ old_alrm = (SigHandler *)signal (SIGALRM, rl_signal_handler);
+ if (old_alrm == (SigHandler *)SIG_IGN)
+ signal (SIGALRM, SIG_IGN);
+
+#if defined (SIGTSTP)
old_tstp = (SigHandler *)signal (SIGTSTP, rl_signal_handler);
if (old_tstp == (SigHandler *)SIG_IGN)
signal (SIGTSTP, SIG_IGN);
#endif
-#ifdef SIGTTOU
+#if defined (SIGTTOU)
old_ttou = (SigHandler *)signal (SIGTTOU, rl_signal_handler);
old_ttin = (SigHandler *)signal (SIGTTIN, rl_signal_handler);
@@ -564,7 +640,7 @@ rl_set_signals ()
}
#endif
-#ifdef SIGWINCH
+#if defined (SIGWINCH)
old_sigwinch = (SigHandler *)signal (SIGWINCH, rl_handle_sigwinch);
#endif
}
@@ -572,17 +648,18 @@ rl_set_signals ()
rl_clear_signals ()
{
signal (SIGINT, old_int);
+ signal (SIGALRM, old_alrm);
-#ifdef SIGTSTP
+#if defined (SIGTSTP)
signal (SIGTSTP, old_tstp);
#endif
-#ifdef SIGTTOU
+#if defined (SIGTTOU)
signal (SIGTTOU, old_ttou);
signal (SIGTTIN, old_ttin);
#endif
-#ifdef SIGWINCH
+#if defined (SIGWINCH)
signal (SIGWINCH, old_sigwinch);
#endif
}
@@ -595,9 +672,12 @@ rl_clear_signals ()
/* */
/* **************************************************************** */
+#if defined (USE_XON_XOFF)
/* If the terminal was in xoff state when we got to it, then xon_char
contains the character that is supposed to start it again. */
static int xon_char, xoff_state;
+#endif /* USE_XON_XOFF */
+
static int pop_index = 0, push_index = 0, ibuffer_len = 511;
static unsigned char ibuffer[512];
@@ -672,20 +752,37 @@ rl_unget_char (key)
and stuff it into IBUFFER. Otherwise, just return. */
rl_gather_tyi ()
{
+#ifdef __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
int tty = fileno (in_stream);
register int tem, result = -1;
long chars_avail;
char input;
-#ifdef FIONREAD
+#if defined (FIONREAD)
result = ioctl (tty, FIONREAD, &chars_avail);
#endif
if (result == -1)
{
- fcntl (tty, F_SETFL, O_NDELAY);
+ 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, 0);
+
+ fcntl (tty, F_SETFL, flags);
if (chars_avail == -1 && errno == EAGAIN)
return;
}
@@ -717,8 +814,10 @@ rl_gather_tyi ()
if (chars_avail)
rl_stuff_char (input);
}
+#endif /* def __GO32__/else */
}
+static int next_macro_key ();
/* Read a key, including pending input. */
int
rl_read_key ()
@@ -734,8 +833,6 @@ rl_read_key ()
}
else
{
- static int next_macro_key ();
-
/* If input is coming from a macro, then use that. */
if (c = next_macro_key ())
return (c);
@@ -756,23 +853,11 @@ rl_read_key ()
}
}
-#ifdef NEVER /* This breaks supdup to 4.0.3c machines. */
-#ifdef TIOCSTART
- /* Ugh. But I can't think of a better way. */
- if (xoff_state && c == xon_char)
- {
- ioctl (fileno (in_stream), TIOCSTART, 0);
- xoff_state = 0;
- return (rl_read_key ());
- }
-#endif /* TIOCSTART */
-#endif
-
return (c);
}
/* I'm beginning to hate the declaration rules for various compilers. */
-static void add_macro_char ();
+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
@@ -813,7 +898,7 @@ rl_dispatch (key, map)
return;
}
- (*map[key].function)(rl_numeric_arg * arg_sign, key);
+ (*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,
@@ -848,9 +933,9 @@ rl_dispatch (key, map)
case ISMACR:
if (map[key].function != (Function *)NULL)
{
- static with_macro_input ();
- char *macro = savestring ((char *)map[key].function);
+ char *macro;
+ macro = savestring ((char *)map[key].function);
with_macro_input (macro);
return;
}
@@ -901,7 +986,7 @@ static void push_executing_macro (), pop_executing_macro ();
/* Set up to read subsequent input from STRING.
STRING is free ()'ed when we are done with it. */
-static
+static void
with_macro_input (string)
char *string;
{
@@ -1087,6 +1172,12 @@ readline_initialize_everything ()
/* Find out if we are running in Emacs. */
running_in_emacs = getenv ("EMACS");
+ /* Set up input and output if they aren't already. */
+ if (!rl_instream)
+ rl_instream = stdin;
+ if (!rl_outstream)
+ rl_outstream = stdout;
+
/* Allocate data structures. */
if (!rl_line_buffer)
rl_line_buffer =
@@ -1117,17 +1208,21 @@ readline_initialize_everything ()
/* If this system allows us to look at the values of the regular
input editing characters, then bind them to their readline
- equivalents. */
+ equivalents, iff the characters are not bound to keymaps. */
readline_default_bindings ()
{
+#ifndef __GO32__
-#ifdef NEW_TTY_DRIVER
+#if defined (NEW_TTY_DRIVER)
struct sgttyb ttybuff;
int tty = fileno (rl_instream);
if (ioctl (tty, TIOCGETP, &ttybuff) != -1)
{
- int erase = ttybuff.sg_erase, kill = ttybuff.sg_kill;
+ int erase, kill;
+
+ erase = ttybuff.sg_erase;
+ kill = ttybuff.sg_kill;
if (erase != -1 && keymap[erase].type == ISFUNC)
keymap[erase].function = rl_rubout;
@@ -1136,13 +1231,16 @@ readline_default_bindings ()
keymap[kill].function = rl_unix_line_discard;
}
-#ifdef TIOCGLTC
+#if defined (TIOCGLTC)
{
struct ltchars lt;
if (ioctl (tty, TIOCGLTC, &lt) != -1)
{
- int erase = lt.t_werasc, nextc = lt.t_lnextc;
+ int erase, nextc;
+
+ erase = lt.t_werasc;
+ nextc = lt.t_lnextc;
if (erase != -1 && keymap[erase].type == ISFUNC)
keymap[erase].function = rl_unix_word_rubout;
@@ -1154,30 +1252,59 @@ readline_default_bindings ()
#endif /* TIOCGLTC */
#else /* not NEW_TTY_DRIVER */
-#if defined (_POSIX_VERSION)
+#if defined (TERMIOS_TTY_DRIVER)
struct termios ttybuff;
#else
struct termio ttybuff;
-#endif /* POSIX */
+#endif /* TERMIOS_TTY_DRIVER */
int tty = fileno (rl_instream);
wait_foreground (); /* XXX this prevents to got editing mode from tcsh */
-#if defined (_POSIX_VERSION)
+#if defined (TERMIOS_TTY_DRIVER)
if (tcgetattr (tty, &ttybuff) != -1)
#else
if (ioctl (tty, TCGETA, &ttybuff) != -1)
-#endif /* POSIX */
+#endif /* !TERMIOS_TTY_DRIVER */
{
- int erase = ttybuff.c_cc[VERASE];
- int kill = ttybuff.c_cc[VKILL];
+ int erase, kill;
+
+ erase = ttybuff.c_cc[VERASE];
+ kill = ttybuff.c_cc[VKILL];
- if (erase != -1 && keymap[(unsigned char)erase].type == ISFUNC)
+ if (erase != _POSIX_VDISABLE &&
+ keymap[(unsigned char)erase].type == ISFUNC)
keymap[(unsigned char)erase].function = rl_rubout;
- if (kill != -1 && keymap[(unsigned char)kill].type == ISFUNC)
+ if (kill != _POSIX_VDISABLE &&
+ keymap[(unsigned char)kill].type == ISFUNC)
keymap[(unsigned char)kill].function = rl_unix_line_discard;
+
+#if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
+ {
+ int nextc;
+
+ nextc = ttybuff.c_cc[VLNEXT];
+
+ if (nextc != _POSIX_VDISABLE &&
+ keymap[(unsigned char)nextc].type == ISFUNC)
+ keymap[(unsigned char)nextc].function = rl_quoted_insert;
+ }
+#endif /* VLNEXT && TERMIOS_TTY_DRIVER */
+
+#if defined (VWERASE)
+ {
+ int werase;
+
+ werase = ttybuff.c_cc[VWERASE];
+
+ if (werase != _POSIX_VDISABLE &&
+ keymap[(unsigned char)werase].type == ISFUNC)
+ keymap[(unsigned char)werase].function = rl_unix_word_rubout;
+ }
+#endif /* VWERASE */
}
-#endif /* NEW_TTY_DRIVER */
+#endif /* !NEW_TTY_DRIVER */
+#endif /* def __GO32__ */
}
@@ -1208,7 +1335,7 @@ rl_discard_argument ()
/* Create a default argument. */
rl_init_argument ()
{
- rl_numeric_arg = arg_sign = 1;
+ rl_numeric_arg = rl_arg_sign = 1;
rl_explicit_arg = 0;
}
@@ -1226,7 +1353,7 @@ rl_digit_loop ()
int key, c;
while (1)
{
- rl_message ("(arg: %d) ", arg_sign * rl_numeric_arg);
+ rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg, 0);
key = c = rl_read_key ();
if (keymap[c].type == ISFUNC &&
@@ -1249,7 +1376,7 @@ rl_digit_loop ()
if (c == '-' && !rl_explicit_arg)
{
rl_numeric_arg = 1;
- arg_sign = -1;
+ rl_arg_sign = -1;
}
else
{
@@ -1415,7 +1542,7 @@ rl_redisplay ()
for (in = 0; in < rl_end; in++)
{
- c = the_line[in];
+ c = (unsigned char)the_line[in];
if (out + 1 >= line_size)
{
@@ -1435,7 +1562,7 @@ rl_redisplay ()
line[out++] = c - 128;
}
#define DISPLAY_TABS
-#ifdef DISPLAY_TABS
+#if defined (DISPLAY_TABS)
else if (c == '\t')
{
register int newout = (out | (int)7) + 1;
@@ -1449,6 +1576,12 @@ rl_redisplay ()
line[out++] = '-';
line[out++] = c + 64;
}
+ else if (c == 127)
+ {
+ line[out++] = 'C';
+ line[out++] = '-';
+ line[out++] = '?';
+ }
else
line[out++] = c;
}
@@ -1731,7 +1864,11 @@ move_cursor_relative (new, data)
of moving backwards. */
if (new + 1 < last_c_pos - new)
{
+#ifdef __MSDOS__
+ putc('\r', out_stream);
+#else
tputs (term_cr, 1, output_character_function);
+#endif
last_c_pos = 0;
}
@@ -1748,7 +1885,7 @@ move_cursor_relative (new, data)
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. */
-#ifdef HACK_TERMCAP_MOTION
+#if defined (HACK_TERMCAP_MOTION)
extern char *term_forward_char;
if (term_forward_char)
@@ -1778,12 +1915,19 @@ move_vert (to)
if (to > screenheight)
return;
+#ifdef __GO32__
+ {
+ int cur_r, cur_c;
+ ScreenGetCursor(&cur_r, &cur_c);
+ ScreenSetCursor(cur_r+to-last_v_pos, cur_c);
+ }
+#else /* __GO32__ */
if ((delta = to - last_v_pos) > 0)
{
for (i = 0; i < delta; i++)
putc ('\n', out_stream);
tputs (term_cr, 1, output_character_function);
- last_c_pos = 0; /* because crlf() will do \r\n */
+ last_c_pos = 0;
}
else
{ /* delta < 0 */
@@ -1791,6 +1935,7 @@ move_vert (to)
for (i = 0; i < -delta; i++)
tputs (term_up, 1, output_character_function);
}
+#endif /* __GO32__ */
last_v_pos = to; /* now to is here */
}
@@ -1805,7 +1950,7 @@ rl_show_char (c)
c -= 128;
}
-#ifdef DISPLAY_TABS
+#if defined (DISPLAY_TABS)
if (c < 32 && c != '\t')
#else
if (c < 32)
@@ -1819,7 +1964,7 @@ rl_show_char (c)
fflush (out_stream);
}
-#ifdef DISPLAY_TABS
+#if defined (DISPLAY_TABS)
int
rl_character_len (c, pos)
register int c, pos;
@@ -1875,6 +2020,11 @@ 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 brings in sys/reg.h,
+ which screws up the Termcap variable PC, used below. */
+
+#undef PC
+
char PC;
char *BC, *UP;
@@ -1892,7 +2042,7 @@ char *term_im, *term_ei, *term_ic, *term_ip, *term_IC;
/* How to delete characters. */
char *term_dc, *term_DC;
-#ifdef HACK_TERMCAP_MOTION
+#if defined (HACK_TERMCAP_MOTION)
char *term_forward_char;
#endif /* HACK_TERMCAP_MOTION */
@@ -1913,13 +2063,27 @@ rl_reset_terminal (terminal_name)
init_terminal_io (terminal_name)
char *terminal_name;
{
- char *term = (terminal_name? terminal_name : getenv ("TERM"));
- char *tgetstr (), *buffer;
-#ifdef TIOCGWINSZ
+#ifdef __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;
+#if defined (HACK_TERMCAP_MOTION)
+ term_forward_char = (char *)NULL;
+#endif
+ terminal_can_insert = 0;
+ return;
+#else
+ extern char *tgetstr ();
+ char *term, *buffer;
+#if defined (TIOCGWINSZ) && !defined (TIOCGWINSZ_BROKEN)
struct winsize window_size;
#endif
int tty;
+ term = terminal_name ? terminal_name : getenv ("TERM");
+
if (!term_string_buffer)
term_string_buffer = (char *)xmalloc (2048);
@@ -1933,9 +2097,18 @@ init_terminal_io (terminal_name)
if (!term)
term = "dumb";
- if (tgetent (term_buffer, term) < 0)
+ 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;
+#if defined (HACK_TERMCAP_MOTION)
+ term_forward_char = (char *)NULL;
+#endif
+ terminal_can_insert = 0;
return;
}
@@ -1951,7 +2124,7 @@ init_terminal_io (terminal_name)
if (!term_cr)
term_cr = "\r";
-#ifdef HACK_TERMCAP_MOTION
+#if defined (HACK_TERMCAP_MOTION)
term_forward_char = tgetstr ("nd", &buffer);
#endif /* HACK_TERMCAP_MOTION */
@@ -1959,9 +2132,9 @@ init_terminal_io (terminal_name)
tty = fileno (rl_instream);
else
tty = 0;
-
+
screenwidth = screenheight = 0;
-#ifdef TIOCGWINSZ
+#if defined (TIOCGWINSZ) && !defined (TIOCGWINSZ_BROKEN)
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
{
screenwidth = (int) window_size.ws_col;
@@ -1999,6 +2172,7 @@ init_terminal_io (terminal_name)
term_DC = tgetstr ("DC", &buffer);
visible_bell = tgetstr ("vb", &buffer);
+#endif /* !__GO32__ */
}
/* A function for the use of tputs () */
@@ -2023,6 +2197,13 @@ static
delete_chars (count)
int count;
{
+#ifdef __GO32__
+ int r, c, w;
+ ScreenGetCursor(&r, &c);
+ w = ScreenCols();
+ memcpy(ScreenPrimary+r*w+c, ScreenPrimary+r*w+c+count, w-c-count);
+ memset(ScreenPrimary+r*w+w-count, 0, count*2);
+#else /* __GO32__ */
if (count > screenwidth)
return;
@@ -2038,14 +2219,23 @@ delete_chars (count)
while (count--)
tputs (term_dc, 1, output_character_function);
}
+#endif /* __GO32__ */
}
/* Insert COUNT characters from STRING to the output stream. */
-static
+static void
insert_some_chars (string, count)
char *string;
int count;
{
+#ifdef __GO32__
+ int r, c, w;
+ ScreenGetCursor(&r, &c);
+ w = ScreenCols();
+ memcpy(ScreenPrimary+r*w+c+count, ScreenPrimary+r*w+c, w-c-count);
+ /* Print the text. */
+ output_some_chars (string, count);
+#else /* __GO32__ */
/* If IC is defined, then we do not have to "enter" insert mode. */
if (term_IC)
{
@@ -2078,6 +2268,7 @@ insert_some_chars (string, count)
if (term_ei && *term_ei)
tputs (term_ei, 1, output_character_function);
}
+#endif /* __GO32__ */
}
/* Move the cursor back. */
@@ -2086,10 +2277,12 @@ backspace (count)
{
register int i;
+#ifndef __GO32__
if (term_backspace)
for (i = 0; i < count; i++)
tputs (term_backspace, 1, output_character_function);
else
+#endif /* !__GO32__ */
for (i = 0; i < count; i++)
putc ('\b', out_stream);
}
@@ -2097,20 +2290,25 @@ backspace (count)
/* Move to the start of the next line. */
crlf ()
{
+#if defined (NEW_TTY_DRIVER)
tputs (term_cr, 1, output_character_function);
+#endif /* NEW_TTY_DRIVER */
putc ('\n', out_stream);
}
/* 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, output_character_function);
}
else
+#endif /* !__GO32__ */
{
register int i;
@@ -2134,7 +2332,7 @@ clear_to_eol (count)
/* Non-zero means that the terminal is in a prepped state. */
static int terminal_prepped = 0;
-#ifdef NEW_TTY_DRIVER
+#if defined (NEW_TTY_DRIVER)
/* Standard flags, including ECHO. */
static int original_tty_flags = 0;
@@ -2146,134 +2344,150 @@ static int local_mode_flags = 0;
static struct tchars original_tchars;
/* Local special characters. This has the interrupt characters in it. */
+#if defined (TIOCGLTC)
static struct ltchars original_ltchars;
+#endif
/* We use this to get and set the tty_flags. */
static struct sgttyb the_ttybuff;
/* Put the terminal in CBREAK mode so that we can detect key presses. */
-static
+static void
rl_prep_terminal ()
{
+#ifndef __GO32__
int tty = fileno (rl_instream);
- int oldmask = sigblock (sigmask (SIGINT));
+ SIGNALS_DECLARE_SAVED (saved_signals);
- if (!terminal_prepped)
- {
- /* We always get the latest tty values. Maybe stty changed them. */
- ioctl (tty, TIOCGETP, &the_ttybuff);
- original_tty_flags = the_ttybuff.sg_flags;
+ if (terminal_prepped)
+ return;
+
+ SIGNALS_BLOCK (SIGINT, saved_signals);
- readline_echoing_p = (original_tty_flags & ECHO);
+ /* We always get the latest tty values. Maybe stty changed them. */
+ ioctl (tty, TIOCGETP, &the_ttybuff);
+ original_tty_flags = the_ttybuff.sg_flags;
+
+ readline_echoing_p = (original_tty_flags & ECHO);
#if defined (TIOCLGET)
- ioctl (tty, TIOCLGET, &local_mode_flags);
+ ioctl (tty, TIOCLGET, &local_mode_flags);
#endif
#if !defined (ANYP)
-#define ANYP (EVENP | ODDP)
+# define ANYP (EVENP | ODDP)
#endif
- /* If this terminal doesn't care how the 8th bit is used,
- then we can use it for the meta-key.
- We check by seeing if BOTH odd and even parity are allowed. */
- if (the_ttybuff.sg_flags & ANYP)
- {
+
+ /* If this terminal doesn't care how the 8th bit is used,
+ then we can use it for the meta-key. We check by seeing
+ if BOTH odd and even parity are allowed. */
+ if (the_ttybuff.sg_flags & ANYP)
+ {
#if defined (PASS8)
- the_ttybuff.sg_flags |= PASS8;
+ the_ttybuff.sg_flags |= PASS8;
#endif
- /* Hack on local mode flags if we can. */
+ /* Hack on local mode flags if we can. */
#if defined (TIOCLGET) && defined (LPASS8)
- {
- int flags;
- flags = local_mode_flags | LPASS8;
- ioctl (tty, TIOCLSET, &flags);
- }
-#endif /* TIOCLGET && LPASS8 */
- }
-#ifdef TIOCGETC
{
- struct tchars temp;
-
- ioctl (tty, TIOCGETC, &original_tchars);
- temp = original_tchars;
-
- /* Get rid of C-s and C-q.
- We remember the value of startc (C-q) so that if the terminal is in
- xoff state, the user can xon it by pressing that character. */
- xon_char = temp.t_startc;
- temp.t_stopc = -1;
- temp.t_startc = -1;
-
- /* If there is an XON character, bind it to restart the output. */
- if (xon_char != -1)
- rl_bind_key (xon_char, rl_restart_output);
-
- /* If there is an EOF char, bind eof_char to it. */
- if (temp.t_eofc != -1)
- eof_char = temp.t_eofc;
-
-#if defined (NOTDEF)
- /* Get rid of C-\ and C-c. */
- temp.t_intrc = temp.t_quitc = -1;
-#endif /* NOTDEF */
-
- ioctl (tty, TIOCSETC, &temp);
+ int flags;
+ flags = local_mode_flags | LPASS8;
+ ioctl (tty, TIOCLSET, &flags);
}
+#endif /* TIOCLGET && LPASS8 */
+ }
+
+#if defined (TIOCGETC)
+ {
+ struct tchars temp;
+
+ ioctl (tty, TIOCGETC, &original_tchars);
+ temp = original_tchars;
+
+#if defined (USE_XON_XOFF)
+ /* Get rid of C-s and C-q.
+ We remember the value of startc (C-q) so that if the terminal is in
+ xoff state, the user can xon it by pressing that character. */
+ xon_char = temp.t_startc;
+ temp.t_stopc = -1;
+ temp.t_startc = -1;
+
+ /* If there is an XON character, bind it to restart the output. */
+ if (xon_char != -1)
+ rl_bind_key (xon_char, rl_restart_output);
+#endif /* USE_XON_XOFF */
+
+ /* If there is an EOF char, bind eof_char to it. */
+ if (temp.t_eofc != -1)
+ eof_char = temp.t_eofc;
+
+#if defined (NO_KILL_INTR)
+ /* Get rid of C-\ and C-c. */
+ temp.t_intrc = temp.t_quitc = -1;
+#endif /* NO_KILL_INTR */
+
+ ioctl (tty, TIOCSETC, &temp);
+ }
#endif /* TIOCGETC */
-#ifdef TIOCGLTC
- {
- struct ltchars temp;
+#if defined (TIOCGLTC)
+ {
+ struct ltchars temp;
- ioctl (tty, TIOCGLTC, &original_ltchars);
- temp = original_ltchars;
+ ioctl (tty, TIOCGLTC, &original_ltchars);
+ temp = original_ltchars;
- /* Make the interrupt keys go away. Just enough to make people
- happy. */
- temp.t_dsuspc = -1; /* C-y */
- temp.t_lnextc = -1; /* C-v */
+ /* Make the interrupt keys go away. Just enough to make people
+ happy. */
+ temp.t_dsuspc = -1; /* C-y */
+ temp.t_lnextc = -1; /* C-v */
- ioctl (tty, TIOCSLTC, &temp);
- }
+ ioctl (tty, TIOCSLTC, &temp);
+ }
#endif /* TIOCGLTC */
- the_ttybuff.sg_flags &= (~ECHO|CRMOD);
- the_ttybuff.sg_flags |= CBREAK;
- ioctl (tty, TIOCSETN, &the_ttybuff);
+ the_ttybuff.sg_flags &= ~(ECHO | CRMOD);
+ the_ttybuff.sg_flags |= CBREAK;
+ ioctl (tty, TIOCSETN, &the_ttybuff);
- terminal_prepped = 1;
- }
- sigsetmask (oldmask);
+ terminal_prepped = 1;
+
+ SIGNALS_RESTORE (saved_signals);
+#endif /* !__GO32__ */
}
/* Restore the terminal to its original state. */
-static
+static void
rl_deprep_terminal ()
{
+#ifndef __GO32__
int tty = fileno (rl_instream);
- int oldmask = sigblock (sigmask (SIGINT));
+ SIGNALS_DECLARE_SAVED (saved_signals);
- if (terminal_prepped)
- {
- the_ttybuff.sg_flags = original_tty_flags;
- ioctl (tty, TIOCSETN, &the_ttybuff);
- readline_echoing_p = 1;
+ if (!terminal_prepped)
+ return;
+
+ SIGNALS_BLOCK (SIGINT, saved_signals);
+
+ the_ttybuff.sg_flags = original_tty_flags;
+ ioctl (tty, TIOCSETN, &the_ttybuff);
+ readline_echoing_p = 1;
#if defined (TIOCLGET)
- ioctl (tty, TIOCLSET, &local_mode_flags);
+ ioctl (tty, TIOCLSET, &local_mode_flags);
#endif
-#ifdef TIOCSLTC
- ioctl (tty, TIOCSLTC, &original_ltchars);
+#if defined (TIOCSLTC)
+ ioctl (tty, TIOCSLTC, &original_ltchars);
#endif
-#ifdef TIOCSETC
- ioctl (tty, TIOCSETC, &original_tchars);
+#if defined (TIOCSETC)
+ ioctl (tty, TIOCSETC, &original_tchars);
#endif
- terminal_prepped = 0;
- }
- sigsetmask (oldmask);
+ terminal_prepped = 0;
+
+ SIGNALS_RESTORE (saved_signals);
+#endif /* !__GO32 */
}
#else /* !defined (NEW_TTY_DRIVER) */
@@ -2286,41 +2500,40 @@ rl_deprep_terminal ()
#define VTIME VEOL
#endif
-#if defined (_POSIX_VERSION)
+#ifndef __GO32__
+#if defined (TERMIOS_TTY_DRIVER)
static struct termios otio;
#else
static struct termio otio;
-#endif
+#endif /* !TERMIOS_TTY_DRIVER */
+#endif /* __GO32__ */
-static
+static void
rl_prep_terminal ()
{
+#ifndef __GO32__
int tty = fileno (rl_instream);
-#if defined (_POSIX_VERSION)
+#if defined (TERMIOS_TTY_DRIVER)
struct termios tio;
#else
struct termio tio;
-#endif
+#endif /* !TERMIOS_TTY_DRIVER */
- /* If we are on a Posix system, block the delivery of SIGINT for a while. */
-#if defined (_POSIX_VERSION)
- sigset_t set, oset;
+ SIGNALS_DECLARE_SAVED (saved_signals);
+
+ if (terminal_prepped)
+ return;
- sigemptyset (&set);
- sigaddset (&set, SIGINT);
- sigprocmask (SIG_BLOCK, &set, &oset);
-#else
-# if defined (HAVE_BSD_SIGNALS)
- int oldmask = sigblock (sigmask (SIGINT));
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* POSIX */
+ /* Try to keep this function from being INTerrupted. We can do it
+ on POSIX and systems with BSD-like signal handling. */
+ SIGNALS_BLOCK (SIGINT, saved_signals);
wait_foreground (); /* XXX this prevents to got editing mode from tcsh */
-#if defined (_POSIX_VERSION)
+#if defined (TERMIOS_TTY_DRIVER)
tcgetattr (tty, &tio);
#else
ioctl (tty, TCGETA, &tio);
-#endif /* POSIX */
+#endif /* !TERMIOS_TTY_DRIVER */
otio = tio;
@@ -2328,20 +2541,29 @@ rl_prep_terminal ()
tio.c_lflag &= ~(ICANON|ECHO);
+ if (otio.c_cc[VEOF] != _POSIX_VDISABLE)
+ eof_char = otio.c_cc[VEOF];
+
+#if defined (USE_XON_XOFF)
#if defined (IXANY)
tio.c_iflag &= ~(IXON|IXOFF|IXANY);
#else
/* `strict' Posix systems do not define IXANY. */
tio.c_iflag &= ~(IXON|IXOFF);
#endif /* IXANY */
+#endif /* USE_XON_XOFF */
/* Only turn this off if we are using all 8 bits. */
/* |ISTRIP|INPCK */
+ tio.c_iflag &= ~(ISTRIP | INPCK);
+
+ /* Make sure we differentiate between CR and NL on input. */
+ tio.c_iflag &= ~(ICRNL | INLCR);
#if !defined (HANDLE_SIGNALS)
tio.c_lflag &= ~ISIG;
#else
- tio.c_lflag |= ISIG; /* shouldn't be needed, but... */
+ tio.c_lflag |= ISIG;
#endif
tio.c_cc[VMIN] = 1;
@@ -2350,11 +2572,7 @@ rl_prep_terminal ()
/* 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 (_POSIX_VERSION) && defined (_POSIX_JOB_CONTROL)
-
-#if !defined (_POSIX_VDISABLE)
-#define _POSIX_VDISABLE 0
-#endif /* POSIX_VDISABLE */
+#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_JOB_CONTROL)
#if defined (VLNEXT)
tio.c_cc[VLNEXT] = _POSIX_VDISABLE;
@@ -2366,56 +2584,47 @@ rl_prep_terminal ()
#endif /* POSIX && JOB_CONTROL */
-#if defined (_POSIX_VERSION)
+#if defined (TERMIOS_TTY_DRIVER)
tcsetattr (tty, TCSADRAIN, &tio);
tcflow (tty, TCOON); /* Simulate a ^Q. */
#else
ioctl (tty, TCSETAW, &tio);
ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
-#endif /* POSIX */
+#endif /* !TERMIOS_TTY_DRIVER */
-#if defined (_POSIX_VERSION)
- sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
-#else
-# if defined (HAVE_BSD_SIGNALS)
- sigsetmask (oldmask);
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* POSIX */
+ terminal_prepped = 1;
+
+ SIGNALS_RESTORE (saved_signals);
+#endif /* !__GO32__ */
}
-static
+static void
rl_deprep_terminal ()
{
+#ifndef __GO32__
int tty = fileno (rl_instream);
- /* If we are on a Posix system, block the delivery of SIGINT for a while. */
-#if defined (_POSIX_VERSION)
- sigset_t set, oset;
+ /* Try to keep this function from being INTerrupted. We can do it
+ on POSIX and systems with BSD-like signal handling. */
+ SIGNALS_DECLARE_SAVED (saved_signals);
- sigemptyset (&set);
- sigaddset (&set, SIGINT);
- sigprocmask (SIG_BLOCK, &set, &oset);
-#else
-# if defined (HAVE_BSD_SIGNALS)
- int oldmask = sigblock (sigmask (SIGINT));
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* POSIX */
+ if (!terminal_prepped)
+ return;
-#if defined (_POSIX_VERSION)
+ SIGNALS_BLOCK (SIGINT, saved_signals);
+
+#if defined (TERMIOS_TTY_DRIVER)
tcsetattr (tty, TCSADRAIN, &otio);
tcflow (tty, TCOON); /* Simulate a ^Q. */
-#else
+#else /* TERMIOS_TTY_DRIVER */
ioctl (tty, TCSETAW, &otio);
ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
-#endif /* POSIX */
+#endif /* !TERMIOS_TTY_DRIVER */
-#if defined (_POSIX_VERSION)
- sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
-#else
-# if defined (HAVE_BSD_SIGNALS)
- sigsetmask (oldmask);
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* POSIX */
+ terminal_prepped = 0;
+
+ SIGNALS_RESTORE (saved_signals);
+#endif /* !__GO32__ */
}
#endif /* NEW_TTY_DRIVER */
@@ -2459,9 +2668,11 @@ ding ()
{
if (readline_echoing_p)
{
+#ifndef __GO32__
if (prefer_visible_bell && visible_bell)
tputs (visible_bell, 1, output_character_function);
else
+#endif /* !__GO32__ */
{
fprintf (stderr, "\007");
fflush (stderr);
@@ -2500,11 +2711,12 @@ rl_copy (from, to)
char *copy;
/* Fix it if the caller is confused. */
- if (from > to) {
- int t = from;
- from = to;
- to = t;
- }
+ if (from > to)
+ {
+ int t = from;
+ from = to;
+ to = t;
+ }
length = to - from;
copy = (char *)xmalloc (1 + length);
@@ -2513,6 +2725,20 @@ rl_copy (from, to)
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;
+}
+
/* **************************************************************** */
/* */
@@ -2528,13 +2754,9 @@ rl_insert_text (string)
{
extern int doing_an_undo;
register int i, l = strlen (string);
- while (rl_end + l >= rl_line_buffer_len)
- {
- rl_line_buffer =
- (char *)xrealloc (rl_line_buffer,
- rl_line_buffer_len += DEFAULT_BUFFER_SIZE);
- the_line = rl_line_buffer;
- }
+
+ 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];
@@ -2630,11 +2852,11 @@ rl_forward (count)
else
while (count)
{
-#ifdef VI_MODE
+#if defined (VI_MODE)
if (rl_point == (rl_end - (rl_editing_mode == vi_mode)))
#else
if (rl_point == rl_end)
-#endif
+#endif /* VI_MODE */
{
ding ();
return;
@@ -2765,8 +2987,17 @@ rl_refresh_line ()
move_vert(curr_line);
move_cursor_relative (0, the_line); /* XXX is this right */
+#ifdef __GO32__
+ {
+ int r, c, w;
+ ScreenGetCursor(&r, &c);
+ w = ScreenCols();
+ memset(ScreenPrimary+r*w+c, 0, (w-c)*2);
+ }
+#else /* __GO32__ */
if (term_clreol)
tputs (term_clreol, 1, output_character_function);
+#endif /* __GO32__/else */
rl_forced_update_display ();
rl_display_fixed = 1;
@@ -2785,41 +3016,45 @@ rl_clear_screen ()
return;
}
+#ifndef __GO32__
if (term_clrpag)
tputs (term_clrpag, 1, output_character_function);
else
+#endif /* !__GO32__ */
crlf ();
rl_forced_update_display ();
rl_display_fixed = 1;
}
-rl_arrow_keys(count,c)
- int count,c;
+rl_arrow_keys (count, c)
+ int count, c;
{
- int ch = rl_read_key();
+ int ch;
- switch(ch) {
- case 'a':
+ ch = rl_read_key ();
+
+ switch (to_upper (ch))
+ {
case 'A':
- rl_get_previous_history(count);
- return;
- case 'b':
+ rl_get_previous_history (count);
+ break;
+
case 'B':
- rl_get_next_history(count);
- return;
- case 'c':
+ rl_get_next_history (count);
+ break;
+
case 'C':
- rl_forward(count);
- return;
- case 'd':
+ rl_forward (count);
+ break;
+
case 'D':
- rl_backward(count);
- return;
+ rl_backward (count);
+ break;
+
default:
- ding();
- return;
- }
+ ding ();
+ }
}
@@ -2931,7 +3166,7 @@ rl_newline (count, key)
rl_done = 1;
-#ifdef VI_MODE
+#if defined (VI_MODE)
{
extern int vi_doing_insert;
if (vi_doing_insert)
@@ -3253,25 +3488,33 @@ rl_transpose_chars (count)
return;
}
- while (count) {
- if (rl_point == rl_end) {
- int t = the_line[rl_point - 1];
- the_line[rl_point - 1] = the_line[rl_point - 2];
- the_line[rl_point - 2] = t;
- } else {
- int t = the_line[rl_point];
- the_line[rl_point] = the_line[rl_point - 1];
- the_line[rl_point - 1] = t;
- if (count < 0 && rl_point)
- rl_point--;
+ while (count)
+ {
+ if (rl_point == rl_end)
+ {
+ int t = the_line[rl_point - 1];
+
+ the_line[rl_point - 1] = the_line[rl_point - 2];
+ the_line[rl_point - 2] = t;
+ }
+ else
+ {
+ int t = the_line[rl_point];
+
+ the_line[rl_point] = the_line[rl_point - 1];
+ the_line[rl_point - 1] = t;
+
+ if (count < 0 && rl_point)
+ rl_point--;
+ else
+ rl_point++;
+ }
+
+ if (count < 0)
+ count++;
else
- rl_point++;
+ count--;
}
- if (count < 0)
- count++;
- else
- count--;
- }
}
@@ -3284,7 +3527,7 @@ rl_transpose_chars (count)
rl_restart_output (count, key)
int count, key;
{
- int fildes = fileno (stdin);
+ int fildes = fileno (rl_outstream);
#if defined (TIOCSTART)
#if defined (apollo)
ioctl (&fildes, TIOCSTART, 0);
@@ -3293,12 +3536,38 @@ rl_restart_output (count, key)
#endif /* apollo */
#else
-# if defined (TCXONC)
- ioctl (fildes, TCXONC, TCOON);
-# endif /* TCXONC */
+# if defined (TERMIOS_TTY_DRIVER)
+ tcflow (fildes, TCOON);
+# else
+# 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
+# if defined (TERMIOS_TTY_DRIVER)
+ tcflow (fildes, TCOOFF);
+# else
+# if defined (TCXONC)
+ ioctl (fildes, TCXONC, TCOON);
+# endif /* TCXONC */
+# endif /* !TERMIOS_TTY_DRIVER */
+#endif /* TIOCSTOP */
+}
+
/* **************************************************************** */
/* */
/* Completion matching, from readline's point of view. */
@@ -3319,13 +3588,17 @@ Function *rl_completion_entry_function = (Function *)NULL;
array of strings returned. */
Function *rl_attempted_completion_function = (Function *)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)
+ if (rl_last_func == rl_complete && !completion_changed_buffer)
rl_complete_internal ('?');
else
rl_complete_internal (TAB);
@@ -3357,13 +3630,19 @@ 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\"\\'`@$><=";
+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;
+/* The list of characters which are used to quote a substring of the command
+ line. Command 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. */
@@ -3399,8 +3678,15 @@ rl_complete_internal (what_to_do)
char *filename_completion_function ();
char **completion_matches (), **matches;
Function *our_func;
- int start, end, delimiter = 0;
- char *text;
+ int start, scan, end, delimiter = 0;
+ char *text, *saved_line_buffer;
+ char quote_char = '\0';
+ char *replacement;
+
+ if (the_line)
+ saved_line_buffer = savestring (the_line);
+ else
+ saved_line_buffer = (char *)NULL;
if (rl_completion_entry_function)
our_func = rl_completion_entry_function;
@@ -3415,11 +3701,44 @@ rl_complete_internal (what_to_do)
if (rl_point)
{
- while (--rl_point &&
- !rindex (rl_completer_word_break_characters, the_line[rl_point]));
+ if (rl_completer_quote_characters)
+ {
+ /* We have a list of characters which can be used in pairs to quote
+ substrings for completion. Try to find the start of an unclosed
+ quoted substring.
+ FIXME: Doesn't yet handle '\' escapes to hid embedded quotes */
+ for (scan = 0; scan < end; scan++)
+ {
+ if (quote_char != '\0')
+ {
+ /* Ignore everything until the matching close quote char */
+ if (the_line[scan] == quote_char)
+ {
+ /* Found matching close quote. Abandon this substring. */
+ quote_char = '\0';
+ rl_point = end;
+ }
+ }
+ else if (rindex (rl_completer_quote_characters, the_line[scan]))
+ {
+ /* Found start of a quoted substring. */
+ quote_char = the_line[scan];
+ rl_point = scan + 1;
+ }
+ }
+ }
+ if (rl_point == end)
+ {
+ /* We didn't find an unclosed quoted substring upon which to do
+ completion, so use the word break characters to find the
+ substring on which to do completion. */
+ while (--rl_point &&
+ !rindex (rl_completer_word_break_characters,
+ the_line[rl_point])) {;}
+ }
/* If we are at a word break, then advance past it. */
- if (rindex (rl_completer_word_break_characters, (the_line[rl_point])))
+ if (rindex (rl_completer_word_break_characters, the_line[rl_point]))
{
/* If the character that caused the word break was a quoting
character, then remember it as the delimiter. */
@@ -3451,7 +3770,7 @@ rl_complete_internal (what_to_do)
{
our_func = (Function *)NULL;
goto after_usual_completion;
- }
+ }
}
matches = completion_matches (text, our_func);
@@ -3468,7 +3787,7 @@ rl_complete_internal (what_to_do)
some_matches:
/* It seems to me that in all the cases we handle we would like
- to ignore duplicate possiblilities. Scan for the text to
+ to ignore duplicate possibilities. Scan for the text to
insert being identical to the other completions. */
if (rl_ignore_completion_duplicates)
{
@@ -3536,18 +3855,47 @@ rl_complete_internal (what_to_do)
/* 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 &&
+ munge the array, deleting matches as it desires. */
+ if (rl_ignore_some_completions_function &&
our_func == (int (*)())filename_completion_function)
(void)(*rl_ignore_some_completions_function)(matches);
-
- if (matches[0])
+
+ /* If we are doing completions 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] != NULL
+ && rl_completer_quote_characters != NULL
+ && (quote_char == '\0'))
+ {
+ for (i = 1; matches[i] != NULL; i++)
+ {
+ if (strpbrk (matches[i], rl_completer_word_break_characters))
+ {
+ /* Found an embedded word break character in a potential
+ match, so 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]);
+ break;
+ }
+ }
+ }
+ if (replacement)
{
rl_delete_text (start, rl_point);
rl_point = start;
- rl_insert_text (matches[0]);
+ 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,
@@ -3559,19 +3907,23 @@ rl_complete_internal (what_to_do)
}
else
{
- char temp_string[2];
+ char temp_string[16];
+ int temp_index = 0;
- temp_string[0] = delimiter ? delimiter : ' ';
- temp_string[1] = '\0';
+ if (quote_char)
+ {
+ temp_string[temp_index++] = quote_char;
+ }
+ temp_string[temp_index++] = delimiter ? delimiter : ' ';
+ temp_string[temp_index++] = '\0';
if (rl_filename_completion_desired)
{
struct stat finfo;
- char *tilde_expand ();
char *filename = tilde_expand (matches[0]);
if ((stat (filename, &finfo) == 0) &&
- ((finfo.st_mode & S_IFMT) == S_IFDIR))
+ S_ISDIR (finfo.st_mode))
{
if (the_line[rl_point] != '/')
rl_insert_text ("/");
@@ -3752,6 +4104,17 @@ rl_complete_internal (what_to_do)
free (matches[i]);
free (matches);
}
+
+ /* Check to see if the line has changed through all of this manipulation. */
+ if (saved_line_buffer)
+ {
+ if (strcmp (the_line, saved_line_buffer) != 0)
+ completion_changed_buffer = 1;
+ else
+ completion_changed_buffer = 0;
+
+ free (saved_line_buffer);
+ }
}
/* Stupid comparison routine for qsort () ing strings. */
@@ -3770,6 +4133,9 @@ username_completion_function (text, state)
int state;
char *text;
{
+#ifdef __GO32__
+ return (char *)NULL;
+#else /* !__GO32__ */
static char *username = (char *)NULL;
static struct passwd *entry;
static int namelen, first_char, first_char_loc;
@@ -3815,6 +4181,7 @@ username_completion_function (text, state)
return (value);
}
+#endif /* !__GO32__ */
}
/* If non-null, this contains the address of a function to call if the
@@ -3901,7 +4268,6 @@ tilde_expand (filename)
}
return (dirname);
}
-
/* **************************************************************** */
/* */
@@ -4104,37 +4470,46 @@ 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);
- }
+ 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);
+ }
}
/* Put back the saved_line_for_history if there is one. */
maybe_unsave_line ()
{
- if (saved_line_for_history) {
- 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 {
+ 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 ();
- }
}
/* 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;
- }
+ 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;
+ }
}
-
/* **************************************************************** */
/* */
@@ -4185,9 +4560,20 @@ rl_get_next_history (count)
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 */
}
}
@@ -4233,23 +4619,24 @@ rl_get_previous_history (count)
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 = strlen (the_line);
-#ifdef VI_MODE
+ rl_end = rl_point = line_len;
+
+#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_point = 0;
#endif /* VI_MODE */
}
}
-/* There is a command in the K*rn shell which yanks into this line, the last
- word of the previous line. Here it is. We left it on M-. */
-rl_yank_previous_last_arg (ignore)
- int ignore;
-{
-}
-
/* **************************************************************** */
/* */
@@ -4291,10 +4678,10 @@ rl_display_search (search_string, reverse_p, where)
*message = '\0';
-#ifdef NEVER
+#if defined (NOTDEF)
if (where != -1)
sprintf (message, "[%d]", where + history_base);
-#endif
+#endif /* NOTDEF */
strcat (message, "(");
@@ -4313,7 +4700,7 @@ rl_display_search (search_string, reverse_p, where)
/* 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
+ DIRECTION is which direction to search; >= 0 means forward, < 0 means
backwards. */
rl_search_history (direction, invoking_key)
int direction;
@@ -4350,7 +4737,6 @@ rl_search_history (direction, invoking_key)
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++);
@@ -4364,9 +4750,13 @@ rl_search_history (direction, invoking_key)
if (saved_line_for_history)
lines[i] = saved_line_for_history->line;
else
+ /* So I have to type it in this way instead. */
{
- /* So I have to type it in this way instead. */
- lines[i] = (char *)alloca (1 + strlen (the_line));
+ char *alloced_line;
+
+ /* Keep that mips alloca happy. */
+ alloced_line = (char *)alloca (1 + strlen (the_line));
+ lines[i] = alloced_line;
strcpy (lines[i], &the_line[0]);
}
@@ -4379,6 +4769,12 @@ rl_search_history (direction, invoking_key)
*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 = the_line;
@@ -4393,12 +4789,14 @@ rl_search_history (direction, invoking_key)
Function *f = (Function *)NULL;
if (keymap[c].type == ISFUNC)
- f = keymap[c].function;
+ {
+ f = keymap[c].function;
- if (f == rl_reverse_search_history)
- c = reverse ? -1 : -2;
- else if (f == rl_forward_search_history)
- c = !reverse ? -1 : -2;
+ if (f == rl_reverse_search_history)
+ c = reverse ? -1 : -2;
+ else if (f == rl_forward_search_history)
+ c = !reverse ? -1 : -2;
+ }
}
switch (c)
@@ -4460,9 +4858,8 @@ rl_search_history (direction, invoking_key)
{
while (index >= 0)
if (strncmp
- (search_string,
- sline + index,
- search_string_index) == 0)
+ (search_string, sline + index, search_string_index)
+ == 0)
goto string_found;
else
index--;
@@ -4516,12 +4913,21 @@ rl_search_history (direction, invoking_key)
/* 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. */
- strcpy (the_line, lines[i]);
- rl_point = index;
- rl_end = strlen (the_line);
- last_found_line = i;
- rl_display_search (search_string, reverse,
- (i == orig_line) ? -1 : i);
+ {
+ int line_len;
+
+ line_len = strlen (lines[i]);
+
+ if (line_len >= rl_line_buffer_len)
+ rl_extend_line_buffer (line_len);
+
+ strcpy (the_line, 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;
@@ -4822,22 +5228,27 @@ rl_yank_nth_arg (count, ignore)
}
rl_begin_undo_group ();
+
+#if defined (VI_MODE)
+ /* Vi mode always inserts a space befoe yanking the argument, and it
+ inserts it right *after* rl_point. */
+ if (rl_editing_mode == vi_mode)
+ rl_point++;
+#endif /* VI_MODE */
+
if (rl_point && the_line[rl_point - 1] != ' ')
rl_insert_text (" ");
+
rl_insert_text (arg);
free (arg);
+
rl_end_undo_group ();
}
-/* Vi Mode. */
-#ifdef VI_MODE
-#include "vi_mode.c"
-#endif /* VI_MODE */
-
/* How to toggle back and forth between editing modes. */
rl_vi_editing_mode ()
{
-#ifdef VI_MODE
+#if defined (VI_MODE)
rl_editing_mode = vi_mode;
rl_vi_insertion_mode ();
#endif /* VI_MODE */
@@ -4862,7 +5273,7 @@ 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 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 *).
@@ -4894,9 +5305,8 @@ completion_matches (text, entry_function)
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 = (char **)xrealloc
+ (match_list, ((match_list_size += 10) + 1) * sizeof (char *));
match_list[++matches] = string;
match_list[matches + 1] = (char *)NULL;
@@ -4972,7 +5382,7 @@ filename_completion_function (text, state)
static char *users_dirname = (char *)NULL;
static int filename_len;
- struct direct *entry = (struct direct *)NULL;
+ dirent *entry = (dirent *)NULL;
/* If we don't have any state, then do some initialization. */
if (!state)
@@ -5002,7 +5412,9 @@ filename_completion_function (text, state)
/* Save the version of the directory that the user typed. */
users_dirname = savestring (dirname);
{
- char *tilde_expand (), *temp_dirname = tilde_expand (dirname);
+ char *temp_dirname;
+
+ temp_dirname = tilde_expand (dirname);
free (dirname);
dirname = temp_dirname;
@@ -5016,9 +5428,9 @@ filename_completion_function (text, state)
}
/* At this point we should entertain the possibility of hacking wildcarded
- filenames, like /usr/man*\/te<TAB>. If the directory name contains
- globbing characters, then build an array of directories to glob on, and
- glob on the first one. */
+ filenames, like /usr/man/man<WILD>/te<TAB>. If the directory name
+ contains globbing characters, then build an array of directories to
+ glob on, and glob on the first one. */
/* Now that we have some state, we can read the directory. */
@@ -5036,7 +5448,7 @@ filename_completion_function (text, state)
{
/* Otherwise, if these match upto the length of filename, then
it is a match. */
- if ((entry->d_namlen >= filename_len) &&
+ if (entry->d_name[0] == filename[0] && /* Quick test */
(strncmp (filename, entry->d_name, filename_len) == 0))
{
break;
@@ -5059,8 +5471,8 @@ filename_completion_function (text, state)
if (dirname && (strcmp (dirname, ".") != 0))
{
- temp = (char *)xmalloc (1 + strlen (users_dirname)
- + entry->d_namlen);
+ temp = (char *)
+ xmalloc (1 + strlen (users_dirname) + strlen (entry->d_name));
strcpy (temp, users_dirname);
strcat (temp, entry->d_name);
}
@@ -5175,9 +5587,11 @@ rl_macro_bind (keyseq, macro, map)
char *keyseq, *macro;
Keymap map;
{
- char *macro_keys = (char *)xmalloc (2 * (strlen (macro)));
+ char *macro_keys;
int macro_keys_len;
+ macro_keys = (char *)xmalloc ((2 * strlen (macro)) + 1);
+
if (rl_translate_keyseq (macro, macro_keys, &macro_keys_len))
{
free (macro_keys);
@@ -5191,6 +5605,8 @@ rl_macro_bind (keyseq, macro, map)
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;
@@ -5284,7 +5700,11 @@ rl_translate_keyseq (seq, array, len)
case 'C':
i += 2;
- array[l++] = CTRL (to_upper (seq[i]));
+ /* Special hack for C-?... */
+ if (seq[i] == '?')
+ array[l++] = RUBOUT;
+ else
+ array[l++] = CTRL (to_upper (seq[i]));
break;
case 'e':
@@ -5318,7 +5738,12 @@ rl_named_function (string)
}
/* The last key bindings file read. */
+#ifdef __MSDOS__
+/* Don't know what to do, but this is a guess */
+static char *last_readline_init_file = "/INPUTRC";
+#else
static char *last_readline_init_file = "~/.inputrc";
+#endif
/* Re-read the current keybindings file. */
rl_re_read_init_file (count, ignore)
@@ -5345,6 +5770,9 @@ rl_read_init_file (filename)
openname = tilde_expand (filename);
+ if (!openname || *openname == '\000')
+ return ENOENT;
+
if ((stat (openname, &finfo) < 0) ||
(file = open (openname, O_RDONLY, 0666)) < 0)
{
@@ -5418,8 +5846,10 @@ parser_if (args)
}
if_stack[if_stack_depth++] = parsing_conditionalized_out;
- /* We only check to see if the first word in ARGS is the same as the
- value stored in rl_readline_name. */
+ /* 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 (parsing_conditionalized_out)
+ return;
/* Isolate first argument. */
for (i = 0; args[i] && !whitespace (args[i]); i++);
@@ -5427,9 +5857,9 @@ parser_if (args)
if (args[i])
args[i++] = '\0';
- /* Handle "if term=foo" construct. If this isn't term=foo, then
- check to see if the first word in ARGS is the same as the
- value stored in rl_readline_name. */
+ /* 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;
@@ -5441,10 +5871,32 @@ parser_if (args)
*tem = '\0';
if (stricmp (args + 5, tname) == 0)
+ parsing_conditionalized_out = 0;
+ else
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)
parsing_conditionalized_out = 0;
+ else
+ 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)
parsing_conditionalized_out = 0;
else
@@ -5455,12 +5907,22 @@ parser_if (args)
parser_else (args)
char *args;
{
- if (if_stack_depth)
- parsing_conditionalized_out = !parsing_conditionalized_out;
- else
+ register int i;
+
+ if (!if_stack_depth)
{
- /* *** What, no error message? *** */
+ /* Error message? */
+ return;
}
+
+ /* 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;
+
+ /* Invert the state of parsing if at top level. */
+ parsing_conditionalized_out = !parsing_conditionalized_out;
}
/* Terminate a conditional, popping the value of
@@ -5524,6 +5986,11 @@ handle_parser_directive (statement)
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.
@@ -5533,10 +6000,12 @@ rl_parse_and_bind (string)
{
extern char *possible_control_prefixes[], *possible_meta_prefixes[];
char *funname, *kname;
- static int substring_member_of_array ();
register int c;
int key, i;
+ while (string && whitespace (*string))
+ string++;
+
if (!string || !*string || *string == '#')
return;
@@ -5678,6 +6147,17 @@ rl_parse_and_bind (string)
rl_macro_bind (seq, &funname[1], 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, keymap);
+ }
+#endif /* PREFIX_META_HACK */
else
rl_bind_key (key, rl_named_function (funname));
}
@@ -5689,9 +6169,15 @@ rl_variable_bind (name, value)
{
if (strnicmp (value, "vi", 2) == 0)
{
-#ifdef VI_MODE
+#if defined (VI_MODE)
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)
@@ -5721,6 +6207,20 @@ rl_variable_bind (name, value)
else
prefer_visible_bell = 0;
}
+ 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 */
+ }
}
/* Return the character which matches NAME.
@@ -5732,18 +6232,17 @@ typedef struct {
} assoc_list;
assoc_list name_key_alist[] = {
- { "Space", ' ' },
- { "SPC", ' ' },
- { "Rubout", 0x7f },
{ "DEL", 0x7f },
- { "Tab", 0x09 },
+ { "ESC", '\033' },
+ { "Escape", '\033' },
+ { "LFD", '\n' },
{ "Newline", '\n' },
- { "Return", '\r' },
{ "RET", '\r' },
- { "LFD", '\n' },
- { "Escape", '\033' },
- { "ESC", '\033' },
-
+ { "Return", '\r' },
+ { "Rubout", 0x7f },
+ { "SPC", ' ' },
+ { "Space", ' ' },
+ { "Tab", 0x09 },
{ (char *)0x0, 0 }
};
@@ -5763,17 +6262,243 @@ glean_key_from_name (name)
/* **************************************************************** */
/* */
+/* 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;
+ extern char **rl_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
+ sprintf (keyname, "%c", key);
+
+ if (result_index + 2 > result_size)
+ {
+ if (!result)
+ result = (char **) xmalloc
+ ((result_size = 10) * sizeof (char *));
+ else
+ 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
+ sprintf (keyname, "%c", key);
+
+ strcat (keyname, seqs[i]);
+
+ if (result_index + 2 > result_size)
+ {
+ if (!result)
+ result = (char **)
+ xmalloc ((result_size = 10) * sizeof (char *));
+ else
+ 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, 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 **rl_funmap_names (), **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, 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;
{
- static char *strindex ();
-
while (*array)
{
if (strindex (string, *array))
@@ -5814,6 +6539,11 @@ rl_getc (stream)
int result;
unsigned char c;
+#ifdef __GO32__
+ if (isatty(0))
+ return getkey();
+#endif /* __GO32__ */
+
while (1)
{
result = read (fileno (stream), &c, sizeof (char));
@@ -5821,12 +6551,22 @@ rl_getc (stream)
if (result == sizeof (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);
+
+#ifndef __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__ */
}
}
-#ifdef STATIC_MALLOC
+#if defined (STATIC_MALLOC)
/* **************************************************************** */
/* */
@@ -5852,10 +6592,16 @@ xrealloc (pointer, bytes)
char *pointer;
int bytes;
{
- char *temp = (char *)realloc (pointer, bytes);
+ char *temp;
+
+ if (!pointer)
+ temp = (char *)malloc (bytes);
+ else
+ temp = (char *)realloc (pointer, bytes);
if (!temp)
memory_error_and_abort ();
+
return (temp);
}
@@ -5902,17 +6648,20 @@ main ()
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);
+ 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);
}
}
diff --git a/gnu/lib/libreadline/readline/history.h b/gnu/lib/libreadline/readline/history.h
index cd5574d..0041171 100644
--- a/gnu/lib/libreadline/readline/history.h
+++ b/gnu/lib/libreadline/readline/history.h
@@ -1,5 +1,6 @@
/* History.h -- the names of functions that you can call in history. */
+/* The structure used to store a history entry. */
typedef struct _hist_entry {
char *line;
char *data;
diff --git a/gnu/lib/libreadline/readline/readline.h b/gnu/lib/libreadline/readline/readline.h
index ad1e27a..5b8b2a8 100644
--- a/gnu/lib/libreadline/readline/readline.h
+++ b/gnu/lib/libreadline/readline/readline.h
@@ -1,49 +1,51 @@
/* Readline.h -- the names of functions callable from within readline. */
-#ifndef _READLINE_H_
+#if !defined (_READLINE_H_)
#define _READLINE_H_
#include <readline/keymaps.h>
-#ifndef __FUNCTION_DEF
+#if !defined (__FUNCTION_DEF)
typedef int Function ();
#define __FUNCTION_DEF
-#endif
+#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_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 ();
-#ifdef VI_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 ();
+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. */
@@ -111,6 +113,12 @@ extern char *rl_basic_word_break_characters;
rl_basic_word_break_characters. */
extern char *rl_completer_word_break_characters;
+/* List of characters which are used to quote a substring of the command
+ line, upon which completion is to be performed for the entire substring.
+ Within quoted substrings, rl_completer_word_break_characters are treated
+ as normal characters, unless they also appear in this list. */
+extern char *rl_completer_quote_characters;
+
/* List of characters that are word break characters, but should be left
in TEXT when it is passed to the completion function. The shell uses
this to help determine what kind of completing to do. */
@@ -153,10 +161,37 @@ extern Function *rl_startup_hook;
the address of a string (the current directory name) as an arg. */
extern Function *rl_symbolic_link_hook;
+/* If non-zero then this is the address of a function you want called
+ while Readline is waiting for character input. */
+extern Function *rl_event_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 */
diff --git a/gnu/lib/libreadline/sysdep.h b/gnu/lib/libreadline/sysdep.h
new file mode 100644
index 0000000..007a561
--- /dev/null
+++ b/gnu/lib/libreadline/sysdep.h
@@ -0,0 +1,37 @@
+/* System-dependent stuff, for ``normal'' systems */
+/* If you think you need to change this file, then you are wrong. In order to
+ avoid a huge ugly mass of nested #ifdefs, you should create a new file just
+ for your system, which contains exactly those #includes and definitions that
+ your system needs, AND NOTHING MORE! Then, add that file to the appropriate
+ place in configure.in, and viola, you are done. sysdep-sunos4.h is a good
+ example of how to do this. */
+
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else
+#if defined (sparc) && defined (sun)
+#include <alloca.h>
+#endif
+#ifndef alloca /* May be a macro, with args. */
+extern char *alloca ();
+#endif
+#endif
+
+#include <sys/types.h> /* Needed by dirent.h */
+#include <sys/ioctl.h> /* Needed for TIOC?WINSZ */
+
+#if defined (USG) && defined (TIOCGWINSZ)
+#include <sys/stream.h>
+#if defined (USGr4) || defined (USGr3)
+#include <sys/ptem.h>
+#endif /* USGr4 */
+#endif /* USG && TIOCGWINSZ */
+
+#include <dirent.h>
+typedef struct dirent dirent;
+
+/* SVR4 systems should use <termios.h> rather than <termio.h>. */
+
+#if defined (USGr4)
+#define _POSIX_VERSION
+#endif
diff --git a/gnu/lib/libreadline/vi_keymap.c b/gnu/lib/libreadline/vi_keymap.c
index 712889c..3863e83 100644
--- a/gnu/lib/libreadline/vi_keymap.c
+++ b/gnu/lib/libreadline/vi_keymap.c
@@ -1,29 +1,23 @@
/* vi_keymap.c -- the keymap for vi_mode in readline (). */
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1988, 1989, 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 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.
- 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.
+ 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"
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
@@ -99,7 +93,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
{ ISFUNC, (Function *)0x0 }, /* : */
{ ISFUNC, rl_vi_char_search }, /* ; */
{ ISFUNC, (Function *)0x0 }, /* < */
- { ISFUNC, (Function *)0x0 }, /* = */
+ { ISFUNC, rl_vi_complete }, /* = */
{ ISFUNC, (Function *)0x0 }, /* > */
{ ISFUNC, rl_vi_search }, /* ? */
{ ISFUNC, (Function *)0x0 }, /* @ */
@@ -111,7 +105,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
{ ISFUNC, rl_vi_delete_to }, /* D */
{ ISFUNC, rl_vi_end_word }, /* E */
{ ISFUNC, rl_vi_char_search }, /* F */
- { ISFUNC, (Function *)0x0 }, /* G */
+ { ISFUNC, rl_vi_fetch_history }, /* G */
{ ISFUNC, (Function *)0x0 }, /* H */
{ ISFUNC, rl_vi_insert_beg }, /* I */
{ ISFUNC, (Function *)0x0 }, /* J */
@@ -134,7 +128,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
/* Some more punctuation. */
{ ISFUNC, (Function *)0x0 }, /* [ */
- { ISFUNC, (Function *)0x0 }, /* \ */
+ { ISFUNC, rl_vi_complete }, /* \ */
{ ISFUNC, (Function *)0x0 }, /* ] */
{ ISFUNC, rl_vi_first_print }, /* ^ */
{ ISFUNC, rl_vi_yank_arg }, /* _ */
diff --git a/gnu/lib/libreadline/vi_mode.c b/gnu/lib/libreadline/vi_mode.c
index f0d9e04..a399791 100644
--- a/gnu/lib/libreadline/vi_mode.c
+++ b/gnu/lib/libreadline/vi_mode.c
@@ -1,7 +1,25 @@
/* vi_mode.c -- A vi emulation mode for Bash.
+ Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
- Derived from code written by Jeff Sparkes (jeff1@????).
- */
+/* 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 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. */
/* **************************************************************** */
@@ -9,6 +27,49 @@
/* VI Emulation Mode */
/* */
/* **************************************************************** */
+#if defined (VI_MODE)
+
+/* Some standard library routines. */
+#include "sysdep.h"
+#include <stdio.h>
+#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;
@@ -17,6 +78,9 @@ 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|";
@@ -26,13 +90,43 @@ static char *vi_motion = " hl^$0ftFt;,%wbeWBE|";
static Keymap vi_replace_map = (Keymap)NULL;
/* The number of characters inserted in the last replace operation. */
-static vi_replace_count = 0;
+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;
{
- rl_yank_nth_arg (count, 0);
+ /* 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. */
@@ -78,7 +172,7 @@ rl_vi_search (count, key)
save_pos = rl_point;
/* Reuse the line input buffer to read the search string. */
- the_line[0] = 0;
+ rl_line_buffer[0] = 0;
rl_end = rl_point = 0;
p = (char *)alloca (2 + (rl_prompt ? strlen (rl_prompt) : 0));
@@ -128,8 +222,38 @@ rl_vi_search (count, key)
if (vi_last_search)
free (vi_last_search);
- vi_last_search = savestring (the_line);
- rl_vi_dosearch (the_line, dir);
+ 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)
@@ -145,7 +269,7 @@ rl_vi_dosearch (string, dir)
return;
}
- if ((save = history_search_pos (string, dir, vi_histpos + dir)) == -1)
+ if ((save = vi_history_search_pos (string, dir, vi_histpos + dir)) == -1)
{
maybe_unsave_line ();
rl_clear_message ();
@@ -161,9 +285,16 @@ rl_vi_dosearch (string, dir)
h = current_history ();
history_set_pos (old);
- strcpy (the_line, h->line);
+ {
+ 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 (the_line);
+ rl_end = strlen (rl_line_buffer);
rl_point = 0;
rl_clear_message ();
}
@@ -172,19 +303,21 @@ rl_vi_dosearch (string, dir)
rl_vi_complete (ignore, key)
int ignore, key;
{
- if ((rl_point < rl_end) && (!whitespace (the_line[rl_point])))
+ if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
{
- if (!whitespace (the_line[rl_point + 1]))
+ if (!whitespace (rl_line_buffer[rl_point + 1]))
rl_vi_end_word (1, 'E');
rl_point++;
}
if (key == '*')
- rl_complete_internal ('*');
+ 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);
-
- rl_vi_insertion_mode ();
}
/* Previous word in vi mode. */
@@ -197,6 +330,12 @@ rl_vi_prev_word (count, key)
return;
}
+ if (rl_point == 0)
+ {
+ ding ();
+ return;
+ }
+
if (uppercase_p (key))
rl_vi_bWord (count);
else
@@ -213,6 +352,12 @@ rl_vi_next_word (count, key)
return;
}
+ if (rl_point >= (rl_end - 1))
+ {
+ ding ();
+ return;
+ }
+
if (uppercase_p (key))
rl_vi_fWord (count);
else
@@ -236,19 +381,18 @@ rl_vi_end_word (count, key)
}
/* Move forward a word the way that 'W' does. */
-/* 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 (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
+ while (!whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
+ rl_point++;
/* Now skip whitespace. */
- while (whitespace (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
+ while (whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
+ rl_point++;
}
}
@@ -258,19 +402,19 @@ rl_vi_bWord (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 (the_line[rl_point]) &&
- whitespace (the_line[rl_point - 1]))
- rl_point--;
+ 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 (the_line[rl_point]))
- rl_point--;
+ while (rl_point > 0 && whitespace (rl_line_buffer[rl_point]))
+ rl_point--;
if (rl_point > 0)
- {
- while (--rl_point >= 0 && !whitespace (the_line[rl_point]));
- rl_point++;
- }
+ {
+ while (--rl_point >= 0 && !whitespace (rl_line_buffer[rl_point]));
+ rl_point++;
+ }
}
}
@@ -279,23 +423,26 @@ rl_vi_eWord (count)
{
while (count-- && rl_point < (rl_end - 1))
{
- /* Move to white space. */
- while (++rl_point < rl_end && whitespace (the_line[rl_point]))
- ;
+ 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 (the_line[rl_point]))
- rl_point++;
+ {
+ /* Skip whitespace. */
+ while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
+ rl_point++;
- /* Skip until whitespace. */
- while (rl_point < rl_end && !whitespace (the_line[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--;
- }
+ /* Move back to the last character of the word. */
+ rl_point--;
+ }
}
}
@@ -305,21 +452,21 @@ rl_vi_fword (count)
while (count-- && rl_point < (rl_end - 1))
{
/* Move to white space (really non-identifer). */
- if (isident (the_line[rl_point]))
- {
- while (isident (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
- }
- else /* if (!whitespace (the_line[rl_point])) */
- {
- while (!isident (the_line[rl_point]) &&
- !whitespace (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
- }
+ 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 (the_line[rl_point]) && rl_point < rl_end)
- rl_point++;
+ while (whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
+ rl_point++;
}
}
@@ -330,32 +477,33 @@ rl_vi_bword (count)
{
int last_is_ident;
- /* If we are at the start of a word, move back to a non-identifier
- so we will go back to the start of the previous word. */
- if (isident (the_line[rl_point]) && !isident (the_line[rl_point - 1]))
- rl_point--;
+ /* 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 (the_line[rl_point - 1]);
- if ((isident (the_line[rl_point]) && !last_is_ident) ||
- (!isident (the_line[rl_point]) && last_is_ident))
- rl_point--;
+ 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 (the_line[rl_point]))
- rl_point--;
+ while (rl_point > 0 && whitespace (rl_line_buffer[rl_point]))
+ rl_point--;
if (rl_point > 0)
- {
- if (isident (the_line[rl_point]))
- while (--rl_point >= 0 && isident (the_line[rl_point]));
- else
- while (--rl_point >= 0 && !isident (the_line[rl_point]) &&
- !whitespace (the_line[rl_point]));
- rl_point++;
- }
+ {
+ 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++;
+ }
}
}
@@ -364,18 +512,21 @@ rl_vi_eword (count)
{
while (count-- && rl_point < rl_end - 1)
{
- while (++rl_point < rl_end && whitespace (the_line[rl_point]))
- ;
+ 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 (the_line[rl_point]))
- while (++rl_point < rl_end && isident (the_line[rl_point]));
- else
- while (++rl_point < rl_end && !isident (the_line[rl_point])
- && !whitespace (the_line[rl_point]));
- rl_point--;
- }
+ {
+ 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--;
}
}
@@ -444,39 +595,41 @@ rl_vi_arg_digit (count, c)
rl_digit_argument (count, c);
}
-/* Doesn't take an arg count in vi */
-rl_vi_change_case (ignore1, ignore2)
- int ignore1, ignore2;
+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 - 1)
+ if (rl_point >= rl_end)
return;
- if (uppercase_p (the_line[rl_point]))
- c = to_lower (the_line[rl_point]);
- else if (lowercase_p (the_line[rl_point]))
- c = to_upper (the_line[rl_point]);
-
- /* Vi is kind of strange here. */
- if (c)
+ while (count-- && rl_point < rl_end)
{
- rl_begin_undo_group ();
- rl_delete (1, c);
- rl_insert (1, c);
- rl_end_undo_group ();
- rl_vi_check ();
+ 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);
}
- else
- rl_forward (1);
}
rl_vi_put (count, key)
int count, key;
{
if (!uppercase_p (key) && (rl_point + 1 <= rl_end))
- rl_forward (1);
+ rl_point++;
rl_yank ();
rl_backward (1);
@@ -501,6 +654,9 @@ 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 ();
@@ -511,10 +667,14 @@ rl_vi_domove (key, nextkey)
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;
@@ -525,15 +685,41 @@ rl_vi_domove (key, nextkey)
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);
- if ((c == 'w' || c == 'W') && rl_point < rl_end)
+ /* 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);
@@ -548,7 +734,7 @@ rl_digit_loop1 ()
while (1)
{
- rl_message ("(arg: %d) ", arg_sign * rl_numeric_arg, 0);
+ rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg, 0);
key = c = rl_read_key ();
if (keymap[c].type == ISFUNC &&
@@ -562,9 +748,9 @@ rl_digit_loop1 ()
if (numeric (c))
{
if (rl_explicit_arg)
- rl_numeric_arg = (rl_numeric_arg * 10) + (c - '0');
+ rl_numeric_arg = (rl_numeric_arg * 10) + digit_value (c);
else
- rl_numeric_arg = (c - '0');
+ rl_numeric_arg = digit_value (c);
rl_explicit_arg = 1;
}
else
@@ -590,7 +776,7 @@ rl_vi_delete_to (count, key)
return;
}
- if ((c != '|') && (c != 'h') && rl_mark < rl_end)
+ if ((c != 'l') && (c != '|') && (c != 'h') && rl_mark < rl_end)
rl_mark++;
rl_kill_text (rl_point, rl_mark);
@@ -610,7 +796,7 @@ rl_vi_change_to (count, key)
return;
}
- if ((c != '|') && (c != 'h') && rl_mark < rl_end)
+ if ((c != 'l') && (c != '|') && (c != 'h') && rl_mark < rl_end)
rl_mark++;
rl_begin_undo_group ();
@@ -633,6 +819,9 @@ rl_vi_yank_to (count, key)
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 ();
@@ -666,21 +855,26 @@ rl_vi_delete (count)
rl_vi_comment ()
{
rl_beg_of_line ();
- rl_insert_text (": "); /* `#' doesn't work in interactive mode */
+
+ 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 (0, 0);
}
rl_back_to_indent (ignore1, ignore2)
int ignore1, ignore2;
{
rl_beg_of_line ();
- while (rl_point < rl_end && whitespace (the_line[rl_point]))
+ while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
rl_point++;
}
@@ -701,70 +895,88 @@ rl_vi_char_search (count, key)
dir = (key == ';' ? orig_dir : -orig_dir);
else
{
- target = rl_getc (in_stream);
+ target = rl_getc (rl_instream);
switch (key)
- {
- case 't':
- orig_dir = dir = FTO;
- break;
+ {
+ case 't':
+ orig_dir = dir = FTO;
+ break;
- case 'T':
- orig_dir = dir = BTO;
- break;
+ case 'T':
+ orig_dir = dir = BTO;
+ break;
- case 'f':
- orig_dir = dir = FFIND;
- break;
+ case 'f':
+ orig_dir = dir = FFIND;
+ break;
- case 'F':
- orig_dir = dir = BFIND;
- break;
- }
+ case 'F':
+ orig_dir = dir = BFIND;
+ break;
+ }
}
pos = rl_point;
- if (dir < 0)
+ while (count--)
{
- pos--;
- do
+ if (dir < 0)
{
- if (the_line[pos] == target)
+ if (pos == 0)
{
- if (dir == BTO)
- rl_point = pos + 1;
- else
- rl_point = pos;
+ ding ();
return;
}
- }
- while (pos--);
- if (pos < 0)
- {
- ding ();
- return;
- }
- }
- else
- { /* dir > 0 */
- pos++;
- do
- {
- if (the_line[pos] == target)
+ pos--;
+ do
{
- if (dir == FTO)
- rl_point = pos - 1;
- else
- rl_point = pos;
+ 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;
}
}
- while (++pos < rl_end);
+ else
+ { /* dir > 0 */
+ if (pos >= rl_end)
+ {
+ ding ();
+ return;
+ }
- if (pos >= (rl_end - 1))
- ding ();
+ 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;
+ }
+ }
}
}
@@ -774,9 +986,9 @@ rl_vi_match ()
int count = 1, brack, pos;
pos = rl_point;
- if ((brack = rl_vi_bracktype (the_line[rl_point])) == 0)
+ if ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0)
{
- while ((brack = rl_vi_bracktype (the_line[rl_point])) == 0 &&
+ while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0 &&
rl_point < rl_end - 1)
rl_forward (1);
@@ -796,7 +1008,7 @@ rl_vi_match ()
{
if (--pos >= 0)
{
- int b = rl_vi_bracktype (the_line[pos]);
+ int b = rl_vi_bracktype (rl_line_buffer[pos]);
if (b == -brack)
count--;
else if (b == brack)
@@ -815,7 +1027,7 @@ rl_vi_match ()
{
if (++pos < rl_end)
{
- int b = rl_vi_bracktype (the_line[pos]);
+ int b = rl_vi_bracktype (rl_line_buffer[pos]);
if (b == -brack)
count--;
else if (b == brack)
@@ -847,24 +1059,26 @@ rl_vi_bracktype (c)
}
}
-rl_vi_change_char ()
+rl_vi_change_char (count, key)
+ int count, key;
{
int c;
- c = rl_getc (in_stream);
+ c = rl_getc (rl_instream);
- switch (c)
- {
- case '\033':
- case CTRL('C'):
- return;
+ if (c == '\033' || c == CTRL ('C'))
+ return;
- default:
+ 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 ();
- break;
}
}
@@ -882,6 +1096,7 @@ rl_vi_subst (count, key)
else
rl_delete (count, key);
+ rl_end_undo_group ();
rl_vi_insertion_mode ();
}
@@ -942,21 +1157,33 @@ rl_vi_overstrike_delete (count)
}
}
-rl_vi_replace ()
+rl_vi_replace (count, key)
+ int count, key;
{
int i;
vi_replace_count = 0;
- vi_replace_map = rl_make_bare_keymap ();
+ if (!vi_replace_map)
+ {
+ vi_replace_map = rl_make_bare_keymap ();
- for (i = ' '; i < 127; i++)
- vi_replace_map[i].function = rl_vi_overstrike;
+ 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;
+ 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;
}
@@ -969,12 +1196,12 @@ rl_vi_possible_completions()
{
int save_pos = rl_point;
- if (!index (" ;", the_line[rl_point]))
+ if (!index (" ;", rl_line_buffer[rl_point]))
{
- while (!index(" ;", the_line[++rl_point]))
+ while (!index(" ;", rl_line_buffer[++rl_point]))
;
}
- else if (the_line[rl_point-1] == ';')
+ else if (rl_line_buffer[rl_point-1] == ';')
{
ding ();
return (0);
@@ -985,3 +1212,5 @@ rl_vi_possible_completions()
return (0);
}
+
+#endif /* VI_MODE */
OpenPOWER on IntegriCloud