mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Merged with new readline 2.0 from bash
This commit is contained in:
parent
ce4acff5b6
commit
9cadef18e6
34 changed files with 10485 additions and 5243 deletions
|
|
@ -1,40 +1,46 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 1, February 1989
|
||||
|
||||
Copyright (C) 1989 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
The Free Software Foundation has exempted Bash from the requirement of
|
||||
Paragraph 2c of the General Public License. This is to say, there is
|
||||
no requirement for Bash to print a notice when it is started
|
||||
interactively in the usual way. We made this exception because users
|
||||
and standards expect shells not to print such messages. This
|
||||
exception applies to any program that serves as a shell and that is
|
||||
based primarily on Bash as opposed to other GNU software.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
The license agreements of most software companies try to keep users
|
||||
at the mercy of those companies. By contrast, our General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. 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.
|
||||
software--to make sure the software is free for all its users. The
|
||||
General Public License applies to the Free Software Foundation's
|
||||
software and to any other program whose authors commit to using it.
|
||||
You can use it for your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. 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.
|
||||
price. Specifically, the General Public License is designed to make
|
||||
sure that you have the freedom to give away or sell copies of free
|
||||
software, that you receive source code or can get it if you want it,
|
||||
that you can change the software or use pieces of it in new free
|
||||
programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
For example, if you distribute copies of a such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
source code. And you must tell them their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
|
|
@ -47,209 +53,122 @@ want its recipients to know that what they have is not the original, so
|
|||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
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".
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
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:
|
||||
|
||||
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.
|
||||
a) cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change; and
|
||||
|
||||
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:
|
||||
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).
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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.)
|
||||
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.
|
||||
|
||||
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.
|
||||
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:
|
||||
|
||||
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.
|
||||
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,
|
||||
|
||||
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.
|
||||
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,
|
||||
|
||||
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
|
||||
c) accompany it with the information you received as to where the
|
||||
corresponding source code may be obtained. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
received the program in object code or executable form alone.)
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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.
|
||||
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. 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.
|
||||
5. By copying, distributing or modifying the Program (or any work based
|
||||
on the Program) you indicate your acceptance of this license to do so,
|
||||
and all its terms and conditions.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
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.
|
||||
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.
|
||||
|
||||
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
|
||||
7. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of the license which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
the license, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
8. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
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
|
||||
|
|
@ -257,7 +176,7 @@ of promoting the sharing and reuse of software generally.
|
|||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
|
|
@ -267,7 +186,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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
|
|
@ -282,21 +201,22 @@ 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 the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
possible use to humanity, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
|
@ -312,28 +232,26 @@ Also add information on how to contact you by electronic and paper mail.
|
|||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision version 69, Copyright (C) 19xx name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
The hypothetical commands `show w' and `show c' should show the
|
||||
appropriate parts of the General Public License. Of course, the
|
||||
commands you use may be called something other than `show w' and `show
|
||||
c'; they could even be mouse-clicks or menu items--whatever suits your
|
||||
program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
necessary. Here a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
program `Gnomovision' (a program to direct compilers to make passes
|
||||
at assemblers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
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.
|
||||
That's all there is to it!
|
||||
|
|
|
|||
|
|
@ -1,217 +1,171 @@
|
|||
Fri Oct 22 07:55:08 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||
Tue Mar 23 14:36:51 1993 Brian Fox (bfox@eos.crseo.ucsb.edu)
|
||||
|
||||
* configure.in: Add * to end of all OS names.
|
||||
* readline.c (rl_copy): Changed name to rl_copy_text.
|
||||
|
||||
Tue Oct 5 12:33:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||
Mon Mar 22 19:16:05 1993 Brian Fox (bfox@eos.crseo.ucsb.edu)
|
||||
|
||||
* readline.c: Add stuff for HIUX to place where we detect termio
|
||||
vs. sgtty (ugh, but I don't see a simple better way).
|
||||
* dispose_cmd.c, several other files. Declare dispose_xxx () as
|
||||
"void".
|
||||
|
||||
Wed Sep 29 11:02:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||
* builtins/hashcom.h: Make declarations of hashed_filenames be
|
||||
"extern" to keep the SGI compiler happy.
|
||||
|
||||
* readline.c (parser_if): Free tname when done with it (change
|
||||
imported from from bash 1.12 readline).
|
||||
* readline.c (rl_initialize_everything): Assign values to
|
||||
out_stream and in_stream immediately, since
|
||||
output_character_function () can be called before
|
||||
readline_internal () is called.
|
||||
|
||||
Tue Sep 7 17:15:37 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||
Tue Dec 8 09:30:56 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
* configure.in (m88k-*-sysvr4*): Comment out previous change.
|
||||
* readline.c (rl_init_terminal) Set PC from BC, not from *buffer.
|
||||
|
||||
Fri Jul 2 11:05:34 1993 Ian Lance Taylor (ian@cygnus.com)
|
||||
Mon Nov 30 09:35:47 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
* configure.in (*-*-riscos*): New entry; use mh-sysv.
|
||||
* readline.c (invoking_keyseqs_in_map, rl_parse_and_bind) Allow
|
||||
backslash to quote characters, such as backslash, double quote,
|
||||
and space. Backslash quotes all character indiscriminately.
|
||||
|
||||
Wed Jun 23 13:00:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||
* funmap.c (vi_keymap) Fix type in "vi-replace" declaration.
|
||||
|
||||
* configure.in: Add comment.
|
||||
Fri Nov 20 10:55:05 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Mon Jun 14 14:28:55 1993 Jim Kingdon (kingdon@eric)
|
||||
* readline.c (init_terminal_io, rl_prep_terminal): FINALLY!
|
||||
Declare and use termcap variable `ospeed' when setting up terminal
|
||||
parameters.
|
||||
|
||||
* configure.in (m88k-*-sysvr4*): Use sysdep-norm.h.
|
||||
Thu Oct 8 08:53:07 1992 Brian J. Fox (bfox@helios)
|
||||
|
||||
Sun Jun 13 13:04:09 1993 Jim Kingdon (kingdon@cygnus.com)
|
||||
* Makefile, this directory: Include (as links to the canonical
|
||||
sources), tilde.c, tilde.h, posixstat.h and xmalloc.c.
|
||||
|
||||
* Makefile.in ({real,dist}clean): Remove sysdep.h.
|
||||
Tue Sep 29 13:07:21 1992 Brian J. Fox (bfox@helios)
|
||||
|
||||
Thu Jun 10 11:22:41 1993 Jim Kingdon (kingdon@cygnus.com)
|
||||
* readline.c (init_terminal_io) Don't set arrow keys if the key
|
||||
sequences that represent them are already set.
|
||||
|
||||
* Makefile.in: Add mostlyclean, distclean, and realclean targets.
|
||||
* readline.c (rl_function_of_keyseq) New function returns the first
|
||||
function (or macro) found while searching a key sequence.
|
||||
|
||||
Fri May 21 17:09:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||
Mon Sep 28 00:34:04 1992 Brian J. Fox (bfox@helios)
|
||||
|
||||
* config/mh-isc: New file.
|
||||
* configure.in: Use it.
|
||||
* readline.c (LibraryVersion) New static char * contains current
|
||||
version number. Version is at 2.0.
|
||||
|
||||
Sat Apr 17 00:40:12 1993 Jim Kingdon (kingdon at calvin)
|
||||
* readline.c (rl_complete_internal): Incorporated clean changes
|
||||
from gilmore (gnu@cygnus.com) to support quoted substrings within
|
||||
completion functions.
|
||||
|
||||
* readline.c, history.c: Don't include sys/types.h; sysdep.h does.
|
||||
* readline.c (many locations) Added support for the _GO32_,
|
||||
whatever that is. Patches supplied by Cygnus, typed in by hand,
|
||||
with cleanups.
|
||||
|
||||
* config/mh-sysv: Define TIOCGWINSZ_BROKEN.
|
||||
readline.c: Check it.
|
||||
Sun Aug 16 12:46:24 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Wed Mar 24 02:06:15 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
|
||||
* readline.c (init_terminal_io): Find out the values of the keypad
|
||||
arrows and bind them to appropriate RL functions if present.
|
||||
|
||||
* Makefile.in: add installcheck & dvi targets
|
||||
Mon Aug 10 18:13:24 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Fri Mar 12 18:36:53 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
|
||||
* history.c (stifle_history): A negative argument to stifle
|
||||
becomes zero.
|
||||
|
||||
* 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 Jul 28 09:28:41 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Tue Mar 2 21:25:36 1993 Fred Fish (fnf@cygnus.com)
|
||||
* readline.c (rl_variable_bind): New local structure describes
|
||||
booleans by name and address; code in rl_variable_bind () looks at
|
||||
structure to set simple variables.
|
||||
|
||||
* sysdep-sysv4.h: New file for SVR4.
|
||||
* configure.in (*-*-sysv4*): Use sysdep-sysv4.h.
|
||||
* parens.c (rl_insert_close): New variable rl_blink_matching_paren
|
||||
is non-zero if we want to blink the matching open when a close is
|
||||
inserted. If FD_SET is defined, rl_blink_matching_paren defaults
|
||||
to 1, else 0. If FD_SET is not defined, and
|
||||
rl_blink_matching_paren is non-zero, the close character(s) are/is
|
||||
simply inserted.
|
||||
|
||||
* configure.in (*-*-ultrix2): Add triplet from Michael Rendell
|
||||
(michael@mercury.cs.mun.ca)
|
||||
Wed Jul 22 20:03:59 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Tue Dec 15 12:38:16 1992 Ian Lance Taylor (ian@cygnus.com)
|
||||
* history.c, readline.c, vi_mode.c: Cause the functions strchr ()
|
||||
and strrchr () to be used instead of index () and rindex ()
|
||||
throughout the source.
|
||||
|
||||
* configure.in (i[34]86-*-sco3.2v4*): use mh-sco4.
|
||||
* config/mh-sco4: New file, like mh-sco but without defining
|
||||
_POSIX_SOURCE.
|
||||
Mon Jul 13 11:34:07 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Wed Nov 11 21:20:14 1992 John Gilmore (gnu@cygnus.com)
|
||||
* readline.c: (rl_variable_bind) New variable "meta-flag" if "on"
|
||||
means force the use of the 8th bit as Meta bit. Internal variable
|
||||
is called meta_flag.
|
||||
|
||||
* configure.in: Reformat to one-case-per-line.
|
||||
Handle SunOS 3.5, as per Karl Berry, <karl@claude.cs.umb.edu>.
|
||||
Thu Jul 9 10:37:56 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Wed Nov 4 15:32:31 1992 Stu Grossman (grossman at cygnus.com)
|
||||
* history.c (get_history_event) Change INDEX to LOCAL_INDEX. If
|
||||
compiling for the shell, allow shell metacharacters to separate
|
||||
history tokens as they would for shell tokens.
|
||||
|
||||
* sysdep-norm.h: Remove some crud, install dire warning.
|
||||
Sat Jul 4 19:29:12 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Thu Oct 22 01:08:13 1992 Stu Grossman (grossman at cygnus.com)
|
||||
* vi_keymap.c: According to Posix, TAB self-inserts instead of
|
||||
doing completion.
|
||||
|
||||
* configure.in: Make SCO work again...
|
||||
* vi_mode.c: (rl_vi_yank_arg) Enter VI insert mode after yanking
|
||||
an arg from the previous line.
|
||||
|
||||
Mon Oct 12 15:04:07 1992 Ian Lance Taylor (ian@cygnus.com)
|
||||
* search.c: New file takes over vi style searching and implements
|
||||
non-incremental searching the history.
|
||||
|
||||
* readline.c (init_terminal_io): if tgetent returns 0, the
|
||||
terminal type is unknown.
|
||||
Makefile: Add search.c and search.o.
|
||||
|
||||
Thu Oct 1 23:44:14 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
|
||||
funmap.c: Add names for non-incremental-forward-search-history and
|
||||
non-incremental-reverse-search-history.
|
||||
|
||||
* configure.in: use cpu-vendor-os triple instead of nested cases
|
||||
readline.h: Add extern definitions for non-incremental searching.
|
||||
|
||||
Wed Sep 30 12:58:57 1992 Stu Grossman (grossman at cygnus.com)
|
||||
vi_mode.c: Remove old search code; add calls to code in search.c.
|
||||
|
||||
* readline.c (rl_complete_internal): Cast alloca to (char *) to
|
||||
avoid warning.
|
||||
Fri Jul 3 10:36:33 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Fri Sep 25 12:45:05 1992 Stu Grossman (grossman at cygnus.com)
|
||||
* readline.c (rl_delete_horizontal_space); New function deletes
|
||||
all whitespace surrounding point.
|
||||
|
||||
* 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().
|
||||
funmap.c: Add "delete-horizontal-space".
|
||||
emacs_keymap.c: Put rl_delete_horizontal_space () on M-\.
|
||||
|
||||
Wed Aug 19 14:59:07 1992 Ian Lance Taylor (ian@cygnus.com)
|
||||
* readline.c (rl_set_signals, rl_clear_signals); New function
|
||||
rl_set_sighandler () is either defined in a Posix way (if
|
||||
HAVE_POSIX_SIGNALS is defined) or in a BSD way. Function is
|
||||
called from rl_set_signals () and rl_clear_signals ().
|
||||
|
||||
* Makefile.in: always create installation directories, use full
|
||||
file name for install target.
|
||||
Fri May 8 12:50:15 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Wed Aug 12 15:50:57 1992 John Gilmore (gnu@cygnus.com)
|
||||
* readline.c: (readline_default_bindings) Do comparisons with
|
||||
_POSIX_VDISABLE casted to `unsigned char'. Change tty characters
|
||||
to be unsigned char.
|
||||
|
||||
* readline.c (last_readline_init_file): Fix typo made by Steve
|
||||
Chamberlain/DJ Delorie. Proper control file name is ~/.inputrc,
|
||||
not ~/inputrc.
|
||||
Thu Apr 30 12:36:35 1992 Brian Fox (bfox@cubit)
|
||||
|
||||
Thu Jun 25 16:15:27 1992 Stu Grossman (grossman at cygnus.com)
|
||||
* readline.c: (rl_getc) Handle "read would block" error on
|
||||
non-blocking IO streams.
|
||||
|
||||
* configure.in: Make bsd based systems use sysdep-obsd.h.
|
||||
* readline.c: (rl_signal_handler): Unblock only the signal that we
|
||||
have caught, not all signals.
|
||||
|
||||
Tue Jun 23 23:22:53 1992 Per Bothner (bothner@cygnus.com)
|
||||
Sun Feb 23 03:33:09 1992 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
* config/mh-posix: New file, for Posix-compliant systems.
|
||||
* configure.in: Use mh-posix for Linux (free Unix clone).
|
||||
* readline.c: Many functions. Use only the macros META_CHAR and
|
||||
UNMETA to deal with meta characters. Prior to this, we used
|
||||
numeric values and tests.
|
||||
|
||||
Tue Jun 23 21:59:20 1992 Fred Fish (fnf@cygnus.com)
|
||||
* readline.c (rl_complete_internal) Report exactly the number of
|
||||
possible completions, not the number + 1.
|
||||
|
||||
* sysdep-norm.h (alloca): Protect against previous definition as
|
||||
a macro with arguments.
|
||||
* vi_mode.c (rl_do_move) Do not change the cursor position when
|
||||
using `cw' or `cW'.
|
||||
|
||||
Fri Jun 19 15:48:54 1992 Stu Grossman (grossman at cygnus.com)
|
||||
* vi_mode.c (rl_vi_complete) Enter insert mode after completing
|
||||
with `*' or `\'.
|
||||
|
||||
* sysdep-obsd.h: #include <sys/types.h> to make this more Kosher.
|
||||
Fri Feb 21 05:58:18 1992 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
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.
|
||||
* readline.c (rl_dispatch) Increment rl_key_sequence_length for
|
||||
meta characters that map onto ESC map.
|
||||
|
||||
Mon Feb 10 01:41:35 1992 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
|
|
@ -219,108 +173,56 @@ Mon Feb 10 01:41:35 1992 Brian Fox (bfox at gnuwest.fsf.org)
|
|||
to write and write them in one fell swoop (lower overhead than
|
||||
calling write () for each line). Suggested by Peter Ho.
|
||||
|
||||
* readline.c: Include hbullx20 as well as hpux for determining
|
||||
USGr3ness.
|
||||
|
||||
* readline.c (rl_unix_word_rubout) As per the "Now REMEMBER"
|
||||
comment, pass arguments to rl_kill_text () in the correct order to
|
||||
preserve prepending and appending of killed text.
|
||||
|
||||
* readline.c (rl_search_history) malloc (), realloc (), and free
|
||||
() SEARCH_STRING so that there are no static limits on searching.
|
||||
|
||||
* 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)
|
||||
Fri Jan 31 14:51:02 1992 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
* Makefile.in: remove FIXME's on info and install-info targets.
|
||||
* readline.c (rl_signal_handler): Zero the current history entry's
|
||||
pointer after freeing the undo_list when SIGINT received.
|
||||
Reformat a couple of functions.
|
||||
|
||||
Fri Mar 6 22:02:04 1992 K. Richard Pixley (rich@cygnus.com)
|
||||
Sat Jan 25 13:47:35 1992 Brian Fox (bfox at bears)
|
||||
|
||||
* Makefile.in: added check target.
|
||||
* readline.c (parser_if): free () TNAME after use.
|
||||
|
||||
Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
|
||||
Tue Jan 21 01:01:35 1992 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
* Makefile.in, configure.in: removed traces of namesubdir,
|
||||
-subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
|
||||
copyrights to '92, changed some from Cygnus to FSF.
|
||||
* readline.c (rl_redisplay) and (rl_character_len): Display
|
||||
Control characters as "^c" and Meta characters as "\234", instead
|
||||
of "C-C" and "M-C".
|
||||
|
||||
Fri Feb 21 14:37:32 1992 Steve Chamberlain (sac at rtl.cygnus.com)
|
||||
Sun Dec 29 10:59:00 1991 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
* readline.c, examples/fileman.c: patches from DJ to support DOS
|
||||
* readline.c (init_terminal_io) Default to environment variables
|
||||
LINES and COLUMNS before termcap entry values. If all else fails,
|
||||
then assume 80x24 terminal.
|
||||
|
||||
Thu Feb 20 23:23:16 1992 Stu Grossman (grossman at cygnus.com)
|
||||
Sat Dec 28 16:33:11 1991 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
* 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[].
|
||||
* readline.c: If this machine is USG and it is hpux, then define
|
||||
USGr3.
|
||||
|
||||
Mon Feb 17 17:15:09 1992 Fred Fish (fnf at cygnus.com)
|
||||
* history.c: Cosmetic fixes.
|
||||
|
||||
* 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.
|
||||
Thu Nov 21 00:10:12 1991 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
* sysdep-norm.h (_POSIX_VERSION): Define this for all SVR4
|
||||
systems so that <termios.h> gets used, instead of <termio.h>.
|
||||
* vi_mode.c: (rl_do_move) Place cursor at end of line, never at
|
||||
next to last character.
|
||||
|
||||
Fri Dec 20 12:04:31 1991 Fred Fish (fnf at cygnus.com)
|
||||
Thu Nov 14 05:08:01 1991 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
* 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.
|
||||
* history.c (get_history_event) Non-anchored searches can have a
|
||||
return index of greater than zero from get_history_event ().
|
||||
|
||||
Fri Nov 1 07:02:13 1991 Brian Fox (bfox at gnuwest.fsf.org)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
# $Id: Makefile,v 1.1 1993/12/28 07:54:51 ache Exp $
|
||||
# $Id: Makefile,v 1.3 1994/05/09 20:35:26 ache Exp $
|
||||
|
||||
SHLIB_MAJOR=1
|
||||
SHLIB_MINOR=0
|
||||
|
||||
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/readline -DVOID_SIGHANDLER \
|
||||
-DHAVE_UNISTD_H -DSTATIC_MALLOC \
|
||||
-DHAVE_UNISTD_H -DHAVE_STRING_H -DHAVE_STDLIB_H \
|
||||
-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp
|
||||
|
||||
LIB= readline
|
||||
SRCS+= readline.c history.c funmap.c keymaps.c
|
||||
SRCS+= readline.c funmap.c keymaps.c vi_mode.c parens.c \
|
||||
rltty.c complete.c bind.c isearch.c display.c signals.c \
|
||||
history.c search.c tilde.c xmalloc.c
|
||||
NOMAN= noman
|
||||
|
||||
beforeinstall:
|
||||
|
|
|
|||
|
|
@ -12,5 +12,6 @@ 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
|
||||
and with readline 2.0 comes from bash
|
||||
|
||||
ache@astral.msk.su
|
||||
|
|
|
|||
1378
gnu/lib/libreadline/bind.c
Normal file
1378
gnu/lib/libreadline/bind.c
Normal file
File diff suppressed because it is too large
Load diff
1326
gnu/lib/libreadline/complete.c
Normal file
1326
gnu/lib/libreadline/complete.c
Normal file
File diff suppressed because it is too large
Load diff
818
gnu/lib/libreadline/display.c
Normal file
818
gnu/lib/libreadline/display.c
Normal file
|
|
@ -0,0 +1,818 @@
|
|||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include "posixstat.h"
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
/* Global and pseudo-global variables and functions
|
||||
imported from readline.c. */
|
||||
extern char *rl_prompt;
|
||||
extern int readline_echoing_p;
|
||||
extern char *term_clreol, *term_im, *term_ic, *term_ei, *term_DC;
|
||||
/* Termcap variables. */
|
||||
extern char *term_up, *term_dc, *term_cr, *term_IC;
|
||||
extern int screenheight, screenwidth, terminal_can_insert;
|
||||
|
||||
extern void _rl_output_some_chars ();
|
||||
extern void _rl_output_character_function ();
|
||||
|
||||
extern int _rl_convert_meta_chars_to_ascii;
|
||||
extern int _rl_horizontal_scroll_mode;
|
||||
extern int _rl_mark_modified_lines;
|
||||
extern int _rl_prefer_visible_bell;
|
||||
|
||||
/* Pseudo-global functions (local to the readline library) exported
|
||||
by this file. */
|
||||
void _rl_move_cursor_relative (), _rl_output_some_chars ();
|
||||
void _rl_move_vert ();
|
||||
|
||||
static void update_line (), clear_to_eol ();
|
||||
static void delete_chars (), insert_some_chars ();
|
||||
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Display stuff */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* This is the stuff that is hard for me. I never seem to write good
|
||||
display routines in C. Let's see how I do this time. */
|
||||
|
||||
/* (PWP) Well... Good for a simple line updater, but totally ignores
|
||||
the problems of input lines longer than the screen width.
|
||||
|
||||
update_line and the code that calls it makes a multiple line,
|
||||
automatically wrapping line update. Carefull attention needs
|
||||
to be paid to the vertical position variables.
|
||||
|
||||
handling of terminals with autowrap on (incl. DEC braindamage)
|
||||
could be improved a bit. Right now I just cheat and decrement
|
||||
screenwidth by one. */
|
||||
|
||||
/* Keep two buffers; one which reflects the current contents of the
|
||||
screen, and the other to draw what we think the new contents should
|
||||
be. Then compare the buffers, and make whatever changes to the
|
||||
screen itself that we should. Finally, make the buffer that we
|
||||
just drew into be the one which reflects the current contents of the
|
||||
screen, and place the cursor where it belongs.
|
||||
|
||||
Commands that want to can fix the display themselves, and then let
|
||||
this function know that the display has been fixed by setting the
|
||||
RL_DISPLAY_FIXED variable. This is good for efficiency. */
|
||||
|
||||
/* Global variables declared here. */
|
||||
/* What YOU turn on when you have handled all redisplay yourself. */
|
||||
int rl_display_fixed = 0;
|
||||
|
||||
/* The stuff that gets printed out before the actual text of the line.
|
||||
This is usually pointing to rl_prompt. */
|
||||
char *rl_display_prompt = (char *)NULL;
|
||||
|
||||
/* Pseudo-global variables declared here. */
|
||||
/* The visible cursor position. If you print some text, adjust this. */
|
||||
int _rl_last_c_pos = 0;
|
||||
int _rl_last_v_pos = 0;
|
||||
|
||||
/* Number of lines currently on screen minus 1. */
|
||||
int _rl_vis_botlin = 0;
|
||||
|
||||
/* Variables used only in this file. */
|
||||
/* The last left edge of text that was displayed. This is used when
|
||||
doing horizontal scrolling. It shifts in thirds of a screenwidth. */
|
||||
static int last_lmargin = 0;
|
||||
|
||||
/* The line display buffers. One is the line currently displayed on
|
||||
the screen. The other is the line about to be displayed. */
|
||||
static char *visible_line = (char *)NULL;
|
||||
static char *invisible_line = (char *)NULL;
|
||||
|
||||
/* A buffer for `modeline' messages. */
|
||||
static char msg_buf[128];
|
||||
|
||||
/* Non-zero forces the redisplay even if we thought it was unnecessary. */
|
||||
static int forced_display = 0;
|
||||
|
||||
/* Default and initial buffer size. Can grow. */
|
||||
static int line_size = 1024;
|
||||
|
||||
/* Basic redisplay algorithm. */
|
||||
void
|
||||
rl_redisplay ()
|
||||
{
|
||||
register int in, out, c, linenum;
|
||||
register char *line = invisible_line;
|
||||
char *prompt_this_line;
|
||||
int c_pos = 0;
|
||||
int inv_botlin = 0; /* Number of lines in newly drawn buffer. */
|
||||
|
||||
if (!readline_echoing_p)
|
||||
return;
|
||||
|
||||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
|
||||
if (!invisible_line)
|
||||
{
|
||||
visible_line = (char *)xmalloc (line_size);
|
||||
invisible_line = (char *)xmalloc (line_size);
|
||||
line = invisible_line;
|
||||
for (in = 0; in < line_size; in++)
|
||||
{
|
||||
visible_line[in] = 0;
|
||||
invisible_line[in] = 1;
|
||||
}
|
||||
rl_on_new_line ();
|
||||
}
|
||||
|
||||
/* Draw the line into the buffer. */
|
||||
c_pos = -1;
|
||||
|
||||
/* Mark the line as modified or not. We only do this for history
|
||||
lines. */
|
||||
out = 0;
|
||||
if (_rl_mark_modified_lines && current_history () && rl_undo_list)
|
||||
{
|
||||
line[out++] = '*';
|
||||
line[out] = '\0';
|
||||
}
|
||||
|
||||
/* If someone thought that the redisplay was handled, but the currently
|
||||
visible line has a different modification state than the one about
|
||||
to become visible, then correct the caller's misconception. */
|
||||
if (visible_line[0] != invisible_line[0])
|
||||
rl_display_fixed = 0;
|
||||
|
||||
prompt_this_line = strrchr (rl_display_prompt, '\n');
|
||||
if (!prompt_this_line)
|
||||
prompt_this_line = rl_display_prompt;
|
||||
else
|
||||
{
|
||||
prompt_this_line++;
|
||||
if (forced_display)
|
||||
_rl_output_some_chars
|
||||
(rl_display_prompt, prompt_this_line - rl_display_prompt);
|
||||
}
|
||||
|
||||
strncpy (line + out, prompt_this_line, strlen (prompt_this_line));
|
||||
out += strlen (prompt_this_line);
|
||||
line[out] = '\0';
|
||||
|
||||
for (in = 0; in < rl_end; in++)
|
||||
{
|
||||
c = (unsigned char)rl_line_buffer[in];
|
||||
|
||||
if (out + 8 >= line_size) /* XXX - 8 for \t */
|
||||
{
|
||||
line_size *= 2;
|
||||
visible_line = (char *)xrealloc (visible_line, line_size);
|
||||
invisible_line = (char *)xrealloc (invisible_line, line_size);
|
||||
line = invisible_line;
|
||||
}
|
||||
|
||||
if (in == rl_point)
|
||||
c_pos = out;
|
||||
|
||||
if (META_CHAR (c))
|
||||
{
|
||||
if (_rl_convert_meta_chars_to_ascii)
|
||||
{
|
||||
sprintf (line + out, "\\%o", c);
|
||||
out += 4;
|
||||
}
|
||||
else
|
||||
line[out++] = c;
|
||||
}
|
||||
#define DISPLAY_TABS
|
||||
#if defined (DISPLAY_TABS)
|
||||
else if (c == '\t')
|
||||
{
|
||||
register int newout = (out | (int)7) + 1;
|
||||
while (out < newout)
|
||||
line[out++] = ' ';
|
||||
}
|
||||
#endif
|
||||
else if (c < ' ')
|
||||
{
|
||||
line[out++] = '^';
|
||||
line[out++] = UNCTRL (c); /* XXX was c ^ 0x40 */
|
||||
}
|
||||
else if (c == 127)
|
||||
{
|
||||
line[out++] = '^';
|
||||
line[out++] = '?';
|
||||
}
|
||||
else
|
||||
line[out++] = c;
|
||||
}
|
||||
line[out] = '\0';
|
||||
if (c_pos < 0)
|
||||
c_pos = out;
|
||||
|
||||
/* PWP: now is when things get a bit hairy. The visible and invisible
|
||||
line buffers are really multiple lines, which would wrap every
|
||||
(screenwidth - 1) characters. Go through each in turn, finding
|
||||
the changed region and updating it. The line order is top to bottom. */
|
||||
|
||||
/* If we can move the cursor up and down, then use multiple lines,
|
||||
otherwise, let long lines display in a single terminal line, and
|
||||
horizontally scroll it. */
|
||||
|
||||
if (!_rl_horizontal_scroll_mode && term_up && *term_up)
|
||||
{
|
||||
int total_screen_chars = (screenwidth * screenheight);
|
||||
|
||||
if (!rl_display_fixed || forced_display)
|
||||
{
|
||||
forced_display = 0;
|
||||
|
||||
/* If we have more than a screenful of material to display, then
|
||||
only display a screenful. We should display the last screen,
|
||||
not the first. I'll fix this in a minute. */
|
||||
if (out >= total_screen_chars)
|
||||
out = total_screen_chars - 1;
|
||||
|
||||
/* Number of screen lines to display. */
|
||||
inv_botlin = out / screenwidth;
|
||||
|
||||
/* For each line in the buffer, do the updating display. */
|
||||
for (linenum = 0; linenum <= inv_botlin; linenum++)
|
||||
update_line (linenum > _rl_vis_botlin ? ""
|
||||
: &visible_line[linenum * screenwidth],
|
||||
&invisible_line[linenum * screenwidth],
|
||||
linenum);
|
||||
|
||||
/* We may have deleted some lines. If so, clear the left over
|
||||
blank ones at the bottom out. */
|
||||
if (_rl_vis_botlin > inv_botlin)
|
||||
{
|
||||
char *tt;
|
||||
for (; linenum <= _rl_vis_botlin; linenum++)
|
||||
{
|
||||
tt = &visible_line[linenum * screenwidth];
|
||||
_rl_move_vert (linenum);
|
||||
_rl_move_cursor_relative (0, tt);
|
||||
clear_to_eol
|
||||
((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth);
|
||||
}
|
||||
}
|
||||
_rl_vis_botlin = inv_botlin;
|
||||
|
||||
/* Move the cursor where it should be. */
|
||||
_rl_move_vert (c_pos / screenwidth);
|
||||
_rl_move_cursor_relative (c_pos % screenwidth,
|
||||
&invisible_line[(c_pos / screenwidth) * screenwidth]);
|
||||
}
|
||||
}
|
||||
else /* Do horizontal scrolling. */
|
||||
{
|
||||
int lmargin;
|
||||
|
||||
/* Always at top line. */
|
||||
_rl_last_v_pos = 0;
|
||||
|
||||
/* If the display position of the cursor would be off the edge
|
||||
of the screen, start the display of this line at an offset that
|
||||
leaves the cursor on the screen. */
|
||||
if (c_pos - last_lmargin > screenwidth - 2)
|
||||
lmargin = (c_pos / (screenwidth / 3) - 2) * (screenwidth / 3);
|
||||
else if (c_pos - last_lmargin < 1)
|
||||
lmargin = ((c_pos - 1) / (screenwidth / 3)) * (screenwidth / 3);
|
||||
else
|
||||
lmargin = last_lmargin;
|
||||
|
||||
/* If the first character on the screen isn't the first character
|
||||
in the display line, indicate this with a special character. */
|
||||
if (lmargin > 0)
|
||||
line[lmargin] = '<';
|
||||
|
||||
if (lmargin + screenwidth < out)
|
||||
line[lmargin + screenwidth - 1] = '>';
|
||||
|
||||
if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
|
||||
{
|
||||
forced_display = 0;
|
||||
update_line (&visible_line[last_lmargin],
|
||||
&invisible_line[lmargin], 0);
|
||||
|
||||
_rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]);
|
||||
last_lmargin = lmargin;
|
||||
}
|
||||
}
|
||||
fflush (rl_outstream);
|
||||
|
||||
/* Swap visible and non-visible lines. */
|
||||
{
|
||||
char *temp = visible_line;
|
||||
visible_line = invisible_line;
|
||||
invisible_line = temp;
|
||||
rl_display_fixed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* PWP: update_line() is based on finding the middle difference of each
|
||||
line on the screen; vis:
|
||||
|
||||
/old first difference
|
||||
/beginning of line | /old last same /old EOL
|
||||
v v v v
|
||||
old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as
|
||||
new: eddie> Oh, my little buggy says to me, as lurgid as
|
||||
^ ^ ^ ^
|
||||
\beginning of line | \new last same \new end of line
|
||||
\new first difference
|
||||
|
||||
All are character pointers for the sake of speed. Special cases for
|
||||
no differences, as well as for end of line additions must be handeled.
|
||||
|
||||
Could be made even smarter, but this works well enough */
|
||||
static void
|
||||
update_line (old, new, current_line)
|
||||
register char *old, *new;
|
||||
int current_line;
|
||||
{
|
||||
register char *ofd, *ols, *oe, *nfd, *nls, *ne;
|
||||
int lendiff, wsatend;
|
||||
|
||||
/* Find first difference. */
|
||||
for (ofd = old, nfd = new;
|
||||
(ofd - old < screenwidth) && *ofd && (*ofd == *nfd);
|
||||
ofd++, nfd++)
|
||||
;
|
||||
|
||||
/* Move to the end of the screen line. */
|
||||
for (oe = ofd; ((oe - old) < screenwidth) && *oe; oe++);
|
||||
for (ne = nfd; ((ne - new) < screenwidth) && *ne; ne++);
|
||||
|
||||
/* If no difference, continue to next line. */
|
||||
if (ofd == oe && nfd == ne)
|
||||
return;
|
||||
|
||||
wsatend = 1; /* flag for trailing whitespace */
|
||||
ols = oe - 1; /* find last same */
|
||||
nls = ne - 1;
|
||||
while ((ols > ofd) && (nls > nfd) && (*ols == *nls))
|
||||
{
|
||||
if (*ols != ' ')
|
||||
wsatend = 0;
|
||||
ols--;
|
||||
nls--;
|
||||
}
|
||||
|
||||
if (wsatend)
|
||||
{
|
||||
ols = oe;
|
||||
nls = ne;
|
||||
}
|
||||
else if (*ols != *nls)
|
||||
{
|
||||
if (*ols) /* don't step past the NUL */
|
||||
ols++;
|
||||
if (*nls)
|
||||
nls++;
|
||||
}
|
||||
|
||||
_rl_move_vert (current_line);
|
||||
_rl_move_cursor_relative (ofd - old, old);
|
||||
|
||||
/* if (len (new) > len (old)) */
|
||||
lendiff = (nls - nfd) - (ols - ofd);
|
||||
|
||||
/* Insert (diff (len (old), len (new)) ch. */
|
||||
if (lendiff > 0)
|
||||
{
|
||||
if (terminal_can_insert)
|
||||
{
|
||||
/* Sometimes it is cheaper to print the characters rather than
|
||||
use the terminal's capabilities. */
|
||||
if ((2 * (ne - nfd)) < lendiff && !term_IC)
|
||||
{
|
||||
_rl_output_some_chars (nfd, (ne - nfd));
|
||||
_rl_last_c_pos += (ne - nfd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*ols)
|
||||
{
|
||||
insert_some_chars (nfd, lendiff);
|
||||
_rl_last_c_pos += lendiff;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* At the end of a line the characters do not have to
|
||||
be "inserted". They can just be placed on the screen. */
|
||||
_rl_output_some_chars (nfd, lendiff);
|
||||
_rl_last_c_pos += lendiff;
|
||||
}
|
||||
/* Copy (new) chars to screen from first diff to last match. */
|
||||
if (((nls - nfd) - lendiff) > 0)
|
||||
{
|
||||
_rl_output_some_chars (&nfd[lendiff], ((nls - nfd) - lendiff));
|
||||
_rl_last_c_pos += ((nls - nfd) - lendiff);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* cannot insert chars, write to EOL */
|
||||
_rl_output_some_chars (nfd, (ne - nfd));
|
||||
_rl_last_c_pos += (ne - nfd);
|
||||
}
|
||||
}
|
||||
else /* Delete characters from line. */
|
||||
{
|
||||
/* If possible and inexpensive to use terminal deletion, then do so. */
|
||||
if (term_dc && (2 * (ne - nfd)) >= (-lendiff))
|
||||
{
|
||||
if (lendiff)
|
||||
delete_chars (-lendiff); /* delete (diff) characters */
|
||||
|
||||
/* Copy (new) chars to screen from first diff to last match */
|
||||
if ((nls - nfd) > 0)
|
||||
{
|
||||
_rl_output_some_chars (nfd, (nls - nfd));
|
||||
_rl_last_c_pos += (nls - nfd);
|
||||
}
|
||||
}
|
||||
/* Otherwise, print over the existing material. */
|
||||
else
|
||||
{
|
||||
_rl_output_some_chars (nfd, (ne - nfd));
|
||||
_rl_last_c_pos += (ne - nfd);
|
||||
clear_to_eol ((oe - old) - (ne - new));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Tell the update routines that we have moved onto a new (empty) line. */
|
||||
rl_on_new_line ()
|
||||
{
|
||||
if (visible_line)
|
||||
visible_line[0] = '\0';
|
||||
|
||||
_rl_last_c_pos = _rl_last_v_pos = 0;
|
||||
_rl_vis_botlin = last_lmargin = 0;
|
||||
}
|
||||
|
||||
/* Actually update the display, period. */
|
||||
rl_forced_update_display ()
|
||||
{
|
||||
if (visible_line)
|
||||
{
|
||||
register char *temp = visible_line;
|
||||
|
||||
while (*temp) *temp++ = '\0';
|
||||
}
|
||||
rl_on_new_line ();
|
||||
forced_display++;
|
||||
rl_redisplay ();
|
||||
}
|
||||
|
||||
/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices.
|
||||
DATA is the contents of the screen line of interest; i.e., where
|
||||
the movement is being done. */
|
||||
void
|
||||
_rl_move_cursor_relative (new, data)
|
||||
int new;
|
||||
char *data;
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* It may be faster to output a CR, and then move forwards instead
|
||||
of moving backwards. */
|
||||
if (new + 1 < _rl_last_c_pos - new)
|
||||
{
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
_rl_last_c_pos = 0;
|
||||
}
|
||||
|
||||
if (_rl_last_c_pos == new) return;
|
||||
|
||||
if (_rl_last_c_pos < new)
|
||||
{
|
||||
/* Move the cursor forward. We do it by printing the command
|
||||
to move the cursor forward if there is one, else print that
|
||||
portion of the output buffer again. Which is cheaper? */
|
||||
|
||||
/* The above comment is left here for posterity. It is faster
|
||||
to print one character (non-control) than to print a control
|
||||
sequence telling the terminal to move forward one character.
|
||||
That kind of control is for people who don't know what the
|
||||
data is underneath the cursor. */
|
||||
#if defined (HACK_TERMCAP_MOTION)
|
||||
extern char *term_forward_char;
|
||||
|
||||
if (term_forward_char)
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
tputs (term_forward_char, 1, _rl_output_character_function);
|
||||
else
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
#else
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
}
|
||||
else
|
||||
backspace (_rl_last_c_pos - new);
|
||||
_rl_last_c_pos = new;
|
||||
}
|
||||
|
||||
/* PWP: move the cursor up or down. */
|
||||
void
|
||||
_rl_move_vert (to)
|
||||
int to;
|
||||
{
|
||||
register int delta, i;
|
||||
|
||||
if (_rl_last_v_pos == to || to > screenheight)
|
||||
return;
|
||||
|
||||
#if defined (_GO32_)
|
||||
{
|
||||
int row, col;
|
||||
|
||||
ScreenGetCursor (&row, &col);
|
||||
ScreenSetCursor ((row + to - _rl_last_v_pos), col);
|
||||
}
|
||||
#else /* !_GO32_ */
|
||||
|
||||
if ((delta = to - _rl_last_v_pos) > 0)
|
||||
{
|
||||
for (i = 0; i < delta; i++)
|
||||
putc ('\n', rl_outstream);
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
_rl_last_c_pos = 0;
|
||||
}
|
||||
else
|
||||
{ /* delta < 0 */
|
||||
if (term_up && *term_up)
|
||||
for (i = 0; i < -delta; i++)
|
||||
tputs (term_up, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !_GO32_ */
|
||||
_rl_last_v_pos = to; /* Now TO is here */
|
||||
}
|
||||
|
||||
/* Physically print C on rl_outstream. This is for functions which know
|
||||
how to optimize the display. */
|
||||
rl_show_char (c)
|
||||
int c;
|
||||
{
|
||||
if (META_CHAR (c) && _rl_convert_meta_chars_to_ascii)
|
||||
{
|
||||
fprintf (rl_outstream, "M-");
|
||||
c = UNMETA (c);
|
||||
}
|
||||
|
||||
#if defined (DISPLAY_TABS)
|
||||
if (c < 32 && c != '\t')
|
||||
#else
|
||||
if (c < 32)
|
||||
#endif /* !DISPLAY_TABS */
|
||||
{
|
||||
c += 64;
|
||||
}
|
||||
|
||||
putc (c, rl_outstream);
|
||||
fflush (rl_outstream);
|
||||
}
|
||||
|
||||
int
|
||||
rl_character_len (c, pos)
|
||||
register int c, pos;
|
||||
{
|
||||
if (META_CHAR (c))
|
||||
return (_rl_convert_meta_chars_to_ascii ? 4 : 1);
|
||||
|
||||
if (c == '\t')
|
||||
{
|
||||
#if defined (DISPLAY_TABS)
|
||||
return (((pos | (int)7) + 1) - pos);
|
||||
#else
|
||||
return (2);
|
||||
#endif /* !DISPLAY_TABS */
|
||||
}
|
||||
|
||||
if (isprint (c))
|
||||
return (1);
|
||||
else
|
||||
return (2);
|
||||
}
|
||||
|
||||
/* How to print things in the "echo-area". The prompt is treated as a
|
||||
mini-modeline. */
|
||||
|
||||
#if defined (HAVE_VARARGS_H)
|
||||
rl_message (va_alist)
|
||||
va_dcl
|
||||
{
|
||||
char *format;
|
||||
va_list args;
|
||||
|
||||
va_start (args);
|
||||
format = va_arg (args, char *);
|
||||
vsprintf (msg_buf, format, args);
|
||||
va_end (args);
|
||||
|
||||
rl_display_prompt = msg_buf;
|
||||
rl_redisplay ();
|
||||
}
|
||||
#else /* !HAVE_VARARGS_H */
|
||||
rl_message (format, arg1, arg2)
|
||||
char *format;
|
||||
{
|
||||
sprintf (msg_buf, format, arg1, arg2);
|
||||
rl_display_prompt = msg_buf;
|
||||
rl_redisplay ();
|
||||
}
|
||||
#endif /* !HAVE_VARARGS_H */
|
||||
|
||||
/* How to clear things from the "echo-area". */
|
||||
rl_clear_message ()
|
||||
{
|
||||
rl_display_prompt = rl_prompt;
|
||||
rl_redisplay ();
|
||||
}
|
||||
|
||||
rl_reset_line_state ()
|
||||
{
|
||||
rl_on_new_line ();
|
||||
|
||||
rl_display_prompt = rl_prompt ? rl_prompt : "";
|
||||
forced_display = 1;
|
||||
}
|
||||
|
||||
/* Quick redisplay hack when erasing characters at the end of the line. */
|
||||
void
|
||||
_rl_erase_at_end_of_line (l)
|
||||
int l;
|
||||
{
|
||||
register int i;
|
||||
|
||||
backspace (l);
|
||||
for (i = 0; i < l; i++)
|
||||
putc (' ', rl_outstream);
|
||||
backspace (l);
|
||||
for (i = 0; i < l; i++)
|
||||
visible_line[--_rl_last_c_pos] = '\0';
|
||||
rl_display_fixed++;
|
||||
}
|
||||
|
||||
/* Clear to the end of the line. COUNT is the minimum
|
||||
number of character spaces to clear, */
|
||||
static void
|
||||
clear_to_eol (count)
|
||||
int count;
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
if (term_clreol)
|
||||
{
|
||||
tputs (term_clreol, 1, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
#endif /* !_GO32_ */
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* Do one more character space. */
|
||||
count++;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
putc (' ', rl_outstream);
|
||||
|
||||
backspace (count);
|
||||
}
|
||||
}
|
||||
|
||||
/* Insert COUNT characters from STRING to the output stream. */
|
||||
static void
|
||||
insert_some_chars (string, count)
|
||||
char *string;
|
||||
int count;
|
||||
{
|
||||
#if defined (_GO32_)
|
||||
int row, col, width;
|
||||
char *row_start;
|
||||
|
||||
ScreenGetCursor (&row, &col);
|
||||
width = ScreenCols ();
|
||||
row_start = ScreenPrimary + (row * width);
|
||||
|
||||
memcpy (row_start + col + count, row_start + col, width - col - count);
|
||||
|
||||
/* Place the text on the screen. */
|
||||
_rl_output_some_chars (string, count);
|
||||
#else /* !_GO32 */
|
||||
|
||||
/* If IC is defined, then we do not have to "enter" insert mode. */
|
||||
if (term_IC)
|
||||
{
|
||||
char *tgoto (), *buffer;
|
||||
buffer = tgoto (term_IC, 0, count);
|
||||
tputs (buffer, 1, _rl_output_character_function);
|
||||
_rl_output_some_chars (string, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* If we have to turn on insert-mode, then do so. */
|
||||
if (term_im && *term_im)
|
||||
tputs (term_im, 1, _rl_output_character_function);
|
||||
|
||||
/* If there is a special command for inserting characters, then
|
||||
use that first to open up the space. */
|
||||
if (term_ic && *term_ic)
|
||||
{
|
||||
for (i = count; i--; )
|
||||
tputs (term_ic, 1, _rl_output_character_function);
|
||||
}
|
||||
|
||||
/* Print the text. */
|
||||
_rl_output_some_chars (string, count);
|
||||
|
||||
/* If there is a string to turn off insert mode, we had best use
|
||||
it now. */
|
||||
if (term_ei && *term_ei)
|
||||
tputs (term_ei, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !_GO32_ */
|
||||
}
|
||||
|
||||
/* Delete COUNT characters from the display line. */
|
||||
static void
|
||||
delete_chars (count)
|
||||
int count;
|
||||
{
|
||||
#if defined (_GO32_)
|
||||
int row, col, width;
|
||||
char *row_start;
|
||||
|
||||
ScreenGetCursor (&row, &col);
|
||||
width = ScreenCols ();
|
||||
row_start = ScreenPrimary + (row * width);
|
||||
|
||||
memcpy (row_start + col, row_start + col + count, width - col - count);
|
||||
memset (row_start + width - count, 0, count * 2);
|
||||
#else /* !_GO32 */
|
||||
|
||||
if (count > screenwidth)
|
||||
return;
|
||||
|
||||
if (term_DC && *term_DC)
|
||||
{
|
||||
char *tgoto (), *buffer;
|
||||
buffer = tgoto (term_DC, count, count);
|
||||
tputs (buffer, count, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (term_dc && *term_dc)
|
||||
while (count--)
|
||||
tputs (term_dc, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !_GO32_ */
|
||||
}
|
||||
|
|
@ -1,30 +1,34 @@
|
|||
# This makefile for Readline library documentation is in -*- text -*- mode.
|
||||
# This makefile for History library documentation is in -*- text -*- mode.
|
||||
# Emacs likes it that way.
|
||||
|
||||
DVIOBJ = readline.dvi history.dvi
|
||||
INFOBJ = readline.info history.info
|
||||
DOC_SUPPORT = ../../doc-support/
|
||||
TEXINDEX = $(DOC_SUPPORT)/texindex
|
||||
|
||||
TEX = tex
|
||||
DVIOBJ = history.dvi
|
||||
INFOBJ = history.info
|
||||
|
||||
all: $(DVIOBJ) $(INFOBJ)
|
||||
|
||||
readline.dvi: rlman.texinfo rluser.texinfo rltech.texinfo
|
||||
tex rlman.texinfo
|
||||
tex rlman.texinfo
|
||||
mv rlman.dvi readline.dvi
|
||||
|
||||
history.dvi: hist.texinfo hsuser.texinfo hstech.texinfo
|
||||
tex hist.texinfo
|
||||
tex hist.texinfo
|
||||
$(TEX) hist.texinfo
|
||||
$(TEXINDEX) hist.??
|
||||
$(TEX) hist.texinfo
|
||||
mv hist.dvi history.dvi
|
||||
|
||||
readline.info: rlman.texinfo rluser.texinfo rltech.texinfo
|
||||
makeinfo rlman.texinfo
|
||||
|
||||
history.info: hist.texinfo hsuser.texinfo hstech.texinfo
|
||||
makeinfo hist.texinfo
|
||||
|
||||
./texinfo.tex: $(DOC_SUPPORT)texinfo.tex
|
||||
ln -s $(DOC_SUPPORT)texinfo.tex .
|
||||
|
||||
$(TEXINDEX):
|
||||
(cd $(DOC_SUPPORT); $(MAKE) $(MFLAGS) CFLAGS='$(CFLAGS)' texindex)
|
||||
|
||||
clean:
|
||||
rm -f *.log *.cp *.ky *.tp *.vr *.fn *.aux *.pg *.toc core
|
||||
rm -f *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
|
||||
*.fns *.kys *.tps *.vrs *.o core texinfo.tex
|
||||
|
||||
squeaky-clean:
|
||||
rm -f *.log *.cp *.ky *.tp *.vr *.fn *.aux *.pg *.toc core *.dvi *.~* *.info
|
||||
|
||||
rm -f *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
|
||||
*.dvi *.info *.info-* *.fns *.kys *.tps *.vrs *.o core
|
||||
|
|
|
|||
|
|
@ -306,6 +306,3 @@ main ()
|
|||
@}
|
||||
@}
|
||||
@end smallexample
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,18 @@ into another language, under the above conditions for modified versions.
|
|||
@node Using History Interactively
|
||||
@chapter Using History Interactively
|
||||
|
||||
@ifset BashFeatures
|
||||
This chapter describes how to use the GNU History Library interactively,
|
||||
from a user's standpoint. It should be considered a user's guide. For
|
||||
information on using the GNU History Library in your own programs,
|
||||
see the GNU Readline Library Manual.
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
This chapter describes how to use the GNU History Library interactively,
|
||||
from a user's standpoint. It should be considered a user's guide. For
|
||||
information on using the GNU History Library in your own programs,
|
||||
@pxref{Programming with GNU History}.
|
||||
@end ifclear
|
||||
|
||||
@menu
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
@comment %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename rluser.info
|
||||
@comment %**end of header (This is for running Texinfo on a region.)
|
||||
@setchapternewpage odd
|
||||
|
||||
@ignore
|
||||
This file documents the end user interface to the GNU command line
|
||||
editing feautres. It is to be an appendix to manuals for programs which
|
||||
|
|
@ -28,8 +33,11 @@ Permission is granted to copy and distribute translations of this manual
|
|||
into another language, under the above conditions for modified versions.
|
||||
@end ignore
|
||||
|
||||
@comment If you are including this manual as an appendix, then set the
|
||||
@comment variable readline-appendix.
|
||||
|
||||
@node Command Line Editing
|
||||
@appendix Command Line Editing
|
||||
@chapter Command Line Editing
|
||||
|
||||
This text describes GNU's command line editing interface.
|
||||
|
||||
|
|
@ -168,8 +176,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 from the cursor to the start of the previous word, or if between
|
||||
words, to the start of the previous word.
|
||||
Kill from the cursor the start of the previous word, or if between
|
||||
words, to the start of the previous word.
|
||||
|
||||
@item C-w
|
||||
Kill from the cursor to the previous whitespace. This is different than
|
||||
|
|
@ -226,7 +234,7 @@ 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
|
||||
In addition, the @code{C-x C-r} command re-reads this init file, thus
|
||||
incorporating any changes that you might have made to it.
|
||||
|
||||
@menu
|
||||
|
|
@ -305,8 +313,8 @@ 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
|
||||
In the above example, @samp{C-u} is bound to the function
|
||||
@code{universal-argument}, and @samp{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).
|
||||
|
||||
|
|
@ -322,10 +330,10 @@ following example:
|
|||
"\e[11~": "Function Key 1"
|
||||
@end example
|
||||
|
||||
In the above example, @key{C-u} is bound to the function
|
||||
In the above example, @samp{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}.
|
||||
@samp{C-x C-r} is bound to the function @code{re-read-init-file}, and
|
||||
@samp{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}.
|
||||
|
||||
@end table
|
||||
@end table
|
||||
|
|
@ -343,25 +351,25 @@ In the above example, @key{C-u} is bound to the function
|
|||
@node Commands For Moving
|
||||
@subsubsection Commands For Moving
|
||||
@ftable @code
|
||||
@item beginning-of-line (@key{C-a})
|
||||
@item beginning-of-line (C-a)
|
||||
Move to the start of the current line.
|
||||
|
||||
@item end-of-line (@key{C-e})
|
||||
@item end-of-line (C-e)
|
||||
Move to the end of the line.
|
||||
|
||||
@item forward-char (@key{C-f})
|
||||
@item forward-char (C-f)
|
||||
Move forward a character.
|
||||
|
||||
@item backward-char (@key{C-b})
|
||||
@item backward-char (C-b)
|
||||
Move back a character.
|
||||
|
||||
@item forward-word (@key{M-f})
|
||||
@item forward-word (M-f)
|
||||
Move forward to the end of the next word.
|
||||
|
||||
@item backward-word (@key{M-b})
|
||||
@item backward-word (M-b)
|
||||
Move back to the start of this, or the previous, word.
|
||||
|
||||
@item clear-screen (@key{C-l})
|
||||
@item clear-screen (C-l)
|
||||
Clear the screen leaving the current line at the top of the screen.
|
||||
|
||||
@end ftable
|
||||
|
|
@ -375,23 +383,23 @@ Accept the line regardless of where the cursor is. If this line is
|
|||
non-empty, add it to the history list. If this line was a history
|
||||
line, then restore the history line to its original state.
|
||||
|
||||
@item previous-history (@key{C-p})
|
||||
@item previous-history (C-p)
|
||||
Move `up' through the history list.
|
||||
|
||||
@item next-history (@key{C-n})
|
||||
@item next-history (C-n)
|
||||
Move `down' through the history list.
|
||||
|
||||
@item beginning-of-history (@key{M-<})
|
||||
@item beginning-of-history (M-<)
|
||||
Move to the first line in the history.
|
||||
|
||||
@item end-of-history (@key{M->})
|
||||
@item end-of-history (M->)
|
||||
Move to the end of the input history, i.e., the line you are entering!
|
||||
|
||||
@item reverse-search-history (@key{C-r})
|
||||
@item reverse-search-history (C-r)
|
||||
Search backward starting at the current line and moving `up' through
|
||||
the history as necessary. This is an incremental search.
|
||||
|
||||
@item forward-search-history (@key{C-s})
|
||||
@item forward-search-history (C-s)
|
||||
Search forward starting at the current line and moving `down' through
|
||||
the the history as neccessary.
|
||||
|
||||
|
|
@ -401,45 +409,45 @@ the the history as neccessary.
|
|||
@subsubsection Commands For Changing Text
|
||||
|
||||
@ftable @code
|
||||
@item delete-char (@key{C-d})
|
||||
@item delete-char (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 @key{C-d}, then return EOF.
|
||||
the last character typed was not 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 (@key{C-q}, @key{C-v})
|
||||
@item quoted-insert (C-q, C-v)
|
||||
Add the next character that you type to the line verbatim. This is
|
||||
how to insert things like @key{C-q} for example.
|
||||
how to insert things like C-q for example.
|
||||
|
||||
@item tab-insert (@key{M-TAB})
|
||||
@item tab-insert (M-TAB)
|
||||
Insert a tab character.
|
||||
|
||||
@item self-insert (a, b, A, 1, !, ...)
|
||||
Insert yourself.
|
||||
|
||||
@item transpose-chars (@key{C-t})
|
||||
@item transpose-chars (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 (@key{M-t})
|
||||
@item transpose-words (M-t)
|
||||
Drag the word behind the cursor past the word in front of the cursor
|
||||
moving the cursor over that word as well.
|
||||
|
||||
@item upcase-word (@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 upcase-word (M-u)
|
||||
Uppercase 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 downcase-word (M-l)
|
||||
Lowercase 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.
|
||||
@item capitalize-word (M-c)
|
||||
Uppercase the current (or following) word. With a negative argument,
|
||||
do the previous word, but do not move point.
|
||||
|
||||
@end ftable
|
||||
|
||||
|
|
@ -448,32 +456,32 @@ negative argument, do the previous word, but do not move point.
|
|||
|
||||
@ftable @code
|
||||
|
||||
@item kill-line (@key{C-k})
|
||||
@item kill-line (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 (@key{M-d})
|
||||
@item kill-word (M-d)
|
||||
Kill from the cursor to the end of the current word, or if between
|
||||
words, to the end of the next word.
|
||||
|
||||
@item backward-kill-word (@key{M-DEL})
|
||||
@item backward-kill-word (M-DEL)
|
||||
Kill the word behind the cursor.
|
||||
|
||||
@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
|
||||
@item unix-line-discard (C-u)
|
||||
Do what C-u used to do in Unix line input. We save the killed text on
|
||||
the kill-ring, though.
|
||||
|
||||
@item unix-word-rubout (@key{C-w})
|
||||
Do what @key{C-w} used to do in Unix line input. The killed text is saved
|
||||
@item unix-word-rubout (C-w)
|
||||
Do what 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 (@key{C-y})
|
||||
@item yank (C-y)
|
||||
Yank the top of the kill ring into the buffer at point.
|
||||
|
||||
@item yank-pop (@key{M-y})
|
||||
@item yank-pop (M-y)
|
||||
Rotate the kill-ring, and yank the new top. You can only do this if
|
||||
the prior command is yank or yank-pop.
|
||||
@end ftable
|
||||
|
|
@ -482,12 +490,12 @@ the prior command is yank or yank-pop.
|
|||
@subsubsection Specifying Numeric Arguments
|
||||
@ftable @code
|
||||
|
||||
@item digit-argument (@key{M-0}, @key{M-1}, ... @key{M--})
|
||||
@item digit-argument (M-0, M-1, ... M--)
|
||||
Add this digit to the argument already accumulating, or start a new
|
||||
argument. @key{M--} starts a negative argument.
|
||||
argument. M-- starts a negative argument.
|
||||
|
||||
@item universal-argument ()
|
||||
Do what @key{C-u} does in emacs. By default, this is not bound.
|
||||
Do what C-u does in emacs. By default, this is not bound.
|
||||
@end ftable
|
||||
|
||||
|
||||
|
|
@ -511,30 +519,25 @@ List the possible completions of the text before point.
|
|||
@subsubsection Some Miscellaneous Commands
|
||||
@ftable @code
|
||||
|
||||
@item re-read-init-file (@key{C-x} @key{C-r})
|
||||
@item re-read-init-file (C-x C-r)
|
||||
Read in the contents of your @file{~/.inputrc} file, and incorporate
|
||||
any bindings found there.
|
||||
|
||||
@item abort (@key{C-g})
|
||||
Stop running the current editing command.
|
||||
@item abort (C-g)
|
||||
Ding! Stops things.
|
||||
|
||||
@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}, ...)
|
||||
@item do-uppercase-version (M-a, 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. Typing @key{ESC f} is equivalent to typing
|
||||
@key{M-f}.
|
||||
without a meta key. Typing @samp{ESC f} is equivalent to typing
|
||||
@samp{M-f}.
|
||||
|
||||
@item undo (@key{C-_})
|
||||
@item undo (C-_)
|
||||
Incremental undo, separately remembered for each line.
|
||||
|
||||
@item revert-line (@key{M-r})
|
||||
@item revert-line (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 ftable
|
||||
|
|
@ -542,17 +545,14 @@ command enough times to get back to the beginning.
|
|||
@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 @key{M-C-j} (toggle-editing-mode).
|
||||
the command 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.
|
||||
|
||||
|
|
|
|||
1606
gnu/lib/libreadline/doc/texindex.c
Normal file
1606
gnu/lib/libreadline/doc/texindex.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,23 +1,30 @@
|
|||
/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
|
||||
|
||||
/* Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Readline, a library for reading lines
|
||||
of text with interactive input and history editing.
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
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
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (BUFSIZ)
|
||||
#include <stdio.h>
|
||||
#endif /* !BUFSIZ */
|
||||
|
||||
#include "readline.h"
|
||||
|
||||
/* An array of function pointers, one for each possible key.
|
||||
If the type byte is ISKMAP, then the pointer is the address of
|
||||
|
|
@ -69,7 +76,11 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
|
|||
{ ISFUNC, rl_insert }, /* & */
|
||||
{ ISFUNC, rl_insert }, /* ' */
|
||||
{ ISFUNC, rl_insert }, /* ( */
|
||||
#if defined (PAREN_MATCHING)
|
||||
{ ISFUNC, rl_insert_close }, /* ) */
|
||||
#else
|
||||
{ ISFUNC, rl_insert }, /* ) */
|
||||
#endif /* !PAREN_MATCHING */
|
||||
{ ISFUNC, rl_insert }, /* * */
|
||||
{ ISFUNC, rl_insert }, /* + */
|
||||
{ ISFUNC, rl_insert }, /* , */
|
||||
|
|
@ -129,7 +140,11 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
|
|||
/* Some more punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* [ */
|
||||
{ ISFUNC, rl_insert }, /* \ */
|
||||
#if defined (PAREN_MATCHING)
|
||||
{ ISFUNC, rl_insert_close }, /* ] */
|
||||
#else
|
||||
{ ISFUNC, rl_insert }, /* ] */
|
||||
#endif /* !PAREN_MATCHING */
|
||||
{ ISFUNC, rl_insert }, /* ^ */
|
||||
{ ISFUNC, rl_insert }, /* _ */
|
||||
{ ISFUNC, rl_insert }, /* ` */
|
||||
|
|
@ -165,9 +180,149 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
|
|||
/* Final punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* { */
|
||||
{ ISFUNC, rl_insert }, /* | */
|
||||
#if defined (PAREN_MATCHING)
|
||||
{ ISFUNC, rl_insert_close }, /* } */
|
||||
#else
|
||||
{ ISFUNC, rl_insert }, /* } */
|
||||
#endif /* !PAREN_MATCHING */
|
||||
{ ISFUNC, rl_insert }, /* ~ */
|
||||
{ ISFUNC, rl_rubout } /* RUBOUT */
|
||||
{ ISFUNC, rl_rubout }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Pure 8-bit characters (128 - 159).
|
||||
These might be used in some
|
||||
character sets. */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
|
||||
/* ISO Latin-1 characters (160 - 255) */
|
||||
{ ISFUNC, rl_insert }, /* No-break space */
|
||||
{ ISFUNC, rl_insert }, /* Inverted exclamation mark */
|
||||
{ ISFUNC, rl_insert }, /* Cent sign */
|
||||
{ ISFUNC, rl_insert }, /* Pound sign */
|
||||
{ ISFUNC, rl_insert }, /* Currency sign */
|
||||
{ ISFUNC, rl_insert }, /* Yen sign */
|
||||
{ ISFUNC, rl_insert }, /* Broken bar */
|
||||
{ ISFUNC, rl_insert }, /* Section sign */
|
||||
{ ISFUNC, rl_insert }, /* Diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Copyright sign */
|
||||
{ ISFUNC, rl_insert }, /* Feminine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Left pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Not sign */
|
||||
{ ISFUNC, rl_insert }, /* Soft hyphen */
|
||||
{ ISFUNC, rl_insert }, /* Registered sign */
|
||||
{ ISFUNC, rl_insert }, /* Macron */
|
||||
{ ISFUNC, rl_insert }, /* Degree sign */
|
||||
{ ISFUNC, rl_insert }, /* Plus-minus sign */
|
||||
{ ISFUNC, rl_insert }, /* Superscript two */
|
||||
{ ISFUNC, rl_insert }, /* Superscript three */
|
||||
{ ISFUNC, rl_insert }, /* Acute accent */
|
||||
{ ISFUNC, rl_insert }, /* Micro sign */
|
||||
{ ISFUNC, rl_insert }, /* Pilcrow sign */
|
||||
{ ISFUNC, rl_insert }, /* Middle dot */
|
||||
{ ISFUNC, rl_insert }, /* Cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Superscript one */
|
||||
{ ISFUNC, rl_insert }, /* Masculine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Right pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one quarter */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one half */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction three quarters */
|
||||
{ ISFUNC, rl_insert }, /* Inverted questionk mark */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Multiplication sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter Y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter sharp s (German) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Division sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert } /* Latin small letter y with diaeresis */
|
||||
#endif /* MEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
||||
|
|
@ -214,7 +369,7 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
|||
{ ISFUNC, (Function *)0x0 }, /* Meta-# */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-$ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-% */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-& */
|
||||
{ ISFUNC, rl_tilde_expand }, /* Meta-& */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-' */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-( */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-) */
|
||||
|
|
@ -275,12 +430,12 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
|||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, rl_arrow_keys }, /* Meta-[ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-\ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-] */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-^ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-_ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-` */
|
||||
{ ISFUNC, rl_arrow_keys }, /* Meta-[ */
|
||||
{ ISFUNC, rl_delete_horizontal_space }, /* Meta-\ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-] */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-^ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-_ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-` */
|
||||
|
||||
/* Lowercase alphabet. */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-a */
|
||||
|
|
@ -296,9 +451,9 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
|||
{ ISFUNC, (Function *)0x0 }, /* Meta-k */
|
||||
{ ISFUNC, rl_downcase_word }, /* Meta-l */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-m */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-n */
|
||||
{ ISFUNC, rl_noninc_forward_search }, /* Meta-n */
|
||||
{ ISFUNC, rl_arrow_keys }, /* Meta-o */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-p */
|
||||
{ ISFUNC, rl_noninc_reverse_search }, /* Meta-p */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-q */
|
||||
{ ISFUNC, rl_revert_line }, /* Meta-r */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-s */
|
||||
|
|
@ -315,7 +470,139 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
|||
{ ISFUNC, (Function *)0x0 }, /* Meta-| */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-} */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Meta-~ */
|
||||
{ ISFUNC, rl_backward_kill_word } /* Meta-rubout */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* Meta-rubout */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = {
|
||||
|
|
@ -462,5 +749,137 @@ KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = {
|
|||
{ ISFUNC, (Function *)0x0 }, /* | */
|
||||
{ ISFUNC, (Function *)0x0 }, /* } */
|
||||
{ ISFUNC, (Function *)0x0 }, /* ~ */
|
||||
{ ISFUNC, rl_backward_kill_line } /* RUBOUT */
|
||||
{ ISFUNC, rl_backward_kill_line }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -247,11 +247,7 @@ com_list (arg)
|
|||
if (!arg)
|
||||
arg = "*";
|
||||
|
||||
#ifdef __GO32__
|
||||
sprintf (syscom, "ls -lp %s", arg);
|
||||
#else
|
||||
sprintf (syscom, "ls -FClg %s", arg);
|
||||
#endif
|
||||
system (syscom);
|
||||
}
|
||||
|
||||
|
|
@ -397,49 +393,3 @@ 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
|
||||
|
|
|
|||
|
|
@ -1,33 +1,40 @@
|
|||
/* funmap.c -- attach names to functions. */
|
||||
|
||||
/* Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Readline, a library for reading lines
|
||||
of text with interactive input and history editing.
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
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
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* #define STATIC_MALLOC */
|
||||
#if !defined (STATIC_MALLOC)
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* STATIC_MALLOC */
|
||||
|
||||
#include "sysdep.h"
|
||||
#if !defined (BUFSIZ)
|
||||
#include <stdio.h>
|
||||
#endif /* BUFSIZ */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include "readline.h"
|
||||
|
||||
|
|
@ -56,6 +63,7 @@ static FUNMAP default_funmap[] = {
|
|||
{ "clear-screen", rl_clear_screen },
|
||||
{ "complete", rl_complete },
|
||||
{ "delete-char", rl_delete },
|
||||
{ "delete-horizontal-space", rl_delete_horizontal_space },
|
||||
{ "digit-argument", rl_digit_argument },
|
||||
{ "do-lowercase-version", rl_do_lowercase_version },
|
||||
{ "downcase-word", rl_downcase_word },
|
||||
|
|
@ -66,9 +74,12 @@ static FUNMAP default_funmap[] = {
|
|||
{ "forward-char", rl_forward },
|
||||
{ "forward-search-history", rl_forward_search_history },
|
||||
{ "forward-word", rl_forward_word },
|
||||
{ "insert-completions", rl_insert_completions },
|
||||
{ "kill-line", rl_kill_line },
|
||||
{ "kill-word", rl_kill_word },
|
||||
{ "next-history", rl_get_next_history },
|
||||
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
|
||||
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
|
||||
{ "possible-completions", rl_possible_completions },
|
||||
{ "previous-history", rl_get_previous_history },
|
||||
{ "quoted-insert", rl_quoted_insert },
|
||||
|
|
@ -107,7 +118,6 @@ static FUNMAP default_funmap[] = {
|
|||
{ "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 },
|
||||
|
|
@ -125,7 +135,7 @@ static FUNMAP default_funmap[] = {
|
|||
{ "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-replace", rl_vi_replace },
|
||||
{ "vi-search", rl_vi_search },
|
||||
{ "vi-search-again", rl_vi_search_again },
|
||||
{ "vi-subst", rl_vi_subst },
|
||||
|
|
@ -158,6 +168,7 @@ rl_add_funmap_entry (name, function)
|
|||
static int funmap_initialized = 0;
|
||||
|
||||
/* Make the funmap contain all of the default entries. */
|
||||
void
|
||||
rl_initialize_funmap ()
|
||||
{
|
||||
register int i;
|
||||
|
|
@ -177,7 +188,12 @@ static int
|
|||
qsort_string_compare (s1, s2)
|
||||
register char **s1, **s2;
|
||||
{
|
||||
return (strcmp (*s1, *s2));
|
||||
int r;
|
||||
|
||||
r = **s1 - **s2;
|
||||
if (r == 0)
|
||||
r = strcmp (*s1, *s2);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Produce a NULL terminated array of known function names. The array
|
||||
|
|
|
|||
|
|
@ -1,48 +1,79 @@
|
|||
/* History.c -- standalone history library */
|
||||
|
||||
/* Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
The 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. */
|
||||
|
||||
/* The goal is to make the implementation transparent, so that you
|
||||
don't have to know what data types are used, just what functions
|
||||
you can call. I think I have done that. */
|
||||
|
||||
/* Remove these declarations when we have a complete libgnu.a. */
|
||||
#if !defined (STATIC_MALLOC)
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#endif
|
||||
#else
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* STATIC_MALLOC */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifndef NO_SYS_FILE
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
#include <errno.h>
|
||||
|
||||
/* Not all systems declare ERRNO in errno.h... and some systems #define it! */
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# else
|
||||
extern char *alloca ();
|
||||
# endif /* sparc || HAVE_ALLOCA_H */
|
||||
#endif /* !__GNU_C__ */
|
||||
|
||||
#include "history.h"
|
||||
|
||||
#ifndef savestring
|
||||
#define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
|
||||
extern char *xmalloc ();
|
||||
# ifndef strcpy
|
||||
extern char *strcpy ();
|
||||
# endif
|
||||
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
|
||||
#endif
|
||||
|
||||
#ifndef whitespace
|
||||
|
|
@ -54,9 +85,16 @@ static char *xmalloc (), *xrealloc ();
|
|||
#endif
|
||||
|
||||
#ifndef member
|
||||
#define member(c, s) ((c) ? index ((s), (c)) : 0)
|
||||
# ifndef strchr
|
||||
extern char *strchr ();
|
||||
# endif
|
||||
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
|
||||
#endif
|
||||
|
||||
static char error_pointer;
|
||||
|
||||
static char *get_history_word_specifier ();
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Functions */
|
||||
|
|
@ -108,6 +146,32 @@ char *history_no_expand_chars = " \t\n\r=";
|
|||
/* The logical `base' of the history array. It defaults to 1. */
|
||||
int history_base = 1;
|
||||
|
||||
/* Return the current HISTORY_STATE of the history. */
|
||||
HISTORY_STATE *
|
||||
history_get_history_state ()
|
||||
{
|
||||
HISTORY_STATE *state;
|
||||
|
||||
state = (HISTORY_STATE *)xmalloc (sizeof (HISTORY_STATE));
|
||||
state->entries = the_history;
|
||||
state->offset = history_offset;
|
||||
state->length = history_length;
|
||||
state->size = history_size;
|
||||
|
||||
return (state);
|
||||
}
|
||||
|
||||
/* Set the state of the current history array to STATE. */
|
||||
void
|
||||
history_set_history_state (state)
|
||||
HISTORY_STATE *state;
|
||||
{
|
||||
the_history = state->entries;
|
||||
history_offset = state->offset;
|
||||
history_length = state->length;
|
||||
history_size = state->size;
|
||||
}
|
||||
|
||||
/* Begin a session in which the history functions might be used. This
|
||||
initializes interactive variables. */
|
||||
void
|
||||
|
|
@ -179,7 +243,7 @@ add_history (string)
|
|||
xrealloc (the_history,
|
||||
((history_size += DEFAULT_HISTORY_GROW_SIZE)
|
||||
* sizeof (HIST_ENTRY *)));
|
||||
}
|
||||
}
|
||||
history_length++;
|
||||
}
|
||||
}
|
||||
|
|
@ -372,6 +436,7 @@ stifle_history (max)
|
|||
{
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
|
||||
if (history_length > max)
|
||||
{
|
||||
register int i, j;
|
||||
|
|
@ -382,12 +447,14 @@ stifle_history (max)
|
|||
free (the_history[i]->line);
|
||||
free (the_history[i]);
|
||||
}
|
||||
|
||||
history_base = i;
|
||||
for (j = 0, i = history_length - max; j < max; i++, j++)
|
||||
the_history[j] = the_history[i];
|
||||
the_history[j] = (HIST_ENTRY *)NULL;
|
||||
history_length = j;
|
||||
}
|
||||
|
||||
history_stifled = 1;
|
||||
max_input_history = max;
|
||||
}
|
||||
|
|
@ -399,11 +466,13 @@ int
|
|||
unstifle_history ()
|
||||
{
|
||||
int result = max_input_history;
|
||||
|
||||
if (history_stifled)
|
||||
{
|
||||
result = - result;
|
||||
result = -result;
|
||||
history_stifled = 0;
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
@ -418,11 +487,18 @@ history_filename (filename)
|
|||
|
||||
if (!return_val)
|
||||
{
|
||||
char *home = (char *)getenv ("HOME");
|
||||
if (!home) home = ".";
|
||||
char *home;
|
||||
|
||||
home = getenv ("HOME");
|
||||
|
||||
if (!home)
|
||||
home = ".";
|
||||
|
||||
return_val = (char *)xmalloc (2 + strlen (home) + strlen (".history"));
|
||||
|
||||
sprintf (return_val, "%s/.history", home);
|
||||
}
|
||||
|
||||
return (return_val);
|
||||
}
|
||||
|
||||
|
|
@ -450,7 +526,6 @@ read_history_range (filename, from, to)
|
|||
char *input, *buffer = (char *)NULL;
|
||||
int file, current_line;
|
||||
struct stat finfo;
|
||||
extern int errno;
|
||||
|
||||
input = history_filename (filename);
|
||||
file = open (input, O_RDONLY, 0666);
|
||||
|
|
@ -459,7 +534,7 @@ read_history_range (filename, from, to)
|
|||
(stat (input, &finfo) == -1))
|
||||
goto error_and_exit;
|
||||
|
||||
buffer = (char *)xmalloc (finfo.st_size + 1);
|
||||
buffer = (char *)xmalloc ((int)finfo.st_size + 1);
|
||||
|
||||
if (read (file, buffer, finfo.st_size) != finfo.st_size)
|
||||
error_and_exit:
|
||||
|
|
@ -467,6 +542,9 @@ read_history_range (filename, from, to)
|
|||
if (file >= 0)
|
||||
close (file);
|
||||
|
||||
if (input)
|
||||
free (input);
|
||||
|
||||
if (buffer)
|
||||
free (buffer);
|
||||
|
||||
|
|
@ -511,17 +589,25 @@ read_history_range (filename, from, to)
|
|||
|
||||
line_start = line_end + 1;
|
||||
}
|
||||
|
||||
if (input)
|
||||
free (input);
|
||||
|
||||
if (buffer)
|
||||
free (buffer);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Truncate the history file FNAME, leaving only LINES trailing lines.
|
||||
If FNAME is NULL, then use ~/.history. */
|
||||
int
|
||||
history_truncate_file (fname, lines)
|
||||
char *fname;
|
||||
register int lines;
|
||||
{
|
||||
register int i;
|
||||
int file;
|
||||
int file, chars_read;
|
||||
char *buffer = (char *)NULL, *filename;
|
||||
struct stat finfo;
|
||||
|
||||
|
|
@ -534,13 +620,16 @@ history_truncate_file (fname, lines)
|
|||
if (file == -1)
|
||||
goto truncate_exit;
|
||||
|
||||
buffer = (char *)xmalloc (finfo.st_size + 1);
|
||||
read (file, buffer, finfo.st_size);
|
||||
buffer = (char *)xmalloc ((int)finfo.st_size + 1);
|
||||
chars_read = read (file, buffer, finfo.st_size);
|
||||
close (file);
|
||||
|
||||
if (chars_read <= 0)
|
||||
goto truncate_exit;
|
||||
|
||||
/* Count backwards from the end of buffer until we have passed
|
||||
LINES lines. */
|
||||
for (i = finfo.st_size; lines && i; i--)
|
||||
for (i = chars_read - 1; lines && i; i--)
|
||||
{
|
||||
if (buffer[i] == '\n')
|
||||
lines--;
|
||||
|
|
@ -572,6 +661,7 @@ history_truncate_file (fname, lines)
|
|||
free (buffer);
|
||||
|
||||
free (filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define HISTORY_APPEND 0
|
||||
|
|
@ -585,8 +675,7 @@ history_do_write (filename, nelements, overwrite)
|
|||
char *filename;
|
||||
int nelements, overwrite;
|
||||
{
|
||||
extern int errno;
|
||||
register int i, j;
|
||||
register int i;
|
||||
char *output = history_filename (filename);
|
||||
int file, mode;
|
||||
|
||||
|
|
@ -596,7 +685,12 @@ history_do_write (filename, nelements, overwrite)
|
|||
mode = O_WRONLY | O_APPEND;
|
||||
|
||||
if ((file = open (output, mode, 0666)) == -1)
|
||||
return (errno);
|
||||
{
|
||||
if (output)
|
||||
free (output);
|
||||
|
||||
return (errno);
|
||||
}
|
||||
|
||||
if (nelements > history_length)
|
||||
nelements = history_length;
|
||||
|
|
@ -627,9 +721,13 @@ history_do_write (filename, nelements, overwrite)
|
|||
}
|
||||
|
||||
close (file);
|
||||
|
||||
if (output)
|
||||
free (output);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* Append NELEMENT entries to FILENAME. The entries appended are from
|
||||
the end of the list minus NELEMENTs up to the end of the list. */
|
||||
int
|
||||
|
|
@ -700,13 +798,13 @@ HIST_ENTRY *
|
|||
history_get (offset)
|
||||
int offset;
|
||||
{
|
||||
int index = offset - history_base;
|
||||
int local_index = offset - history_base;
|
||||
|
||||
if (index >= history_length ||
|
||||
index < 0 ||
|
||||
if (local_index >= history_length ||
|
||||
local_index < 0 ||
|
||||
!the_history)
|
||||
return ((HIST_ENTRY *)NULL);
|
||||
return (the_history[index]);
|
||||
return (the_history[local_index]);
|
||||
}
|
||||
|
||||
/* Search for STRING in the history list. DIR is < 0 for searching
|
||||
|
|
@ -801,7 +899,6 @@ get_history_event (string, caller_index, delimiting_quote)
|
|||
}
|
||||
|
||||
/* Hack case of numeric line specification. */
|
||||
read_which:
|
||||
if (string[i] == '-')
|
||||
{
|
||||
sign = -1;
|
||||
|
|
@ -834,7 +931,7 @@ get_history_event (string, caller_index, delimiting_quote)
|
|||
a '?', then the string may be anywhere on the line. Otherwise,
|
||||
the string must be found at the start of a line. */
|
||||
{
|
||||
int index;
|
||||
int local_index;
|
||||
char *temp;
|
||||
int substring_okay = 0;
|
||||
|
||||
|
|
@ -844,17 +941,20 @@ get_history_event (string, caller_index, delimiting_quote)
|
|||
i++;
|
||||
}
|
||||
|
||||
for (index = i; string[i]; i++)
|
||||
for (local_index = i; string[i]; i++)
|
||||
if (whitespace (string[i]) ||
|
||||
string[i] == '\n' ||
|
||||
string[i] == ':' ||
|
||||
(substring_okay && string[i] == '?') ||
|
||||
#if defined (SHELL)
|
||||
member (string[i], ";&()|<>") ||
|
||||
#endif /* SHELL */
|
||||
string[i] == delimiting_quote)
|
||||
break;
|
||||
|
||||
temp = (char *)alloca (1 + (i - index));
|
||||
strncpy (temp, &string[index], (i - index));
|
||||
temp[i - index] = '\0';
|
||||
temp = (char *)alloca (1 + (i - local_index));
|
||||
strncpy (temp, &string[local_index], (i - local_index));
|
||||
temp[i - local_index] = '\0';
|
||||
|
||||
if (string[i] == '?')
|
||||
i++;
|
||||
|
|
@ -863,19 +963,18 @@ get_history_event (string, caller_index, delimiting_quote)
|
|||
|
||||
search_again:
|
||||
|
||||
index = history_search_internal
|
||||
local_index = history_search_internal
|
||||
(temp, -1, substring_okay ? NON_ANCHORED_SEARCH : ANCHORED_SEARCH);
|
||||
|
||||
if (index < 0)
|
||||
if (local_index < 0)
|
||||
search_lost:
|
||||
{
|
||||
history_offset = history_length;
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
if (local_index == 0 || substring_okay)
|
||||
{
|
||||
search_won:
|
||||
entry = current_history ();
|
||||
history_offset = history_length;
|
||||
|
||||
|
|
@ -900,6 +999,28 @@ get_history_event (string, caller_index, delimiting_quote)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined (SHELL)
|
||||
/* Function for extracting single-quoted strings. Used for inhibiting
|
||||
history expansion within single quotes. */
|
||||
|
||||
/* Extract the contents of STRING as if it is enclosed in single quotes.
|
||||
SINDEX, when passed in, is the offset of the character immediately
|
||||
following the opening single quote; on exit, SINDEX is left pointing
|
||||
to the closing single quote. */
|
||||
static void
|
||||
rl_string_extract_single_quoted (string, sindex)
|
||||
char *string;
|
||||
int *sindex;
|
||||
{
|
||||
register int i = *sindex;
|
||||
|
||||
while (string[i] && string[i] != '\'')
|
||||
i++;
|
||||
|
||||
*sindex = i;
|
||||
}
|
||||
#endif /* SHELL */
|
||||
|
||||
/* Expand the string STRING, placing the result into OUTPUT, a pointer
|
||||
to a string. Returns:
|
||||
|
||||
|
|
@ -922,8 +1043,6 @@ history_expand (string, output)
|
|||
char *word_spec, *event;
|
||||
int starting_index, only_printing = 0, substitute_globally = 0;
|
||||
|
||||
char *get_history_word_specifier (), *rindex ();
|
||||
|
||||
/* The output string, and its length. */
|
||||
int len = 0;
|
||||
char *result = (char *)NULL;
|
||||
|
|
@ -932,7 +1051,7 @@ history_expand (string, output)
|
|||
char *temp, tt[2], tbl[3];
|
||||
|
||||
/* Prepare the buffer for printing error messages. */
|
||||
result = (char *)xmalloc (len = 255);
|
||||
result = (char *)xmalloc (len = 256);
|
||||
|
||||
result[0] = tt[1] = tbl[2] = '\0';
|
||||
tbl[0] = '\\';
|
||||
|
|
@ -964,11 +1083,37 @@ history_expand (string, output)
|
|||
/* `!' followed by one of the characters in history_no_expand_chars
|
||||
is NOT an expansion. */
|
||||
for (i = 0; string[i]; i++)
|
||||
if (string[i] == history_expansion_char)
|
||||
if (!string[i + 1] || member (string[i + 1], history_no_expand_chars))
|
||||
continue;
|
||||
else
|
||||
goto grovel;
|
||||
{
|
||||
if (string[i] == history_expansion_char)
|
||||
{
|
||||
if (!string[i + 1] || member (string[i + 1], history_no_expand_chars))
|
||||
continue;
|
||||
#if defined (SHELL)
|
||||
/* The shell uses ! as a pattern negation character in globbing [...]
|
||||
expressions, so let those pass without expansion. */
|
||||
else if (i > 0 && (string[i - 1] == '[') && member (']', string + i))
|
||||
continue;
|
||||
#endif /* SHELL */
|
||||
else
|
||||
goto grovel;
|
||||
}
|
||||
#if defined (SHELL)
|
||||
else if (string[i] == '\'')
|
||||
{
|
||||
/* If this is bash, single quotes inhibit history expansion. */
|
||||
i++;
|
||||
rl_string_extract_single_quoted (string, &i);
|
||||
}
|
||||
else if (string[i] == '\\')
|
||||
{
|
||||
/* If this is bash, allow backslashes to quote single quotes and
|
||||
the history expansion character. */
|
||||
if (string[i + 1] == '\'' || (string[i + 1] == history_expansion_char))
|
||||
i++;
|
||||
}
|
||||
#endif /* SHELL */
|
||||
}
|
||||
|
||||
|
||||
free (result);
|
||||
*output = savestring (string);
|
||||
|
|
@ -978,10 +1123,18 @@ history_expand (string, output)
|
|||
|
||||
for (i = j = 0; i < l; i++)
|
||||
{
|
||||
int passc = 0;
|
||||
int tchar = string[i];
|
||||
|
||||
if (tchar == history_expansion_char)
|
||||
tchar = -3;
|
||||
|
||||
if (passc)
|
||||
{
|
||||
passc = 0;
|
||||
goto add_char;
|
||||
}
|
||||
|
||||
switch (tchar)
|
||||
{
|
||||
case '\\':
|
||||
|
|
@ -992,7 +1145,27 @@ history_expand (string, output)
|
|||
goto do_add;
|
||||
}
|
||||
else
|
||||
goto add_char;
|
||||
{
|
||||
passc++;
|
||||
goto add_char;
|
||||
}
|
||||
|
||||
#if defined (SHELL)
|
||||
case '\'':
|
||||
{
|
||||
/* If this is bash, single quotes inhibit history expansion. */
|
||||
int quote = i, slen;
|
||||
|
||||
++i;
|
||||
rl_string_extract_single_quoted (string, &i);
|
||||
|
||||
slen = i - quote + 2;
|
||||
temp = (char *)alloca (slen);
|
||||
strncpy (temp, string + quote, slen);
|
||||
temp[slen - 1] = '\0';
|
||||
goto do_add;
|
||||
}
|
||||
#endif /* SHELL */
|
||||
|
||||
/* case history_expansion_char: */
|
||||
case -3:
|
||||
|
|
@ -1041,14 +1214,13 @@ history_expand (string, output)
|
|||
if (!event)
|
||||
event_not_found:
|
||||
{
|
||||
int l = 1 + (i - starting_index);
|
||||
int ll = 1 + (i - starting_index);
|
||||
|
||||
temp = (char *)alloca (1 + l);
|
||||
strncpy (temp, string + starting_index, l);
|
||||
temp[l - 1] = 0;
|
||||
temp = (char *)alloca (1 + ll);
|
||||
strncpy (temp, string + starting_index, ll);
|
||||
temp[ll - 1] = 0;
|
||||
sprintf (result, "%s: %s.", temp,
|
||||
word_spec_error ? "Bad word specifier" : "Event not found");
|
||||
error_exit:
|
||||
*output = result;
|
||||
return (-1);
|
||||
}
|
||||
|
|
@ -1061,12 +1233,11 @@ history_expand (string, output)
|
|||
/* There is no such thing as a `malformed word specifier'. However,
|
||||
it is possible for a specifier that has no match. In that case,
|
||||
we complain. */
|
||||
if (word_spec == (char *)-1)
|
||||
bad_word_spec:
|
||||
{
|
||||
word_spec_error++;
|
||||
goto event_not_found;
|
||||
}
|
||||
if (word_spec == (char *)&error_pointer)
|
||||
{
|
||||
word_spec_error++;
|
||||
goto event_not_found;
|
||||
}
|
||||
|
||||
/* If no word specifier, than the thing of interest was the event. */
|
||||
if (!word_spec)
|
||||
|
|
@ -1097,28 +1268,28 @@ history_expand (string, output)
|
|||
|
||||
/* :t discards all but the last part of the pathname. */
|
||||
case 't':
|
||||
tstr = rindex (temp, '/');
|
||||
tstr = strrchr (temp, '/');
|
||||
if (tstr)
|
||||
temp = ++tstr;
|
||||
goto next_special;
|
||||
|
||||
/* :h discards the last part of a pathname. */
|
||||
case 'h':
|
||||
tstr = rindex (temp, '/');
|
||||
tstr = strrchr (temp, '/');
|
||||
if (tstr)
|
||||
*tstr = '\0';
|
||||
goto next_special;
|
||||
|
||||
/* :r discards the suffix. */
|
||||
case 'r':
|
||||
tstr = rindex (temp, '.');
|
||||
tstr = strrchr (temp, '.');
|
||||
if (tstr)
|
||||
*tstr = '\0';
|
||||
goto next_special;
|
||||
|
||||
/* :e discards everything but the suffix. */
|
||||
case 'e':
|
||||
tstr = rindex (temp, '.');
|
||||
tstr = strrchr (temp, '.');
|
||||
if (tstr)
|
||||
temp = tstr;
|
||||
goto next_special;
|
||||
|
|
@ -1126,12 +1297,19 @@ history_expand (string, output)
|
|||
/* :s/this/that substitutes `this' for `that'. */
|
||||
/* :gs/this/that substitutes `this' for `that' globally. */
|
||||
case 'g':
|
||||
#ifdef NOTYET
|
||||
/* :g/this/that is equivalent to :gs/this/that */
|
||||
substitute_globally = 1;
|
||||
if (string[i + 2] == 's')
|
||||
i++;
|
||||
#else
|
||||
if (string[i + 2] == 's')
|
||||
{
|
||||
i++;
|
||||
substitute_globally = 1;
|
||||
goto substitute;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
|
||||
case 's':
|
||||
|
|
@ -1141,7 +1319,7 @@ history_expand (string, output)
|
|||
int delimiter = 0;
|
||||
int si, l_this, l_that, l_temp = strlen (temp);
|
||||
|
||||
if (i + 2 < strlen (string))
|
||||
if (i + 2 < (int)strlen (string))
|
||||
delimiter = string[i + 2];
|
||||
|
||||
if (!delimiter)
|
||||
|
|
@ -1246,8 +1424,8 @@ history_expand (string, output)
|
|||
|
||||
do_add:
|
||||
j += strlen (temp);
|
||||
while (j > len)
|
||||
result = (char *)xrealloc (result, (len += 255));
|
||||
while (j > (len - 1))
|
||||
result = (char *)xrealloc (result, (len += 256));
|
||||
|
||||
strcpy (result + (j - strlen (temp)), temp);
|
||||
}
|
||||
|
|
@ -1265,11 +1443,11 @@ history_expand (string, output)
|
|||
}
|
||||
|
||||
/* Return a consed string which is the word specified in SPEC, and found
|
||||
in FROM. NULL is returned if there is no spec. -1 is returned if
|
||||
the word specified cannot be found. CALLER_INDEX is the offset in
|
||||
SPEC to start looking; it is updated to point to just after the last
|
||||
character parsed. */
|
||||
char *
|
||||
in FROM. NULL is returned if there is no spec. The address of
|
||||
ERROR_POINTER is returned if the word specified cannot be found.
|
||||
CALLER_INDEX is the offset in SPEC to start looking; it is updated
|
||||
to point to just after the last character parsed. */
|
||||
static char *
|
||||
get_history_word_specifier (spec, from, caller_index)
|
||||
char *spec, *from;
|
||||
int *caller_index;
|
||||
|
|
@ -1327,7 +1505,6 @@ get_history_word_specifier (spec, from, caller_index)
|
|||
goto get_last;
|
||||
}
|
||||
|
||||
get_first:
|
||||
if (digit (spec[i]) && expecting_word_spec)
|
||||
{
|
||||
sscanf (spec + i, "%d", &first);
|
||||
|
|
@ -1376,7 +1553,7 @@ get_history_word_specifier (spec, from, caller_index)
|
|||
if (result)
|
||||
return (result);
|
||||
else
|
||||
return ((char *)-1);
|
||||
return ((char *)&error_pointer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1470,38 +1647,40 @@ history_tokenize (string)
|
|||
if (!string[i] || string[i] == history_comment_char)
|
||||
return (result);
|
||||
|
||||
if (member (string[i], "()\n")) {
|
||||
i++;
|
||||
goto got_token;
|
||||
}
|
||||
|
||||
if (member (string[i], "<>;&|")) {
|
||||
int peek = string[i + 1];
|
||||
|
||||
if (peek == string[i]) {
|
||||
if (peek == '<') {
|
||||
if (string[1 + 2] == '-')
|
||||
i++;
|
||||
i += 2;
|
||||
goto got_token;
|
||||
}
|
||||
|
||||
if (member (peek, ">:&|")) {
|
||||
i += 2;
|
||||
goto got_token;
|
||||
}
|
||||
} else {
|
||||
if ((peek == '&' &&
|
||||
(string[i] == '>' || string[i] == '<')) ||
|
||||
((peek == '>') &&
|
||||
(string[i] == '&'))) {
|
||||
i += 2;
|
||||
goto got_token;
|
||||
}
|
||||
if (member (string[i], "()\n"))
|
||||
{
|
||||
i++;
|
||||
goto got_token;
|
||||
}
|
||||
|
||||
if (member (string[i], "<>;&|$"))
|
||||
{
|
||||
int peek = string[i + 1];
|
||||
|
||||
if (peek == string[i] && peek != '$')
|
||||
{
|
||||
if (peek == '<' && string[i + 2] == '-')
|
||||
i++;
|
||||
i += 2;
|
||||
goto got_token;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((peek == '&' &&
|
||||
(string[i] == '>' || string[i] == '<')) ||
|
||||
((peek == '>') && (string[i] == '&')) ||
|
||||
((peek == '(') && (string[i] == '$')))
|
||||
{
|
||||
i += 2;
|
||||
goto got_token;
|
||||
}
|
||||
}
|
||||
if (string[i] != '$')
|
||||
{
|
||||
i++;
|
||||
goto got_token;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
goto got_token;
|
||||
}
|
||||
|
||||
/* Get word from string + i; */
|
||||
{
|
||||
|
|
@ -1510,46 +1689,53 @@ history_tokenize (string)
|
|||
if (member (string[i], "\"'`"))
|
||||
delimiter = string[i++];
|
||||
|
||||
for (;string[i]; i++) {
|
||||
for (;string[i]; i++)
|
||||
{
|
||||
if (string[i] == '\\')
|
||||
{
|
||||
if (string[i + 1] == '\n')
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (delimiter != '\'')
|
||||
if ((delimiter != '"') ||
|
||||
(member (string[i], slashify_in_quotes)))
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string[i] == '\\') {
|
||||
if (delimiter && string[i] == delimiter)
|
||||
{
|
||||
delimiter = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string[i + 1] == '\n') {
|
||||
i++;
|
||||
continue;
|
||||
} else {
|
||||
if (delimiter != '\'')
|
||||
if ((delimiter != '"') ||
|
||||
(member (string[i], slashify_in_quotes))) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!delimiter && (member (string[i], " \t\n;&()|<>")))
|
||||
goto got_token;
|
||||
|
||||
if (!delimiter && member (string[i], "\"'`"))
|
||||
{
|
||||
delimiter = string[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (delimiter && string[i] == delimiter) {
|
||||
delimiter = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!delimiter && (member (string[i], " \t\n;&()|<>")))
|
||||
goto got_token;
|
||||
|
||||
if (!delimiter && member (string[i], "\"'`")) {
|
||||
delimiter = string[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
got_token:
|
||||
|
||||
len = i - start;
|
||||
if (result_index + 2 >= size) {
|
||||
if (!size)
|
||||
result = (char **)xmalloc ((size = 10) * (sizeof (char *)));
|
||||
else
|
||||
result =
|
||||
(char **)xrealloc (result, ((size += 10) * (sizeof (char *))));
|
||||
}
|
||||
if (result_index + 2 >= size)
|
||||
{
|
||||
if (!size)
|
||||
result = (char **)xmalloc ((size = 10) * (sizeof (char *)));
|
||||
else
|
||||
result =
|
||||
(char **)xrealloc (result, ((size += 10) * (sizeof (char *))));
|
||||
}
|
||||
result[result_index] = (char *)xmalloc (1 + len);
|
||||
strncpy (result[result_index], string + start, len);
|
||||
result[result_index][len] = '\0';
|
||||
|
|
@ -1608,7 +1794,6 @@ memory_error_and_abort ()
|
|||
abort ();
|
||||
}
|
||||
#endif /* STATIC_MALLOC */
|
||||
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
|
|
@ -1684,7 +1869,7 @@ main ()
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
#endif /* TEST */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
|
|
|||
377
gnu/lib/libreadline/isearch.c
Normal file
377
gnu/lib/libreadline/isearch.c
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
/* **************************************************************** */
|
||||
/* */
|
||||
/* I-Search and Searching */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
extern Keymap _rl_keymap;
|
||||
extern HIST_ENTRY *saved_line_for_history;
|
||||
extern int rl_line_buffer_len;
|
||||
extern int rl_point, rl_end;
|
||||
extern char *rl_prompt, *rl_line_buffer;
|
||||
|
||||
/* Remove these declarations when we have a complete libgnu.a. */
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
|
||||
static void rl_search_history ();
|
||||
|
||||
/* Search backwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
rl_reverse_search_history (sign, key)
|
||||
int sign;
|
||||
int key;
|
||||
{
|
||||
rl_search_history (-sign, key);
|
||||
}
|
||||
|
||||
/* Search forwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
rl_forward_search_history (sign, key)
|
||||
int sign;
|
||||
int key;
|
||||
{
|
||||
rl_search_history (sign, key);
|
||||
}
|
||||
|
||||
/* Display the current state of the search in the echo-area.
|
||||
SEARCH_STRING contains the string that is being searched for,
|
||||
DIRECTION is zero for forward, or 1 for reverse,
|
||||
WHERE is the history list number of the current line. If it is
|
||||
-1, then this line is the starting one. */
|
||||
static void
|
||||
rl_display_search (search_string, reverse_p, where)
|
||||
char *search_string;
|
||||
int reverse_p, where;
|
||||
{
|
||||
char *message = (char *)NULL;
|
||||
|
||||
message =
|
||||
(char *)xmalloc (1 + (search_string ? strlen (search_string) : 0) + 30);
|
||||
|
||||
*message = '\0';
|
||||
|
||||
#if defined (NOTDEF)
|
||||
if (where != -1)
|
||||
sprintf (message, "[%d]", where + history_base);
|
||||
#endif /* NOTDEF */
|
||||
|
||||
strcat (message, "(");
|
||||
|
||||
if (reverse_p)
|
||||
strcat (message, "reverse-");
|
||||
|
||||
strcat (message, "i-search)`");
|
||||
|
||||
if (search_string)
|
||||
strcat (message, search_string);
|
||||
|
||||
strcat (message, "': ");
|
||||
rl_message ("%s", message, 0);
|
||||
free (message);
|
||||
rl_redisplay ();
|
||||
}
|
||||
|
||||
/* Search through the history looking for an interactively typed string.
|
||||
This is analogous to i-search. We start the search in the current line.
|
||||
DIRECTION is which direction to search; >= 0 means forward, < 0 means
|
||||
backwards. */
|
||||
static void
|
||||
rl_search_history (direction, invoking_key)
|
||||
int direction;
|
||||
int invoking_key;
|
||||
{
|
||||
/* The string that the user types in to search for. */
|
||||
char *search_string;
|
||||
|
||||
/* The current length of SEARCH_STRING. */
|
||||
int search_string_index;
|
||||
|
||||
/* The amount of space that SEARCH_STRING has allocated to it. */
|
||||
int search_string_size;
|
||||
|
||||
/* The list of lines to search through. */
|
||||
char **lines;
|
||||
|
||||
/* The length of LINES. */
|
||||
int hlen;
|
||||
|
||||
/* Where we get LINES from. */
|
||||
HIST_ENTRY **hlist = history_list ();
|
||||
|
||||
register int i = 0;
|
||||
int orig_point = rl_point;
|
||||
int orig_line = where_history ();
|
||||
int last_found_line = orig_line;
|
||||
int c, done = 0;
|
||||
|
||||
/* The line currently being searched. */
|
||||
char *sline;
|
||||
|
||||
/* Offset in that line. */
|
||||
int index;
|
||||
|
||||
/* Non-zero if we are doing a reverse search. */
|
||||
int reverse = (direction < 0);
|
||||
|
||||
/* Create an arrary of pointers to the lines that we want to search. */
|
||||
maybe_replace_line ();
|
||||
if (hlist)
|
||||
for (i = 0; hlist[i]; i++);
|
||||
|
||||
/* Allocate space for this many lines, +1 for the current input line,
|
||||
and remember those lines. */
|
||||
lines = (char **)alloca ((1 + (hlen = i)) * sizeof (char *));
|
||||
for (i = 0; i < hlen; i++)
|
||||
lines[i] = hlist[i]->line;
|
||||
|
||||
if (saved_line_for_history)
|
||||
lines[i] = saved_line_for_history->line;
|
||||
else
|
||||
/* So I have to type it in this way instead. */
|
||||
{
|
||||
char *alloced_line;
|
||||
|
||||
/* Keep that MIPS alloca () happy. */
|
||||
alloced_line = (char *)alloca (1 + strlen (rl_line_buffer));
|
||||
lines[i] = alloced_line;
|
||||
strcpy (lines[i], &rl_line_buffer[0]);
|
||||
}
|
||||
|
||||
hlen++;
|
||||
|
||||
/* The line where we start the search. */
|
||||
i = orig_line;
|
||||
|
||||
/* Initialize search parameters. */
|
||||
search_string = (char *)xmalloc (search_string_size = 128);
|
||||
*search_string = '\0';
|
||||
search_string_index = 0;
|
||||
|
||||
/* Normalize DIRECTION into 1 or -1. */
|
||||
if (direction >= 0)
|
||||
direction = 1;
|
||||
else
|
||||
direction = -1;
|
||||
|
||||
rl_display_search (search_string, reverse, -1);
|
||||
|
||||
sline = rl_line_buffer;
|
||||
index = rl_point;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
c = rl_read_key ();
|
||||
|
||||
/* Hack C to Do What I Mean. */
|
||||
{
|
||||
Function *f = (Function *)NULL;
|
||||
|
||||
if (_rl_keymap[c].type == ISFUNC)
|
||||
{
|
||||
f = _rl_keymap[c].function;
|
||||
|
||||
if (f == rl_reverse_search_history)
|
||||
c = reverse ? -1 : -2;
|
||||
else if (f == rl_forward_search_history)
|
||||
c = !reverse ? -1 : -2;
|
||||
}
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case ESC:
|
||||
done = 1;
|
||||
continue;
|
||||
|
||||
/* case invoking_key: */
|
||||
case -1:
|
||||
goto search_again;
|
||||
|
||||
/* switch directions */
|
||||
case -2:
|
||||
direction = -direction;
|
||||
reverse = (direction < 0);
|
||||
|
||||
goto do_search;
|
||||
|
||||
case CTRL ('G'):
|
||||
strcpy (rl_line_buffer, lines[orig_line]);
|
||||
rl_point = orig_point;
|
||||
rl_end = strlen (rl_line_buffer);
|
||||
rl_clear_message ();
|
||||
return;
|
||||
|
||||
default:
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
rl_execute_next (c);
|
||||
done = 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (search_string_index + 2 >= search_string_size)
|
||||
search_string = (char *)xrealloc
|
||||
(search_string, (search_string_size += 128));
|
||||
search_string[search_string_index++] = c;
|
||||
search_string[search_string_index] = '\0';
|
||||
goto do_search;
|
||||
|
||||
search_again:
|
||||
|
||||
if (!search_string_index)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
--index;
|
||||
else
|
||||
if (index != strlen (sline))
|
||||
++index;
|
||||
else
|
||||
ding ();
|
||||
}
|
||||
do_search:
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (reverse)
|
||||
{
|
||||
while (index >= 0)
|
||||
if (strncmp
|
||||
(search_string, sline + index, search_string_index)
|
||||
== 0)
|
||||
goto string_found;
|
||||
else
|
||||
index--;
|
||||
}
|
||||
else
|
||||
{
|
||||
register int limit =
|
||||
(strlen (sline) - search_string_index) + 1;
|
||||
|
||||
while (index < limit)
|
||||
{
|
||||
if (strncmp (search_string,
|
||||
sline + index,
|
||||
search_string_index) == 0)
|
||||
goto string_found;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
next_line:
|
||||
i += direction;
|
||||
|
||||
/* At limit for direction? */
|
||||
if ((reverse && i < 0) ||
|
||||
(!reverse && i == hlen))
|
||||
goto search_failed;
|
||||
|
||||
sline = lines[i];
|
||||
if (reverse)
|
||||
index = strlen (sline);
|
||||
else
|
||||
index = 0;
|
||||
|
||||
/* If the search string is longer than the current
|
||||
line, no match. */
|
||||
if (search_string_index > (int)strlen (sline))
|
||||
goto next_line;
|
||||
|
||||
/* Start actually searching. */
|
||||
if (reverse)
|
||||
index -= search_string_index;
|
||||
}
|
||||
|
||||
search_failed:
|
||||
/* We cannot find the search string. Ding the bell. */
|
||||
ding ();
|
||||
i = last_found_line;
|
||||
break;
|
||||
|
||||
string_found:
|
||||
/* We have found the search string. Just display it. But don't
|
||||
actually move there in the history list until the user accepts
|
||||
the location. */
|
||||
{
|
||||
int line_len;
|
||||
|
||||
line_len = strlen (lines[i]);
|
||||
|
||||
if (line_len >= rl_line_buffer_len)
|
||||
rl_extend_line_buffer (line_len);
|
||||
|
||||
strcpy (rl_line_buffer, lines[i]);
|
||||
rl_point = index;
|
||||
rl_end = line_len;
|
||||
last_found_line = i;
|
||||
rl_display_search
|
||||
(search_string, reverse, (i == orig_line) ? -1 : i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The searching is over. The user may have found the string that she
|
||||
was looking for, or else she may have exited a failing search. If
|
||||
INDEX is -1, then that shows that the string searched for was not
|
||||
found. We use this to determine where to place rl_point. */
|
||||
{
|
||||
int now = last_found_line;
|
||||
|
||||
/* First put back the original state. */
|
||||
strcpy (rl_line_buffer, lines[orig_line]);
|
||||
|
||||
/* Free the search string. */
|
||||
free (search_string);
|
||||
|
||||
if (now < orig_line)
|
||||
rl_get_previous_history (orig_line - now);
|
||||
else
|
||||
rl_get_next_history (now - orig_line);
|
||||
|
||||
/* If the index of the "matched" string is less than zero, then the
|
||||
final search string was never matched, so put point somewhere
|
||||
reasonable. */
|
||||
if (index < 0)
|
||||
index = strlen (rl_line_buffer);
|
||||
|
||||
rl_point = index;
|
||||
rl_clear_message ();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +1,30 @@
|
|||
/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
|
||||
|
||||
/* Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Readline, a library for reading lines
|
||||
of text with interactive input and history editing.
|
||||
|
||||
Readline is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, 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 1, or (at your option) any
|
||||
later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with Readline; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include <stdio.h>
|
||||
#include "readline.h"
|
||||
#include "keymaps.h"
|
||||
#include "emacs_keymap.c"
|
||||
|
||||
|
|
@ -29,12 +32,10 @@
|
|||
#include "vi_keymap.c"
|
||||
#endif
|
||||
|
||||
/* Remove these declarations when we have a complete libgnu.a. */
|
||||
/* #define STATIC_MALLOC */
|
||||
#if !defined (STATIC_MALLOC)
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* STATIC_MALLOC */
|
||||
|
||||
/* **************************************************************** */
|
||||
|
|
@ -50,9 +51,9 @@ Keymap
|
|||
rl_make_bare_keymap ()
|
||||
{
|
||||
register int i;
|
||||
Keymap keymap = (Keymap)xmalloc (128 * sizeof (KEYMAP_ENTRY));
|
||||
Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
keymap[i].type = ISFUNC;
|
||||
keymap[i].function = (Function *)NULL;
|
||||
|
|
@ -75,7 +76,7 @@ rl_copy_keymap (map)
|
|||
register int i;
|
||||
Keymap temp = rl_make_bare_keymap ();
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
temp[i].type = map[i].type;
|
||||
temp[i].function = map[i].function;
|
||||
|
|
@ -89,13 +90,13 @@ rl_copy_keymap (map)
|
|||
Keymap
|
||||
rl_make_keymap ()
|
||||
{
|
||||
extern rl_insert (), rl_rubout ();
|
||||
extern int rl_insert (), rl_rubout ();
|
||||
register int i;
|
||||
Keymap newmap;
|
||||
|
||||
newmap = rl_make_bare_keymap ();
|
||||
|
||||
/* All printing characters are self-inserting. */
|
||||
/* All ASCII printing characters are self-inserting. */
|
||||
for (i = ' '; i < 126; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
|
||||
|
|
@ -103,6 +104,16 @@ rl_make_keymap ()
|
|||
newmap[RUBOUT].function = rl_rubout;
|
||||
newmap[CTRL('H')].function = rl_rubout;
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Printing characters in some 8-bit character sets. */
|
||||
for (i = 128; i < 160; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
|
||||
/* ISO Latin-1 printing characters should self-insert. */
|
||||
for (i = 160; i < 256; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
|
||||
return (newmap);
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +126,7 @@ rl_discard_keymap (map)
|
|||
if (!map)
|
||||
return;
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
switch (map[i].type)
|
||||
{
|
||||
|
|
@ -133,7 +144,7 @@ rl_discard_keymap (map)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef STATIC_MALLOC
|
||||
#if defined (STATIC_MALLOC)
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
|
|
|
|||
117
gnu/lib/libreadline/parens.c
Normal file
117
gnu/lib/libreadline/parens.c
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/* parens.c -- Implemenation of matching parenthesis feature. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#if defined (FD_SET)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "readline.h"
|
||||
|
||||
/* Non-zero means try to blink the matching open parenthesis when the
|
||||
close parenthesis is inserted. */
|
||||
#if defined (FD_SET)
|
||||
int rl_blink_matching_paren = 1;
|
||||
#else /* !FD_SET */
|
||||
int rl_blink_matching_paren = 0;
|
||||
#endif /* !FD_SET */
|
||||
|
||||
static int find_matching_open ();
|
||||
|
||||
rl_insert_close (count, invoking_key)
|
||||
int count, invoking_key;
|
||||
{
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
if (rl_explicit_arg || !rl_blink_matching_paren)
|
||||
rl_insert (count, invoking_key);
|
||||
else
|
||||
{
|
||||
#if defined (FD_SET)
|
||||
int orig_point, match_point, ready;
|
||||
struct timeval timer;
|
||||
fd_set readfds;
|
||||
|
||||
rl_insert (1, invoking_key);
|
||||
rl_redisplay ();
|
||||
match_point =
|
||||
find_matching_open (rl_line_buffer, rl_point - 2, invoking_key);
|
||||
|
||||
/* Emacs might message or ring the bell here, but I don't. */
|
||||
if (match_point < 0)
|
||||
return;
|
||||
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (fileno (rl_instream), &readfds);
|
||||
timer.tv_sec = 1;
|
||||
timer.tv_usec = 500;
|
||||
|
||||
orig_point = rl_point;
|
||||
rl_point = match_point;
|
||||
rl_redisplay ();
|
||||
ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer);
|
||||
rl_point = orig_point;
|
||||
#else /* !FD_SET */
|
||||
rl_insert (count, invoking_key);
|
||||
#endif /* !FD_SET */
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
find_matching_open (string, from, closer)
|
||||
char *string;
|
||||
int from, closer;
|
||||
{
|
||||
register int i;
|
||||
int opener, level, delimiter;
|
||||
|
||||
switch (closer)
|
||||
{
|
||||
case ']': opener = '['; break;
|
||||
case '}': opener = '{'; break;
|
||||
case ')': opener = '('; break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
|
||||
level = 1; /* The closer passed in counts as 1. */
|
||||
delimiter = 0; /* Delimited state unknown. */
|
||||
|
||||
for (i = from; i > -1; i--)
|
||||
{
|
||||
if (delimiter && (string[i] == delimiter))
|
||||
delimiter = 0;
|
||||
else if ((string[i] == '\'') || (string[i] == '"'))
|
||||
delimiter = rl_line_buffer[i];
|
||||
else if (!delimiter && (string[i] == closer))
|
||||
level++;
|
||||
else if (!delimiter && (string[i] == opener))
|
||||
level--;
|
||||
|
||||
if (!level)
|
||||
break;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
149
gnu/lib/libreadline/posixstat.h
Normal file
149
gnu/lib/libreadline/posixstat.h
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/* posixstat.h -- Posix stat(2) definitions for systems that
|
||||
don't have them. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* This file should be included instead of <sys/stat.h>.
|
||||
It relies on the local sys/stat.h to work though. */
|
||||
#if !defined (_POSIXSTAT_H)
|
||||
#define _POSIXSTAT_H
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined (isc386)
|
||||
# if !defined (S_IFDIR)
|
||||
# define S_IFDIR 0040000
|
||||
# endif /* !S_IFDIR */
|
||||
# if !defined (S_IFMT)
|
||||
# define S_IFMT 0170000
|
||||
# endif /* !S_IFMT */
|
||||
#endif /* isc386 */
|
||||
|
||||
/* This text is taken directly from the Cadmus I was trying to
|
||||
compile on:
|
||||
the following MACROs are defined for X/OPEN compatibility
|
||||
however, is the param correct ??
|
||||
#define S_ISBLK(s) ((s.st_mode & S_IFMT) == S_IFBLK)
|
||||
|
||||
Well, the answer is no. Thus... */
|
||||
#if defined (BrainDeath)
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
# undef S_ISDIR
|
||||
# undef S_ISFIFO
|
||||
# undef S_ISREG
|
||||
#endif /* BrainDeath */
|
||||
|
||||
/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
|
||||
|
||||
/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
|
||||
do not provide the S_IS* macros that Posix requires. */
|
||||
|
||||
#if defined (_S_IFMT) && !defined (S_IFMT)
|
||||
#define S_IFMT _S_IFMT
|
||||
#endif
|
||||
#if defined (_S_IFIFO) && !defined (S_IFIFO)
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#endif
|
||||
#if defined (_S_IFCHR) && !defined (S_IFCHR)
|
||||
#define S_IFCHR _S_IFCHR
|
||||
#endif
|
||||
#if defined (_S_IFDIR) && !defined (S_IFDIR)
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#endif
|
||||
#if defined (_S_IFBLK) && !defined (S_IFBLK)
|
||||
#define S_IFBLK _S_IFBLK
|
||||
#endif
|
||||
#if defined (_S_IFREG) && !defined (S_IFREG)
|
||||
#define S_IFREG _S_IFREG
|
||||
#endif
|
||||
#if defined (_S_IFLNK) && !defined (S_IFLNK)
|
||||
#define S_IFLNK _S_IFLNK
|
||||
#endif
|
||||
#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
|
||||
#define S_IFSOCK _S_IFSOCK
|
||||
#endif
|
||||
|
||||
/* Test for each symbol individually and define the ones necessary (some
|
||||
systems claiming Posix compatibility define some but not all). */
|
||||
|
||||
#if defined (S_IFBLK) && !defined (S_ISBLK)
|
||||
#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFCHR) && !defined (S_ISCHR)
|
||||
#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFREG) && !defined (S_ISREG)
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFIFO) && !defined (S_ISFIFO)
|
||||
#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFLNK) && !defined (S_ISLNK)
|
||||
#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFSOCK) && !defined (S_ISSOCK)
|
||||
#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
|
||||
*/
|
||||
|
||||
#if !defined (S_IRWXU)
|
||||
# if !defined (S_IREAD)
|
||||
# define S_IREAD 00400
|
||||
# define S_IWRITE 00200
|
||||
# define S_IEXEC 00100
|
||||
# endif /* S_IREAD */
|
||||
|
||||
# if !defined (S_IRUSR)
|
||||
# define S_IRUSR S_IREAD /* read, owner */
|
||||
# define S_IWUSR S_IWRITE /* write, owner */
|
||||
# define S_IXUSR S_IEXEC /* execute, owner */
|
||||
|
||||
# define S_IRGRP (S_IREAD >> 3) /* read, group */
|
||||
# define S_IWGRP (S_IWRITE >> 3) /* write, group */
|
||||
# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
|
||||
|
||||
# define S_IROTH (S_IREAD >> 6) /* read, other */
|
||||
# define S_IWOTH (S_IWRITE >> 6) /* write, other */
|
||||
# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
|
||||
# endif /* !S_IRUSR */
|
||||
|
||||
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
||||
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
||||
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
||||
#endif /* !S_IRWXU */
|
||||
|
||||
/* These are non-standard, but are used in builtins.c$symbolic_umask() */
|
||||
#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
|
||||
#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
|
||||
#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
|
||||
|
||||
#endif /* _POSIXSTAT_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,8 +1,24 @@
|
|||
/* chardefs.h -- Character definitions for readline. */
|
||||
#ifndef _CHARDEFS_
|
||||
#define _CHARDEFS_
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef HAVE_STRING_H
|
||||
#define HAVE_STRING_H
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
|
||||
#ifndef savestring
|
||||
#define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
|
||||
#ifndef STATIC_MALLOC
|
||||
extern char *xmalloc ();
|
||||
#endif
|
||||
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
|
||||
#endif
|
||||
|
||||
#ifndef whitespace
|
||||
|
|
@ -14,11 +30,13 @@
|
|||
#endif
|
||||
|
||||
/* Some character stuff. */
|
||||
#define control_character_threshold 0x020 /* smaller than this is control */
|
||||
#define meta_character_threshold 0x07f /* larger than this is Meta. */
|
||||
#define control_character_threshold 0x020 /* Smaller than this is control. */
|
||||
#define meta_character_threshold 0x07f /* Larger than this is Meta. */
|
||||
#define control_character_bit 0x40 /* 0x000000, must be off. */
|
||||
#define meta_character_bit 0x080 /* x0000000, must be on. */
|
||||
#define largest_char 255 /* Largest character value. */
|
||||
|
||||
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
|
||||
#define CTRL(c) ((c) & (~control_character_bit))
|
||||
#define META(c) ((c) | meta_character_bit)
|
||||
|
||||
|
|
@ -38,13 +56,41 @@
|
|||
#define CTRL_P(c) ((c) < control_character_threshold)
|
||||
#define META_P(c) ((c) > meta_character_threshold)
|
||||
|
||||
#ifndef NEWLINE
|
||||
#define NEWLINE '\n'
|
||||
#endif
|
||||
|
||||
#ifndef RETURN
|
||||
#define RETURN CTRL('M')
|
||||
#endif
|
||||
|
||||
#ifndef RUBOUT
|
||||
#define RUBOUT 0x07f
|
||||
#endif
|
||||
|
||||
#ifndef TAB
|
||||
#define TAB '\t'
|
||||
#endif
|
||||
|
||||
#ifdef ABORT_CHAR
|
||||
#undef ABORT_CHAR
|
||||
#endif
|
||||
#define ABORT_CHAR CTRL('G')
|
||||
|
||||
#ifdef PAGE
|
||||
#undef PAGE
|
||||
#endif
|
||||
#define PAGE CTRL('L')
|
||||
|
||||
#ifdef SPACE
|
||||
#undef SPACE
|
||||
#endif
|
||||
#define SPACE 0x020
|
||||
|
||||
#ifdef ESC
|
||||
#undef ESC
|
||||
#endif
|
||||
|
||||
#define ESC CTRL('[')
|
||||
|
||||
#endif /* _CHARDEFS_ */
|
||||
|
|
|
|||
|
|
@ -6,6 +6,14 @@ typedef struct _hist_entry {
|
|||
char *data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
/* A structure used to pass the current state of the history stuff around. */
|
||||
typedef struct _hist_state {
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
int offset; /* The location pointer within this array. */
|
||||
int length; /* Number of elements within this array. */
|
||||
int size; /* Number of slots allocated to this array. */
|
||||
} HISTORY_STATE;
|
||||
|
||||
/* For convenience only. You set this when interpreting history commands.
|
||||
It is the logical offset of the first history element. */
|
||||
extern int history_base;
|
||||
|
|
@ -14,6 +22,12 @@ extern int history_base;
|
|||
just initializes the interactive variables. */
|
||||
extern void using_history ();
|
||||
|
||||
/* Return the current HISTORY_STATE of the history. */
|
||||
extern HISTORY_STATE *history_get_history_state ();
|
||||
|
||||
/* Set the state of the current history array to STATE. */
|
||||
extern void history_set_history_state ();
|
||||
|
||||
/* Place STRING at the end of the history list.
|
||||
The associated data field (if any) is set to NULL. */
|
||||
extern void add_history ();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,36 @@
|
|||
/* keymaps.h -- Manipulation of readline keymaps. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifndef _KEYMAPS_H_
|
||||
#define _KEYMAPS_H_
|
||||
|
||||
#include <readline/chardefs.h>
|
||||
|
||||
#ifndef __FUNCTION_DEF
|
||||
#if !defined (__FUNCTION_DEF)
|
||||
# define __FUNCTION_DEF
|
||||
typedef int Function ();
|
||||
#define __FUNCTION_DEF
|
||||
typedef void VFunction ();
|
||||
typedef char *CPFunction ();
|
||||
typedef char **CPPFunction ();
|
||||
#endif
|
||||
|
||||
/* A keymap contains one entry for each key in the ASCII set.
|
||||
|
|
@ -20,12 +43,17 @@ typedef struct _keymap_entry {
|
|||
Function *function;
|
||||
} KEYMAP_ENTRY;
|
||||
|
||||
/* This must be large enough to hold bindings for all of the characters
|
||||
in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
|
||||
and so on). */
|
||||
#define KEYMAP_SIZE 256
|
||||
|
||||
/* I wanted to make the above structure contain a union of:
|
||||
union { Function *function; struct _keymap_entry *keymap; } value;
|
||||
but this made it impossible for me to create a static array.
|
||||
Maybe I need C lessons. */
|
||||
|
||||
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[128];
|
||||
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
|
||||
typedef KEYMAP_ENTRY *Keymap;
|
||||
|
||||
/* The values that TYPE can have in a keymap entry. */
|
||||
|
|
@ -48,4 +76,14 @@ Keymap rl_copy_keymap ();
|
|||
the Meta digits bound to produce numeric arguments. */
|
||||
Keymap rl_make_keymap ();
|
||||
|
||||
/* Return the keymap corresponding to a given name. Names look like
|
||||
`emacs' or `emacs-meta' or `vi-insert'. */
|
||||
Keymap rl_get_keymap_by_name ();
|
||||
|
||||
/* Return the current keymap. */
|
||||
Keymap rl_get_keymap ();
|
||||
|
||||
/* Set the current keymap to MAP. */
|
||||
void rl_set_keymap ();
|
||||
|
||||
#endif /* _KEYMAPS_H_ */
|
||||
|
|
|
|||
|
|
@ -1,18 +1,34 @@
|
|||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (_READLINE_H_)
|
||||
#define _READLINE_H_
|
||||
|
||||
#include <readline/keymaps.h>
|
||||
|
||||
#if !defined (__FUNCTION_DEF)
|
||||
typedef int Function ();
|
||||
#define __FUNCTION_DEF
|
||||
#endif /* __FUNCTION_DEF */
|
||||
|
||||
/* The functions for manipulating the text of the line within readline.
|
||||
Most of these functions are bound to keys by default. */
|
||||
extern int
|
||||
rl_tilde_expand (),
|
||||
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 (),
|
||||
|
|
@ -21,19 +37,32 @@ extern int
|
|||
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_complete (), rl_possible_completions (), rl_insert_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 ();
|
||||
rl_restart_output (), rl_re_read_init_file (), rl_dump_functions (),
|
||||
rl_delete_horizontal_space ();
|
||||
|
||||
/* #define PAREN_MATCHING */
|
||||
#if defined (PAREN_MATCHING)
|
||||
extern int rl_insert_close ();
|
||||
#endif /* PAREN_MATCHING */
|
||||
|
||||
/* These are *both* defined even when VI_MODE is not. */
|
||||
extern int rl_vi_editing_mode (), rl_emacs_editing_mode ();
|
||||
|
||||
/* Non incremental history searching. */
|
||||
extern int
|
||||
rl_noninc_forward_search (), rl_noninc_reverse_search (),
|
||||
rl_noninc_forward_search_again (), rl_noninc_reverse_search_again ();
|
||||
|
||||
#if defined (VI_MODE)
|
||||
/* Things for vi mode. */
|
||||
extern int
|
||||
rl_vi_redo (), rl_vi_tilde_expand (),
|
||||
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 (),
|
||||
|
|
@ -42,9 +71,9 @@ extern int
|
|||
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_search_again (), 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 */
|
||||
|
||||
|
|
@ -144,13 +173,7 @@ extern Function *rl_ignore_some_completions_function;
|
|||
If this function exists and returns NULL then call the value of
|
||||
rl_completion_entry_function to try to match, otherwise use the
|
||||
array of strings returned. */
|
||||
extern Function *rl_attempted_completion_function;
|
||||
|
||||
/* If non-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 *rl_tilde_expander;
|
||||
extern CPPFunction *rl_attempted_completion_function;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal () prints the first prompt. */
|
||||
|
|
@ -161,8 +184,8 @@ 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. */
|
||||
/* The address of a function to call periodically while Readline is
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
extern Function *rl_event_hook;
|
||||
|
||||
/* Non-zero means that modified history lines are preceded
|
||||
|
|
|
|||
176
gnu/lib/libreadline/rldefs.h
Normal file
176
gnu/lib/libreadline/rldefs.h
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/* rldefs.h -- an attempt to isolate some of the system-specific defines
|
||||
for readline. This should be included after any files that define
|
||||
system-specific constants like _POSIX_VERSION or USG. */
|
||||
|
||||
/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (_RLDEFS_H)
|
||||
#define _RLDEFS_H
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define NEW_TTY_DRIVER
|
||||
#define HAVE_BSD_SIGNALS
|
||||
/* #define USE_XON_XOFF */
|
||||
|
||||
#if defined (__linux__)
|
||||
# include <termcap.h>
|
||||
#endif /* __linux__ */
|
||||
|
||||
/* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */
|
||||
#if defined (USG) && !defined (hpux)
|
||||
# undef HAVE_BSD_SIGNALS
|
||||
#endif
|
||||
|
||||
/* System V machines use termio. */
|
||||
#if !defined (_POSIX_VERSION)
|
||||
# if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX)
|
||||
# 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 and the Posix signal functions. */
|
||||
#if defined (_POSIX_VERSION)
|
||||
# if !defined (TERMIOS_MISSING)
|
||||
# undef NEW_TTY_DRIVER
|
||||
# define TERMIOS_TTY_DRIVER
|
||||
# include <termios.h>
|
||||
# endif /* !TERMIOS_MISSING */
|
||||
# define HAVE_POSIX_SIGNALS
|
||||
# if !defined (O_NDELAY)
|
||||
# define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */
|
||||
# endif /* O_NDELAY */
|
||||
#endif /* _POSIX_VERSION */
|
||||
|
||||
/* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */
|
||||
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
|
||||
# if defined (USGr3)
|
||||
# if !defined (HAVE_USG_SIGHOLD)
|
||||
# define HAVE_USG_SIGHOLD
|
||||
# endif /* !HAVE_USG_SIGHOLD */
|
||||
# endif /* USGr3 */
|
||||
#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
|
||||
|
||||
/* Other (BSD) machines use sgtty. */
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
# include <sgtty.h>
|
||||
#endif
|
||||
|
||||
/* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
|
||||
it is not already defined. It is used both to determine if a
|
||||
special character is disabled and to disable certain special
|
||||
characters. Posix systems should set to 0, USG systems to -1. */
|
||||
#if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE)
|
||||
# if defined (_POSIX_VERSION)
|
||||
# define _POSIX_VDISABLE 0
|
||||
# else /* !_POSIX_VERSION */
|
||||
# define _POSIX_VDISABLE -1
|
||||
# endif /* !_POSIX_VERSION */
|
||||
#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
|
||||
|
||||
#if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3))
|
||||
# if !defined (HAVE_DIRENT_H)
|
||||
# define HAVE_DIRENT_H
|
||||
# endif /* !HAVE_DIRENT_H */
|
||||
#endif /* !SHELL && (_POSIX_VERSION || USGr3) */
|
||||
|
||||
#if defined (HAVE_DIRENT_H)
|
||||
# include <dirent.h>
|
||||
# if !defined (direct)
|
||||
# define direct dirent
|
||||
# endif /* !direct */
|
||||
# define D_NAMLEN(d) strlen ((d)->d_name)
|
||||
#else /* !HAVE_DIRENT_H */
|
||||
# define D_NAMLEN(d) ((d)->d_namlen)
|
||||
# if defined (USG)
|
||||
# if defined (Xenix)
|
||||
# include <sys/ndir.h>
|
||||
# else /* !Xenix (but USG...) */
|
||||
# include "ndir.h"
|
||||
# endif /* !Xenix */
|
||||
# else /* !USG */
|
||||
# include <sys/dir.h>
|
||||
# endif /* !USG */
|
||||
#endif /* !HAVE_DIRENT_H */
|
||||
|
||||
#if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux)
|
||||
# include <sys/stream.h>
|
||||
# if defined (HAVE_SYS_PTEM_H)
|
||||
# include <sys/ptem.h>
|
||||
# endif /* HAVE_SYS_PTEM_H */
|
||||
# if defined (HAVE_SYS_PTE_H)
|
||||
# include <sys/pte.h>
|
||||
# endif /* HAVE_SYS_PTE_H */
|
||||
#endif /* USG && TIOCGWINSZ && !Linux */
|
||||
|
||||
/* Posix macro to check file in statbuf for directory-ness.
|
||||
This requires that <sys/stat.h> be included before this test. */
|
||||
#if defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/* Decide which flavor of the header file describing the C library
|
||||
string functions to include and include it. */
|
||||
|
||||
#if defined (USG) || defined (NeXT)
|
||||
# if !defined (HAVE_STRING_H)
|
||||
# define HAVE_STRING_H
|
||||
# endif /* !HAVE_STRING_H */
|
||||
#endif /* USG || NeXT */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
#if defined (HAVE_VARARGS_H)
|
||||
# include <varargs.h>
|
||||
#endif /* HAVE_VARARGS_H */
|
||||
|
||||
/* This definition is needed by readline.c, rltty.c, and signals.c. */
|
||||
/* If on, then readline handles signals in a way that doesn't screw. */
|
||||
#define HANDLE_SIGNALS
|
||||
|
||||
#if !defined (emacs_mode)
|
||||
# define no_mode -1
|
||||
# define vi_mode 0
|
||||
# define emacs_mode 1
|
||||
#endif
|
||||
|
||||
#endif /* !_RLDEFS_H */
|
||||
668
gnu/lib/libreadline/rltty.c
Normal file
668
gnu/lib/libreadline/rltty.c
Normal file
|
|
@ -0,0 +1,668 @@
|
|||
/* rltty.c -- functions to prepare and restore the terminal for readline's
|
||||
use. */
|
||||
|
||||
/* Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "readline.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
extern int readline_echoing_p;
|
||||
extern int _rl_eof_char;
|
||||
|
||||
#if defined (_GO32_)
|
||||
# include <sys/pc.h>
|
||||
# undef HANDLE_SIGNALS
|
||||
#endif /* _GO32_ */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Signal Management */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
static sigset_t sigint_set, sigint_oset;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
static int sigint_oldmask;
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
static int sigint_blocked = 0;
|
||||
|
||||
/* Cause SIGINT to not be delivered until the corresponding call to
|
||||
release_sigint(). */
|
||||
static void
|
||||
block_sigint ()
|
||||
{
|
||||
if (sigint_blocked)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigemptyset (&sigint_set);
|
||||
sigemptyset (&sigint_oset);
|
||||
sigaddset (&sigint_set, SIGINT);
|
||||
sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigint_oldmask = sigblock (sigmask (SIGINT));
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sighold (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
sigint_blocked = 1;
|
||||
}
|
||||
|
||||
/* Allow SIGINT to be delivered. */
|
||||
static void
|
||||
release_sigint ()
|
||||
{
|
||||
if (!sigint_blocked)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
|
||||
#else
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigsetmask (sigint_oldmask);
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sigrelse (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
sigint_blocked = 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Controlling the Meta Key */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
extern int term_has_meta;
|
||||
extern char *term_mm;
|
||||
extern char *term_mo;
|
||||
|
||||
static void
|
||||
outchar (c)
|
||||
int c;
|
||||
{
|
||||
putc (c, rl_outstream);
|
||||
}
|
||||
|
||||
/* Turn on/off the meta key depending on ON. */
|
||||
static void
|
||||
control_meta_key (on)
|
||||
int on;
|
||||
{
|
||||
if (term_has_meta)
|
||||
{
|
||||
if (on && term_mm)
|
||||
tputs (term_mm, 1, outchar);
|
||||
else if (!on && term_mo)
|
||||
tputs (term_mo, 1, outchar);
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Saving and Restoring the TTY */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Non-zero means that the terminal is in a prepped state. */
|
||||
static int terminal_prepped = 0;
|
||||
|
||||
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
|
||||
and output is suspended. */
|
||||
#if defined (__ksr1__)
|
||||
static int ksrflow = 0;
|
||||
#endif
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
|
||||
/* Values for the `flags' field of a struct bsdtty. This tells which
|
||||
elements of the struct bsdtty have been fetched from the system and
|
||||
are valid. */
|
||||
#define SGTTY_SET 0x01
|
||||
#define LFLAG_SET 0x02
|
||||
#define TCHARS_SET 0x04
|
||||
#define LTCHARS_SET 0x08
|
||||
|
||||
struct bsdtty {
|
||||
struct sgttyb sgttyb; /* Basic BSD tty driver information. */
|
||||
int lflag; /* Local mode flags, like LPASS8. */
|
||||
#if defined (TIOCGETC)
|
||||
struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */
|
||||
#endif
|
||||
#if defined (TIOCGLTC)
|
||||
struct ltchars ltchars; /* 4.2 BSD editing characters */
|
||||
#endif
|
||||
int flags; /* Bitmap saying which parts of the struct are valid. */
|
||||
};
|
||||
|
||||
#define TIOTYPE struct bsdtty
|
||||
|
||||
static TIOTYPE otio;
|
||||
|
||||
static int
|
||||
get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
tiop->flags = tiop->lflag = 0;
|
||||
|
||||
ioctl (tty, TIOCGETP, &(tiop->sgttyb));
|
||||
tiop->flags |= SGTTY_SET;
|
||||
|
||||
#if defined (TIOCLGET)
|
||||
ioctl (tty, TIOCLGET, &(tiop->lflag));
|
||||
tiop->flags |= LFLAG_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGETC)
|
||||
ioctl (tty, TIOCGETC, &(tiop->tchars));
|
||||
tiop->flags |= TCHARS_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGLTC)
|
||||
ioctl (tty, TIOCGLTC, &(tiop->ltchars));
|
||||
tiop->flags |= LTCHARS_SET;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
if (tiop->flags & SGTTY_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSETN, &(tiop->sgttyb));
|
||||
tiop->flags &= ~SGTTY_SET;
|
||||
}
|
||||
readline_echoing_p = 1;
|
||||
|
||||
#if defined (TIOCLSET)
|
||||
if (tiop->flags & LFLAG_SET)
|
||||
{
|
||||
ioctl (tty, TIOCLSET, &(tiop->lflag));
|
||||
tiop->flags &= ~LFLAG_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (TIOCSETC)
|
||||
if (tiop->flags & TCHARS_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSETC, &(tiop->tchars));
|
||||
tiop->flags &= ~TCHARS_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (TIOCSLTC)
|
||||
if (tiop->flags & LTCHARS_SET)
|
||||
{
|
||||
ioctl (tty, TIOCSLTC, &(tiop->ltchars));
|
||||
tiop->flags &= ~LTCHARS_SET;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, otio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE otio, *tiop;
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
|
||||
|
||||
/* Copy the original settings to the structure we're going to use for
|
||||
our settings. */
|
||||
tiop->sgttyb = otio.sgttyb;
|
||||
tiop->lflag = otio.lflag;
|
||||
#if defined (TIOCGETC)
|
||||
tiop->tchars = otio.tchars;
|
||||
#endif
|
||||
#if defined (TIOCGLTC)
|
||||
tiop->ltchars = otio.ltchars;
|
||||
#endif
|
||||
tiop->flags = otio.flags;
|
||||
|
||||
/* First, the basic settings to put us into character-at-a-time, no-echo
|
||||
input mode. */
|
||||
tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
|
||||
tiop->sgttyb.sg_flags |= CBREAK;
|
||||
|
||||
/* If this terminal doesn't care how the 8th bit is used, then we can
|
||||
use it for the meta-key. If only one of even or odd parity is
|
||||
specified, then the terminal is using parity, and we cannot. */
|
||||
#if !defined (ANYP)
|
||||
# define ANYP (EVENP | ODDP)
|
||||
#endif
|
||||
if (((otio.sgttyb.sg_flags & ANYP) == ANYP) ||
|
||||
((otio.sgttyb.sg_flags & ANYP) == 0))
|
||||
{
|
||||
tiop->sgttyb.sg_flags |= ANYP;
|
||||
|
||||
/* Hack on local mode flags if we can. */
|
||||
#if defined (TIOCLGET)
|
||||
# if defined (LPASS8)
|
||||
tiop->lflag |= LPASS8;
|
||||
# endif /* LPASS8 */
|
||||
#endif /* TIOCLGET */
|
||||
}
|
||||
|
||||
#if defined (TIOCGETC)
|
||||
# if defined (USE_XON_XOFF)
|
||||
/* Get rid of terminal output start and stop characters. */
|
||||
tiop->tchars.t_stopc = -1; /* C-s */
|
||||
tiop->tchars.t_startc = -1; /* C-q */
|
||||
|
||||
/* If there is an XON character, bind it to restart the output. */
|
||||
if (otio.tchars.t_startc != -1)
|
||||
rl_bind_key (otio.tchars.t_startc, rl_restart_output);
|
||||
# endif /* USE_XON_XOFF */
|
||||
|
||||
/* If there is an EOF char, bind _rl_eof_char to it. */
|
||||
if (otio.tchars.t_eofc != -1)
|
||||
_rl_eof_char = otio.tchars.t_eofc;
|
||||
|
||||
# if defined (NO_KILL_INTR)
|
||||
/* Get rid of terminal-generated SIGQUIT and SIGINT. */
|
||||
tiop->tchars.t_quitc = -1; /* C-\ */
|
||||
tiop->tchars.t_intrc = -1; /* C-c */
|
||||
# endif /* NO_KILL_INTR */
|
||||
#endif /* TIOCGETC */
|
||||
|
||||
#if defined (TIOCGLTC)
|
||||
/* Make the interrupt keys go away. Just enough to make people happy. */
|
||||
tiop->ltchars.t_dsuspc = -1; /* C-y */
|
||||
tiop->ltchars.t_lnextc = -1; /* C-v */
|
||||
#endif /* TIOCGLTC */
|
||||
#endif /* !_GO32_ */
|
||||
}
|
||||
|
||||
#else /* !defined (NEW_TTY_DRIVER) */
|
||||
|
||||
#if !defined (VMIN)
|
||||
# define VMIN VEOF
|
||||
#endif
|
||||
|
||||
#if !defined (VTIME)
|
||||
# define VTIME VEOL
|
||||
#endif
|
||||
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# define TIOTYPE struct termios
|
||||
# define DRAIN_OUTPUT(fd) tcdrain (fd)
|
||||
# define GETATTR(tty, tiop) (tcgetattr (tty, tiop))
|
||||
# define SETATTR(tty, tiop) (tcsetattr (tty, TCSANOW, tiop))
|
||||
#else
|
||||
# define TIOTYPE struct termio
|
||||
# define DRAIN_OUTPUT(fd)
|
||||
# define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop))
|
||||
# define SETATTR(tty, tiop) (ioctl (tty, TCSETA, tiop))
|
||||
#endif /* !TERMIOS_TTY_DRIVER */
|
||||
|
||||
static TIOTYPE otio;
|
||||
|
||||
static int
|
||||
get_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
/* XXX this prevents to got editing mode from tcsh. Ache */
|
||||
struct winsize w;
|
||||
|
||||
if (ioctl (tty, TIOCGWINSZ, &w) == 0)
|
||||
(void) ioctl (tty, TIOCSWINSZ, &w);
|
||||
|
||||
while (GETATTR (tty, tiop) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
errno = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
set_tty_settings (tty, tiop)
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
while (SETATTR (tty, tiop) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return -1;
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
if (ksrflow)
|
||||
{
|
||||
ksrflow = 0;
|
||||
tcflow (tty, TCOON);
|
||||
}
|
||||
# else /* !ksr1 */
|
||||
tcflow (tty, TCOON); /* Simulate a ^Q. */
|
||||
# endif /* !ksr1 */
|
||||
#else
|
||||
ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
|
||||
#endif /* !TERMIOS_TTY_DRIVER */
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, otio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE otio, *tiop;
|
||||
{
|
||||
readline_echoing_p = (otio.c_lflag & ECHO);
|
||||
|
||||
tiop->c_lflag &= ~(ICANON | ECHO);
|
||||
|
||||
if ((unsigned char) otio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
|
||||
_rl_eof_char = otio.c_cc[VEOF];
|
||||
|
||||
#if defined (USE_XON_XOFF)
|
||||
#if defined (IXANY)
|
||||
tiop->c_iflag &= ~(IXON | IXOFF | IXANY);
|
||||
#else
|
||||
/* `strict' Posix systems do not define IXANY. */
|
||||
tiop->c_iflag &= ~(IXON | IXOFF);
|
||||
#endif /* IXANY */
|
||||
#endif /* USE_XON_XOFF */
|
||||
|
||||
/* Only turn this off if we are using all 8 bits. */
|
||||
if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag)
|
||||
tiop->c_iflag &= ~(ISTRIP | INPCK);
|
||||
|
||||
/* Make sure we differentiate between CR and NL on input. */
|
||||
tiop->c_iflag &= ~(ICRNL | INLCR);
|
||||
|
||||
#if !defined (HANDLE_SIGNALS)
|
||||
tiop->c_lflag &= ~ISIG;
|
||||
#else
|
||||
tiop->c_lflag |= ISIG;
|
||||
#endif
|
||||
|
||||
tiop->c_cc[VMIN] = 1;
|
||||
tiop->c_cc[VTIME] = 0;
|
||||
|
||||
/* Turn off characters that we need on Posix systems with job control,
|
||||
just to be sure. This includes ^Y and ^V. This should not really
|
||||
be necessary. */
|
||||
#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
|
||||
|
||||
#if defined (VLNEXT)
|
||||
tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
#if defined (VDSUSP)
|
||||
tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
|
||||
}
|
||||
#endif /* NEW_TTY_DRIVER */
|
||||
|
||||
/* Put the terminal in CBREAK mode so that we can detect key presses. */
|
||||
void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
int tty = fileno (rl_instream);
|
||||
TIOTYPE tio;
|
||||
|
||||
if (terminal_prepped)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being INTerrupted. */
|
||||
block_sigint ();
|
||||
|
||||
if (get_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
otio = tio;
|
||||
|
||||
prepare_terminal_settings (meta_flag, otio, &tio);
|
||||
|
||||
if (set_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
control_meta_key (1);
|
||||
terminal_prepped = 1;
|
||||
|
||||
release_sigint ();
|
||||
#endif /* !_GO32_ */
|
||||
}
|
||||
|
||||
/* Restore the terminal's normal settings and modes. */
|
||||
void
|
||||
rl_deprep_terminal ()
|
||||
{
|
||||
#if !defined (_GO32_)
|
||||
int tty = fileno (rl_instream);
|
||||
|
||||
if (!terminal_prepped)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being INTerrupted. */
|
||||
block_sigint ();
|
||||
|
||||
if (set_tty_settings (tty, &otio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
control_meta_key (0);
|
||||
terminal_prepped = 0;
|
||||
|
||||
release_sigint ();
|
||||
#endif /* !_GO32_ */
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Bogus Flow Control */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
rl_restart_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int fildes = fileno (rl_outstream);
|
||||
#if defined (TIOCSTART)
|
||||
#if defined (apollo)
|
||||
ioctl (&fildes, TIOCSTART, 0);
|
||||
#else
|
||||
ioctl (fildes, TIOCSTART, 0);
|
||||
#endif /* apollo */
|
||||
|
||||
#else /* !TIOCSTART */
|
||||
# if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
if (ksrflow)
|
||||
{
|
||||
ksrflow = 0;
|
||||
tcflow (fildes, TCOON);
|
||||
}
|
||||
# else /* !ksr1 */
|
||||
tcflow (fildes, TCOON); /* Simulate a ^Q. */
|
||||
# endif /* !ksr1 */
|
||||
# else /* !TERMIOS_TTY_DRIVER */
|
||||
# if defined (TCXONC)
|
||||
ioctl (fildes, TCXONC, TCOON);
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTART */
|
||||
}
|
||||
|
||||
rl_stop_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int fildes = fileno (rl_instream);
|
||||
|
||||
#if defined (TIOCSTOP)
|
||||
# if defined (apollo)
|
||||
ioctl (&fildes, TIOCSTOP, 0);
|
||||
# else
|
||||
ioctl (fildes, TIOCSTOP, 0);
|
||||
# endif /* apollo */
|
||||
#else /* !TIOCSTOP */
|
||||
# if defined (TERMIOS_TTY_DRIVER)
|
||||
# if defined (__ksr1__)
|
||||
ksrflow = 1;
|
||||
# endif /* ksr1 */
|
||||
tcflow (fildes, TCOOFF);
|
||||
# else
|
||||
# if defined (TCXONC)
|
||||
ioctl (fildes, TCXONC, TCOON);
|
||||
# endif /* TCXONC */
|
||||
# endif /* !TERMIOS_TTY_DRIVER */
|
||||
#endif /* !TIOCSTOP */
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Default Key Bindings */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
void
|
||||
rltty_set_default_bindings (kmap)
|
||||
Keymap kmap;
|
||||
{
|
||||
TIOTYPE ttybuff;
|
||||
int tty = fileno (rl_instream);
|
||||
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
|
||||
if (get_tty_settings (tty, &ttybuff) == 0)
|
||||
{
|
||||
if (ttybuff.flags & SGTTY_SET)
|
||||
{
|
||||
int erase, kill;
|
||||
|
||||
erase = ttybuff.sgttyb.sg_erase;
|
||||
kill = ttybuff.sgttyb.sg_kill;
|
||||
|
||||
if (erase != -1 && kmap[erase].type == ISFUNC)
|
||||
kmap[erase].function = rl_rubout;
|
||||
|
||||
if (kill != -1 && kmap[kill].type == ISFUNC)
|
||||
kmap[kill].function = rl_unix_line_discard;
|
||||
}
|
||||
|
||||
# if defined (TIOCGLTC)
|
||||
|
||||
if (ttybuff.flags & LTCHARS_SET)
|
||||
{
|
||||
int werase, nextc;
|
||||
|
||||
werase = ttybuff.ltchars.t_werasc;
|
||||
nextc = ttybuff.ltchars.t_lnextc;
|
||||
|
||||
if (werase != -1 && kmap[werase].type == ISFUNC)
|
||||
kmap[werase].function = rl_unix_word_rubout;
|
||||
|
||||
if (nextc != -1 && kmap[nextc].type == ISFUNC)
|
||||
kmap[nextc].function = rl_quoted_insert;
|
||||
}
|
||||
}
|
||||
# endif /* TIOCGLTC */
|
||||
|
||||
#else /* !NEW_TTY_DRIVER */
|
||||
|
||||
if (get_tty_settings (tty, &ttybuff) == 0)
|
||||
{
|
||||
unsigned char erase, kill;
|
||||
|
||||
erase = ttybuff.c_cc[VERASE];
|
||||
kill = ttybuff.c_cc[VKILL];
|
||||
|
||||
if (erase != (unsigned char)_POSIX_VDISABLE &&
|
||||
kmap[erase].type == ISFUNC)
|
||||
kmap[erase].function = rl_rubout;
|
||||
|
||||
if (kill != (unsigned char)_POSIX_VDISABLE &&
|
||||
kmap[kill].type == ISFUNC)
|
||||
kmap[kill].function = rl_unix_line_discard;
|
||||
|
||||
# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
|
||||
{
|
||||
unsigned char nextc;
|
||||
|
||||
nextc = ttybuff.c_cc[VLNEXT];
|
||||
|
||||
if (nextc != (unsigned char)_POSIX_VDISABLE &&
|
||||
kmap[nextc].type == ISFUNC)
|
||||
kmap[nextc].function = rl_quoted_insert;
|
||||
}
|
||||
# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
|
||||
|
||||
# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
|
||||
{
|
||||
unsigned char werase;
|
||||
|
||||
werase = ttybuff.c_cc[VWERASE];
|
||||
|
||||
if (werase != (unsigned char)_POSIX_VDISABLE &&
|
||||
kmap[werase].type == ISFUNC)
|
||||
kmap[werase].function = rl_unix_word_rubout;
|
||||
}
|
||||
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
|
||||
}
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
}
|
||||
275
gnu/lib/libreadline/search.c
Normal file
275
gnu/lib/libreadline/search.c
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
/* search.c - code for non-incremental searching in emacs and vi modes. */
|
||||
|
||||
/* Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# if defined (sparc) || defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
|
||||
/* Variables imported from readline.c */
|
||||
extern int rl_point, rl_end, rl_line_buffer_len;
|
||||
extern Keymap _rl_keymap;
|
||||
extern char *rl_prompt;
|
||||
extern char *rl_line_buffer;
|
||||
extern HIST_ENTRY *saved_line_for_history;
|
||||
|
||||
static char *noninc_search_string = (char *) NULL;
|
||||
static int noninc_history_pos = 0;
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
POS. If STRING begins with `^', the search must match STRING at the
|
||||
beginning of a history line, otherwise a full substring match is performed
|
||||
for STRING. DIR < 0 means to search backwards through the history list,
|
||||
DIR >= 0 means to search forward. */
|
||||
static int
|
||||
noninc_search_from_pos (string, pos, dir)
|
||||
char *string;
|
||||
int pos, dir;
|
||||
{
|
||||
int ret, old;
|
||||
|
||||
old = where_history ();
|
||||
history_set_pos (pos);
|
||||
|
||||
if (*string == '^')
|
||||
ret = history_search_prefix (string + 1, dir);
|
||||
else
|
||||
ret = history_search (string, dir);
|
||||
|
||||
if (ret != -1)
|
||||
ret = where_history ();
|
||||
|
||||
history_set_pos (old);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Search for a line in the history containing STRING. If DIR is < 0, the
|
||||
search is backwards through previous entries, else through subsequent
|
||||
entries. */
|
||||
static void
|
||||
noninc_dosearch (string, dir)
|
||||
char *string;
|
||||
int dir;
|
||||
{
|
||||
int oldpos, pos;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
if (string == 0 || *string == 0 || noninc_history_pos < 0)
|
||||
{
|
||||
ding ();
|
||||
return;
|
||||
}
|
||||
|
||||
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir);
|
||||
if (pos == -1)
|
||||
{
|
||||
/* Search failed, current history position unchanged. */
|
||||
maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = 0;
|
||||
ding ();
|
||||
return;
|
||||
}
|
||||
|
||||
noninc_history_pos = pos;
|
||||
|
||||
oldpos = where_history ();
|
||||
history_set_pos (noninc_history_pos);
|
||||
entry = current_history ();
|
||||
history_set_pos (oldpos);
|
||||
|
||||
{
|
||||
int line_len;
|
||||
|
||||
line_len = strlen (entry->line);
|
||||
if (line_len >= rl_line_buffer_len)
|
||||
rl_extend_line_buffer (line_len);
|
||||
strcpy (rl_line_buffer, entry->line);
|
||||
}
|
||||
|
||||
rl_undo_list = (UNDO_LIST *)entry->data;
|
||||
rl_end = strlen (rl_line_buffer);
|
||||
rl_point = 0;
|
||||
rl_clear_message ();
|
||||
|
||||
if (saved_line_for_history)
|
||||
free_history_entry (saved_line_for_history);
|
||||
saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Search non-interactively through the history list. DIR < 0 means to
|
||||
search backwards through the history of previous commands; otherwise
|
||||
the search is for commands subsequent to the current position in the
|
||||
history list. PCHAR is the character to use for prompting when reading
|
||||
the search string; if not specified (0), it defaults to `:'. */
|
||||
static void
|
||||
noninc_search (dir, pchar)
|
||||
int dir;
|
||||
int pchar;
|
||||
{
|
||||
int saved_point, c, pmtlen;
|
||||
char *p;
|
||||
|
||||
maybe_save_line ();
|
||||
saved_point = rl_point;
|
||||
|
||||
/* Use the line buffer to read the search string. */
|
||||
rl_line_buffer[0] = 0;
|
||||
rl_end = rl_point = 0;
|
||||
|
||||
pmtlen = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
|
||||
p = (char *)alloca (2 + pmtlen);
|
||||
if (pmtlen)
|
||||
strcpy (p, rl_prompt);
|
||||
p[pmtlen] = pchar ? pchar : ':';
|
||||
p[pmtlen + 1] = '\0';
|
||||
|
||||
rl_message (p, 0, 0);
|
||||
|
||||
/* Read the search string. */
|
||||
while (c = rl_read_key ())
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case CTRL('H'):
|
||||
case RUBOUT:
|
||||
if (rl_point == 0)
|
||||
{
|
||||
maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = saved_point;
|
||||
return;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case CTRL('W'):
|
||||
case CTRL('U'):
|
||||
rl_dispatch (c, _rl_keymap);
|
||||
break;
|
||||
|
||||
case RETURN:
|
||||
case NEWLINE:
|
||||
goto dosearch;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
|
||||
case CTRL('C'):
|
||||
case CTRL('G'):
|
||||
maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = saved_point;
|
||||
ding ();
|
||||
return;
|
||||
|
||||
default:
|
||||
rl_insert (1, c);
|
||||
break;
|
||||
}
|
||||
rl_redisplay ();
|
||||
}
|
||||
|
||||
dosearch:
|
||||
/* If rl_point == 0, we want to re-use the previous search string and
|
||||
start from the saved history position. If there's no previous search
|
||||
string, punt. */
|
||||
if (rl_point == 0)
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
ding ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We want to start the search from the current history position. */
|
||||
noninc_history_pos = where_history ();
|
||||
if (noninc_search_string)
|
||||
free (noninc_search_string);
|
||||
noninc_search_string = savestring (rl_line_buffer);
|
||||
}
|
||||
|
||||
noninc_dosearch (noninc_search_string, dir);
|
||||
}
|
||||
|
||||
/* Search forward through the history list for a string. If the vi-mode
|
||||
code calls this, KEY will be `?'. */
|
||||
rl_noninc_forward_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (key == '?')
|
||||
noninc_search (1, '?');
|
||||
else
|
||||
noninc_search (1, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reverse search the history list for a string. If the vi-mode code
|
||||
calls this, KEY will be `/'. */
|
||||
rl_noninc_reverse_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (key == '/')
|
||||
noninc_search (-1, '/');
|
||||
else
|
||||
noninc_search (-1, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Search forward through the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
rl_noninc_forward_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
ding ();
|
||||
return (-1);
|
||||
}
|
||||
noninc_dosearch (noninc_search_string, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reverse search in the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
rl_noninc_reverse_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
ding ();
|
||||
return (-1);
|
||||
}
|
||||
noninc_dosearch (noninc_search_string, -1);
|
||||
return 0;
|
||||
}
|
||||
298
gnu/lib/libreadline/signals.c
Normal file
298
gnu/lib/libreadline/signals.c
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
/* signals.c -- signal handling support for readline. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#if !defined (NO_SYS_FILE)
|
||||
# include <sys/file.h>
|
||||
#endif /* !NO_SYS_FILE */
|
||||
#include <signal.h>
|
||||
|
||||
/* This is needed to include support for TIOCGWINSZ and window resizing. */
|
||||
#if defined (OSF1) || defined (BSD386) || defined (_386BSD) || defined (__BSD_4_4__) || defined (AIX)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* OSF1 || BSD386 || _386BSD || __BSD_4_4__ || AIX */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <errno.h>
|
||||
/* Not all systems declare ERRNO in errno.h... and some systems #define it! */
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#include "posixstat.h"
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
static void cr ();
|
||||
|
||||
extern int readline_echoing_p;
|
||||
extern int rl_pending_input;
|
||||
|
||||
extern int _rl_meta_flag;
|
||||
|
||||
extern void _rl_output_character_function ();
|
||||
|
||||
extern void free_undo_list ();
|
||||
|
||||
#if defined (VOID_SIGHANDLER)
|
||||
# define sighandler void
|
||||
#else
|
||||
# define sighandler int
|
||||
#endif /* VOID_SIGHANDLER */
|
||||
|
||||
/* This typedef is equivalant to the one for Function; it allows us
|
||||
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
|
||||
typedef sighandler SigHandler ();
|
||||
|
||||
#if defined (_GO32_)
|
||||
# undef HANDLE_SIGNALS
|
||||
#endif /* _GO32_ */
|
||||
|
||||
#if defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* STATIC_MALLOC */
|
||||
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Signal Handling */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
static SigHandler *old_sigwinch = (SigHandler *)NULL;
|
||||
|
||||
static sighandler
|
||||
rl_handle_sigwinch (sig)
|
||||
int sig;
|
||||
{
|
||||
if (readline_echoing_p)
|
||||
{
|
||||
_rl_set_screen_size (fileno (rl_instream), 1);
|
||||
|
||||
cr (); /* was crlf () */
|
||||
rl_forced_update_display ();
|
||||
}
|
||||
|
||||
if (old_sigwinch &&
|
||||
old_sigwinch != (SigHandler *)SIG_IGN &&
|
||||
old_sigwinch != (SigHandler *)SIG_DFL)
|
||||
(*old_sigwinch) (sig);
|
||||
#if !defined (VOID_SIGHANDLER)
|
||||
return (0);
|
||||
#endif /* VOID_SIGHANDLER */
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
#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,
|
||||
*old_alrm = (SigHandler *)NULL;
|
||||
|
||||
/* Handle an interrupt character. */
|
||||
static sighandler
|
||||
rl_signal_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigset_t set;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
long omask;
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
|
||||
/* Since the signal will not be blocked while we are in the signal
|
||||
handler, ignore it until rl_clear_signals resets the catcher. */
|
||||
if (sig == SIGINT)
|
||||
signal (sig, SIG_IGN);
|
||||
#endif /* !HAVE_BSD_SIGNALS */
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case SIGINT:
|
||||
{
|
||||
register HIST_ENTRY *entry;
|
||||
|
||||
free_undo_list ();
|
||||
|
||||
entry = current_history ();
|
||||
if (entry)
|
||||
entry->data = (char *)NULL;
|
||||
}
|
||||
_rl_kill_kbd_macro ();
|
||||
rl_clear_message ();
|
||||
rl_init_argument ();
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
case SIGTSTP:
|
||||
case SIGTTOU:
|
||||
case SIGTTIN:
|
||||
#endif /* SIGTSTP */
|
||||
case SIGALRM:
|
||||
rl_clean_up_for_exit ();
|
||||
rl_deprep_terminal ();
|
||||
rl_clear_signals ();
|
||||
rl_pending_input = 0;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
|
||||
sigdelset (&set, sig);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
omask = sigblock (0);
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
kill (getpid (), sig);
|
||||
|
||||
/* Let the signal that we just sent through. */
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigsetmask (omask & ~(sigmask (sig)));
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
rl_prep_terminal (_rl_meta_flag);
|
||||
rl_set_signals ();
|
||||
}
|
||||
|
||||
#if !defined (VOID_SIGHANDLER)
|
||||
return (0);
|
||||
#endif /* !VOID_SIGHANDLER */
|
||||
}
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
static SigHandler *
|
||||
rl_set_sighandler (sig, handler)
|
||||
int sig;
|
||||
SigHandler *handler;
|
||||
{
|
||||
struct sigaction act, oact;
|
||||
|
||||
act.sa_handler = handler;
|
||||
act.sa_flags = 0;
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&oact.sa_mask);
|
||||
sigaction (sig, &act, &oact);
|
||||
return (oact.sa_handler);
|
||||
}
|
||||
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# define rl_set_sighandler(sig, handler) (SigHandler *)signal (sig, handler)
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
rl_set_signals ()
|
||||
{
|
||||
old_int = (SigHandler *)rl_set_sighandler (SIGINT, rl_signal_handler);
|
||||
if (old_int == (SigHandler *)SIG_IGN)
|
||||
signal (SIGINT, SIG_IGN);
|
||||
|
||||
old_alrm = (SigHandler *)rl_set_sighandler (SIGALRM, rl_signal_handler);
|
||||
if (old_alrm == (SigHandler *)SIG_IGN)
|
||||
signal (SIGALRM, SIG_IGN);
|
||||
|
||||
#if !defined (SHELL)
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
old_tstp = (SigHandler *)rl_set_sighandler (SIGTSTP, rl_signal_handler);
|
||||
if (old_tstp == (SigHandler *)SIG_IGN)
|
||||
signal (SIGTSTP, SIG_IGN);
|
||||
#endif /* SIGTSTP */
|
||||
#if defined (SIGTTOU)
|
||||
old_ttou = (SigHandler *)rl_set_sighandler (SIGTTOU, rl_signal_handler);
|
||||
old_ttin = (SigHandler *)rl_set_sighandler (SIGTTIN, rl_signal_handler);
|
||||
|
||||
if (old_tstp == (SigHandler *)SIG_IGN)
|
||||
{
|
||||
signal (SIGTTOU, SIG_IGN);
|
||||
signal (SIGTTIN, SIG_IGN);
|
||||
}
|
||||
#endif /* SIGTTOU */
|
||||
|
||||
#endif /* !SHELL */
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
old_sigwinch =
|
||||
(SigHandler *) rl_set_sighandler (SIGWINCH, rl_handle_sigwinch);
|
||||
#endif /* SIGWINCH */
|
||||
}
|
||||
|
||||
rl_clear_signals ()
|
||||
{
|
||||
rl_set_sighandler (SIGINT, old_int);
|
||||
rl_set_sighandler (SIGALRM, old_alrm);
|
||||
|
||||
#if !defined (SHELL)
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
signal (SIGTSTP, old_tstp);
|
||||
#endif
|
||||
|
||||
#if defined (SIGTTOU)
|
||||
signal (SIGTTOU, old_ttou);
|
||||
signal (SIGTTIN, old_ttin);
|
||||
#endif /* SIGTTOU */
|
||||
|
||||
#endif /* !SHELL */
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
signal (SIGWINCH, old_sigwinch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move to the start of the current line. */
|
||||
static void
|
||||
cr ()
|
||||
{
|
||||
extern char *term_cr;
|
||||
|
||||
if (term_cr)
|
||||
tputs (term_cr, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* HANDLE_SIGNALS */
|
||||
|
|
@ -1,50 +1,27 @@
|
|||
*** readline.c.orig Thu May 5 04:02:17 1994
|
||||
--- readline.c Mon May 9 00:33:44 1994
|
||||
*** rltty.c.orig Tue May 10 02:18:03 1994
|
||||
--- rltty.c Tue May 10 03:12:55 1994
|
||||
***************
|
||||
*** 32,37 ****
|
||||
--- 32,38 ----
|
||||
|
||||
#include <stdio.h>
|
||||
*** 21,26 ****
|
||||
--- 21,27 ----
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include <sys/types.h>
|
||||
+ #include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
***************
|
||||
*** 280,285 ****
|
||||
--- 281,295 ----
|
||||
/* Non-zero means to save keys that we dispatch on in a kbd macro. */
|
||||
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);
|
||||
*** 347,352 ****
|
||||
--- 348,359 ----
|
||||
int tty;
|
||||
TIOTYPE *tiop;
|
||||
{
|
||||
+ /* XXX this prevents to got editing mode from tcsh. Ache */
|
||||
+ struct winsize w;
|
||||
+
|
||||
+ if (ioctl (tty, TIOCGWINSZ, &w) == 0)
|
||||
+ (void) ioctl (tty, TIOCSWINSZ, &w);
|
||||
+ }
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
***************
|
||||
*** 1153,1158 ****
|
||||
--- 1163,1169 ----
|
||||
#endif /* POSIX */
|
||||
int tty = fileno (rl_instream);
|
||||
|
||||
+ wait_foreground (); /* XXX this prevents to got editing mode from tcsh */
|
||||
#if defined (_POSIX_VERSION)
|
||||
if (tcgetattr (tty, &ttybuff) != -1)
|
||||
#else
|
||||
***************
|
||||
*** 2307,2312 ****
|
||||
--- 2318,2324 ----
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* POSIX */
|
||||
|
||||
+ wait_foreground (); /* XXX this prevents to got editing mode from tcsh */
|
||||
#if defined (_POSIX_VERSION)
|
||||
tcgetattr (tty, &tio);
|
||||
#else
|
||||
+ if (ioctl (tty, TIOCGWINSZ, &w) == 0)
|
||||
+ (void) ioctl (tty, TIOCSWINSZ, &w);
|
||||
+
|
||||
while (GETATTR (tty, tiop) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
|
|
|
|||
398
gnu/lib/libreadline/tilde.c
Normal file
398
gnu/lib/libreadline/tilde.c
Normal file
|
|
@ -0,0 +1,398 @@
|
|||
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
|
||||
|
||||
/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Readline, a library for reading lines
|
||||
of text with interactive input and history editing.
|
||||
|
||||
Readline is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 1, or (at your option) any
|
||||
later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
#else /* !__GNUC__ */
|
||||
# if defined (_AIX)
|
||||
#pragma alloca
|
||||
# else /* !_AIX */
|
||||
# if defined (HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# endif /* HAVE_ALLOCA_H */
|
||||
# endif /* !AIX */
|
||||
#endif /* !__GNUC__ */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <tilde.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#if defined (USG) && !defined (isc386) && !defined (sgi)
|
||||
extern struct passwd *getpwuid (), *getpwent ();
|
||||
#endif
|
||||
#if defined (isc386) && !defined (__STDC__) && defined (_POSIX_SOURCE)
|
||||
extern struct passwd *getpwent ();
|
||||
#endif
|
||||
|
||||
#if !defined (savestring)
|
||||
extern char *xmalloc ();
|
||||
# ifndef strcpy
|
||||
extern char *strcpy ();
|
||||
# endif
|
||||
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
|
||||
#endif /* !savestring */
|
||||
|
||||
#if !defined (NULL)
|
||||
# if defined (__STDC__)
|
||||
# define NULL ((void *) 0)
|
||||
# else
|
||||
# define NULL 0x0
|
||||
# endif /* !__STDC__ */
|
||||
#endif /* !NULL */
|
||||
|
||||
#if defined (TEST) || defined (STATIC_MALLOC)
|
||||
static char *xmalloc (), *xrealloc ();
|
||||
#else
|
||||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* TEST || STATIC_MALLOC */
|
||||
|
||||
/* The default value of tilde_additional_prefixes. This is set to
|
||||
whitespace preceding a tilde so that simple programs which do not
|
||||
perform any word separation get desired behaviour. */
|
||||
static char *default_prefixes[] =
|
||||
{ " ~", "\t~", (char *)NULL };
|
||||
|
||||
/* The default value of tilde_additional_suffixes. This is set to
|
||||
whitespace or newline so that simple programs which do not
|
||||
perform any word separation get desired behaviour. */
|
||||
static char *default_suffixes[] =
|
||||
{ " ", "\n", (char *)NULL };
|
||||
|
||||
/* If non-null, this contains the address of a function to call if the
|
||||
standard meaning for expanding a tilde fails. The function is called
|
||||
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if there is no expansion. */
|
||||
CPFunction *tilde_expansion_failure_hook = (CPFunction *)NULL;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which
|
||||
are duplicates for a tilde prefix. Bash uses this to expand
|
||||
`=~' and `:~'. */
|
||||
char **tilde_additional_prefixes = default_prefixes;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which match
|
||||
the end of a username, instead of just "/". Bash sets this to
|
||||
`:' and `=~'. */
|
||||
char **tilde_additional_suffixes = default_suffixes;
|
||||
|
||||
/* Find the start of a tilde expansion in STRING, and return the index of
|
||||
the tilde which starts the expansion. Place the length of the text
|
||||
which identified this tilde starter in LEN, excluding the tilde itself. */
|
||||
static int
|
||||
tilde_find_prefix (string, len)
|
||||
char *string;
|
||||
int *len;
|
||||
{
|
||||
register int i, j, string_len;
|
||||
register char **prefixes = tilde_additional_prefixes;
|
||||
|
||||
string_len = strlen (string);
|
||||
*len = 0;
|
||||
|
||||
if (!*string || *string == '~')
|
||||
return (0);
|
||||
|
||||
if (prefixes)
|
||||
{
|
||||
for (i = 0; i < string_len; i++)
|
||||
{
|
||||
for (j = 0; prefixes[j]; j++)
|
||||
{
|
||||
if (strncmp (string + i, prefixes[j], strlen (prefixes[j])) == 0)
|
||||
{
|
||||
*len = strlen (prefixes[j]) - 1;
|
||||
return (i + *len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (string_len);
|
||||
}
|
||||
|
||||
/* Find the end of a tilde expansion in STRING, and return the index of
|
||||
the character which ends the tilde definition. */
|
||||
static int
|
||||
tilde_find_suffix (string)
|
||||
char *string;
|
||||
{
|
||||
register int i, j, string_len;
|
||||
register char **suffixes = tilde_additional_suffixes;
|
||||
|
||||
string_len = strlen (string);
|
||||
|
||||
for (i = 0; i < string_len; i++)
|
||||
{
|
||||
if (string[i] == '/' || !string[i])
|
||||
break;
|
||||
|
||||
for (j = 0; suffixes && suffixes[j]; j++)
|
||||
{
|
||||
if (strncmp (string + i, suffixes[j], strlen (suffixes[j])) == 0)
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
/* Return a new string which is the result of tilde expanding STRING. */
|
||||
char *
|
||||
tilde_expand (string)
|
||||
char *string;
|
||||
{
|
||||
char *result, *tilde_expand_word ();
|
||||
int result_size, result_index;
|
||||
|
||||
result_size = result_index = 0;
|
||||
result = (char *)NULL;
|
||||
|
||||
/* Scan through STRING expanding tildes as we come to them. */
|
||||
while (1)
|
||||
{
|
||||
register int start, end;
|
||||
char *tilde_word, *expansion;
|
||||
int len;
|
||||
|
||||
/* Make START point to the tilde which starts the expansion. */
|
||||
start = tilde_find_prefix (string, &len);
|
||||
|
||||
/* Copy the skipped text into the result. */
|
||||
if ((result_index + start + 1) > result_size)
|
||||
result = (char *)xrealloc (result, 1 + (result_size += (start + 20)));
|
||||
|
||||
strncpy (result + result_index, string, start);
|
||||
result_index += start;
|
||||
|
||||
/* Advance STRING to the starting tilde. */
|
||||
string += start;
|
||||
|
||||
/* Make END be the index of one after the last character of the
|
||||
username. */
|
||||
end = tilde_find_suffix (string);
|
||||
|
||||
/* If both START and END are zero, we are all done. */
|
||||
if (!start && !end)
|
||||
break;
|
||||
|
||||
/* Expand the entire tilde word, and copy it into RESULT. */
|
||||
tilde_word = (char *)xmalloc (1 + end);
|
||||
strncpy (tilde_word, string, end);
|
||||
tilde_word[end] = '\0';
|
||||
string += end;
|
||||
|
||||
expansion = tilde_expand_word (tilde_word);
|
||||
free (tilde_word);
|
||||
|
||||
len = strlen (expansion);
|
||||
if ((result_index + len + 1) > result_size)
|
||||
result = (char *)xrealloc (result, 1 + (result_size += (len + 20)));
|
||||
|
||||
strcpy (result + result_index, expansion);
|
||||
result_index += len;
|
||||
free (expansion);
|
||||
}
|
||||
|
||||
result[result_index] = '\0';
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
|
||||
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
|
||||
char *
|
||||
tilde_expand_word (filename)
|
||||
char *filename;
|
||||
{
|
||||
char *dirname;
|
||||
|
||||
dirname = filename ? savestring (filename) : (char *)NULL;
|
||||
|
||||
if (dirname && *dirname == '~')
|
||||
{
|
||||
char *temp_name;
|
||||
if (!dirname[1] || dirname[1] == '/')
|
||||
{
|
||||
/* Prepend $HOME to the rest of the string. */
|
||||
char *temp_home = (char *)getenv ("HOME");
|
||||
|
||||
/* If there is no HOME variable, look up the directory in
|
||||
the password database. */
|
||||
if (!temp_home)
|
||||
{
|
||||
struct passwd *entry;
|
||||
|
||||
entry = getpwuid (getuid ());
|
||||
if (entry)
|
||||
temp_home = entry->pw_dir;
|
||||
}
|
||||
|
||||
temp_name = (char *)alloca (1 + strlen (&dirname[1])
|
||||
+ (temp_home ? strlen (temp_home) : 0));
|
||||
temp_name[0] = '\0';
|
||||
if (temp_home)
|
||||
strcpy (temp_name, temp_home);
|
||||
strcat (temp_name, &dirname[1]);
|
||||
free (dirname);
|
||||
dirname = savestring (temp_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct passwd *user_entry;
|
||||
char *username = (char *)alloca (257);
|
||||
int i, c;
|
||||
|
||||
for (i = 1; c = dirname[i]; i++)
|
||||
{
|
||||
if (c == '/')
|
||||
break;
|
||||
else
|
||||
username[i - 1] = c;
|
||||
}
|
||||
username[i - 1] = '\0';
|
||||
|
||||
if (!(user_entry = getpwnam (username)))
|
||||
{
|
||||
/* If the calling program has a special syntax for
|
||||
expanding tildes, and we couldn't find a standard
|
||||
expansion, then let them try. */
|
||||
if (tilde_expansion_failure_hook)
|
||||
{
|
||||
char *expansion;
|
||||
|
||||
expansion = (*tilde_expansion_failure_hook) (username);
|
||||
|
||||
if (expansion)
|
||||
{
|
||||
temp_name = (char *)alloca (1 + strlen (expansion)
|
||||
+ strlen (&dirname[i]));
|
||||
strcpy (temp_name, expansion);
|
||||
strcat (temp_name, &dirname[i]);
|
||||
free (expansion);
|
||||
goto return_name;
|
||||
}
|
||||
}
|
||||
/* We shouldn't report errors. */
|
||||
}
|
||||
else
|
||||
{
|
||||
temp_name = (char *)alloca (1 + strlen (user_entry->pw_dir)
|
||||
+ strlen (&dirname[i]));
|
||||
strcpy (temp_name, user_entry->pw_dir);
|
||||
strcat (temp_name, &dirname[i]);
|
||||
return_name:
|
||||
free (dirname);
|
||||
dirname = savestring (temp_name);
|
||||
}
|
||||
endpwent ();
|
||||
}
|
||||
}
|
||||
return (dirname);
|
||||
}
|
||||
|
||||
|
||||
#if defined (TEST)
|
||||
#undef NULL
|
||||
#include <stdio.h>
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *result, line[512];
|
||||
int done = 0;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
printf ("~expand: ");
|
||||
fflush (stdout);
|
||||
|
||||
if (!gets (line))
|
||||
strcpy (line, "done");
|
||||
|
||||
if ((strcmp (line, "done") == 0) ||
|
||||
(strcmp (line, "quit") == 0) ||
|
||||
(strcmp (line, "exit") == 0))
|
||||
{
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
result = tilde_expand (line);
|
||||
printf (" --> %s\n", result);
|
||||
free (result);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
static void memory_error_and_abort ();
|
||||
|
||||
static char *
|
||||
xmalloc (bytes)
|
||||
int bytes;
|
||||
{
|
||||
char *temp = (char *)malloc (bytes);
|
||||
|
||||
if (!temp)
|
||||
memory_error_and_abort ();
|
||||
return (temp);
|
||||
}
|
||||
|
||||
static char *
|
||||
xrealloc (pointer, bytes)
|
||||
char *pointer;
|
||||
int bytes;
|
||||
{
|
||||
char *temp;
|
||||
|
||||
if (!pointer)
|
||||
temp = (char *)malloc (bytes);
|
||||
else
|
||||
temp = (char *)realloc (pointer, bytes);
|
||||
|
||||
if (!temp)
|
||||
memory_error_and_abort ();
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
static void
|
||||
memory_error_and_abort ()
|
||||
{
|
||||
fprintf (stderr, "readline: Out of virtual memory!\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* compile-command: "gcc -g -DTEST -o tilde tilde.c"
|
||||
* end:
|
||||
*/
|
||||
#endif /* TEST */
|
||||
|
|
@ -1,29 +1,35 @@
|
|||
/* vi_keymap.c -- the keymap for vi_mode in readline (). */
|
||||
|
||||
/* Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Readline, a library for reading lines
|
||||
of text with interactive input and history editing.
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
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
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (BUFSIZ)
|
||||
#include <stdio.h>
|
||||
#endif /* !BUFSIZ */
|
||||
|
||||
#include "readline.h"
|
||||
|
||||
extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
|
||||
|
||||
/* The keymap arrays for handling vi mode. */
|
||||
KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
||||
|
||||
/* The regular control keys come first. */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-@ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-a */
|
||||
|
|
@ -33,7 +39,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
|||
{ ISFUNC, rl_emacs_editing_mode }, /* Control-e */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Control-g */
|
||||
{ ISFUNC, rl_rubout }, /* Control-h */
|
||||
{ ISFUNC, rl_backward }, /* Control-h */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-i */
|
||||
{ ISFUNC, rl_newline }, /* Control-j */
|
||||
{ ISFUNC, rl_kill_line }, /* Control-k */
|
||||
|
|
@ -53,7 +59,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
|||
{ ISFUNC, rl_yank }, /* Control-y */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-z */
|
||||
|
||||
{ ISKMAP, (Function *)vi_escape_keymap }, /* Control-[ */
|
||||
{ ISFUNC, rl_abort }, /* Control-[ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-\ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-] */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-^ */
|
||||
|
|
@ -66,7 +72,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
|||
{ ISFUNC, rl_vi_comment }, /* # */
|
||||
{ ISFUNC, rl_end_of_line }, /* $ */
|
||||
{ ISFUNC, rl_vi_match }, /* % */
|
||||
{ ISFUNC, (Function *)0x0 }, /* & */
|
||||
{ ISFUNC, rl_vi_tilde_expand }, /* & */
|
||||
{ ISFUNC, (Function *)0x0 }, /* ' */
|
||||
{ ISFUNC, (Function *)0x0 }, /* ( */
|
||||
{ ISFUNC, (Function *)0x0 }, /* ) */
|
||||
|
|
@ -74,7 +80,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
|||
{ ISFUNC, rl_get_next_history}, /* + */
|
||||
{ ISFUNC, rl_vi_char_search }, /* , */
|
||||
{ ISFUNC, rl_get_previous_history }, /* - */
|
||||
{ ISFUNC, (Function *)0x0 }, /* . */
|
||||
{ ISFUNC, rl_vi_redo }, /* . */
|
||||
{ ISFUNC, rl_vi_search }, /* / */
|
||||
|
||||
/* Regular digits. */
|
||||
|
|
@ -167,12 +173,143 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
|
|||
{ ISFUNC, rl_vi_column }, /* | */
|
||||
{ ISFUNC, (Function *)0x0 }, /* } */
|
||||
{ ISFUNC, rl_vi_change_case }, /* ~ */
|
||||
{ ISFUNC, rl_backward } /* RUBOUT */
|
||||
{ ISFUNC, (Function *)0x0 }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
|
||||
KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
|
||||
|
||||
/* The regular control keys come first. */
|
||||
{ ISFUNC, (Function *)0x0 }, /* Control-@ */
|
||||
{ ISFUNC, rl_insert }, /* Control-a */
|
||||
|
|
@ -316,7 +453,143 @@ KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
|
|||
{ ISFUNC, rl_insert }, /* | */
|
||||
{ ISFUNC, rl_insert }, /* } */
|
||||
{ ISFUNC, rl_insert }, /* ~ */
|
||||
{ ISFUNC, rl_rubout } /* RUBOUT */
|
||||
{ ISFUNC, rl_rubout }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Pure 8-bit characters (128 - 159).
|
||||
These might be used in some
|
||||
character sets. */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
|
||||
/* ISO Latin-1 characters (160 - 255) */
|
||||
{ ISFUNC, rl_insert }, /* No-break space */
|
||||
{ ISFUNC, rl_insert }, /* Inverted exclamation mark */
|
||||
{ ISFUNC, rl_insert }, /* Cent sign */
|
||||
{ ISFUNC, rl_insert }, /* Pound sign */
|
||||
{ ISFUNC, rl_insert }, /* Currency sign */
|
||||
{ ISFUNC, rl_insert }, /* Yen sign */
|
||||
{ ISFUNC, rl_insert }, /* Broken bar */
|
||||
{ ISFUNC, rl_insert }, /* Section sign */
|
||||
{ ISFUNC, rl_insert }, /* Diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Copyright sign */
|
||||
{ ISFUNC, rl_insert }, /* Feminine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Left pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Not sign */
|
||||
{ ISFUNC, rl_insert }, /* Soft hyphen */
|
||||
{ ISFUNC, rl_insert }, /* Registered sign */
|
||||
{ ISFUNC, rl_insert }, /* Macron */
|
||||
{ ISFUNC, rl_insert }, /* Degree sign */
|
||||
{ ISFUNC, rl_insert }, /* Plus-minus sign */
|
||||
{ ISFUNC, rl_insert }, /* Superscript two */
|
||||
{ ISFUNC, rl_insert }, /* Superscript three */
|
||||
{ ISFUNC, rl_insert }, /* Acute accent */
|
||||
{ ISFUNC, rl_insert }, /* Micro sign */
|
||||
{ ISFUNC, rl_insert }, /* Pilcrow sign */
|
||||
{ ISFUNC, rl_insert }, /* Middle dot */
|
||||
{ ISFUNC, rl_insert }, /* Cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Superscript one */
|
||||
{ ISFUNC, rl_insert }, /* Masculine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Right pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one quarter */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one half */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction three quarters */
|
||||
{ ISFUNC, rl_insert }, /* Inverted questionk mark */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Multiplication sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter Y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter sharp s (German) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Division sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert } /* Latin small letter y with diaeresis */
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
|
||||
|
|
@ -424,7 +697,7 @@ KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
|
|||
{ ISFUNC, rl_do_lowercase_version }, /* Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, (Function *)0x0 }, /* [ */
|
||||
{ ISFUNC, rl_arrow_keys }, /* [ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* \ */
|
||||
{ ISFUNC, (Function *)0x0 }, /* ] */
|
||||
{ ISFUNC, (Function *)0x0 }, /* ^ */
|
||||
|
|
@ -446,7 +719,7 @@ KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
|
|||
{ ISFUNC, (Function *)0x0 }, /* l */
|
||||
{ ISFUNC, (Function *)0x0 }, /* m */
|
||||
{ ISFUNC, (Function *)0x0 }, /* n */
|
||||
{ ISFUNC, (Function *)0x0 }, /* o */
|
||||
{ ISFUNC, rl_arrow_keys }, /* o */
|
||||
{ ISFUNC, (Function *)0x0 }, /* p */
|
||||
{ ISFUNC, (Function *)0x0 }, /* q */
|
||||
{ ISFUNC, (Function *)0x0 }, /* r */
|
||||
|
|
@ -464,5 +737,137 @@ KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
|
|||
{ ISFUNC, (Function *)0x0 }, /* | */
|
||||
{ ISFUNC, (Function *)0x0 }, /* } */
|
||||
{ ISFUNC, (Function *)0x0 }, /* ~ */
|
||||
{ ISFUNC, rl_backward_kill_word } /* RUBOUT */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 },
|
||||
{ ISFUNC, (Function *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
78
gnu/lib/libreadline/xmalloc.c
Normal file
78
gnu/lib/libreadline/xmalloc.c
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/* xmalloc.c -- safe versions of malloc and realloc */
|
||||
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Readline, a library for reading lines
|
||||
of text with interactive input and history editing.
|
||||
|
||||
Readline is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 1, or (at your option) any
|
||||
later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if defined (ALREADY_HAVE_XMALLOC)
|
||||
#else
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
static void memory_error_and_abort ();
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Memory Allocation and Deallocation. */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Return a pointer to free()able block of memory large enough
|
||||
to hold BYTES number of bytes. If the memory cannot be allocated,
|
||||
print an error message and abort. */
|
||||
char *
|
||||
xmalloc (bytes)
|
||||
int bytes;
|
||||
{
|
||||
char *temp = (char *)malloc (bytes);
|
||||
|
||||
if (!temp)
|
||||
memory_error_and_abort ("xmalloc");
|
||||
return (temp);
|
||||
}
|
||||
|
||||
char *
|
||||
xrealloc (pointer, bytes)
|
||||
char *pointer;
|
||||
int bytes;
|
||||
{
|
||||
char *temp;
|
||||
|
||||
if (!pointer)
|
||||
temp = (char *)malloc (bytes);
|
||||
else
|
||||
temp = (char *)realloc (pointer, bytes);
|
||||
|
||||
if (!temp)
|
||||
memory_error_and_abort ("xrealloc");
|
||||
return (temp);
|
||||
}
|
||||
|
||||
static void
|
||||
memory_error_and_abort (fname)
|
||||
char *fname;
|
||||
{
|
||||
fprintf (stderr, "%s: Out of virtual memory!\n", fname);
|
||||
abort ();
|
||||
}
|
||||
#endif /* !ALREADY_HAVE_XMALLOC */
|
||||
Loading…
Reference in a new issue