summaryrefslogtreecommitdiff
path: root/lib/readline
diff options
context:
space:
mode:
Diffstat (limited to 'lib/readline')
-rw-r--r--lib/readline/COPYING913
-rw-r--r--lib/readline/Makefile.in35
-rw-r--r--lib/readline/ansi_stdlib.h26
-rw-r--r--lib/readline/bind.c170
-rw-r--r--lib/readline/callback.c41
-rw-r--r--lib/readline/chardefs.h25
-rw-r--r--lib/readline/compat.c26
-rw-r--r--lib/readline/complete.c415
-rw-r--r--lib/readline/display.c451
-rw-r--r--lib/readline/doc/._fdl.texibin0 -> 4096 bytes
-rw-r--r--lib/readline/doc/Makefile25
-rw-r--r--lib/readline/doc/fdl.texi96
-rw-r--r--lib/readline/doc/history.texi27
-rw-r--r--lib/readline/doc/hstech.texi2
-rw-r--r--lib/readline/doc/hsuser.texi17
-rw-r--r--lib/readline/doc/rlman.texi26
-rw-r--r--lib/readline/doc/rltech.texi217
-rw-r--r--lib/readline/doc/rluser.texi195
-rw-r--r--lib/readline/doc/rluserman.texi27
-rw-r--r--lib/readline/doc/version.texi12
-rw-r--r--lib/readline/emacs_keymap.c25
-rw-r--r--lib/readline/examples/Inputrc24
-rw-r--r--lib/readline/examples/Makefile26
-rw-r--r--lib/readline/examples/fileman.c29
-rw-r--r--lib/readline/examples/histexamp.c25
-rw-r--r--lib/readline/examples/manexamp.c23
-rw-r--r--lib/readline/examples/rl.c23
-rw-r--r--lib/readline/examples/rlcat.c23
-rw-r--r--lib/readline/examples/rltest.c23
-rw-r--r--lib/readline/funmap.c31
-rw-r--r--lib/readline/histexpand.c100
-rw-r--r--lib/readline/histfile.c31
-rw-r--r--lib/readline/histlib.h30
-rw-r--r--lib/readline/history.c31
-rw-r--r--lib/readline/history.h30
-rw-r--r--lib/readline/histsearch.c29
-rw-r--r--lib/readline/input.c73
-rw-r--r--lib/readline/isearch.c54
-rw-r--r--lib/readline/keymaps.c45
-rw-r--r--lib/readline/keymaps.h23
-rw-r--r--lib/readline/kill.c30
-rw-r--r--lib/readline/macro.c30
-rw-r--r--lib/readline/mbutil.c44
-rw-r--r--lib/readline/misc.c80
-rw-r--r--lib/readline/nls.c26
-rw-r--r--lib/readline/parens.c42
-rw-r--r--lib/readline/posixdir.h20
-rw-r--r--lib/readline/posixjmp.h20
-rw-r--r--lib/readline/posixselect.h47
-rw-r--r--lib/readline/posixstat.h20
-rw-r--r--lib/readline/readline.c95
-rw-r--r--lib/readline/readline.h68
-rw-r--r--lib/readline/rlconf.h29
-rw-r--r--lib/readline/rldefs.h32
-rw-r--r--lib/readline/rlmbutil.h25
-rw-r--r--lib/readline/rlprivate.h90
-rw-r--r--lib/readline/rlshell.h25
-rw-r--r--lib/readline/rlstdc.h28
-rw-r--r--lib/readline/rltty.c151
-rw-r--r--lib/readline/rltty.h28
-rw-r--r--lib/readline/rltypedefs.h25
-rw-r--r--lib/readline/rlwinsize.h33
-rw-r--r--lib/readline/savestring.c26
-rw-r--r--lib/readline/search.c33
-rw-r--r--lib/readline/shell.c26
-rw-r--r--lib/readline/signals.c234
-rw-r--r--lib/readline/tcap.h32
-rw-r--r--lib/readline/terminal.c44
-rw-r--r--lib/readline/text.c96
-rw-r--r--lib/readline/tilde.c34
-rw-r--r--lib/readline/tilde.h29
-rw-r--r--lib/readline/undo.c41
-rw-r--r--lib/readline/util.c192
-rw-r--r--lib/readline/vi_keymap.c31
-rw-r--r--lib/readline/vi_mode.c143
-rw-r--r--lib/readline/xmalloc.c27
-rw-r--r--lib/readline/xmalloc.h25
77 files changed, 3710 insertions, 1735 deletions
diff --git a/lib/readline/COPYING b/lib/readline/COPYING
index 1bf1526..94a9ed0 100644
--- a/lib/readline/COPYING
+++ b/lib/readline/COPYING
@@ -1,285 +1,626 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111 USA
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
+ Preamble
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. 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.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
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
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ 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
@@ -287,15 +628,15 @@ 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
+state 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) <year> <name of author>
- This program is free software; you can redistribute it and/or modify
+ 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
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -304,36 +645,30 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
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:
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU 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 Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in
index 5ab97b8..2204628 100644
--- a/lib/readline/Makefile.in
+++ b/lib/readline/Makefile.in
@@ -4,21 +4,20 @@
# #
#############################################################################
-# Copyright (C) 1994-2005 Free Software Foundation, Inc.
+# Copyright (C) 1994-2009 Free Software Foundation, Inc.
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
PACKAGE = @PACKAGE_NAME@
VERSION = @PACKAGE_VERSION@
@@ -33,6 +32,8 @@ VPATH = .:@srcdir@
topdir = @top_srcdir@
BUILD_DIR = @BUILD_DIR@
+datarootdir = @datarootdir@
+
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
@@ -98,6 +99,12 @@ OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
util.o kill.o undo.o macro.o input.o callback.o terminal.o \
text.o nls.o misc.o $(HISTOBJ) $(TILDEOBJ) xmalloc.o compat.o
+# The texinfo files which document this library.
+DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
+DOCOBJECT = doc/readline.dvi
+DOCSUPPORT = doc/Makefile
+DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT)
+
SUPPORT = Makefile ChangeLog $(DOCSUPPORT) examples/[-a-z.]*
SOURCES = $(CSOURCES) $(HSOURCES) $(DOCSOURCE)
@@ -123,6 +130,7 @@ libhistory.a: $(HISTOBJ) xmalloc.o
documentation: force
test -d doc || mkdir doc
+ -( cd doc && $(MAKE) $(MFLAGS) )
# Since tilde.c is shared between readline and bash, make sure we compile
# it with the right flags when it's built as part of readline
@@ -146,10 +154,13 @@ tags: force
clean: force
$(RM) $(OBJECTS) *.a
+ -( cd doc && $(MAKE) $(MFLAGS) $@ )
mostlyclean: clean
+ -( cd doc && $(MAKE) $(MFLAGS) $@ )
distclean maintainer-clean: clean
+ -( cd doc && $(MAKE) $(MFLAGS) $@ )
$(RM) Makefile
$(RM) TAGS tags
diff --git a/lib/readline/ansi_stdlib.h b/lib/readline/ansi_stdlib.h
index db13cd2..7dc2ee0 100644
--- a/lib/readline/ansi_stdlib.h
+++ b/lib/readline/ansi_stdlib.h
@@ -6,19 +6,19 @@
This file is part of GNU Bash, the Bourne Again SHell.
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_STDLIB_H_)
#define _STDLIB_H_ 1
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 67d14d6..fc8c2a2 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -1,24 +1,23 @@
/* bind.c -- key binding and startup file support for the readline library. */
-/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#define READLINE_LIBRARY
@@ -80,7 +79,7 @@ static int glean_key_from_name PARAMS((char *));
static int find_boolean_var PARAMS((const char *));
static char *_rl_get_string_variable_value PARAMS((const char *));
-static int substring_member_of_array PARAMS((char *, const char **));
+static int substring_member_of_array PARAMS((const char *, const char * const *));
static int currently_reading_init_file;
@@ -317,7 +316,7 @@ rl_macro_bind (keyseq, macro, map)
if (rl_translate_keyseq (macro, macro_keys, &macro_keys_len))
{
- free (macro_keys);
+ xfree (macro_keys);
return -1;
}
rl_generic_bind (ISMACR, keyseq, macro_keys, map);
@@ -347,7 +346,7 @@ rl_generic_bind (type, keyseq, data, map)
if (keyseq == 0 || *keyseq == 0)
{
if (type == ISMACR)
- free (data);
+ xfree (data);
return -1;
}
@@ -358,7 +357,7 @@ rl_generic_bind (type, keyseq, data, map)
KEYS into KEYS_LEN. */
if (rl_translate_keyseq (keyseq, keys, &keys_len))
{
- free (keys);
+ xfree (keys);
return -1;
}
@@ -371,7 +370,7 @@ rl_generic_bind (type, keyseq, data, map)
ic = uc;
if (ic < 0 || ic >= KEYMAP_SIZE)
{
- free (keys);
+ xfree (keys);
return -1;
}
@@ -414,11 +413,18 @@ rl_generic_bind (type, keyseq, data, map)
else
{
if (map[ic].type == ISMACR)
- free ((char *)map[ic].function);
+ xfree ((char *)map[ic].function);
else if (map[ic].type == ISKMAP)
{
map = FUNCTION_TO_KEYMAP (map, ic);
ic = ANYOTHERKEY;
+ /* If we're trying to override a keymap with a null function
+ (e.g., trying to unbind it), we can't use a null pointer
+ here because that's indistinguishable from having not been
+ overridden. We use a special bindable function that does
+ nothing. */
+ if (type == ISFUNC && data == 0)
+ data = (char *)_rl_null_function;
}
map[ic].function = KEYMAP_TO_FUNCTION (data);
@@ -427,7 +433,7 @@ rl_generic_bind (type, keyseq, data, map)
rl_binding_keymap = map;
}
- free (keys);
+ xfree (keys);
return 0;
}
@@ -752,9 +758,6 @@ rl_function_of_keyseq (keyseq, map, type)
/* The last key bindings file read. */
static char *last_readline_init_file = (char *)NULL;
-/* Flag to read system init file */
-static int read_system_init_file = 0;
-
/* The file we're currently reading key bindings from. */
static const char *current_readline_init_file;
static int current_readline_init_include_level;
@@ -796,10 +799,12 @@ _rl_read_file (filename, sizep)
if (i < 0)
{
- free (buffer);
+ xfree (buffer);
return ((char *)NULL);
}
+ RL_CHECK_SIGNALS ();
+
buffer[i] = '\0';
if (sizep)
*sizep = i;
@@ -866,8 +871,9 @@ _rl_read_init_file (filename, include_level)
openname = tilde_expand (filename);
buffer = _rl_read_file (openname, &file_size);
- free (openname);
+ xfree (openname);
+ RL_CHECK_SIGNALS ();
if (buffer == 0)
return (errno);
@@ -914,7 +920,7 @@ _rl_read_init_file (filename, include_level)
current_readline_init_lineno++;
}
- free (buffer);
+ xfree (buffer);
currently_reading_init_file = 0;
return (0);
}
@@ -924,10 +930,10 @@ _rl_init_file_error (msg)
const char *msg;
{
if (currently_reading_init_file)
- fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
+ _rl_errmsg ("%s: line %d: %s\n", current_readline_init_file,
current_readline_init_lineno, msg);
else
- fprintf (stderr, "readline: %s\n", msg);
+ _rl_errmsg ("%s", msg);
}
/* **************************************************************** */
@@ -939,11 +945,11 @@ _rl_init_file_error (msg)
typedef int _rl_parser_func_t PARAMS((char *));
/* Things that mean `Control'. */
-const char *_rl_possible_control_prefixes[] = {
+const char * const _rl_possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (const char *)NULL
};
-const char *_rl_possible_meta_prefixes[] = {
+const char * const _rl_possible_meta_prefixes[] = {
"Meta", "M-", (const char *)NULL
};
@@ -1005,7 +1011,7 @@ parser_if (args)
`$if term=sun-cmd' into their .inputrc. */
_rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) &&
_rl_stricmp (args + 5, rl_terminal_name);
- free (tname);
+ xfree (tname);
}
#if defined (VI_MODE)
else if (_rl_strnicmp (args, "mode=", 5) == 0)
@@ -1102,8 +1108,8 @@ parser_include (args)
}
/* Associate textual names with actual functions. */
-static struct {
- const char *name;
+static const struct {
+ const char * const name;
_rl_parser_func_t *function;
} parser_directives [] = {
{ "if", parser_if },
@@ -1355,7 +1361,7 @@ rl_parse_and_bind (string)
else
rl_bind_keyseq (seq, rl_named_function (funname));
- free (seq);
+ xfree (seq);
return 0;
}
@@ -1409,8 +1415,8 @@ rl_parse_and_bind (string)
#define V_SPECIAL 0x1
-static struct {
- const char *name;
+static const struct {
+ const char * const name;
int *value;
int flags;
} boolean_varlist [] = {
@@ -1420,7 +1426,9 @@ static struct {
{ "completion-ignore-case", &_rl_completion_case_fold, 0 },
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
{ "disable-completion", &rl_inhibit_completion, 0 },
+ { "echo-control-characters", &_rl_echo_control_chars, 0 },
{ "enable-keypad", &_rl_enable_keypad, 0 },
+ { "enable-meta-key", &_rl_enable_meta, 0 },
{ "expand-tilde", &rl_complete_with_tilde_expansion, 0 },
{ "history-preserve-point", &_rl_history_preserve_point, 0 },
{ "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 },
@@ -1434,8 +1442,10 @@ static struct {
{ "page-completions", &_rl_page_completions, 0 },
{ "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
{ "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
+ { "revert-all-at-newline", &_rl_revert_all_at_newline, 0 },
{ "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
{ "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 },
+ { "skip-completed-text", &_rl_skip_completed_text, 0 },
#if defined (VISIBLE_STATS)
{ "visible-stats", &rl_visible_stats, 0 },
#endif /* VISIBLE_STATS */
@@ -1492,20 +1502,24 @@ typedef int _rl_sv_func_t PARAMS((const char *));
/* Forward declarations */
static int sv_bell_style PARAMS((const char *));
static int sv_combegin PARAMS((const char *));
+static int sv_dispprefix PARAMS((const char *));
static int sv_compquery PARAMS((const char *));
static int sv_editmode PARAMS((const char *));
+static int sv_histsize PARAMS((const char *));
static int sv_isrchterm PARAMS((const char *));
static int sv_keymap PARAMS((const char *));
-static struct {
- const char *name;
+static const struct {
+ const char * const name;
int flags;
_rl_sv_func_t *set_func;
} string_varlist[] = {
{ "bell-style", V_STRING, sv_bell_style },
{ "comment-begin", V_STRING, sv_combegin },
+ { "completion-prefix-display-length", V_INT, sv_dispprefix },
{ "completion-query-items", V_INT, sv_compquery },
{ "editing-mode", V_STRING, sv_editmode },
+ { "history-size", V_INT, sv_histsize },
{ "isearch-terminators", V_STRING, sv_isrchterm },
{ "keymap", V_STRING, sv_keymap },
{ (char *)NULL, 0 }
@@ -1617,6 +1631,22 @@ sv_combegin (value)
}
static int
+sv_dispprefix (value)
+ const char *value;
+{
+ int nval = 0;
+
+ if (value && *value)
+ {
+ nval = atoi (value);
+ if (nval < 0)
+ nval = 0;
+ }
+ _rl_completion_prefix_display_length = nval;
+ return 0;
+}
+
+static int
sv_compquery (value)
const char *value;
{
@@ -1633,6 +1663,22 @@ sv_compquery (value)
}
static int
+sv_histsize (value)
+ const char *value;
+{
+ int nval = 500;
+
+ if (value && *value)
+ {
+ nval = atoi (value);
+ if (nval < 0)
+ return 1;
+ }
+ stifle_history (nval);
+ return 0;
+}
+
+static int
sv_keymap (value)
const char *value;
{
@@ -1696,7 +1742,7 @@ sv_isrchterm (value)
rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
_rl_isearch_terminators[end] = '\0';
- free (v);
+ xfree (v);
return 0;
}
@@ -1704,11 +1750,11 @@ sv_isrchterm (value)
For example, `Space' returns ' '. */
typedef struct {
- const char *name;
+ const char * const name;
int value;
} assoc_list;
-static assoc_list name_key_alist[] = {
+static const assoc_list name_key_alist[] = {
{ "DEL", 0x7f },
{ "ESC", '\033' },
{ "Escape", '\033' },
@@ -1737,8 +1783,8 @@ glean_key_from_name (name)
}
/* Auxiliary functions to manage keymaps. */
-static struct {
- const char *name;
+static const struct {
+ const char * const name;
Keymap map;
} keymap_names[] = {
{ "emacs", emacs_standard_keymap },
@@ -1841,7 +1887,7 @@ rl_list_funmap_names ()
for (i = 0; funmap_names[i]; i++)
fprintf (rl_outstream, "%s\n", funmap_names[i]);
- free (funmap_names);
+ xfree (funmap_names);
}
static char *
@@ -2007,7 +2053,7 @@ rl_invoking_keyseqs_in_map (function, map)
}
strcat (keyname, seqs[i]);
- free (seqs[i]);
+ xfree (seqs[i]);
if (result_index + 2 > result_size)
{
@@ -2019,7 +2065,7 @@ rl_invoking_keyseqs_in_map (function, map)
result[result_index] = (char *)NULL;
}
- free (seqs);
+ xfree (seqs);
}
break;
}
@@ -2071,10 +2117,10 @@ rl_function_dumper (print_readably)
{
fprintf (rl_outstream, "\"%s\": %s\n",
invokers[j], name);
- free (invokers[j]);
+ xfree (invokers[j]);
}
- free (invokers);
+ xfree (invokers);
}
}
else
@@ -2098,9 +2144,9 @@ rl_function_dumper (print_readably)
fprintf (rl_outstream, "...\n");
for (j = 0; invokers[j]; j++)
- free (invokers[j]);
+ xfree (invokers[j]);
- free (invokers);
+ xfree (invokers);
}
}
}
@@ -2146,8 +2192,8 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "",
keyname,
out ? out : "");
- free (keyname);
- free (out);
+ xfree (keyname);
+ xfree (out);
break;
case ISFUNC:
break;
@@ -2170,13 +2216,13 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);
strcpy (out, prefix);
strcpy (out + prefix_len, keyname);
- free (keyname);
+ xfree (keyname);
keyname = out;
}
}
_rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname);
- free (keyname);
+ xfree (keyname);
break;
}
}
@@ -2222,6 +2268,11 @@ _rl_get_string_variable_value (name)
}
else if (_rl_stricmp (name, "comment-begin") == 0)
return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
+ else if (_rl_stricmp (name, "completion-prefix-display-length") == 0)
+ {
+ sprintf (numbuf, "%d", _rl_completion_prefix_display_length);
+ return (numbuf);
+ }
else if (_rl_stricmp (name, "completion-query-items") == 0)
{
sprintf (numbuf, "%d", rl_completion_query_items);
@@ -2229,6 +2280,11 @@ _rl_get_string_variable_value (name)
}
else if (_rl_stricmp (name, "editing-mode") == 0)
return (rl_get_keymap_name_from_edit_mode ());
+ else if (_rl_stricmp (name, "history-size") == 0)
+ {
+ sprintf (numbuf, "%d", history_is_stifled() ? history_max_entries : 0);
+ return (numbuf);
+ }
else if (_rl_stricmp (name, "isearch-terminators") == 0)
{
if (_rl_isearch_terminators == 0)
@@ -2237,7 +2293,7 @@ _rl_get_string_variable_value (name)
if (ret)
{
strncpy (numbuf, ret, sizeof (numbuf) - 1);
- free (ret);
+ xfree (ret);
numbuf[sizeof(numbuf) - 1] = '\0';
}
else
@@ -2301,8 +2357,8 @@ rl_dump_variables (count, key)
/* Return non-zero if any members of ARRAY are a substring in STRING. */
static int
substring_member_of_array (string, array)
- char *string;
- const char **array;
+ const char *string;
+ const char * const *array;
{
while (*array)
{
diff --git a/lib/readline/callback.c b/lib/readline/callback.c
index ada04d8..6c52ac0 100644
--- a/lib/readline/callback.c
+++ b/lib/readline/callback.c
@@ -1,24 +1,24 @@
/* callback.c -- functions to use readline as an X `callback' mechanism. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -87,6 +87,7 @@ _rl_callback_newline ()
}
readline_internal_setup ();
+ RL_CHECK_SIGNALS ();
}
/* Install a readline handler, set up the terminal, and issue the prompt. */
@@ -111,22 +112,23 @@ rl_callback_read_char ()
if (rl_linefunc == NULL)
{
- fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n");
+ _rl_errmsg ("readline_callback_read_char() called with no handler!");
abort ();
}
- memcpy ((void *)olevel, (void *)readline_top_level, sizeof (procenv_t));
- jcode = setjmp (readline_top_level);
+ memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t));
+ jcode = setjmp (_rl_top_level);
if (jcode)
{
(*rl_redisplay_function) ();
_rl_want_redisplay = 0;
- memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t));
+ memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
return;
}
do
{
+ RL_CHECK_SIGNALS ();
if (RL_ISSTATE (RL_STATE_ISEARCH))
{
eof = _rl_isearch_callback (_rl_iscxt);
@@ -186,6 +188,7 @@ rl_callback_read_char ()
else
eof = readline_internal_char ();
+ RL_CHECK_SIGNALS ();
if (rl_done == 0 && _rl_want_redisplay)
{
(*rl_redisplay_function) ();
@@ -223,6 +226,7 @@ rl_callback_handler_remove ()
{
rl_linefunc = NULL;
RL_UNSETSTATE (RL_STATE_CALLBACK);
+ RL_CHECK_SIGNALS ();
if (in_handler)
{
in_handler = 0;
@@ -251,8 +255,7 @@ _rl_callback_data_alloc (count)
void _rl_callback_data_dispose (arg)
_rl_callback_generic_arg *arg;
{
- if (arg)
- free (arg);
+ xfree (arg);
}
#endif
diff --git a/lib/readline/chardefs.h b/lib/readline/chardefs.h
index def3a11..e76c34b 100644
--- a/lib/readline/chardefs.h
+++ b/lib/readline/chardefs.h
@@ -1,24 +1,23 @@
/* chardefs.h -- Character definitions for readline. */
-/* Copyright (C) 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#ifndef _CHARDEFS_H_
#define _CHARDEFS_H_
diff --git a/lib/readline/compat.c b/lib/readline/compat.c
index a66d210..2af5120 100644
--- a/lib/readline/compat.c
+++ b/lib/readline/compat.c
@@ -1,24 +1,24 @@
/* compat.c -- backwards compatibility functions. */
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index 73f834a..ad9ca05 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -1,24 +1,24 @@
/* complete.c -- filename completion for readline. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -110,8 +110,8 @@ static int get_y_or_n PARAMS((int));
static int _rl_internal_pager PARAMS((int));
static char *printable_part PARAMS((char *));
static int fnwidth PARAMS((const char *));
-static int fnprint PARAMS((const char *));
-static int print_filename PARAMS((char *, char *));
+static int fnprint PARAMS((const char *, int));
+static int print_filename PARAMS((char *, char *, int));
static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
@@ -164,6 +164,12 @@ int _rl_completion_case_fold;
Unix) when doing filename completion. */
int _rl_match_hidden_files = 1;
+/* Length in characters of a common prefix replaced with an ellipsis (`...')
+ when displaying completion matches. Matches whose printable portion has
+ more than this number of displaying characters in common will have the common
+ display prefix replaced with an ellipsis. */
+int _rl_completion_prefix_display_length = 0;
+
/* Global variables available to applications using readline. */
#if defined (VISIBLE_STATS)
@@ -173,6 +179,12 @@ int _rl_match_hidden_files = 1;
int rl_visible_stats = 0;
#endif /* VISIBLE_STATS */
+/* If non-zero, when completing in the middle of a word, don't insert
+ characters from the match that match characters following point in
+ the word. This means, for instance, completing when the cursor is
+ after the `e' in `Makefile' won't result in `Makefilefile'. */
+int _rl_skip_completed_text = 0;
+
/* If non-zero, then this is the address of a function to call when
completing on a directory name. The function is called with
the address of a string (the current directory name) as an arg. */
@@ -180,6 +192,17 @@ rl_icppfunc_t *rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
rl_icppfunc_t *rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
+/* If non-zero, this is the address of a function to call when reading
+ directory entries from the filesystem for completion and comparing
+ them to the partial word to be completed. The function should
+ either return its first argument (if no conversion takes place) or
+ newly-allocated memory. This can, for instance, convert filenames
+ between character sets for comparison against what's typed at the
+ keyboard. The returned value is what is added to the list of
+ matches. The second argument is the length of the filename to be
+ converted. */
+rl_dequote_func_t *rl_filename_rewrite_hook = (rl_dequote_func_t *)NULL;
+
/* Non-zero means readline completion functions perform tilde expansion. */
int rl_complete_with_tilde_expansion = 0;
@@ -188,6 +211,10 @@ int rl_complete_with_tilde_expansion = 0;
completer. */
rl_compentry_func_t *rl_completion_entry_function = (rl_compentry_func_t *)NULL;
+/* Pointer to generator function for rl_menu_complete (). NULL means to use
+ *rl_completion_entry_function (see above). */
+rl_compentry_func_t *rl_menu_completion_entry_function = (rl_compentry_func_t *)NULL;
+
/* Pointer to alternative function to create matches.
Function is called with TEXT, START, and END.
START and END are indices in RL_LINE_BUFFER saying what the boundaries
@@ -325,11 +352,20 @@ int rl_completion_mark_symlink_dirs;
/* If non-zero, inhibit completion (temporarily). */
int rl_inhibit_completion;
+/* Set to the last key used to invoke one of the completion functions */
+int rl_completion_invoking_key;
+
+/* If non-zero, sort the completion matches. On by default. */
+int rl_sort_completion_matches = 1;
+
/* Variables local to this file. */
/* Local variable states what happened during the last completion attempt. */
static int completion_changed_buffer;
+/* The result of the query to the user about displaying completion matches */
+static int completion_y_or_n;
+
/*************************************/
/* */
/* Bindable completion functions */
@@ -343,6 +379,8 @@ int
rl_complete (ignore, invoking_key)
int ignore, invoking_key;
{
+ rl_completion_invoking_key = invoking_key;
+
if (rl_inhibit_completion)
return (_rl_insert_char (ignore, invoking_key));
else if (rl_last_func == rl_complete && !completion_changed_buffer)
@@ -360,6 +398,7 @@ int
rl_possible_completions (ignore, invoking_key)
int ignore, invoking_key;
{
+ rl_completion_invoking_key = invoking_key;
return (rl_complete_internal ('?'));
}
@@ -367,6 +406,7 @@ int
rl_insert_completions (ignore, invoking_key)
int ignore, invoking_key;
{
+ rl_completion_invoking_key = invoking_key;
return (rl_complete_internal ('*'));
}
@@ -395,6 +435,14 @@ rl_completion_mode (cfunc)
/* */
/************************************/
+/* Reset readline state on a signal or other event. */
+void
+_rl_reset_completion_state ()
+{
+ rl_completion_found_quote = 0;
+ rl_completion_quote_character = 0;
+}
+
/* Set default values for readline word completion. These are the variables
that application completion functions can change or inspect. */
static void
@@ -406,6 +454,7 @@ set_completion_defaults (what_to_do)
rl_filename_quoting_desired = 1;
rl_completion_type = what_to_do;
rl_completion_suppress_append = rl_completion_suppress_quote = 0;
+ rl_completion_append_character = ' ';
/* The completion entry function may optionally change this. */
rl_completion_mark_symlink_dirs = _rl_complete_mark_symlink_dirs;
@@ -428,7 +477,7 @@ get_y_or_n (for_pager)
return (1);
if (c == 'n' || c == 'N' || c == RUBOUT)
return (0);
- if (c == ABORT_CHAR)
+ if (c == ABORT_CHAR || c < 0)
_rl_abort_internal ();
if (for_pager && (c == NEWLINE || c == RETURN))
return (2);
@@ -481,6 +530,13 @@ stat_char (filename)
struct stat finfo;
int character, r;
+ /* Short-circuit a //server on cygwin, since that will always behave as
+ a directory. */
+#if __CYGWIN__
+ if (filename[0] == '/' && filename[1] == '/' && strchr (filename+2, '/') == 0)
+ return '/';
+#endif
+
#if defined (HAVE_LSTAT) && defined (S_ISLNK)
r = lstat (filename, &finfo);
#else
@@ -581,7 +637,7 @@ fnwidth (string)
width = pos = 0;
while (string[pos])
{
- if (CTRL_CHAR (*string) || *string == RUBOUT)
+ if (CTRL_CHAR (string[pos]) || string[pos] == RUBOUT)
{
width += 2;
pos++;
@@ -614,17 +670,20 @@ fnwidth (string)
return width;
}
+#define ELLIPSIS_LEN 3
+
static int
-fnprint (to_print)
+fnprint (to_print, prefix_bytes)
const char *to_print;
+ int prefix_bytes;
{
- int printed_len;
+ int printed_len, w;
const char *s;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
const char *end;
size_t tlen;
- int width, w;
+ int width;
wchar_t wc;
end = to_print + strlen (to_print) + 1;
@@ -632,7 +691,23 @@ fnprint (to_print)
#endif
printed_len = 0;
- s = to_print;
+
+ /* Don't print only the ellipsis if the common prefix is one of the
+ possible completions */
+ if (to_print[prefix_bytes] == '\0')
+ prefix_bytes = 0;
+
+ if (prefix_bytes)
+ {
+ char ellipsis;
+
+ ellipsis = (to_print[prefix_bytes] == '.') ? '_' : '.';
+ for (w = 0; w < ELLIPSIS_LEN; w++)
+ putc (ellipsis, rl_outstream);
+ printed_len = ELLIPSIS_LEN;
+ }
+
+ s = to_print + prefix_bytes;
while (*s)
{
if (CTRL_CHAR (*s))
@@ -691,14 +766,15 @@ fnprint (to_print)
filenames. Return the number of characters we output. */
static int
-print_filename (to_print, full_pathname)
+print_filename (to_print, full_pathname, prefix_bytes)
char *to_print, *full_pathname;
+ int prefix_bytes;
{
int printed_len, extension_char, slen, tlen;
char *s, c, *new_full_pathname, *dn;
extension_char = 0;
- printed_len = fnprint (to_print);
+ printed_len = fnprint (to_print, prefix_bytes);
#if defined (VISIBLE_STATS)
if (rl_filename_completion_desired && (rl_visible_stats || _rl_complete_mark_directories))
@@ -960,7 +1036,10 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
variable rl_attempted_completion_function. */
if (rl_attempted_completion_function)
{
+ _rl_interrupt_immediately++;
matches = (*rl_attempted_completion_function) (text, start, end);
+ if (_rl_interrupt_immediately > 0)
+ _rl_interrupt_immediately--;
if (matches || rl_attempted_completion_over)
{
@@ -992,7 +1071,7 @@ remove_duplicate_matches (matches)
/* Sort the array without matches[0], since we need it to
stay in place no matter what. */
- if (i)
+ if (i && rl_sort_completion_matches)
qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
/* Remember the lowest common denominator for it may be unique. */
@@ -1256,8 +1335,24 @@ rl_display_match_list (matches, len, max)
int len, max;
{
int count, limit, printed_len, lines;
- int i, j, k, l;
- char *temp;
+ int i, j, k, l, common_length, sind;
+ char *temp, *t;
+
+ /* Find the length of the prefix common to all items: length as displayed
+ characters (common_length) and as a byte index into the matches (sind) */
+ common_length = sind = 0;
+ if (_rl_completion_prefix_display_length > 0)
+ {
+ t = printable_part (matches[0]);
+ temp = strrchr (t, '/');
+ common_length = temp ? fnwidth (temp) : fnwidth (t);
+ sind = temp ? strlen (temp) : strlen (t);
+
+ if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN)
+ max -= common_length - ELLIPSIS_LEN;
+ else
+ common_length = sind = 0;
+ }
/* How many items of MAX length can we fit in the screen window? */
max += 2;
@@ -1278,7 +1373,7 @@ rl_display_match_list (matches, len, max)
0 < len <= limit implies count = 1. */
/* Sort the items if they are not already sorted. */
- if (rl_ignore_completion_duplicates == 0)
+ if (rl_ignore_completion_duplicates == 0 && rl_sort_completion_matches)
qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
rl_crlf ();
@@ -1296,7 +1391,7 @@ rl_display_match_list (matches, len, max)
else
{
temp = printable_part (matches[l]);
- printed_len = print_filename (temp, matches[l]);
+ printed_len = print_filename (temp, matches[l], sind);
if (j + 1 < limit)
for (k = 0; k < max - printed_len; k++)
@@ -1320,7 +1415,7 @@ rl_display_match_list (matches, len, max)
for (i = 1; matches[i]; i++)
{
temp = printable_part (matches[i]);
- printed_len = print_filename (temp, matches[i]);
+ printed_len = print_filename (temp, matches[i], sind);
/* Have we reached the end of this line? */
if (matches[i+1])
{
@@ -1370,7 +1465,7 @@ display_matches (matches)
{
temp = printable_part (matches[0]);
rl_crlf ();
- print_filename (temp, matches[0]);
+ print_filename (temp, matches[0], 0);
rl_crlf ();
rl_forced_update_display ();
@@ -1406,7 +1501,7 @@ display_matches (matches)
rl_crlf ();
fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
fflush (rl_outstream);
- if (get_y_or_n (0) == 0)
+ if ((completion_y_or_n = get_y_or_n (0)) == 0)
{
rl_crlf ();
@@ -1474,8 +1569,9 @@ insert_match (match, start, mtype, qc)
int start, mtype;
char *qc;
{
- char *replacement;
+ char *replacement, *r;
char oqc;
+ int end, rlen;
oqc = qc ? *qc : '\0';
replacement = make_quoted_replacement (match, mtype, qc);
@@ -1483,6 +1579,7 @@ insert_match (match, start, mtype, qc)
/* Now insert the match. */
if (replacement)
{
+ rlen = strlen (replacement);
/* Don't double an opening quote character. */
if (qc && *qc && start && rl_line_buffer[start - 1] == *qc &&
replacement[0] == *qc)
@@ -1492,7 +1589,24 @@ insert_match (match, start, mtype, qc)
else if (qc && (*qc != oqc) && start && rl_line_buffer[start - 1] == oqc &&
replacement[0] != oqc)
start--;
- _rl_replace_text (replacement, start, rl_point - 1);
+ end = rl_point - 1;
+ /* Don't double a closing quote character */
+ if (qc && *qc && end && rl_line_buffer[rl_point] == *qc && replacement[rlen - 1] == *qc)
+ end++;
+ if (_rl_skip_completed_text)
+ {
+ r = replacement;
+ while (start < rl_end && *r && rl_line_buffer[start] == *r)
+ {
+ start++;
+ r++;
+ }
+ if (start <= end || *r)
+ _rl_replace_text (r, start, end);
+ rl_point = start + strlen (r);
+ }
+ else
+ _rl_replace_text (replacement, start, end);
if (replacement != match)
free (replacement);
}
@@ -1678,6 +1792,7 @@ rl_complete_internal (what_to_do)
FREE (saved_line_buffer);
completion_changed_buffer = 0;
RL_UNSETSTATE(RL_STATE_COMPLETING);
+ _rl_reset_completion_state ();
return (0);
}
@@ -1692,6 +1807,7 @@ rl_complete_internal (what_to_do)
FREE (saved_line_buffer);
completion_changed_buffer = 0;
RL_UNSETSTATE(RL_STATE_COMPLETING);
+ _rl_reset_completion_state ();
return (0);
}
@@ -1742,10 +1858,11 @@ rl_complete_internal (what_to_do)
break;
default:
- fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do);
+ _rl_ttymsg ("bad value %d for what_to_do in rl_complete", what_to_do);
rl_ding ();
FREE (saved_line_buffer);
RL_UNSETSTATE(RL_STATE_COMPLETING);
+ _rl_reset_completion_state ();
return 1;
}
@@ -1759,6 +1876,7 @@ rl_complete_internal (what_to_do)
}
RL_UNSETSTATE(RL_STATE_COMPLETING);
+ _rl_reset_completion_state ();
return 0;
}
@@ -1802,6 +1920,7 @@ rl_completion_matches (text, entry_function)
match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *));
match_list[1] = (char *)NULL;
+ _rl_interrupt_immediately++;
while (string = (*entry_function) (text, matches))
{
if (matches + 1 == match_list_size)
@@ -1811,6 +1930,8 @@ rl_completion_matches (text, entry_function)
match_list[++matches] = string;
match_list[matches + 1] = (char *)NULL;
}
+ if (_rl_interrupt_immediately > 0)
+ _rl_interrupt_immediately--;
/* If there were any matches, then look through them finding out the
lowest common denominator. That then becomes match_list[0]. */
@@ -1898,8 +2019,8 @@ rl_filename_completion_function (text, state)
static char *dirname = (char *)NULL;
static char *users_dirname = (char *)NULL;
static int filename_len;
- char *temp;
- int dirlen;
+ char *temp, *dentry, *convfn;
+ int dirlen, dentlen, convlen;
struct dirent *entry;
/* If we don't have any state, then do some initialization. */
@@ -2003,6 +2124,15 @@ rl_filename_completion_function (text, state)
entry = (struct dirent *)NULL;
while (directory && (entry = readdir (directory)))
{
+ convfn = dentry = entry->d_name;
+ convlen = dentlen = D_NAMLEN (entry);
+
+ if (rl_filename_rewrite_hook)
+ {
+ convfn = (*rl_filename_rewrite_hook) (dentry, dentlen);
+ convlen = (convfn == dentry) ? dentlen : strlen (convfn);
+ }
+
/* Special case for no filename. If the user has disabled the
`match-hidden-files' variable, skip filenames beginning with `.'.
All other entries except "." and ".." match. */
@@ -2011,9 +2141,8 @@ rl_filename_completion_function (text, state)
if (_rl_match_hidden_files == 0 && HIDDEN_FILE (entry->d_name))
continue;
- if (entry->d_name[0] != '.' ||
- (entry->d_name[1] &&
- (entry->d_name[1] != '.' || entry->d_name[2])))
+ if (convfn[0] != '.' ||
+ (convfn[1] && (convfn[1] != '.' || convfn[2])))
break;
}
else
@@ -2022,16 +2151,16 @@ rl_filename_completion_function (text, state)
it is a match. */
if (_rl_completion_case_fold)
{
- if ((_rl_to_lower (entry->d_name[0]) == _rl_to_lower (filename[0])) &&
- (((int)D_NAMLEN (entry)) >= filename_len) &&
- (_rl_strnicmp (filename, entry->d_name, filename_len) == 0))
+ if ((_rl_to_lower (convfn[0]) == _rl_to_lower (filename[0])) &&
+ (convlen >= filename_len) &&
+ (_rl_strnicmp (filename, convfn, filename_len) == 0))
break;
}
else
{
- if ((entry->d_name[0] == filename[0]) &&
- (((int)D_NAMLEN (entry)) >= filename_len) &&
- (strncmp (filename, entry->d_name, filename_len) == 0))
+ if ((convfn[0] == filename[0]) &&
+ (convlen >= filename_len) &&
+ (strncmp (filename, convfn, filename_len) == 0))
break;
}
}
@@ -2093,22 +2222,145 @@ rl_filename_completion_function (text, state)
strcpy (temp + dirlen, entry->d_name);
}
else
- temp = savestring (entry->d_name);
+ temp = savestring (convfn);
+
+ if (convfn != dentry)
+ free (convfn);
return (temp);
}
}
/* An initial implementation of a menu completion function a la tcsh. The
- first time (if the last readline command was not rl_menu_complete), we
+ first time (if the last readline command was not rl_old_menu_complete), we
generate the list of matches. This code is very similar to the code in
rl_complete_internal -- there should be a way to combine the two. Then,
for each item in the list of matches, we insert the match in an undoable
fashion, with the appropriate character appended (this happens on the
- second and subsequent consecutive calls to rl_menu_complete). When we
+ second and subsequent consecutive calls to rl_old_menu_complete). When we
hit the end of the match list, we restore the original unmatched text,
ring the bell, and reset the counter to zero. */
int
+rl_old_menu_complete (count, invoking_key)
+ int count, invoking_key;
+{
+ rl_compentry_func_t *our_func;
+ int matching_filenames, found_quote;
+
+ static char *orig_text;
+ static char **matches = (char **)0;
+ static int match_list_index = 0;
+ static int match_list_size = 0;
+ static int orig_start, orig_end;
+ static char quote_char;
+ static int delimiter;
+
+ /* The first time through, we generate the list of matches and set things
+ up to insert them. */
+ if (rl_last_func != rl_old_menu_complete)
+ {
+ /* Clean up from previous call, if any. */
+ FREE (orig_text);
+ if (matches)
+ _rl_free_match_list (matches);
+
+ match_list_index = match_list_size = 0;
+ matches = (char **)NULL;
+
+ rl_completion_invoking_key = invoking_key;
+
+ RL_SETSTATE(RL_STATE_COMPLETING);
+
+ /* Only the completion entry function can change these. */
+ set_completion_defaults ('%');
+
+ our_func = rl_menu_completion_entry_function;
+ if (our_func == 0)
+ our_func = rl_completion_entry_function
+ ? rl_completion_entry_function
+ : rl_filename_completion_function;
+
+ /* We now look backwards for the start of a filename/variable word. */
+ orig_end = rl_point;
+ found_quote = delimiter = 0;
+ quote_char = '\0';
+
+ if (rl_point)
+ /* This (possibly) changes rl_point. If it returns a non-zero char,
+ we know we have an open quote. */
+ quote_char = _rl_find_completion_word (&found_quote, &delimiter);
+
+ orig_start = rl_point;
+ rl_point = orig_end;
+
+ orig_text = rl_copy_text (orig_start, orig_end);
+ matches = gen_completion_matches (orig_text, orig_start, orig_end,
+ our_func, found_quote, quote_char);
+
+ /* If we are matching filenames, the attempted completion function will
+ have set rl_filename_completion_desired to a non-zero value. The basic
+ rl_filename_completion_function does this. */
+ matching_filenames = rl_filename_completion_desired;
+
+ if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0)
+ {
+ rl_ding ();
+ FREE (matches);
+ matches = (char **)0;
+ FREE (orig_text);
+ orig_text = (char *)0;
+ completion_changed_buffer = 0;
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
+ return (0);
+ }
+
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
+
+ for (match_list_size = 0; matches[match_list_size]; match_list_size++)
+ ;
+ /* matches[0] is lcd if match_list_size > 1, but the circular buffer
+ code below should take care of it. */
+
+ if (match_list_size > 1 && _rl_complete_show_all)
+ display_matches (matches);
+ }
+
+ /* Now we have the list of matches. Replace the text between
+ rl_line_buffer[orig_start] and rl_line_buffer[rl_point] with
+ matches[match_list_index], and add any necessary closing char. */
+
+ if (matches == 0 || match_list_size == 0)
+ {
+ rl_ding ();
+ FREE (matches);
+ matches = (char **)0;
+ completion_changed_buffer = 0;
+ return (0);
+ }
+
+ match_list_index += count;
+ if (match_list_index < 0)
+ match_list_index += match_list_size;
+ else
+ match_list_index %= match_list_size;
+
+ if (match_list_index == 0 && match_list_size > 1)
+ {
+ rl_ding ();
+ insert_match (orig_text, orig_start, MULT_MATCH, &quote_char);
+ }
+ else
+ {
+ insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, &quote_char);
+ append_to_match (matches[match_list_index], delimiter, quote_char,
+ strcmp (orig_text, matches[match_list_index]));
+ }
+
+ completion_changed_buffer = 1;
+ return (0);
+}
+
+int
rl_menu_complete (count, ignore)
int count, ignore;
{
@@ -2119,13 +2371,15 @@ rl_menu_complete (count, ignore)
static char **matches = (char **)0;
static int match_list_index = 0;
static int match_list_size = 0;
+ static int nontrivial_lcd = 0;
+ static int full_completion = 0; /* set to 1 if menu completion should reinitialize on next call */
static int orig_start, orig_end;
static char quote_char;
static int delimiter;
/* The first time through, we generate the list of matches and set things
up to insert them. */
- if (rl_last_func != rl_menu_complete)
+ if ((rl_last_func != rl_menu_complete && rl_last_func != rl_backward_menu_complete) || full_completion)
{
/* Clean up from previous call, if any. */
FREE (orig_text);
@@ -2135,10 +2389,16 @@ rl_menu_complete (count, ignore)
match_list_index = match_list_size = 0;
matches = (char **)NULL;
+ full_completion = 0;
+
+ RL_SETSTATE(RL_STATE_COMPLETING);
+
/* Only the completion entry function can change these. */
set_completion_defaults ('%');
- our_func = rl_completion_entry_function
+ our_func = rl_menu_completion_entry_function;
+ if (our_func == 0)
+ our_func = rl_completion_entry_function
? rl_completion_entry_function
: rl_filename_completion_function;
@@ -2159,6 +2419,8 @@ rl_menu_complete (count, ignore)
matches = gen_completion_matches (orig_text, orig_start, orig_end,
our_func, found_quote, quote_char);
+ nontrivial_lcd = matches && strcmp (orig_text, matches[0]) != 0;
+
/* If we are matching filenames, the attempted completion function will
have set rl_filename_completion_desired to a non-zero value. The basic
rl_filename_completion_function does this. */
@@ -2172,13 +2434,55 @@ rl_menu_complete (count, ignore)
FREE (orig_text);
orig_text = (char *)0;
completion_changed_buffer = 0;
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
return (0);
}
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
+
for (match_list_size = 0; matches[match_list_size]; match_list_size++)
;
+
+ if (match_list_size == 0)
+ {
+ rl_ding ();
+ FREE (matches);
+ matches = (char **)0;
+ match_list_index = 0;
+ completion_changed_buffer = 0;
+ return (0);
+ }
+
/* matches[0] is lcd if match_list_size > 1, but the circular buffer
code below should take care of it. */
+ if (*matches[0])
+ {
+ insert_match (matches[0], orig_start, matches[1] ? MULT_MATCH : SINGLE_MATCH, &quote_char);
+ orig_end = orig_start + strlen (matches[0]);
+ completion_changed_buffer = STREQ (orig_text, matches[0]) == 0;
+ }
+
+ if (match_list_size > 1 && _rl_complete_show_all)
+ {
+ display_matches (matches);
+ /* If there are so many matches that the user has to be asked
+ whether or not he wants to see the matches, menu completion
+ is unwieldy. */
+ if (rl_completion_query_items > 0 && match_list_size >= rl_completion_query_items)
+ {
+ rl_ding ();
+ FREE (matches);
+ matches = (char **)0;
+ full_completion = 1;
+ return (0);
+ }
+ }
+ else if (match_list_size <= 1)
+ {
+ append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd);
+ full_completion = 1;
+ return (0);
+ }
}
/* Now we have the list of matches. Replace the text between
@@ -2203,7 +2507,7 @@ rl_menu_complete (count, ignore)
if (match_list_index == 0 && match_list_size > 1)
{
rl_ding ();
- insert_match (orig_text, orig_start, MULT_MATCH, &quote_char);
+ insert_match (matches[0], orig_start, MULT_MATCH, &quote_char);
}
else
{
@@ -2215,3 +2519,12 @@ rl_menu_complete (count, ignore)
completion_changed_buffer = 1;
return (0);
}
+
+int
+rl_backward_menu_complete (count, key)
+ int count, key;
+{
+ /* Positive arguments to backward-menu-complete translate into negative
+ arguments for menu-complete, and vice versa. */
+ return (rl_menu_complete (-count, key));
+}
diff --git a/lib/readline/display.c b/lib/readline/display.c
index 47ff061..e4105ee 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -1,24 +1,24 @@
/* display.c -- readline redisplay facility. */
-/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -65,15 +65,39 @@ static void delete_chars PARAMS((int));
static void insert_some_chars PARAMS((char *, int, int));
static void cr PARAMS((void));
+/* State of visible and invisible lines. */
+struct line_state
+ {
+ char *line;
+ int *lbreaks;
+ int lbsize;
#if defined (HANDLE_MULTIBYTE)
-static int _rl_col_width PARAMS((const char *, int, int));
-static int *_rl_wrapped_line;
-#else
-# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
+ int *wrapped_line;
+ int wbsize;
#endif
+ };
+
+/* The line display buffers. One is the line currently displayed on
+ the screen. The other is the line about to be displayed. */
+static struct line_state line_state_array[2];
+static struct line_state *line_state_visible = &line_state_array[0];
+static struct line_state *line_state_invisible = &line_state_array[1];
+static int line_structures_initialized = 0;
-static int *inv_lbreaks, *vis_lbreaks;
-static int inv_lbsize, vis_lbsize;
+/* Backwards-compatible names. */
+#define inv_lbreaks (line_state_invisible->lbreaks)
+#define inv_lbsize (line_state_invisible->lbsize)
+#define vis_lbreaks (line_state_visible->lbreaks)
+#define vis_lbsize (line_state_visible->lbsize)
+
+#define visible_line (line_state_visible->line)
+#define invisible_line (line_state_invisible->line)
+
+#if defined (HANDLE_MULTIBYTE)
+static int _rl_col_width PARAMS((const char *, int, int, int));
+#else
+# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s))
+#endif
/* Heuristic used to decide whether it is faster to move from CUR to NEW
by backing up or outputting a carriage return and moving forward. CUR
@@ -83,7 +107,7 @@ static int inv_lbsize, vis_lbsize;
/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a
buffer index in others. This macro is used when deciding whether the
current cursor position is in the middle of a prompt string containing
- invisible characters. */
+ invisible characters. XXX - might need to take `modmark' into account. */
#define PROMPT_ENDING_INDEX \
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)
@@ -141,6 +165,7 @@ int _rl_last_v_pos = 0;
static int cpos_adjusted;
static int cpos_buffer_position;
+static int prompt_multibyte_chars;
/* Number of lines currently on screen minus 1. */
int _rl_vis_botlin = 0;
@@ -150,11 +175,6 @@ int _rl_vis_botlin = 0;
doing horizontal scrolling. It shifts in thirds of a screenwidth. */
static int last_lmargin;
-/* 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];
@@ -195,6 +215,10 @@ static int prompt_last_screen_line;
static int prompt_physical_chars;
+/* set to a non-zero value by rl_redisplay if we are marking modified history
+ lines and the current line is so marked. */
+static int modmark;
+
/* Variables to save and restore prompt and display information. */
/* These are getting numerous enough that it's time to create a struct. */
@@ -282,8 +306,13 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
*r++ = *p++;
if (!ignoring)
{
+ /* rl ends up being assigned to prompt_visible_length,
+ which is the number of characters in the buffer that
+ contribute to characters on the screen, which might
+ not be the same as the number of physical characters
+ on the screen in the presence of multibyte characters */
rl += ind - pind;
- physchars += _rl_col_width (pmt, pind, ind);
+ physchars += _rl_col_width (pmt, pind, ind, 0);
}
else
ninvis += ind - pind;
@@ -391,14 +420,14 @@ rl_expand_prompt (prompt)
t = ++p;
local_prompt = expand_prompt (p, &prompt_visible_length,
&prompt_last_invisible,
- (int *)NULL,
+ &prompt_invis_chars_first_line,
&prompt_physical_chars);
c = *t; *t = '\0';
/* The portion of the prompt string up to and including the
final newline is now null-terminated. */
local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
(int *)NULL,
- &prompt_invis_chars_first_line,
+ (int *)NULL,
(int *)NULL);
*t = c;
local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
@@ -443,13 +472,21 @@ init_line_structures (minsize)
{
/* should be enough. */
inv_lbsize = vis_lbsize = 256;
- inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
- vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
+
#if defined (HANDLE_MULTIBYTE)
- _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int));
+ line_state_visible->wbsize = vis_lbsize;
+ line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wbsize * sizeof (int));
+
+ line_state_invisible->wbsize = inv_lbsize;
+ line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wbsize * sizeof (int));
#endif
+
+ inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
+ vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
inv_lbreaks[0] = vis_lbreaks[0] = 0;
}
+
+ line_structures_initialized = 1;
}
/* Basic redisplay algorithm. */
@@ -459,7 +496,7 @@ rl_redisplay ()
register int in, out, c, linenum, cursor_linenum;
register char *line;
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
- int newlines, lpos, temp, modmark, n0, num;
+ int newlines, lpos, temp, n0, num, prompt_lines_estimate;
char *prompt_this_line;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
@@ -469,13 +506,18 @@ rl_redisplay ()
int _rl_wrapped_multicolumn = 0;
#endif
- if (!readline_echoing_p)
+ if (_rl_echoing_p == 0)
return;
+ /* Block keyboard interrupts because this function manipulates global
+ data structures. */
+ _rl_block_sigint ();
+ RL_SETSTATE (RL_STATE_REDISPLAYING);
+
if (!rl_display_prompt)
rl_display_prompt = "";
- if (invisible_line == 0 || vis_lbreaks == 0)
+ if (line_structures_initialized == 0)
{
init_line_structures (0);
rl_on_new_line ();
@@ -484,6 +526,8 @@ rl_redisplay ()
/* Draw the line into the buffer. */
cpos_buffer_position = -1;
+ prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars;
+
line = invisible_line;
out = inv_botlin = 0;
@@ -580,10 +624,14 @@ rl_redisplay ()
{ \
inv_lbsize *= 2; \
inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
- _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
} \
inv_lbreaks[++newlines] = out; \
- _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \
+ if (newlines >= (line_state_invisible->wbsize - 1)) \
+ { \
+ line_state_invisible->wbsize *= 2; \
+ line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \
+ } \
+ line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \
lpos = 0; \
} \
} while (0)
@@ -606,21 +654,20 @@ rl_redisplay ()
/* inv_lbreaks[i] is where line i starts in the buffer. */
inv_lbreaks[newlines = 0] = 0;
-#if 0
- lpos = out - wrap_offset;
-#else
lpos = prompt_physical_chars + modmark;
-#endif
#if defined (HANDLE_MULTIBYTE)
- memset (_rl_wrapped_line, 0, vis_lbsize);
+ memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int));
num = 0;
#endif
/* prompt_invis_chars_first_line is the number of invisible characters in
the first physical line of the prompt.
wrap_offset - prompt_invis_chars_first_line is the number of invis
- chars on the second line. */
+ chars on the second (or, more generally, last) line. */
+
+ /* This is zero-based, used to set the newlines */
+ prompt_lines_estimate = lpos / _rl_screenwidth;
/* what if lpos is already >= _rl_screenwidth before we start drawing the
contents of the command line? */
@@ -635,13 +682,13 @@ rl_redisplay ()
prompts that exceed two physical lines?
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
{
n0 = num;
temp = local_prompt_len;
while (num < temp)
{
- z = _rl_col_width (local_prompt, n0, num);
+ z = _rl_col_width (local_prompt, n0, num, 1);
if (z > _rl_screenwidth)
{
num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
@@ -658,14 +705,16 @@ rl_redisplay ()
temp = ((newlines + 1) * _rl_screenwidth);
/* Now account for invisible characters in the current line. */
+ /* XXX - this assumes that the invisible characters may be split, but only
+ between the first and the last lines. */
temp += ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
- : ((newlines == 1) ? wrap_offset : 0))
- : ((newlines == 0) ? wrap_offset :0));
+ : ((newlines == prompt_lines_estimate) ? wrap_offset : prompt_invis_chars_first_line))
+ : ((newlines == 0) ? wrap_offset : 0));
inv_lbreaks[++newlines] = temp;
#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- lpos -= _rl_col_width (local_prompt, n0, num);
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
+ lpos -= _rl_col_width (local_prompt, n0, num, 1);
else
#endif
lpos -= _rl_screenwidth;
@@ -684,6 +733,7 @@ rl_redisplay ()
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
memset (&ps, 0, sizeof (mbstate_t));
+ /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps);
}
else
@@ -844,6 +894,7 @@ rl_redisplay ()
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
in += wc_bytes;
+ /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps);
}
else
@@ -898,6 +949,10 @@ rl_redisplay ()
second and subsequent lines start at inv_lbreaks[N], offset by
OFFSET (which has already been calculated above). */
+#define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
+#define WRAP_OFFSET(line, offset) ((line == 0) \
+ ? (offset ? INVIS_FIRST() : 0) \
+ : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
@@ -905,6 +960,11 @@ rl_redisplay ()
#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
#define INV_LINE(line) (invisible_line + inv_lbreaks[line])
+#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \
+ _rl_last_c_pos != o_cpos && \
+ _rl_last_c_pos > wrap_offset && \
+ o_cpos < prompt_last_invisible)
+
/* For each line in the buffer, do the updating display. */
for (linenum = 0; linenum <= inv_botlin; linenum++)
{
@@ -919,7 +979,7 @@ rl_redisplay ()
take invisible characters into account, since _rl_last_c_pos
is an absolute cursor position in a multibyte locale. See
if compensating here is the right thing, or if we have to
- change update_line itself. There is one case in which
+ change update_line itself. There are several cases in which
update_line adjusts _rl_last_c_pos itself (so it can pass
_rl_move_cursor_relative accurate values); it communicates
this back by setting cpos_adjusted. If we assume that
@@ -927,12 +987,14 @@ rl_redisplay ()
time update_line is called, then we can assume in our
calculations that o_cpos does not need to be adjusted by
wrap_offset. */
- if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
- cpos_adjusted == 0 &&
- _rl_last_c_pos != o_cpos &&
- _rl_last_c_pos > wrap_offset &&
- o_cpos < prompt_last_invisible)
- _rl_last_c_pos -= wrap_offset;
+ if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
+ _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
+ else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
+ (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+ cpos_adjusted == 0 &&
+ _rl_last_c_pos != o_cpos &&
+ _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
+ _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
/* If this is the line with the prompt, we might need to
compensate for invisible characters in the new line. Do
@@ -952,6 +1014,19 @@ rl_redisplay ()
if (nleft)
_rl_clear_to_eol (nleft);
}
+#if 0
+ /* This segment is intended to handle the case where the prompt
+ has invisible characters on the second line and the new line
+ to be displayed needs to clear the rest of the old characters
+ out (e.g., when printing the i-search prompt). In general,
+ the case of the new line being shorter than the old.
+ Incomplete */
+ else if (linenum == prompt_last_screen_line &&
+ prompt_physical_chars > _rl_screenwidth &&
+ wrap_offset != prompt_invis_chars_first_line &&
+ _rl_last_c_pos == out &&
+#endif
+
/* Since the new first line is now visible, save its length. */
if (linenum == 0)
@@ -1007,11 +1082,14 @@ rl_redisplay ()
if (_rl_term_cr)
tputs (_rl_term_cr, 1, _rl_output_character_function);
#endif
+ if (modmark)
+ _rl_output_some_chars ("*", 1);
+
_rl_output_some_chars (local_prompt, nleft);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset;
+ _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
else
- _rl_last_c_pos = nleft;
+ _rl_last_c_pos = nleft + modmark;
}
/* Where on that line? And where does that line start
@@ -1033,10 +1111,10 @@ rl_redisplay ()
{
/* TX == new physical cursor position in multibyte locale. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
+ tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
else
tx = nleft;
- if (_rl_last_c_pos > tx)
+ if (tx >= 0 && _rl_last_c_pos > tx)
{
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
_rl_last_c_pos = tx;
@@ -1114,9 +1192,11 @@ rl_redisplay ()
if (t < out)
line[t - 1] = '>';
- if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
+ if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
{
forced_display = 0;
+ o_cpos = _rl_last_c_pos;
+ cpos_adjusted = 0;
update_line (&visible_line[last_lmargin],
&invisible_line[lmargin],
0,
@@ -1124,6 +1204,9 @@ rl_redisplay ()
_rl_screenwidth + (lmargin ? 0 : wrap_offset),
0);
+ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
+ _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
+
/* If the visible new line is shorter than the old, but the number
of invisible characters is greater, and we are at the end of
the new line, we need to clear to eol. */
@@ -1147,17 +1230,10 @@ rl_redisplay ()
/* Swap visible and non-visible lines. */
{
- char *vtemp = visible_line;
- int *itemp = vis_lbreaks, ntemp = vis_lbsize;
-
- visible_line = invisible_line;
- invisible_line = vtemp;
-
- vis_lbreaks = inv_lbreaks;
- inv_lbreaks = itemp;
+ struct line_state *vtemp = line_state_visible;
- vis_lbsize = inv_lbsize;
- inv_lbsize = ntemp;
+ line_state_visible = line_state_invisible;
+ line_state_invisible = vtemp;
rl_display_fixed = 0;
/* If we are displaying on a single line, and last_lmargin is > 0, we
@@ -1168,6 +1244,9 @@ rl_redisplay ()
else
visible_wrap_offset = wrap_offset;
}
+
+ RL_UNSETSTATE (RL_STATE_REDISPLAYING);
+ _rl_release_sigint ();
}
/* PWP: update_line() is based on finding the middle difference of each
@@ -1192,7 +1271,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
int current_line, omax, nmax, inv_botlin;
{
register char *ofd, *ols, *oe, *nfd, *nls, *ne;
- int temp, lendiff, wsatend, od, nd;
+ int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
int current_invis_chars;
int col_lendiff, col_temp;
#if defined (HANDLE_MULTIBYTE)
@@ -1208,7 +1287,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
temp = _rl_last_c_pos;
else
- temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
+ temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
&& _rl_last_v_pos == current_line - 1)
{
@@ -1223,8 +1302,8 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* This fixes only double-column characters, but if the wrapped
character comsumes more than three columns, spaces will be
inserted in the string buffer. */
- if (_rl_wrapped_line[current_line] > 0)
- _rl_clear_to_eol (_rl_wrapped_line[current_line]);
+ if (current_line < line_state_visible->wbsize && line_state_visible->wrapped_line[current_line] > 0)
+ _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]);
memset (&ps, 0, sizeof (mbstate_t));
ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps);
@@ -1240,7 +1319,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (tempwidth > 0)
{
- int count;
+ int count, i;
bytes = ret;
for (count = 0; count < bytes; count++)
putc (new[count], rl_outstream);
@@ -1251,10 +1330,13 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (ret != 0 && bytes != 0)
{
if (MB_INVALIDCH (ret))
- memmove (old+bytes, old+1, strlen (old+1));
- else
- memmove (old+bytes, old+ret, strlen (old+ret));
+ ret = 1;
+ memmove (old+bytes, old+ret, strlen (old+ret));
memcpy (old, new, bytes);
+ /* Fix up indices if we copy data from one line to another */
+ omax += bytes - ret;
+ for (i = current_line+1; i < inv_botlin+1; i++)
+ vis_lbreaks[i] += bytes - ret;
}
}
else
@@ -1288,7 +1370,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* See if the old line is a subset of the new line, so that the
only change is adding characters. */
temp = (omax < nmax) ? omax : nmax;
- if (memcmp (old, new, temp) == 0)
+ if (memcmp (old, new, temp) == 0) /* adding at the end */
{
ofd = old + temp;
nfd = new + temp;
@@ -1441,18 +1523,22 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
#else
tputs (_rl_term_cr, 1, _rl_output_character_function);
#endif
+ if (modmark)
+ _rl_output_some_chars ("*", 1);
_rl_output_some_chars (local_prompt, lendiff);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
/* We take wrap_offset into account here so we can pass correct
information to _rl_move_cursor_relative. */
- _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset;
+ _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff, 1) - wrap_offset + modmark;
cpos_adjusted = 1;
}
else
- _rl_last_c_pos = lendiff;
+ _rl_last_c_pos = lendiff + modmark;
}
+ o_cpos = _rl_last_c_pos;
+
/* When this function returns, _rl_last_c_pos is correct, and an absolute
cursor postion in multibyte mode, but a buffer index when not in a
multibyte locale. */
@@ -1462,7 +1548,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* We need to indicate that the cursor position is correct in the presence of
invisible characters in the prompt string. Let's see if setting this when
we make sure we're at the end of the drawn prompt string works. */
- if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
+ if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
+ (_rl_last_c_pos > 0 || o_cpos > 0) &&
+ _rl_last_c_pos == prompt_physical_chars)
cpos_adjusted = 1;
#endif
#endif
@@ -1473,7 +1561,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
When not using multibyte characters, these are equal */
lendiff = (nls - nfd) - (ols - ofd);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- col_lendiff = _rl_col_width (new, nfd - new, nls - new) - _rl_col_width (old, ofd - old, ols - old);
+ col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1);
else
col_lendiff = lendiff;
@@ -1498,7 +1586,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* Insert (diff (len (old), len (new)) ch. */
temp = ne - nfd;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- col_temp = _rl_col_width (new, nfd - new, ne - new);
+ col_temp = _rl_col_width (new, nfd - new, ne - new, 1);
else
col_temp = temp;
@@ -1506,22 +1594,60 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
{
/* Non-zero if we're increasing the number of lines. */
int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
+ /* If col_lendiff is > 0, implying that the new string takes up more
+ screen real estate than the old, but lendiff is < 0, meaning that it
+ takes fewer bytes, we need to just output the characters starting
+ from the first difference. These will overwrite what is on the
+ display, so there's no reason to do a smart update. This can really
+ only happen in a multibyte environment. */
+ if (lendiff < 0)
+ {
+ _rl_output_some_chars (nfd, temp);
+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
+ /* If nfd begins before any invisible characters in the prompt,
+ adjust _rl_last_c_pos to account for wrap_offset and set
+ cpos_adjusted to let the caller know. */
+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
+ return;
+ }
/* Sometimes it is cheaper to print the characters rather than
use the terminal's capabilities. If we're growing the number
of lines, make sure we actually cause the new line to wrap
around on auto-wrapping terminals. */
- if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
+ else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
{
/* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
_rl_horizontal_scroll_mode == 1, inserting the characters with
_rl_term_IC or _rl_term_ic will screw up the screen because of the
invisible characters. We need to just draw them. */
- if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 ||
- lendiff <= prompt_visible_length || !current_invis_chars))
+ /* The same thing happens if we're trying to draw before the last
+ invisible character in the prompt string or we're increasing the
+ number of invisible characters in the line and we're not drawing
+ the entire prompt string. */
+ if (*ols && ((_rl_horizontal_scroll_mode &&
+ _rl_last_c_pos == 0 &&
+ lendiff > prompt_visible_length &&
+ current_invis_chars > 0) == 0) &&
+ (((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+ current_line == 0 && wrap_offset &&
+ ((nfd - new) <= prompt_last_invisible) &&
+ (col_lendiff < prompt_visible_length)) == 0) &&
+ (visible_wrap_offset >= current_invis_chars))
{
insert_some_chars (nfd, lendiff, col_lendiff);
_rl_last_c_pos += col_lendiff;
}
+#if 0 /* XXX - for now */
+ else if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && _rl_last_c_pos == 0 && wrap_offset && (nfd-new) <= prompt_last_invisible && col_lendiff < prompt_visible_length && visible_wrap_offset >= current_invis_chars)
+ {
+ _rl_output_some_chars (nfd, lendiff);
+ _rl_last_c_pos += col_lendiff;
+ }
+#endif
else if ((MB_CUR_MAX == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0)
{
/* At the end of a line the characters do not have to
@@ -1533,11 +1659,16 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
}
else
{
- /* We have horizontal scrolling and we are not inserting at
- the end. We have invisible characters in this line. This
- is a dumb update. */
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += col_temp;
+ /* If nfd begins before the last invisible character in the
+ prompt, adjust _rl_last_c_pos to account for wrap_offset
+ and set cpos_adjusted to let the caller know. */
+ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
return;
}
/* Copy (new) chars to screen from first diff to last match. */
@@ -1545,15 +1676,23 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if ((temp - lendiff) > 0)
{
_rl_output_some_chars (nfd + lendiff, temp - lendiff);
-#if 1
/* XXX -- this bears closer inspection. Fixes a redisplay bug
reported against bash-3.0-alpha by Andreas Schwab involving
multibyte characters and prompt strings with invisible
characters, but was previously disabled. */
- _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
-#else
- _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
-#endif
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff, 1);
+ else
+ twidth = temp - lendiff;
+ _rl_last_c_pos += twidth;
+ /* If nfd begins before the last invisible character in the
+ prompt, adjust _rl_last_c_pos to account for wrap_offset
+ and set cpos_adjusted to let the caller know. */
+ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
}
}
else
@@ -1565,6 +1704,14 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
char in the current line (which implies we just output some invisible
characters) we need to adjust _rl_last_c_pos, since it represents
a physical character position. */
+ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+ current_line == prompt_last_screen_line && wrap_offset &&
+ wrap_offset != prompt_invis_chars_first_line &&
+ ((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth))))
+ {
+ _rl_last_c_pos -= wrap_offset - prompt_invis_chars_first_line;
+ cpos_adjusted = 1;
+ }
}
}
else /* Delete characters from line. */
@@ -1586,8 +1733,22 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
temp = nls - nfd;
if (temp > 0)
{
+ /* If nfd begins at the prompt, or before the invisible
+ characters in the prompt, we need to adjust _rl_last_c_pos
+ in a multibyte locale to account for the wrap offset and
+ set cpos_adjusted accordingly. */
_rl_output_some_chars (nfd, temp);
- _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
+ }
+ else
+ _rl_last_c_pos += temp;
}
}
/* Otherwise, print over the existing material. */
@@ -1595,16 +1756,37 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
{
if (temp > 0)
{
+ /* If nfd begins at the prompt, or before the invisible
+ characters in the prompt, we need to adjust _rl_last_c_pos
+ in a multibyte locale to account for the wrap offset and
+ set cpos_adjusted accordingly. */
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += col_temp; /* XXX */
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
+ }
}
lendiff = (oe - old) - (ne - new);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new);
+ col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1);
else
col_lendiff = lendiff;
+#if 0
if (col_lendiff)
+#else
+ /* If we've already printed over the entire width of the screen,
+ including the old material, then col_lendiff doesn't matter and
+ space_to_eol will insert too many spaces. XXX - maybe we should
+ adjust col_lendiff based on the difference between _rl_last_c_pos
+ and _rl_screenwidth */
+ if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth)))
+#endif
{
if (_rl_term_autowrap && current_line < inv_botlin)
space_to_eol (col_lendiff);
@@ -1658,7 +1840,7 @@ rl_on_new_line_with_prompt ()
l = strlen (prompt_last_line);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); /* XXX */
+ _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1); /* XXX */
else
_rl_last_c_pos = l;
@@ -1720,9 +1902,14 @@ _rl_move_cursor_relative (new, data)
register int i;
int woff; /* number of invisible chars on current line */
int cpos, dpos; /* current and desired cursor positions */
+ int adjust;
- woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
+ woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
cpos = _rl_last_c_pos;
+
+ if (cpos == 0 && cpos == new)
+ return;
+
#if defined (HANDLE_MULTIBYTE)
/* If we have multibyte characters, NEW is indexed by the buffer point in
a multibyte string, but _rl_last_c_pos is the display position. In
@@ -1731,8 +1918,35 @@ _rl_move_cursor_relative (new, data)
as long as we are past them and they are counted by _rl_col_width. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
- dpos = _rl_col_width (data, 0, new);
- if (dpos > prompt_last_invisible) /* XXX - don't use woff here */
+ adjust = 1;
+ /* Try to short-circuit common cases and eliminate a bunch of multibyte
+ character function calls. */
+ /* 1. prompt string */
+ if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0)
+ {
+ dpos = prompt_physical_chars;
+ cpos_adjusted = 1;
+ adjust = 0;
+ }
+ /* 2. prompt_string + line contents */
+ else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0)
+ {
+ dpos = prompt_physical_chars + _rl_col_width (data, local_prompt_len, new, 1);
+ cpos_adjusted = 1;
+ adjust = 0;
+ }
+ else
+ dpos = _rl_col_width (data, 0, new, 1);
+
+ /* Use NEW when comparing against the last invisible character in the
+ prompt string, since they're both buffer indices and DPOS is a
+ desired display position. */
+ if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */
+ (prompt_physical_chars >= _rl_screenwidth &&
+ _rl_last_v_pos == prompt_last_screen_line &&
+ wrap_offset >= woff && dpos >= woff &&
+ new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset))))
+ /* XXX last comparison might need to be >= */
{
dpos -= woff;
/* Since this will be assigned to _rl_last_c_pos at the end (more
@@ -2145,7 +2359,7 @@ insert_some_chars (string, count, col)
/* DEBUGGING */
if (MB_CUR_MAX == 1 || rl_byte_oriented)
if (count != col)
- fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col);
+ _rl_ttymsg ("debug: insert_some_chars: count (%d) != col (%d)", count, col);
/* If IC is defined, then we do not have to "enter" insert mode. */
if (_rl_term_IC)
@@ -2286,10 +2500,14 @@ _rl_redisplay_after_sigwinch ()
{
char *t;
- /* Clear the current line and put the cursor at column 0. Make sure
- the right thing happens if we have wrapped to a new screen line. */
+ /* Clear the last line (assuming that the screen size change will result in
+ either more or fewer characters on that line only) and put the cursor at
+ column 0. Make sure the right thing happens if we have wrapped to a new
+ screen line. */
if (_rl_term_cr)
{
+ _rl_move_vert (_rl_vis_botlin);
+
#if defined (__MSDOS__)
putc ('\r', rl_outstream);
#else
@@ -2325,7 +2543,7 @@ _rl_redisplay_after_sigwinch ()
void
_rl_clean_up_for_exit ()
{
- if (readline_echoing_p)
+ if (_rl_echoing_p)
{
_rl_move_vert (_rl_vis_botlin);
_rl_vis_botlin = 0;
@@ -2370,9 +2588,9 @@ _rl_current_display_line ()
In the case of multibyte characters with stateful encoding, we have to
scan from the beginning of the string to take the state into account. */
static int
-_rl_col_width (str, start, end)
+_rl_col_width (str, start, end, flags)
const char *str;
- int start, end;
+ int start, end, flags;
{
wchar_t wc;
mbstate_t ps;
@@ -2380,12 +2598,31 @@ _rl_col_width (str, start, end)
if (end <= start)
return 0;
+ if (MB_CUR_MAX == 1 || rl_byte_oriented)
+{
+_rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
+ return (end - start);
+}
memset (&ps, 0, sizeof (mbstate_t));
point = 0;
max = end;
+ /* Try to short-circuit common cases. The adjustment to remove wrap_offset
+ is done by the caller. */
+ /* 1. prompt string */
+ if (flags && start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
+ return (prompt_physical_chars + wrap_offset);
+ /* 2. prompt string + line contents */
+ else if (flags && start == 0 && local_prompt_len > 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
+ {
+ tmp = prompt_physical_chars + wrap_offset;
+ /* XXX - try to call ourselves recursively with non-prompt portion */
+ tmp += _rl_col_width (str, local_prompt_len, end, flags);
+ return (tmp);
+ }
+
while (point < start)
{
tmp = mbrlen (str + point, max, &ps);
diff --git a/lib/readline/doc/._fdl.texi b/lib/readline/doc/._fdl.texi
new file mode 100644
index 0000000..3dd8e43
--- /dev/null
+++ b/lib/readline/doc/._fdl.texi
Binary files differ
diff --git a/lib/readline/doc/Makefile b/lib/readline/doc/Makefile
index 817c2af..af5ee3e 100644
--- a/lib/readline/doc/Makefile
+++ b/lib/readline/doc/Makefile
@@ -2,21 +2,22 @@
# This makefile for Readline library documentation is in -*- text -*- mode.
# Emacs likes it that way.
-# Copyright (C) 1996-2002 Free Software Foundation, Inc.
+# Copyright (C) 1996-2002 Free Software Foundation, Inc.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
topdir = .
srcdir = .
diff --git a/lib/readline/doc/fdl.texi b/lib/readline/doc/fdl.texi
index 47ead9f..8805f1a 100644
--- a/lib/readline/doc/fdl.texi
+++ b/lib/readline/doc/fdl.texi
@@ -1,13 +1,12 @@
+@c The GNU Free Documentation License.
+@center Version 1.3, 3 November 2008
-@node GNU Free Documentation License
-@appendixsec GNU Free Documentation License
-
-@cindex FDL, GNU Free Documentation License
-@center Version 1.2, November 2002
+@c This file is intended to be included within another document,
+@c hence no sectioning command or @node.
@display
-Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
-59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+@uref{http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -112,6 +111,9 @@ formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
+The ``publisher'' means any person or entity that distributes copies
+of the Document to the public.
+
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
@@ -344,7 +346,7 @@ and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
-When the Document is included an aggregate, this License does not
+When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
@@ -380,13 +382,30 @@ title.
@item
TERMINATION
-You may not copy, modify, sublicense, or distribute the Document except
-as expressly provided for under this License. Any other attempt to
-copy, modify, sublicense or distribute the Document 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.
+You may not copy, modify, sublicense, or distribute the Document
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense, or distribute it is void, and
+will automatically terminate your rights under this License.
+
+However, if you cease all violation of this License, then your license
+from a particular copyright holder is reinstated (a) provisionally,
+unless and until the copyright holder explicitly and finally
+terminates your license, and (b) permanently, if the copyright holder
+fails to notify you of the violation by some reasonable means prior to
+60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, receipt of a copy of some or all of the same material does
+not give you any rights to use it.
@item
FUTURE REVISIONS OF THIS LICENSE
@@ -404,11 +423,46 @@ following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation.
+as a draft) by the Free Software Foundation. If the Document
+specifies that a proxy can decide which future versions of this
+License can be used, that proxy's public statement of acceptance of a
+version permanently authorizes you to choose that version for the
+Document.
+
+@item
+RELICENSING
+
+``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
+World Wide Web server that publishes copyrightable works and also
+provides prominent facilities for anybody to edit those works. A
+public wiki that anybody can edit is an example of such a server. A
+``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
+site means any set of copyrightable works thus published on the MMC
+site.
+
+``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
+license published by Creative Commons Corporation, a not-for-profit
+corporation with a principal place of business in San Francisco,
+California, as well as future copyleft versions of that license
+published by that same organization.
+
+``Incorporate'' means to publish or republish a Document, in whole or
+in part, as part of another Document.
+
+An MMC is ``eligible for relicensing'' if it is licensed under this
+License, and if all works that were first published under this License
+somewhere other than this MMC, and subsequently incorporated in whole
+or in part into the MMC, (1) had no cover texts or invariant sections,
+and (2) were thus incorporated prior to November 1, 2008.
+
+The operator of an MMC Site may republish an MMC contained in the site
+under CC-BY-SA on the same site at any time before August 1, 2009,
+provided the MMC is eligible for relicensing.
+
@end enumerate
@page
-@appendixsubsec ADDENDUM: How to use this License for your documents
+@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
@@ -418,16 +472,16 @@ license notices just after the title page:
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.2
+ under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
- A copy of the license is included in the section entitled ``GNU
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
+ Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the ``with...Texts.'' line with this:
+replace the ``with@dots{}Texts.'' line with this:
@smallexample
@group
diff --git a/lib/readline/doc/history.texi b/lib/readline/doc/history.texi
index 1af40c7..afdb901 100644
--- a/lib/readline/doc/history.texi
+++ b/lib/readline/doc/history.texi
@@ -4,8 +4,6 @@
@settitle GNU History Library
@c %**end of header (This is for running Texinfo on a region.)
-@setchapternewpage odd
-
@include version.texi
@copying
@@ -14,7 +12,7 @@ This document describes the GNU History library
a programming tool that provides a consistent user interface for
recalling lines of previously typed input.
-Copyright @copyright{} 1988-2006 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2009 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -22,15 +20,16 @@ are preserved on all copies.
@quotation
Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
+under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
+Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
and with the Back-Cover Texts as in (a) below. A copy of the license is
-included in the section entitled ``GNU Free Documentation License.''
+included in the section entitled ``GNU Free Documentation License''.
+
+(a) The FSF's Back-Cover Text is: You are free to copy and modify
+this GNU manual. Buying copies from GNU Press supports the FSF in
+developing GNU and promoting software freedom.''
-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
-this GNU Manual, like GNU software. Copies published by the Free
-Software Foundation raise funds for GNU development.''
@end quotation
@end copying
@@ -72,7 +71,7 @@ typed input.
@menu
* Using History Interactively:: GNU History User's Manual.
* Programming with GNU History:: GNU History Programmer's Manual.
-* Copying This Manual:: Copying This Manual.
+* GNU Free Documentation License:: License for copying this manual.
* Concept Index:: Index of concepts described in this manual.
* Function and Variable Index:: Index of externally visible functions
and variables.
@@ -84,12 +83,8 @@ typed input.
@include hsuser.texi
@include hstech.texi
-@node Copying This Manual
-@appendix Copying This Manual
-
-@menu
-* GNU Free Documentation License:: License for copying this manual.
-@end menu
+@node GNU Free Documentation License
+@appendix GNU Free Documentation License
@include fdl.texi
diff --git a/lib/readline/doc/hstech.texi b/lib/readline/doc/hstech.texi
index 47ba8a5..c4e5a75 100644
--- a/lib/readline/doc/hstech.texi
+++ b/lib/readline/doc/hstech.texi
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988-2006 Free Software Foundation, Inc.
+Copyright (C) 1988-2007 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
diff --git a/lib/readline/doc/hsuser.texi b/lib/readline/doc/hsuser.texi
index f98983b..87b3541 100644
--- a/lib/readline/doc/hsuser.texi
+++ b/lib/readline/doc/hsuser.texi
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988-2006 Free Software Foundation, Inc.
+Copyright (C) 1988-2007 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -97,7 +97,11 @@ to contain no more than @env{$HISTFILESIZE}
lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
If the @env{HISTTIMEFORMAT} is set, the time stamp information
-associated with each history entry is written to the history file.
+associated with each history entry is written to the history file,
+marked with the history comment character.
+When the history file is read, lines beginning with the history
+comment character followed immediately by a digit are interpreted
+as timestamps for the previous history line.
The builtin command @code{fc} may be used to list or edit and re-execute
a portion of the history list.
@@ -133,7 +137,7 @@ history list and history file.
@item fc
@btindex fc
@example
-@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
+@code{fc [-e @var{ename}] [-lnr] [@var{first}] [@var{last}]}
@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
@end example
@@ -277,7 +281,10 @@ them, so that they are available for subsequent recall.
This is most useful in conjunction with Readline.
The shell allows control of the various characters used by the
-history expansion mechanism with the @code{histchars} variable.
+history expansion mechanism with the @code{histchars} variable,
+as explained above (@pxref{Bash Variables}). The shell uses
+the history comment character to mark history timestamps when
+writing the history file.
@end ifset
@menu
@@ -412,7 +419,7 @@ of the following modifiers, each preceded by a @samp{:}.
Remove a trailing pathname component, leaving only the head.
@item t
-Remove all leading pathname components, leaving the tail.
+Remove all leading pathname components, leaving the tail.
@item r
Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
diff --git a/lib/readline/doc/rlman.texi b/lib/readline/doc/rlman.texi
index e14c655..be24709 100644
--- a/lib/readline/doc/rlman.texi
+++ b/lib/readline/doc/rlman.texi
@@ -4,7 +4,6 @@
@settitle GNU Readline Library
@comment %**end of header (This is for running Texinfo on a region.)
@synindex vr fn
-@setchapternewpage odd
@include version.texi
@@ -14,7 +13,7 @@ This manual describes the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
-Copyright @copyright{} 1988-2006 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2009 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -22,15 +21,16 @@ are preserved on all copies.
@quotation
Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
+under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
+Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
and with the Back-Cover Texts as in (a) below. A copy of the license is
-included in the section entitled ``GNU Free Documentation License.''
+included in the section entitled ``GNU Free Documentation License''.
+
+(a) The FSF's Back-Cover Text is: You are free to copy and modify
+this GNU manual. Buying copies from GNU Press supports the FSF in
+developing GNU and promoting software freedom.''
-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
-this GNU Manual, like GNU software. Copies published by the Free
-Software Foundation raise funds for GNU development.''
@end quotation
@end copying
@@ -71,7 +71,7 @@ provide a command line interface.
@menu
* Command Line Editing:: GNU Readline User's Manual.
* Programming with GNU Readline:: GNU Readline Programmer's Manual.
-* Copying This Manual:: Copying this manual.
+* GNU Free Documentation License:: License for copying this manual.
* Concept Index:: Index of concepts described in this manual.
* Function and Variable Index:: Index of externally visible functions
and variables.
@@ -81,12 +81,8 @@ provide a command line interface.
@include rluser.texi
@include rltech.texi
-@node Copying This Manual
-@appendix Copying This Manual
-
-@menu
-* GNU Free Documentation License:: License for copying this manual.
-@end menu
+@node GNU Free Documentation License
+@appendix GNU Free Documentation License
@include fdl.texi
diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi
index ecff106..04c8489 100644
--- a/lib/readline/doc/rltech.texi
+++ b/lib/readline/doc/rltech.texi
@@ -1,14 +1,13 @@
@comment %**start of header (This is for running Texinfo on a region.)
@setfilename rltech.info
@comment %**end of header (This is for running Texinfo on a region.)
-@setchapternewpage odd
@ifinfo
This document describes the GNU Readline Library, a utility for aiding
in the consistency of user interface across discrete programs that need
to provide a command line interface.
-Copyright (C) 1988-2006 Free Software Foundation, Inc.
+Copyright (C) 1988-2007 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -351,6 +350,12 @@ The @code{rl_set_prompt()} function (@pxref{Redisplay}) may
be used to modify the prompt string after calling @code{readline()}.
@end deftypevar
+@deftypevar {char *} rl_display_prompt
+The string displayed as the prompt. This is usually identical to
+@var{rl_prompt}, but may be changed temporarily by functions that
+use the prompt string as a message area, such as incremental search.
+@end deftypevar
+
@deftypevar int rl_already_prompted
If an application wishes to display the prompt itself, rather than have
Readline do it the first time @code{readline()} is called, it should set
@@ -518,6 +523,20 @@ Readline is performing word completion.
Readline is currently executing the readline signal handler.
@item RL_STATE_UNDOING
Readline is performing an undo.
+@item RL_STATE_INPUTPENDING
+Readline has input pending due to a call to @code{rl_execute_next()}.
+@item RL_STATE_TTYCSAVED
+Readline has saved the values of the terminal's special characters.
+@item RL_STATE_CALLBACK
+Readline is currently using the alternate (callback) interface
+(@pxref{Alternate Interface}).
+@item RL_STATE_VIMOTION
+Readline is reading the argument to a vi-mode "motion" command.
+@item RL_STATE_MULTIKEY
+Readline is reading a multiple-keystroke command.
+@item RL_STATE_VICMDONCE
+Readline has entered vi command (movement) mode at least one time during
+the current call to @code{readline()}.
@item RL_STATE_DONE
Readline has read a key sequence bound to @code{accept-line}
and is about to return the line to the caller.
@@ -603,7 +622,7 @@ Readline which keymap to use.
@deftypefun Keymap rl_make_bare_keymap (void)
Returns a new, empty keymap. The space for the keymap is allocated with
@code{malloc()}; the caller should free it by calling
-@code{rl_discard_keymap()} when done.
+@code{rl_free_keymap()} when done.
@end deftypefun
@deftypefun Keymap rl_copy_keymap (Keymap map)
@@ -617,7 +636,13 @@ the Meta digits bound to produce numeric arguments.
@end deftypefun
@deftypefun void rl_discard_keymap (Keymap keymap)
-Free the storage associated with @var{keymap}.
+Free the storage associated with the data in @var{keymap}.
+The caller should free @var{keymap}.
+@end deftypefun
+
+@deftypefun void rl_free_keymap (Keymap keymap)
+Free all storage associated with @var{keymap}. This calls
+@code{rl_discard_keymap} to free subordindate keymaps and macros.
@end deftypefun
Readline has several internal keymaps. These functions allow you to
@@ -793,7 +818,8 @@ Print the names of all bindable Readline functions to @code{rl_outstream}.
@deftypefun {const char **} rl_funmap_names (void)
Return a NULL terminated array of known function names. The array is
sorted. The array itself is allocated, but not the strings inside. You
-should @code{free()} the array when you are done, but not the pointers.
+should free the array, but not the pointers, using @code{free} or
+@code{rl_free} when you are done.
@end deftypefun
@deftypefun int rl_add_funmap_entry (const char *name, rl_command_func_t *function)
@@ -1077,6 +1103,26 @@ environment variable is used.
@node Utility Functions
@subsection Utility Functions
+@deftypefun int rl_save_state (struct readline_state *sp)
+Save a snapshot of Readline's internal state to @var{sp}.
+The contents of the @var{readline_state} structure are documented
+in @file{readline.h}.
+The caller is responsible for allocating the structure.
+@end deftypefun
+
+@deftypefun int rl_restore_state (struct readline_state *sp)
+Restore Readline's internal state to that stored in @var{sp}, which must
+have been saved by a call to @code{rl_save_state}.
+The contents of the @var{readline_state} structure are documented
+in @file{readline.h}.
+The caller is responsible for freeing the structure.
+@end deftypefun
+
+@deftypefun void rl_free (void *mem)
+Deallocate the memory pointed to by @var{mem}. @var{mem} must have been
+allocated by @code{malloc}.
+@end deftypefun
+
@deftypefun void rl_replace_line (const char *text, int clear_undo)
Replace the contents of @code{rl_line_buffer} with @var{text}.
The point and mark are preserved, if possible.
@@ -1084,7 +1130,7 @@ If @var{clear_undo} is non-zero, the undo list associated with the
current line is cleared.
@end deftypefun
-@deftypefun int rl_extend_line_buffer (int len)
+@deftypefun void rl_extend_line_buffer (int len)
Ensure that @code{rl_line_buffer} has enough space to hold @var{len}
characters, possibly reallocating it if necessary.
@end deftypefun
@@ -1394,6 +1440,13 @@ call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force
Readline to update its idea of the terminal size when a @code{SIGWINCH}
is received.
+@deftypefun void rl_echo_signal_char (int sig)
+If an application wishes to install its own signal handlers, but still
+have readline display characters that generate signals, calling this
+function with @var{sig} set to @code{SIGINT}, @code{SIGQUIT}, or
+@code{SIGTSTP} will display the character generating that signal.
+@end deftypefun
+
@deftypefun void rl_resize_terminal (void)
Update Readline's internal screen size by reading values from the kernel.
@end deftypefun
@@ -1675,6 +1728,35 @@ remove any quote characters from the directory name, because its result will
be passed directly to @code{opendir()}.
@end deftypevar
+@ignore
+@deftypevar extern rl_icppfunc_t *rl_directory_rewrite_hook;
+If non-zero, this is the address of a function to call when completing
+a directory name. This function takes the address of the directory name
+to be modified as an argument. Unlike @code{rl_directory_completion_hook},
+it only modifies the directory name used in @code{opendir}, not what is
+displayed when the possible completions are printed or inserted. It is
+called before rl_directory_completion_hook.
+
+I'm not happy with how this worksyet, so it's undocumented.
+@end deftypevar
+@end ignore
+
+@deftypevar {rl_dequote_func_t *} rl_filename_rewrite_hook
+If non-zero, this is the address of a function called when reading
+directory entries from the filesystem for completion and comparing
+them to the partial word to be completed. The function should
+perform any necesary application or system-specific conversion on
+the filename, such as converting between character sets or converting
+from a filesystem format to a character input format.
+The function takes two arguments: @var{fname}, the filename to be converted,
+and @var{fnlen}, its length in bytes.
+It must either return its first argument (if no conversion takes place)
+or the converted filename in newly-allocated memory. The converted
+form is used to compare against the word to be completed, and, if it
+matches, is added to the list of matches. Readline will free the
+allocated string.
+@end deftypevar
+
@deftypevar {rl_compdisp_func_t *} rl_completion_display_matches_hook
If non-zero, then this is the address of a function to call when
completing a word would normally display the list of possible matches.
@@ -1827,6 +1909,15 @@ if the application's completion function returns no matches.
It should be set only by an application's completion function.
@end deftypevar
+@deftypevar int rl_sort_completion_matches
+If an application sets this variable to 0, Readline will not sort the
+list of completions (which implies that it cannot remove any duplicate
+completions). The default value is 1, which means that Readline will
+sort the completions and, depending on the value of
+@code{rl_ignore_completion_duplicates}, will attempt to remove duplicate
+matches.
+@end deftypevar
+
@deftypevar int rl_completion_type
Set to a character describing the type of completion Readline is currently
attempting; see the description of @code{rl_complete_internal()}
@@ -1836,6 +1927,13 @@ completion function is called, allowing such functions to present
the same interface as @code{rl_complete()}.
@end deftypevar
+@deftypevar int rl_completion_invoking_key
+Set to the final character in the key sequence that invoked one of the
+completion functions that call @code{rl_complete_internal()}. This is
+set to the appropriate value before any application-specific completion
+function is called.
+@end deftypevar
+
@deftypevar int rl_inhibit_completion
If this variable is non-zero, completion is inhibited. The completion
character will be inserted as any other bound to @code{self-insert}.
@@ -1856,27 +1954,51 @@ history list.
GNU Readline library. This application interactively allows users
to manipulate files and their modes. */
-#include <stdio.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <sys/types.h>
-#include <sys/file.h>
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif
#include <sys/stat.h>
-#include <sys/errno.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+
+#if defined (HAVE_STRING_H)
+# include <string.h>
+#else /* !HAVE_STRING_H */
+# include <strings.h>
+#endif /* !HAVE_STRING_H */
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#include <time.h>
#include <readline/readline.h>
#include <readline/history.h>
-extern char *xmalloc ();
+extern char *xmalloc PARAMS((size_t));
/* The names of functions that actually do the manipulation. */
-int com_list __P((char *));
-int com_view __P((char *));
-int com_rename __P((char *));
-int com_stat __P((char *));
-int com_pwd __P((char *));
-int com_delete __P((char *));
-int com_help __P((char *));
-int com_cd __P((char *));
-int com_quit __P((char *));
+int com_list PARAMS((char *));
+int com_view PARAMS((char *));
+int com_rename PARAMS((char *));
+int com_stat PARAMS((char *));
+int com_pwd PARAMS((char *));
+int com_delete PARAMS((char *));
+int com_help PARAMS((char *));
+int com_cd PARAMS((char *));
+int com_quit PARAMS((char *));
/* A structure which contains information on the commands this program
can understand. */
@@ -1909,12 +2031,12 @@ COMMAND *find_command ();
/* The name of this program, as taken from argv[0]. */
char *progname;
-/* When non-zero, this means the user is done using this program. */
+/* When non-zero, this global means the user is done using this program. */
int done;
char *
dupstr (s)
- int s;
+ char *s;
@{
char *r;
@@ -2039,12 +2161,12 @@ stripwhite (string)
/* */
/* **************************************************************** */
-char *command_generator __P((const char *, int));
-char **fileman_completion __P((const char *, int, int));
+char *command_generator PARAMS((const char *, int));
+char **fileman_completion PARAMS((const char *, int, int));
-/* Tell the GNU Readline library how to complete. We want to try to
- complete on command names if this is the first word in the line, or
- on filenames if not. */
+/* Tell the GNU Readline library how to complete. We want to try to complete
+ on command names if this is the first word in the line, or on filenames
+ if not. */
initialize_readline ()
@{
/* Allow conditional parsing of the ~/.inputrc file. */
@@ -2054,11 +2176,11 @@ initialize_readline ()
rl_attempted_completion_function = fileman_completion;
@}
-/* Attempt to complete on the contents of TEXT. START and END
- bound the region of rl_line_buffer that contains the word to
- complete. TEXT is the word to complete. We can use the entire
- contents of rl_line_buffer in case we want to do some simple
- parsing. Returnthe array of matches, or NULL if there aren't any. */
+/* Attempt to complete on the contents of TEXT. START and END bound the
+ region of rl_line_buffer that contains the word to complete. TEXT is
+ the word to complete. We can use the entire contents of rl_line_buffer
+ in case we want to do some simple parsing. Return the array of matches,
+ or NULL if there aren't any. */
char **
fileman_completion (text, start, end)
const char *text;
@@ -2077,9 +2199,9 @@ fileman_completion (text, start, end)
return (matches);
@}
-/* Generator function for command completion. STATE lets us
- know whether to start from scratch; without any state
- (i.e. STATE == 0), then we start at the top of the list. */
+/* Generator function for command completion. STATE lets us know whether
+ to start from scratch; without any state (i.e. STATE == 0), then we
+ start at the top of the list. */
char *
command_generator (text, state)
const char *text;
@@ -2088,17 +2210,16 @@ command_generator (text, state)
static int list_index, len;
char *name;
- /* If this is a new word to complete, initialize now. This
- includes saving the length of TEXT for efficiency, and
- initializing the index variable to 0. */
+ /* If this is a new word to complete, initialize now. This includes
+ saving the length of TEXT for efficiency, and initializing the index
+ variable to 0. */
if (!state)
@{
list_index = 0;
len = strlen (text);
@}
- /* Return the next name which partially matches from the
- command list. */
+ /* Return the next name which partially matches from the command list. */
while (name = commands[list_index].name)
@{
list_index++;
@@ -2138,7 +2259,12 @@ com_view (arg)
if (!valid_argument ("view", arg))
return 1;
+#if defined (__MSDOS__)
+ /* more.com doesn't grok slashes in pathnames */
+ sprintf (syscom, "less %s", arg);
+#else
sprintf (syscom, "more %s", arg);
+#endif
return (system (syscom));
@}
@@ -2165,7 +2291,8 @@ com_stat (arg)
printf ("Statistics for `%s':\n", arg);
- printf ("%s has %d link%s, and is %d byte%s in length.\n", arg,
+ printf ("%s has %d link%s, and is %d byte%s in length.\n",
+ arg,
finfo.st_nlink,
(finfo.st_nlink == 1) ? "" : "s",
finfo.st_size,
@@ -2254,8 +2381,7 @@ com_pwd (ignore)
return 0;
@}
-/* The user wishes to quit using this program. Just set DONE
- non-zero. */
+/* The user wishes to quit using this program. Just set DONE non-zero. */
com_quit (arg)
char *arg;
@{
@@ -2268,13 +2394,12 @@ too_dangerous (caller)
char *caller;
@{
fprintf (stderr,
- "%s: Too dangerous for me to distribute.\n",
+ "%s: Too dangerous for me to distribute. Write it yourself.\n",
caller);
- fprintf (stderr, "Write it yourself.\n");
@}
-/* Return non-zero if ARG is a valid argument for CALLER,
- else print an error message and return zero. */
+/* Return non-zero if ARG is a valid argument for CALLER, else print
+ an error message and return zero. */
int
valid_argument (caller, arg)
char *caller, *arg;
diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi
index 5c6467a..519c0de 100644
--- a/lib/readline/doc/rluser.texi
+++ b/lib/readline/doc/rluser.texi
@@ -1,7 +1,6 @@
@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
@@ -10,7 +9,7 @@ use these features. There is a document entitled "readline.texinfo"
which contains both end-user and programmer documentation for the
GNU Readline Library.
-Copyright (C) 1988-2006 Free Software Foundation, Inc.
+Copyright (C) 1988--2009 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -48,6 +47,16 @@ command line editing interface.
@ifset BashFeatures
Command line editing is provided by the Readline library, which is
used by several different programs, including Bash.
+Command line editing is enabled by default when using an interactive shell,
+unless the @option{--noediting} option is supplied at shell invocation.
+Line editing is also used when using the @option{-e} option to the
+@code{read} builtin command (@pxref{Bash Builtins}).
+By default, the line editing commands are similar to those of emacs.
+A vi-style line editing interface is also available.
+Line editing can be enabled at any time using the @option{-o emacs} or
+@option{-o vi} options to the @code{set} builtin command
+(@pxref{The Set Builtin}), or disabled using the @option{+o emacs} or
+@option{+o vi} options to @code{set}.
@end ifset
@menu
@@ -427,6 +436,13 @@ If set to @samp{on}, Readline performs filename matching and completion
in a case-insensitive fashion.
The default value is @samp{off}.
+@item completion-prefix-display-length
+@vindex completion-prefix-display-length
+The length in characters of the common prefix of a list of possible
+completions that is displayed without modification. When set to a
+value greater than zero, common prefixes longer than this value are
+replaced with an ellipsis when displaying possible completions.
+
@item completion-query-items
@vindex completion-query-items
The number of possible completions that determines when the user is
@@ -458,12 +474,23 @@ key bindings is used. By default, Readline starts up in Emacs editing
mode, where the keystrokes are most similar to Emacs. This variable can be
set to either @samp{emacs} or @samp{vi}.
+@item echo-control-characters
+When set to @samp{on}, on operating systems that indicate they support it,
+readline echoes a character corresponding to a signal generated from the
+keyboard. The default is @samp{on}.
+
@item enable-keypad
@vindex enable-keypad
When set to @samp{on}, Readline will try to enable the application
keypad when it is called. Some systems need this to enable the
arrow keys. The default is @samp{off}.
+@item enable-meta-key
+When set to @samp{on}, Readline will try to enable any meta modifier
+key the terminal claims to support when it is called. On many terminals,
+the meta key is used to send eight-bit characters.
+The default is @samp{on}.
+
@item expand-tilde
@vindex expand-tilde
If set to @samp{on}, tilde expansion is performed when Readline
@@ -471,10 +498,16 @@ attempts word completion. The default is @samp{off}.
@item history-preserve-point
@vindex history-preserve-point
-If set to @samp{on}, the history code attempts to place point at the
+If set to @samp{on}, the history code attempts to place the point (the
+current cursor position) at the
same location on each history line retrieved with @code{previous-history}
or @code{next-history}. The default is @samp{off}.
+@item history-size
+@vindex history-size
+Set the maximum number of history entries saved in the history list. If
+set to zero, the number of entries in the history list is not limited.
+
@item horizontal-scroll-mode
@vindex horizontal-scroll-mode
This variable can be set to either @samp{on} or @samp{off}. Setting it
@@ -558,6 +591,13 @@ If set to @samp{on}, Readline will display completions with matches
sorted horizontally in alphabetical order, rather than down the screen.
The default is @samp{off}.
+@item revert-all-at-newline
+@vindex revert-all-at-newline
+If set to @samp{on}, Readline will undo all changes to history lines
+before returning when @code{accept-line} is executed. By default,
+history lines may be modified and retain individual undo lists across
+calls to @code{readline}. The default is @samp{off}.
+
@item show-all-if-ambiguous
@vindex show-all-if-ambiguous
This alters the default behavior of the completion functions. If
@@ -577,6 +617,20 @@ a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
The default value is @samp{off}.
+@item skip-completed-text
+@vindex skip-completed-text
+If set to @samp{on}, this alters the default completion behavior when
+inserting a single match into the line. It's only active when
+performing completion in the middle of a word. If enabled, readline
+does not insert characters from the completion that match characters
+after point in the word being completed, so portions of the word
+following the cursor are not duplicated.
+For instance, if this is enabled, attempting completion when the cursor
+is after the @samp{e} in @samp{Makefile} will result in @samp{Makefile}
+rather than @samp{Makefilefile}, assuming there is a single possible
+completion.
+The default value is @samp{off}.
+
@item visible-stats
@vindex visible-stats
If set to @samp{on}, a character denoting a file's type
@@ -941,12 +995,22 @@ Move forward a character.
Move back a character.
@item forward-word (M-f)
-Move forward to the end of the next word. Words are composed of
-letters and digits.
+Move forward to the end of the next word.
+Words are composed of letters and digits.
@item backward-word (M-b)
-Move back to the start of the current or previous word. Words are
-composed of letters and digits.
+Move back to the start of the current or previous word.
+Words are composed of letters and digits.
+
+@ifset BashFeatures
+@item shell-forward-word ()
+Move forward to the end of the next word.
+Words are delimited by non-quoted shell metacharacters.
+
+@item shell-backward-word ()
+Move back to the start of the current or previous word.
+Words are delimited by non-quoted shell metacharacters.
+@end ifset
@item clear-screen (C-l)
Clear the screen and redraw the current line,
@@ -1142,6 +1206,17 @@ Word boundaries are the same as @code{forward-word}.
Kill the word behind point.
Word boundaries are the same as @code{backward-word}.
+@ifset BashFeatures
+@item shell-kill-word ()
+Kill from point to the end of the current word, or if between
+words, to the end of the next word.
+Word boundaries are the same as @code{shell-forward-word}.
+
+@item backward-kill-word ()
+Kill the word behind point.
+Word boundaries are the same as @code{shell-backward-word}.
+@end ifset
+
@item unix-word-rubout (C-w)
Kill the word behind point, using white space as a word boundary.
The killed text is saved on the kill-ring.
@@ -1242,6 +1317,11 @@ through the list.
This command is intended to be bound to @key{TAB}, but is unbound
by default.
+@item menu-complete-backward ()
+Identical to @code{menu-complete}, but moves backward through the list
+of possible completions, as if @code{menu-complete} had been given a
+negative argument.
+
@item delete-char-or-list ()
Deletes the character under the cursor if not at the beginning or
end of the line (like @code{delete-char}).
@@ -1297,6 +1377,11 @@ Attempt completion on the text before point, comparing
the text against lines from the history list for possible
completion matches.
+@item dabbrev-expand ()
+Attempt menu completion on the text before point, comparing
+the text against lines from the history list for possible
+completion matches.
+
@item complete-into-braces (M-@{)
Perform filename completion and insert the list of possible completions
enclosed within braces so the list is available to the shell
@@ -1376,6 +1461,15 @@ A character is read and point is moved to the previous occurrence
of that character. A negative count searches for subsequent
occurrences.
+@item skip-csi-sequence ()
+Read enough characters to consume a multi-key sequence such as those
+defined for keys like Home and End. Such sequences begin with a
+Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
+bound to "\e[", keys producing such sequences will have no effect
+unless explicitly bound to a readline command, instead of inserting
+stray characters into the editing buffer. This is unbound by default,
+but usually bound to ESC-[.
+
@item insert-comment (M-#)
Without a numeric argument, the value of the @code{comment-begin}
variable is inserted at the beginning of the current line.
@@ -1519,10 +1613,15 @@ the programmable completion facilities are invoked.
First, the command name is identified.
If a compspec has been defined for that command, the
compspec is used to generate the list of possible completions for the word.
+If the command word is the empty string (completion attempted at the
+beginning of an empty line), any compspec defined with
+the @option{-E} option to @code{complete} is used.
If the command word is a full pathname, a compspec for the full
pathname is searched for first.
If no compspec is found for the full pathname, an attempt is made to
find a compspec for the portion following the final slash.
+If those searches do not result in a compspec, any compspec defined with
+the @option{-D} option to @code{complete} is used as the default.
Once a compspec has been found, it is used to generate the list of
matching words.
@@ -1559,9 +1658,9 @@ completed, and the matching words become the possible completions.
After these matches have been generated, any shell function or command
specified with the @option{-F} and @option{-C} options is invoked.
-When the command or function is invoked, the @env{COMP_LINE} and
-@env{COMP_POINT} variables are assigned values as described above
-(@pxref{Bash Variables}).
+When the command or function is invoked, the @env{COMP_LINE},
+@env{COMP_POINT}, @env{COMP_KEY}, and @env{COMP_TYPE} variables are
+assigned values as described above (@pxref{Bash Variables}).
If a shell function is being invoked, the @env{COMP_WORDS} and
@env{COMP_CWORD} variables are also set.
When the function or command is invoked, the first argument is the
@@ -1574,7 +1673,7 @@ the matches.
Any function specified with @option{-F} is invoked first.
The function may use any of the shell facilities, including the
-@code{compgen} builtin described below
+@code{compgen} and @code{compopt} builtins described below
(@pxref{Programmable Completion Builtins}), to generate the matches.
It must put the possible completions in the @env{COMPREPLY} array
variable.
@@ -1626,6 +1725,30 @@ to completed names which are symbolic links to directories, subject to
the value of the @var{mark-directories} Readline variable, regardless
of the setting of the @var{mark-symlinked-directories} Readline variable.
+There is some support for dynamically modifying completions. This is
+most useful when used in combination with a default completion specified
+with @option{-D}. It's possible for shell functions executed as completion
+handlers to indicate that completion should be retried by returning an
+exit status of 124. If a shell function returns 124, and changes
+the compspec associated with the command on which completion is being
+attempted (supplied as the first argument when the function is executed),
+programmable completion restarts from the beginning, with an
+attempt to find a compspec for that command. This allows a set of
+completions to be built dynamically as completion is attempted, rather than
+being loaded all at once.
+
+For instance, assuming that there is a library of compspecs, each kept in a
+file corresponding to the name of the command, the following default
+completion function would load completions dynamically:
+
+@example
+_completion_loader()
+@{
+ . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
+@}
+complete -D -F _completion_loader
+@end example
+
@node Programmable Completion Builtins
@section Programmable Completion Builtins
@cindex completion builtins
@@ -1661,10 +1784,10 @@ matches were generated.
@item complete
@btindex complete
@example
-@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
-[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
-[-C @var{command}] @var{name} [@var{name} @dots{}]}
-@code{complete -pr [@var{name} @dots{}]}
+@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DE] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
+[-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
+[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
+@code{complete -pr [-DE] [@var{name} @dots{}]}
@end example
Specify how arguments to each @var{name} should be completed.
@@ -1674,9 +1797,16 @@ reused as input.
The @option{-r} option removes a completion specification for
each @var{name}, or, if no @var{name}s are supplied, all
completion specifications.
+The @option{-D} option indicates that the remaining options and actions should
+apply to the ``default'' command completion; that is, completion attempted
+on a command for which no completion has previously been defined.
+The @option{-E} option indicates that the remaining options and actions should
+apply to ``empty'' command completion; that is, completion attempted on a
+blank line.
The process of applying these completion specifications when word completion
-is attempted is described above (@pxref{Programmable Completion}).
+is attempted is described above (@pxref{Programmable Completion}). The
+@option{-D} option takes precedence over @option{-E}.
Other options, if specified, have the following meanings.
The arguments to the @option{-G}, @option{-W}, and @option{-X} options
@@ -1706,9 +1836,10 @@ Perform directory name completion if the compspec generates no matches.
@item filenames
Tell Readline that the compspec generates filenames, so it can perform any
-filename-specific processing (like adding a slash to directory names or
-suppressing trailing spaces). This option is intended to be used with
-shell functions specified with @option{-F}.
+filename-specific processing (like adding a slash to directory names
+quoting special characters, or suppressing trailing spaces).
+This option is intended to be used with shell functions specified
+with @option{-F}.
@item nospace
Tell Readline not to append a space (the default) to words completed at
@@ -1846,5 +1977,31 @@ argument, an attempt is made to remove a completion specification for
a @var{name} for which no specification exists, or
an error occurs adding a completion specification.
+@item compopt
+@btindex compopt
+@example
+@code{compopt} [-o @var{option}] [-DE] [+o @var{option}] [@var{name}]
+@end example
+Modify completion options for each @var{name} according to the
+@var{option}s, or for the currently-execution completion if no @var{name}s
+are supplied.
+If no @var{option}s are given, display the completion options for each
+@var{name} or the current completion.
+The possible values of @var{option} are those valid for the @code{complete}
+builtin described above.
+The @option{-D} option indicates that the remaining options should
+apply to the ``default'' command completion; that is, completion attempted
+on a command for which no completion has previously been defined.
+The @option{-E} option indicates that the remaining options should
+apply to ``empty'' command completion; that is, completion attempted on a
+blank line.
+
+The @option{-D} option takes precedence over @option{-E}.
+
+The return value is true unless an invalid option is supplied, an attempt
+is made to modify the options for a @var{name} for which no completion
+specification exists, or an output error occurs.
+
@end table
+
@end ifset
diff --git a/lib/readline/doc/rluserman.texi b/lib/readline/doc/rluserman.texi
index 086aa83..49d9a2c 100644
--- a/lib/readline/doc/rluserman.texi
+++ b/lib/readline/doc/rluserman.texi
@@ -4,8 +4,6 @@
@settitle GNU Readline Library
@comment %**end of header (This is for running Texinfo on a region.)
-@setchapternewpage odd
-
@include version.texi
@copying
@@ -14,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
-Copyright @copyright{} 1988-2006 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2009 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -22,15 +20,16 @@ are preserved on all copies.
@quotation
Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
+under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
+Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
and with the Back-Cover Texts as in (a) below. A copy of the license is
-included in the section entitled ``GNU Free Documentation License.''
+included in the section entitled ``GNU Free Documentation License''.
+
+(a) The FSF's Back-Cover Text is: You are free to copy and modify
+this GNU manual. Buying copies from GNU Press supports the FSF in
+developing GNU and promoting software freedom.''
-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
-this GNU Manual, like GNU software. Copies published by the Free
-Software Foundation raise funds for GNU development.''
@end quotation
@end copying
@@ -70,18 +69,14 @@ programs which provide a command line interface.
@menu
* Command Line Editing:: GNU Readline User's Manual.
-* Copying This Manual:: Copying This Manual.
+* GNU Free Documentation License:: License for copying this manual.
@end menu
@end ifnottex
@include rluser.texi
-@node Copying This Manual
-@appendix Copying This Manual
-
-@menu
-* GNU Free Documentation License:: License for copying this manual.
-@end menu
+@node GNU Free Documentation License
+@appendix GNU Free Documentation License
@include fdl.texi
diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi
index 654e837..823b3ba 100644
--- a/lib/readline/doc/version.texi
+++ b/lib/readline/doc/version.texi
@@ -1,10 +1,10 @@
@ignore
-Copyright (C) 1988-2006 Free Software Foundation, Inc.
+Copyright (C) 1988-2009 Free Software Foundation, Inc.
@end ignore
-@set EDITION 5.2
-@set VERSION 5.2
-@set UPDATED 26 April 2006
-@set UPDATED-MONTH April 2006
+@set EDITION 6.1
+@set VERSION 6.1
+@set UPDATED 9 October 2009
+@set UPDATED-MONTH October 2009
-@set LASTCHANGE Wed Apr 26 09:22:57 EDT 2006
+@set LASTCHANGE Fri Oct 9 12:57:58 EDT 2009
diff --git a/lib/readline/emacs_keymap.c b/lib/readline/emacs_keymap.c
index ca9d134..cb6e140 100644
--- a/lib/readline/emacs_keymap.c
+++ b/lib/readline/emacs_keymap.c
@@ -1,24 +1,23 @@
/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (BUFSIZ)
#include <stdio.h>
diff --git a/lib/readline/examples/Inputrc b/lib/readline/examples/Inputrc
index d7fdb42..a358bc4 100644
--- a/lib/readline/examples/Inputrc
+++ b/lib/readline/examples/Inputrc
@@ -4,21 +4,21 @@
# on which program is running, or what terminal is active.
#
-# Copyright (C) 1989-2002 Free Software Foundation, Inc.
+# Copyright (C) 1989-2009 Free Software Foundation, Inc.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
# In all programs, all terminals, make sure this is bound.
"\C-x\C-r": re-read-init-file
diff --git a/lib/readline/examples/Makefile b/lib/readline/examples/Makefile
index 636a1dc..2df2240 100644
--- a/lib/readline/examples/Makefile
+++ b/lib/readline/examples/Makefile
@@ -2,19 +2,19 @@
#
# Copyright (C) 1994 Free Software Foundation, Inc.
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+# 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
EXECUTABLES = fileman rltest rl
CFLAGS = -g -I../.. -I.. -DREADLINE_LIBRARY
diff --git a/lib/readline/examples/fileman.c b/lib/readline/examples/fileman.c
index 340eee7..f7eed8a 100644
--- a/lib/readline/examples/fileman.c
+++ b/lib/readline/examples/fileman.c
@@ -1,22 +1,23 @@
-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+/* fileman.c - file manager example for readline library. */
- This file is part of the GNU Readline Library, a library for
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
/* fileman.c -- A tiny application which demonstrates how to use the
GNU Readline library. This application interactively allows users
@@ -50,6 +51,8 @@
# include <stdlib.h>
#endif
+#include <time.h>
+
#ifdef READLINE_LIBRARY
# include "readline.h"
# include "history.h"
@@ -58,7 +61,7 @@
# include <readline/history.h>
#endif
-extern char *xmalloc ();
+extern char *xmalloc PARAMS((size_t));
/* The names of functions that actually do the manipulation. */
int com_list PARAMS((char *));
diff --git a/lib/readline/examples/histexamp.c b/lib/readline/examples/histexamp.c
index 4f059c1..3b43674 100644
--- a/lib/readline/examples/histexamp.c
+++ b/lib/readline/examples/histexamp.c
@@ -1,22 +1,23 @@
-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+/* histexamp.c - history library example program. */
- This file is part of the GNU Readline Library, a library for
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#include <stdio.h>
diff --git a/lib/readline/examples/manexamp.c b/lib/readline/examples/manexamp.c
index 9c6cf2c..351c628 100644
--- a/lib/readline/examples/manexamp.c
+++ b/lib/readline/examples/manexamp.c
@@ -1,24 +1,23 @@
/* manexamp.c -- The examples which appear in the documentation are here. */
-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
+ This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#include <stdio.h>
#include <readline/readline.h>
diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c
index c608c15..845a4b1 100644
--- a/lib/readline/examples/rl.c
+++ b/lib/readline/examples/rl.c
@@ -5,25 +5,24 @@
* usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
*/
-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
+ This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if defined (HAVE_CONFIG_H)
# include <config.h>
diff --git a/lib/readline/examples/rlcat.c b/lib/readline/examples/rlcat.c
index 33aea4a..fa9e06f 100644
--- a/lib/readline/examples/rlcat.c
+++ b/lib/readline/examples/rlcat.c
@@ -4,25 +4,24 @@
* usage: rlcat
*/
-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
+ This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if defined (HAVE_CONFIG_H)
# include <config.h>
diff --git a/lib/readline/examples/rltest.c b/lib/readline/examples/rltest.c
index cb67bab..78e2608 100644
--- a/lib/readline/examples/rltest.c
+++ b/lib/readline/examples/rltest.c
@@ -4,25 +4,24 @@
/* */
/* **************************************************************** */
-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
+ This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if defined (HAVE_CONFIG_H)
#include <config.h>
diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c
index 9c760cc..cccddb6 100644
--- a/lib/readline/funmap.c
+++ b/lib/readline/funmap.c
@@ -1,24 +1,24 @@
/* funmap.c -- attach names to functions. */
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -56,7 +56,7 @@ static int funmap_entry;
program specific function. */
int funmap_program_specific_entry_start;
-static FUNMAP default_funmap[] = {
+static const FUNMAP default_funmap[] = {
{ "abort", rl_abort },
{ "accept-line", rl_newline },
{ "arrow-key-prefix", rl_arrow_keys },
@@ -105,11 +105,13 @@ static FUNMAP default_funmap[] = {
{ "kill-region", rl_kill_region },
{ "kill-word", rl_kill_word },
{ "menu-complete", rl_menu_complete },
+ { "menu-complete-backward", rl_backward_menu_complete },
{ "next-history", rl_get_next_history },
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
+ { "old-menu-complete", rl_old_menu_complete },
{ "overwrite-mode", rl_overwrite_mode },
#ifdef __CYGWIN__
{ "paste-from-clipboard", rl_paste_from_clipboard },
@@ -123,6 +125,7 @@ static FUNMAP default_funmap[] = {
{ "revert-line", rl_revert_line },
{ "self-insert", rl_insert },
{ "set-mark", rl_set_mark },
+ { "skip-csi-sequence", rl_skip_csi_sequence },
{ "start-kbd-macro", rl_start_kbd_macro },
{ "tab-insert", rl_tab_insert },
{ "tilde-expand", rl_tilde_expand },
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index f46c0b2..42498d2 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -1,24 +1,23 @@
/* histexpand.c -- history expansion. */
-/* Copyright (C) 1989-2004 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
- This file contains the GNU History Library (the Library), a set of
+ This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
- The Library is free software; you can redistribute it and/or modify
+ History is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ History is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with History. If not, see <http://www.gnu.org/licenses/>.
+*/
#define READLINE_LIBRARY
@@ -64,9 +63,11 @@ static int subst_lhs_len;
static int subst_rhs_len;
static char *get_history_word_specifier PARAMS((char *, char *, int *));
-static char *history_find_word PARAMS((char *, int));
static int history_tokenize_word PARAMS((const char *, int));
+static char **history_tokenize_internal PARAMS((const char *, int, int *));
static char *history_substring PARAMS((const char *, int, int));
+static void freewords PARAMS((char **, int));
+static char *history_find_word PARAMS((char *, int));
static char *quote_breaks PARAMS((char *));
@@ -304,16 +305,20 @@ get_history_event (string, caller_index, delimiting_quote)
/* 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. */
+ to the closing single quote. FLAGS currently used to allow backslash
+ to escape a single quote (e.g., for bash $'...'). */
static void
-hist_string_extract_single_quoted (string, sindex)
+hist_string_extract_single_quoted (string, sindex, flags)
char *string;
- int *sindex;
+ int *sindex, flags;
{
register int i;
for (i = *sindex; string[i] && string[i] != '\''; i++)
- ;
+ {
+ if ((flags & 1) && string[i] == '\\' && string[i+1])
+ i++;
+ }
*sindex = i;
}
@@ -923,7 +928,7 @@ history_expand (hstring, output)
char **output;
{
register int j;
- int i, r, l, passc, cc, modified, eindex, only_printing, dquote;
+ int i, r, l, passc, cc, modified, eindex, only_printing, dquote, flag;
char *string;
/* The output string, and its length. */
@@ -1015,7 +1020,7 @@ history_expand (hstring, output)
}
else if (string[i] == history_expansion_char)
{
- if (!cc || member (cc, history_no_expand_chars))
+ if (cc == 0 || member (cc, history_no_expand_chars))
continue;
/* If the calling application has set
history_inhibit_expansion_function to a function that checks
@@ -1043,8 +1048,9 @@ history_expand (hstring, output)
else if (dquote == 0 && history_quotes_inhibit_expansion && string[i] == '\'')
{
/* If this is bash, single quotes inhibit history expansion. */
+ flag = (i > 0 && string[i - 1] == '$');
i++;
- hist_string_extract_single_quoted (string, &i);
+ hist_string_extract_single_quoted (string, &i, flag);
}
else if (history_quotes_inhibit_expansion && string[i] == '\\')
{
@@ -1095,7 +1101,7 @@ history_expand (hstring, output)
if (strlen (mb) > 1)
{
ADD_STRING (mb);
- break;
+ continue;
}
}
#endif /* HANDLE_MULTIBYTE */
@@ -1129,8 +1135,9 @@ history_expand (hstring, output)
{
int quote, slen;
+ flag = (i > 0 && string[i - 1] == '$');
quote = i++;
- hist_string_extract_single_quoted (string, &i);
+ hist_string_extract_single_quoted (string, &i, flag);
slen = i - quote + 2;
temp = (char *)xmalloc (slen);
@@ -1163,7 +1170,8 @@ history_expand (hstring, output)
/* If the history_expansion_char is followed by one of the
characters in history_no_expand_chars, then it is not a
candidate for expansion of any kind. */
- if (member (cc, history_no_expand_chars))
+ if (cc == 0 || member (cc, history_no_expand_chars) ||
+ (history_inhibit_expansion_function && (*history_inhibit_expansion_function) (string, i)))
{
ADD_CHAR (string[i]);
break;
@@ -1433,17 +1441,21 @@ history_tokenize_word (string, ind)
i += 2;
return i;
}
- else
+ else if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
+ (peek == '>' && string[i] == '&') ||
+ (peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */
+ (peek == '(' && string[i] == '$')) /* ) */
{
- if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
- (peek == '>' && string[i] == '&') ||
- (peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */
- (peek == '(' && string[i] == '$')) /* ) */
- {
- i += 2;
- return i;
- }
+ i += 2;
+ return i;
}
+#if 0
+ else if (peek == '\'' && string[i] == '$')
+ {
+ i += 2; /* XXX */
+ return i;
+ }
+#endif
if (string[i] != '$')
{
@@ -1569,6 +1581,18 @@ history_tokenize (string)
return (history_tokenize_internal (string, -1, (int *)NULL));
}
+/* Free members of WORDS from START to an empty string */
+static void
+freewords (words, start)
+ char **words;
+ int start;
+{
+ register int i;
+
+ for (i = start; words[i]; i++)
+ free (words[i]);
+}
+
/* Find and return the word which contains the character at index IND
in the history line LINE. Used to save the word matched by the
last history !?string? search. */
@@ -1582,12 +1606,16 @@ history_find_word (line, ind)
words = history_tokenize_internal (line, ind, &wind);
if (wind == -1 || words == 0)
- return ((char *)NULL);
+ {
+ if (words)
+ freewords (words, 0);
+ FREE (words);
+ return ((char *)NULL);
+ }
s = words[wind];
for (i = 0; i < wind; i++)
free (words[i]);
- for (i = wind + 1; words[i]; i++)
- free (words[i]);
+ freewords (words, wind + 1);
free (words);
return s;
}
diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c
index 2f051a3..a75fc16 100644
--- a/lib/readline/histfile.c
+++ b/lib/readline/histfile.c
@@ -1,24 +1,23 @@
/* histfile.c - functions to manipulate the history file. */
-/* Copyright (C) 1989-2003 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
- This file contains the GNU History Library (the Library), a set of
+ This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
- The Library is free software; you can redistribute it and/or modify
+ History is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ History is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with History. If not, see <http://www.gnu.org/licenses/>.
+*/
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@@ -53,7 +52,9 @@
# include <unistd.h>
#endif
-#if defined (__EMX__) || defined (__CYGWIN__)
+#include <ctype.h>
+
+#if defined (__EMX__)
# undef HAVE_MMAP
#endif
@@ -103,7 +104,7 @@ int history_write_timestamps = 0;
/* Does S look like the beginning of a history timestamp entry? Placeholder
for more extensive tests. */
-#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char)
+#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char && isdigit ((s)[1]) )
/* Return the string that should be used in the place of this
filename. This only matters when you don't specify the
diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h
index c39af71..c938a10 100644
--- a/lib/readline/histlib.h
+++ b/lib/readline/histlib.h
@@ -1,23 +1,23 @@
/* histlib.h -- internal definitions for the history library. */
-/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
- This file contains the GNU History Library (the Library), a set of
+/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
+
+ This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
- The Library is free software; you can redistribute it and/or modify
+ History is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ History 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 History. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_HISTLIB_H_)
#define _HISTLIB_H_
diff --git a/lib/readline/history.c b/lib/readline/history.c
index 1ccf4db..8e613bb 100644
--- a/lib/readline/history.c
+++ b/lib/readline/history.c
@@ -1,24 +1,23 @@
/* history.c -- standalone history library */
-/* Copyright (C) 1989-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
- This file contains the GNU History Library (the Library), a set of
+ This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
- The Library is free software; you can redistribute it and/or modify
+ History is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ History is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with History. If not, see <http://www.gnu.org/licenses/>.
+*/
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@@ -158,7 +157,7 @@ history_set_pos (pos)
return (1);
}
-/* Return the current history array. The caller has to be carefull, since this
+/* Return the current history array. The caller has to be careful, since this
is the actual array of data, and could be bashed or made corrupt easily.
The array is terminated with a NULL pointer. */
HIST_ENTRY **
@@ -319,6 +318,8 @@ add_history_time (string)
{
HIST_ENTRY *hs;
+ if (string == 0)
+ return;
hs = the_history[history_length - 1];
FREE (hs->timestamp);
hs->timestamp = savestring (string);
@@ -483,7 +484,7 @@ stifle_history (max)
/* Stop stifling the history. This returns the previous maximum
number of history entries. The value is positive if the history
- was stifled, negative if it wasn't. */
+ was stifled, negative if it wasn't. */
int
unstifle_history ()
{
diff --git a/lib/readline/history.h b/lib/readline/history.h
index 14ca2a9..1257e66 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -1,23 +1,23 @@
/* history.h -- the names of functions that you can call in history. */
-/* Copyright (C) 1989-2003 Free Software Foundation, Inc.
- This file contains the GNU History Library (the Library), a set of
+/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
+
+ This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
- The Library is free software; you can redistribute it and/or modify
+ History is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ History 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 History. If not, see <http://www.gnu.org/licenses/>.
+*/
#ifndef _HISTORY_H_
#define _HISTORY_H_
diff --git a/lib/readline/histsearch.c b/lib/readline/histsearch.c
index 1cc5875..1ad55d2 100644
--- a/lib/readline/histsearch.c
+++ b/lib/readline/histsearch.c
@@ -1,24 +1,23 @@
/* histsearch.c -- searching the history list. */
-/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1992-2009 Free Software Foundation, Inc.
- This file contains the GNU History Library (the Library), a set of
+ This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
- The Library is free software; you can redistribute it and/or modify
+ History is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ History 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 History. If not, see <http://www.gnu.org/licenses/>.
+*/
#define READLINE_LIBRARY
diff --git a/lib/readline/input.c b/lib/readline/input.c
index da5d771..b5876da 100644
--- a/lib/readline/input.c
+++ b/lib/readline/input.c
@@ -1,24 +1,24 @@
/* input.c -- character input functions for readline. */
-/* Copyright (C) 1994-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (__TANDEM)
@@ -45,14 +45,7 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
-#if defined (HAVE_SELECT)
-# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
-# include <sys/time.h>
-# endif
-#endif /* HAVE_SELECT */
-#if defined (HAVE_SYS_SELECT_H)
-# include <sys/select.h>
-#endif
+#include "posixselect.h"
#if defined (FIONREAD_IN_SYS_IOCTL)
# include <sys/ioctl.h>
@@ -133,8 +126,11 @@ rl_get_char (key)
return (0);
*key = ibuffer[pop_index++];
-
+#if 0
if (pop_index >= ibuffer_len)
+#else
+ if (pop_index > ibuffer_len)
+#endif
pop_index = 0;
return (1);
@@ -151,7 +147,7 @@ _rl_unget_char (key)
{
pop_index--;
if (pop_index < 0)
- pop_index = ibuffer_len - 1;
+ pop_index = ibuffer_len;
ibuffer[pop_index] = key;
return (1);
}
@@ -187,8 +183,7 @@ rl_gather_tyi ()
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
- timeout.tv_sec = 0;
- timeout.tv_usec = _keyboard_input_timeout;
+ USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
if (result <= 0)
return 0; /* Nothing to read. */
@@ -249,8 +244,10 @@ rl_gather_tyi ()
{
while (chars_avail--)
{
+ RL_CHECK_SIGNALS ();
k = (*rl_getc_function) (rl_instream);
- rl_stuff_char (k);
+ if (rl_stuff_char (k) == 0)
+ break; /* some problem; no more room */
if (k == NEWLINE || k == RETURN)
break;
}
@@ -354,7 +351,7 @@ _rl_insert_typein (c)
string[i] = '\0';
rl_insert_text (string);
- free (string);
+ xfree (string);
}
/* Add KEY to the buffer of characters to be read. Returns 1 if the
@@ -373,7 +370,11 @@ rl_stuff_char (key)
RL_SETSTATE (RL_STATE_INPUTPENDING);
}
ibuffer[push_index++] = key;
+#if 0
if (push_index >= ibuffer_len)
+#else
+ if (push_index > ibuffer_len)
+#endif
push_index = 0;
return 1;
@@ -429,6 +430,7 @@ rl_read_key ()
while (rl_event_hook && rl_get_char (&c) == 0)
{
(*rl_event_hook) ();
+ RL_CHECK_SIGNALS ();
if (rl_done) /* XXX - experimental */
return ('\n');
if (rl_gather_tyi () < 0) /* XXX - EIO */
@@ -442,6 +444,7 @@ rl_read_key ()
{
if (rl_get_char (&c) == 0)
c = (*rl_getc_function) (rl_instream);
+ RL_CHECK_SIGNALS ();
}
}
@@ -457,6 +460,8 @@ rl_getc (stream)
while (1)
{
+ RL_CHECK_SIGNALS ();
+
#if defined (__MINGW32__)
if (isatty (fileno (stream)))
return (getch ());
@@ -513,20 +518,26 @@ _rl_read_mbchar (mbchar, size)
char *mbchar;
int size;
{
- int mb_len = 0;
+ int mb_len, c;
size_t mbchar_bytes_length;
wchar_t wc;
mbstate_t ps, ps_back;
memset(&ps, 0, sizeof (mbstate_t));
memset(&ps_back, 0, sizeof (mbstate_t));
-
+
+ mb_len = 0;
while (mb_len < size)
{
RL_SETSTATE(RL_STATE_MOREINPUT);
- mbchar[mb_len++] = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ break;
+
+ mbchar[mb_len++] = c;
+
mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
if (mbchar_bytes_length == (size_t)(-1))
break; /* invalid byte sequence for the current locale */
@@ -564,7 +575,7 @@ _rl_read_mbstring (first, mb, mlen)
c = first;
memset (mb, 0, mlen);
- for (i = 0; i < mlen; i++)
+ for (i = 0; c >= 0 && i < mlen; i++)
{
mb[i] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));
diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c
index 9f67bfc..f3f46a7 100644
--- a/lib/readline/isearch.c
+++ b/lib/readline/isearch.c
@@ -1,29 +1,30 @@
+/* isearch.c - incremental searching */
+
/* **************************************************************** */
/* */
/* I-Search and Searching */
/* */
/* **************************************************************** */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file contains the Readline Library (the Library), a set of
- routines for providing Emacs style line input to programs that ask
- for it.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The Library is free software; you can redistribute it and/or modify
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -75,7 +76,7 @@ static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
static char *last_isearch_string;
static int last_isearch_string_len;
-static char *default_isearch_terminators = "\033\012";
+static char * const default_isearch_terminators = "\033\012";
_rl_search_cxt *
_rl_scxt_alloc (type, flags)
@@ -125,7 +126,7 @@ _rl_scxt_dispose (cxt, flags)
FREE (cxt->allocated_line);
FREE (cxt->lines);
- free (cxt);
+ xfree (cxt);
}
/* Search backwards through the history looking for a string which is typed
@@ -192,7 +193,7 @@ rl_display_search (search_string, reverse_p, where)
strcpy (message + msglen, "': ");
rl_message ("%s", message);
- free (message);
+ xfree (message);
(*rl_redisplay_function) ();
}
@@ -327,8 +328,15 @@ _rl_isearch_dispatch (cxt, c)
rl_command_func_t *f;
f = (rl_command_func_t *)NULL;
-
- /* Translate the keys we do something with to opcodes. */
+
+ if (c < 0)
+ {
+ cxt->sflags |= SF_FAILED;
+ cxt->history_pos = cxt->last_found_line;
+ return -1;
+ }
+
+ /* Translate the keys we do something with to opcodes. */
if (c >= 0 && _rl_keymap[c].type == ISFUNC)
{
f = _rl_keymap[c].function;
@@ -375,7 +383,7 @@ _rl_isearch_dispatch (cxt, c)
{
if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
{
- /* This sets rl_pending_input to c; it will be picked up the next
+ /* This sets rl_pending_input to LASTC; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (cxt->lastc);
return (0);
diff --git a/lib/readline/keymaps.c b/lib/readline/keymaps.c
index 70d0cc0..9379dec 100644
--- a/lib/readline/keymaps.c
+++ b/lib/readline/keymaps.c
@@ -1,23 +1,24 @@
/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1988,1989-2009 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 (Readline), a library
+ for reading lines of text with interactive input and history editing.
- Readline is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Readline is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -56,8 +57,9 @@ Keymap
rl_make_bare_keymap ()
{
register int i;
- Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
+ Keymap keymap;
+ keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
for (i = 0; i < KEYMAP_SIZE; i++)
{
keymap[i].type = ISFUNC;
@@ -75,7 +77,8 @@ rl_make_bare_keymap ()
return (keymap);
}
-/* Return a new keymap which is a copy of MAP. */
+/* Return a new keymap which is a copy of MAP. Just copies pointers, does
+ not copy text of macros or descend into child keymaps. */
Keymap
rl_copy_keymap (map)
Keymap map;
@@ -127,7 +130,7 @@ rl_discard_keymap (map)
{
int i;
- if (!map)
+ if (map == 0)
return;
for (i = 0; i < KEYMAP_SIZE; i++)
@@ -139,6 +142,7 @@ rl_discard_keymap (map)
case ISKMAP:
rl_discard_keymap ((Keymap)map[i].function);
+ free ((char *)map[i].function);
break;
case ISMACR:
@@ -147,3 +151,12 @@ rl_discard_keymap (map)
}
}
}
+
+/* Convenience function that discards, then frees, MAP. */
+void
+rl_free_keymap (map)
+ Keymap map;
+{
+ rl_discard_keymap (map);
+ free ((char *)map);
+}
diff --git a/lib/readline/keymaps.h b/lib/readline/keymaps.h
index 66fa2a5..6c4611d 100644
--- a/lib/readline/keymaps.h
+++ b/lib/readline/keymaps.h
@@ -2,23 +2,22 @@
/* 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.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#ifndef _KEYMAPS_H_
#define _KEYMAPS_H_
diff --git a/lib/readline/kill.c b/lib/readline/kill.c
index 031ddf4..a4d6d14 100644
--- a/lib/readline/kill.c
+++ b/lib/readline/kill.c
@@ -2,23 +2,23 @@
/* Copyright (C) 1994 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -115,7 +115,7 @@ _rl_copy_to_kill_ring (text, append)
if (slot == rl_max_kills)
{
register int i;
- free (rl_kill_ring[0]);
+ xfree (rl_kill_ring[0]);
for (i = 0; i < slot; i++)
rl_kill_ring[i] = rl_kill_ring[i + 1];
}
@@ -146,7 +146,7 @@ _rl_copy_to_kill_ring (text, append)
strcpy (new, text);
strcat (new, old);
}
- free (old);
+ xfree (old);
free (text);
rl_kill_ring[slot] = new;
}
@@ -686,7 +686,7 @@ rl_paste_from_clipboard (count, key)
_rl_set_mark_at_pos (rl_point);
rl_insert_text (ptr);
if (ptr != data)
- free (ptr);
+ xfree (ptr);
CloseClipboard ();
}
return (0);
diff --git a/lib/readline/macro.c b/lib/readline/macro.c
index 00cd58d..c2fac8a 100644
--- a/lib/readline/macro.c
+++ b/lib/readline/macro.c
@@ -1,24 +1,24 @@
/* macro.c -- keyboard macros for readline. */
-/* Copyright (C) 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -152,7 +152,7 @@ _rl_pop_executing_macro ()
rl_executing_macro = macro_list->string;
executing_macro_index = macro_list->sindex;
macro_list = macro_list->next;
- free (macro);
+ xfree (macro);
}
if (rl_executing_macro == 0)
@@ -181,7 +181,7 @@ _rl_kill_kbd_macro ()
{
if (current_macro)
{
- free (current_macro);
+ xfree (current_macro);
current_macro = (char *) NULL;
}
current_macro_size = current_macro_index = 0;
diff --git a/lib/readline/mbutil.c b/lib/readline/mbutil.c
index 17dde53..eeb7e55 100644
--- a/lib/readline/mbutil.c
+++ b/lib/readline/mbutil.c
@@ -1,24 +1,24 @@
/* mbutil.c -- readline multibyte character utility functions */
-/* Copyright (C) 2001-2005 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -77,7 +77,7 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
char *string;
int seed, count, find_non_zero;
{
- size_t tmp;
+ size_t tmp, len;
mbstate_t ps;
int point;
wchar_t wc;
@@ -91,17 +91,21 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
return seed;
point = seed + _rl_adjust_point (string, seed, &ps);
- /* if this is true, means that seed was not pointed character
- started byte. So correct the point and consume count */
+ /* if this is true, means that seed was not pointing to a byte indicating
+ the beginning of a multibyte character. Correct the point and consume
+ one char. */
if (seed < point)
count--;
while (count > 0)
{
- tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
+ len = strlen (string + point);
+ if (len == 0)
+ break;
+ tmp = mbrtowc (&wc, string+point, len, &ps);
if (MB_INVALIDCH ((size_t)tmp))
{
- /* invalid bytes. asume a byte represents a character */
+ /* invalid bytes. assume a byte represents a character */
point++;
count--;
/* reset states. */
@@ -128,12 +132,10 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
if (find_non_zero)
{
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
- while (tmp > 0 && wcwidth (wc) == 0)
+ while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && wcwidth (wc) == 0)
{
point += tmp;
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
- if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
- break;
}
}
diff --git a/lib/readline/misc.c b/lib/readline/misc.c
index 94ecb25..12ae4a5 100644
--- a/lib/readline/misc.c
+++ b/lib/readline/misc.c
@@ -1,24 +1,24 @@
/* misc.c -- miscellaneous bindable readline functions. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -146,6 +146,8 @@ _rl_arg_dispatch (cxt, c)
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
+ if (key < 0)
+ return -1;
return (_rl_dispatch (key, _rl_keymap));
}
}
@@ -429,6 +431,56 @@ rl_replace_from_history (entry, flags)
rl_mark = rl_end;
}
#endif
+}
+
+/* Process and free undo lists attached to each history entry prior to the
+ current entry, inclusive, reverting each line to its saved state. This
+ is destructive, and state about the current line is lost. This is not
+ intended to be called while actively editing, and the current line is
+ not assumed to have been added to the history list. */
+void
+_rl_revert_all_lines ()
+{
+ int hpos;
+ HIST_ENTRY *entry;
+ UNDO_LIST *ul, *saved_undo_list;
+ char *lbuf;
+
+ lbuf = savestring (rl_line_buffer);
+ saved_undo_list = rl_undo_list;
+ hpos = where_history ();
+
+ entry = (hpos == history_length) ? previous_history () : current_history ();
+ while (entry)
+ {
+ if (ul = (UNDO_LIST *)entry->data)
+ {
+ if (ul == saved_undo_list)
+ saved_undo_list = 0;
+ /* Set up rl_line_buffer and other variables from history entry */
+ rl_replace_from_history (entry, 0); /* entry->line is now current */
+ /* Undo all changes to this history entry */
+ while (rl_undo_list)
+ rl_do_undo ();
+ /* And copy the reverted line back to the history entry, preserving
+ the timestamp. */
+ FREE (entry->line);
+ entry->line = savestring (rl_line_buffer);
+ entry->data = 0;
+ }
+ entry = previous_history ();
+ }
+
+ /* Restore history state */
+ rl_undo_list = saved_undo_list; /* may have been set to null */
+ history_set_pos (hpos);
+
+ /* reset the line buffer */
+ rl_replace_line (lbuf, 0);
+ _rl_set_the_line ();
+
+ /* and clean up */
+ free (lbuf);
}
/* **************************************************************** */
@@ -558,7 +610,7 @@ rl_vi_editing_mode (count, key)
#if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
rl_editing_mode = vi_mode;
- rl_vi_insertion_mode (1, key);
+ rl_vi_insert_mode (1, key);
#endif /* VI_MODE */
return 0;
diff --git a/lib/readline/nls.c b/lib/readline/nls.c
index bcee875..7f10f01 100644
--- a/lib/readline/nls.c
+++ b/lib/readline/nls.c
@@ -1,24 +1,24 @@
/* nls.c -- skeletal internationalization code. */
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
diff --git a/lib/readline/parens.c b/lib/readline/parens.c
index 737f767..9c98488 100644
--- a/lib/readline/parens.c
+++ b/lib/readline/parens.c
@@ -1,24 +1,24 @@
-/* parens.c -- Implementation of matching parentheses feature. */
+/* parens.c -- implementation of matching parentheses feature. */
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 1992-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (__TANDEM)
@@ -38,16 +38,7 @@
# include <unistd.h>
#endif
-#if defined (FD_SET) && !defined (HAVE_SELECT)
-# define HAVE_SELECT
-#endif
-
-#if defined (HAVE_SELECT)
-# include <sys/time.h>
-#endif /* HAVE_SELECT */
-#if defined (HAVE_SYS_SELECT_H)
-# include <sys/select.h>
-#endif
+#include "posixselect.h"
#if defined (HAVE_STRING_H)
# include <string.h>
@@ -130,8 +121,7 @@ rl_insert_close (count, invoking_key)
FD_ZERO (&readfds);
FD_SET (fileno (rl_instream), &readfds);
- timer.tv_sec = 0;
- timer.tv_usec = _paren_blink_usec;
+ USEC_TO_TIMEVAL (_paren_blink_usec, timer);
orig_point = rl_point;
rl_point = match_point;
diff --git a/lib/readline/posixdir.h b/lib/readline/posixdir.h
index 91f6d96..bd33694 100644
--- a/lib/readline/posixdir.h
+++ b/lib/readline/posixdir.h
@@ -4,19 +4,19 @@
This file is part of GNU Bash, the Bourne Again SHell.
- Bash is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
diff --git a/lib/readline/posixjmp.h b/lib/readline/posixjmp.h
index b52aa00..49bfecf 100644
--- a/lib/readline/posixjmp.h
+++ b/lib/readline/posixjmp.h
@@ -4,19 +4,19 @@
This file is part of GNU Bash, the Bourne Again SHell.
- Bash is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
#ifndef _POSIXJMP_H_
#define _POSIXJMP_H_
diff --git a/lib/readline/posixselect.h b/lib/readline/posixselect.h
new file mode 100644
index 0000000..da6a1ac
--- /dev/null
+++ b/lib/readline/posixselect.h
@@ -0,0 +1,47 @@
+/* posixselect.h -- wrapper for select(2) includes and definitions */
+
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _POSIXSELECT_H_
+#define _POSIXSELECT_H_
+
+#if defined (FD_SET) && !defined (HAVE_SELECT)
+# define HAVE_SELECT 1
+#endif
+
+#if defined (HAVE_SELECT)
+# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
+# include <sys/time.h>
+# endif
+#endif /* HAVE_SELECT */
+#if defined (HAVE_SYS_SELECT_H)
+# include <sys/select.h>
+#endif
+
+#ifndef USEC_PER_SEC
+# define USEC_PER_SEC 1000000
+#endif
+
+#define USEC_TO_TIMEVAL(us, tv) \
+do { \
+ (tv).tv_sec = (us) / USEC_PER_SEC; \
+ (tv).tv_usec = (us) % USEC_PER_SEC; \
+} while (0)
+
+#endif /* _POSIXSELECT_H_ */
diff --git a/lib/readline/posixstat.h b/lib/readline/posixstat.h
index c93b528..3eb7f29 100644
--- a/lib/readline/posixstat.h
+++ b/lib/readline/posixstat.h
@@ -5,19 +5,19 @@
This file is part of GNU Bash, the Bourne Again SHell.
- Bash is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
/* This file should be included instead of <sys/stat.h>.
It relies on the local sys/stat.h to work though. */
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index c2b7400..c0e78d4 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -1,25 +1,25 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -163,7 +163,7 @@ int rl_done;
rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
/* Top level environment for readline_internal (). */
-procenv_t readline_top_level;
+procenv_t _rl_top_level;
/* The streams we interact with. */
FILE *_rl_in_stream, *_rl_out_stream;
@@ -176,7 +176,7 @@ FILE *rl_outstream = (FILE *)NULL;
set to 1 if there is a controlling terminal, we can get its attributes,
and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings
for the code that sets it. */
-int readline_echoing_p = 0;
+int _rl_echoing_p = 0;
/* Current prompt. */
char *rl_prompt = (char *)NULL;
@@ -270,6 +270,15 @@ int _rl_output_meta_chars = 0;
them to equivalent readline functions at startup. */
int _rl_bind_stty_chars = 1;
+/* Non-zero means to go through the history list at every newline (or
+ whenever rl_done is set and readline returns) and revert each line to
+ its initial state. */
+int _rl_revert_all_at_newline = 0;
+
+/* Non-zero means to honor the termios ECHOCTL bit and echo control
+ characters corresponding to keyboard-generated signals. */
+int _rl_echo_control_chars = 1;
+
/* **************************************************************** */
/* */
/* Top Level Functions */
@@ -300,6 +309,9 @@ readline (prompt)
const char *prompt;
{
char *value;
+#if 0
+ int in_callback;
+#endif
/* If we are at EOF return a NULL string. */
if (rl_pending_input == EOF)
@@ -308,6 +320,15 @@ readline (prompt)
return ((char *)NULL);
}
+#if 0
+ /* If readline() is called after installing a callback handler, temporarily
+ turn off the callback state to avoid ensuing messiness. Patch supplied
+ by the gdb folks. XXX -- disabled. This can be fooled and readline
+ left in a strange state by a poorly-timed longjmp. */
+ if (in_callback = RL_ISSTATE (RL_STATE_CALLBACK))
+ RL_UNSETSTATE (RL_STATE_CALLBACK);
+#endif
+
rl_set_prompt (prompt);
rl_initialize ();
@@ -326,6 +347,11 @@ readline (prompt)
rl_clear_signals ();
#endif
+#if 0
+ if (in_callback)
+ RL_SETSTATE (RL_STATE_CALLBACK);
+#endif
+
return (value);
}
@@ -349,7 +375,7 @@ readline_internal_setup ()
/* If we're not echoing, we still want to at least print a prompt, because
rl_redisplay will not do it for us. If the calling application has a
custom redisplay function, though, let that function handle it. */
- if (readline_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
+ if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
{
if (rl_prompt && rl_already_prompted == 0)
{
@@ -370,11 +396,13 @@ readline_internal_setup ()
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
- rl_vi_insertion_mode (1, 'i');
+ rl_vi_insert_mode (1, 'i');
#endif /* VI_MODE */
if (rl_pre_input_hook)
(*rl_pre_input_hook) ();
+
+ RL_CHECK_SIGNALS ();
}
STATIC_CALLBACK char *
@@ -384,6 +412,8 @@ readline_internal_teardown (eof)
char *temp;
HIST_ENTRY *entry;
+ RL_CHECK_SIGNALS ();
+
/* Restore the original of this history line, iff the line that we
are editing was originally in the history, AND the line has changed. */
entry = current_history ();
@@ -399,6 +429,9 @@ readline_internal_teardown (eof)
free (temp);
}
+ if (_rl_revert_all_at_newline)
+ _rl_revert_all_lines ();
+
/* At any rate, it is highly likely that this line has an undo list. Get
rid of it now. */
if (rl_undo_list)
@@ -459,7 +492,7 @@ readline_internal_charloop ()
#endif
lk = _rl_last_command_was_kill;
- code = setjmp (readline_top_level);
+ code = setjmp (_rl_top_level);
if (code)
{
@@ -467,7 +500,7 @@ readline_internal_charloop ()
_rl_want_redisplay = 0;
/* If we get here, we're not being called from something dispatched
from _rl_callback_read_char(), which sets up its own value of
- readline_top_level (saving and restoring the old, of course), so
+ _rl_top_level (saving and restoring the old, of course), so
we can just return here. */
if (RL_ISSTATE (RL_STATE_CALLBACK))
return (0);
@@ -517,6 +550,7 @@ readline_internal_charloop ()
lastc = c;
_rl_dispatch ((unsigned char)c, _rl_keymap);
+ RL_CHECK_SIGNALS ();
/* If there was no change in _rl_last_command_was_kill, then no kill
has taken place. Note that if input is pending we are reading
@@ -637,7 +671,6 @@ _rl_dispatch_callback (cxt)
int nkey, r;
/* For now */
-#if 1
/* The first time this context is used, we want to read input and dispatch
on it. When traversing the chain of contexts back `up', we want to use
the value from the next context down. We're simulating recursion using
@@ -645,18 +678,22 @@ _rl_dispatch_callback (cxt)
if ((cxt->flags & KSEQ_DISPATCHED) == 0)
{
nkey = _rl_subseq_getchar (cxt->okey);
+ if (nkey < 0)
+ {
+ _rl_abort_internal ();
+ return -1;
+ }
r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
cxt->flags |= KSEQ_DISPATCHED;
}
else
r = cxt->childval;
-#else
- r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
-#endif
/* For now */
- r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
+ if (r != -3) /* don't do this if we indicate there will be other matches */
+ r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
+ RL_CHECK_SIGNALS ();
if (r == 0) /* success! */
{
_rl_keyseq_chain_dispose ();
@@ -743,6 +780,8 @@ _rl_dispatch_subseq (key, map, got_subseq)
remember the last command executed in this variable. */
if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
rl_last_func = map[key].function;
+
+ RL_CHECK_SIGNALS ();
}
else if (map[ANYOTHERKEY].function)
{
@@ -797,7 +836,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
{
/* Return 0 only the first time, to indicate success to
_rl_callback_read_char. The rest of the time, we're called
- from _rl_dispatch_callback, so we return 3 to indicate
+ from _rl_dispatch_callback, so we return -3 to indicate
special handling is necessary. */
r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0;
cxt = _rl_keyseq_cxt_alloc ();
@@ -861,7 +900,7 @@ _rl_subseq_result (r, map, key, got_subseq)
Keymap m;
int type, nt;
rl_command_func_t *func, *nf;
-
+
if (r == -2)
/* We didn't match anything, and the keymap we're indexed into
shadowed a function previously bound to that prefix. Call
@@ -1135,6 +1174,10 @@ bind_arrow_keys ()
#if defined (VI_MODE)
bind_arrow_keys_internal (vi_movement_keymap);
+ /* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC
+ in vi command mode while still allowing the arrow keys to work. */
+ if (vi_movement_keymap[ESC].type == ISKMAP)
+ rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
bind_arrow_keys_internal (vi_insertion_keymap);
#endif
}
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
index b71bf98..7a4ffaa 100644
--- a/lib/readline/readline.h
+++ b/lib/readline/readline.h
@@ -1,24 +1,23 @@
/* Readline.h -- the names of functions callable from within readline. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_READLINE_H_)
#define _READLINE_H_
@@ -40,9 +39,9 @@ extern "C" {
#endif
/* Hex-encoded Readline version number. */
-#define RL_READLINE_VERSION 0x0502 /* Readline 5.2 */
-#define RL_VERSION_MAJOR 5
-#define RL_VERSION_MINOR 2
+#define RL_READLINE_VERSION 0x0600 /* Readline 6.0 */
+#define RL_VERSION_MAJOR 6
+#define RL_VERSION_MINOR 0
/* Readline data structures. */
@@ -96,6 +95,7 @@ extern int rl_forward_word PARAMS((int, int));
extern int rl_backward_word PARAMS((int, int));
extern int rl_refresh_line PARAMS((int, int));
extern int rl_clear_screen PARAMS((int, int));
+extern int rl_skip_csi_sequence PARAMS((int, int));
extern int rl_arrow_keys PARAMS((int, int));
/* Bindable commands for inserting and deleting text. */
@@ -151,7 +151,9 @@ extern int rl_dump_variables PARAMS((int, int));
extern int rl_complete PARAMS((int, int));
extern int rl_possible_completions PARAMS((int, int));
extern int rl_insert_completions PARAMS((int, int));
+extern int rl_old_menu_complete PARAMS((int, int));
extern int rl_menu_complete PARAMS((int, int));
+extern int rl_backward_menu_complete PARAMS((int, int));
/* Bindable commands for killing and yanking text, and managing the kill ring. */
extern int rl_kill_word PARAMS((int, int));
@@ -233,6 +235,7 @@ extern int rl_vi_append_mode PARAMS((int, int));
extern int rl_vi_append_eol PARAMS((int, int));
extern int rl_vi_eof_maybe PARAMS((int, int));
extern int rl_vi_insertion_mode PARAMS((int, int));
+extern int rl_vi_insert_mode PARAMS((int, int));
extern int rl_vi_movement_mode PARAMS((int, int));
extern int rl_vi_arg_digit PARAMS((int, int));
extern int rl_vi_change_case PARAMS((int, int));
@@ -420,6 +423,7 @@ extern int rl_set_keyboard_input_timeout PARAMS((int));
extern void rl_extend_line_buffer PARAMS((int));
extern int rl_ding PARAMS((void));
extern int rl_alphabetic PARAMS((int));
+extern void rl_free PARAMS((void *));
/* Readline signal handling, from signals.c */
extern int rl_set_signals PARAMS((void));
@@ -427,7 +431,9 @@ extern int rl_clear_signals PARAMS((void));
extern void rl_cleanup_after_signal PARAMS((void));
extern void rl_reset_after_signal PARAMS((void));
extern void rl_free_line_state PARAMS((void));
-
+
+extern void rl_echo_signal_char PARAMS((int));
+
extern int rl_set_paren_blink_timeout PARAMS((int));
/* Undocumented. */
@@ -493,6 +499,10 @@ extern const char *rl_readline_name;
readline (), and should not be assigned to directly. */
extern char *rl_prompt;
+/* The prompt string that is actually displayed by rl_redisplay. Public so
+ applications can more easily supply their own redisplay functions. */
+extern char *rl_display_prompt;
+
/* The line buffer that is in use. */
extern char *rl_line_buffer;
@@ -599,6 +609,10 @@ extern int rl_catch_sigwinch;
filename completer. */
extern rl_compentry_func_t *rl_completion_entry_function;
+/* Optional generator for menu completion. Default is
+ rl_completion_entry_function (rl_filename_completion_function). */
+ extern rl_compentry_func_t *rl_menu_completion_entry_function;
+
/* If rl_ignore_some_completions_function is non-NULL it is the address
of a function to call after all of the possible matches have been
generated, but before the actual completion is done to the input line.
@@ -664,6 +678,17 @@ extern rl_icppfunc_t *rl_directory_completion_hook;
yet, so it's undocumented. */
extern rl_icppfunc_t *rl_directory_rewrite_hook;
+/* If non-zero, this is the address of a function to call when reading
+ directory entries from the filesystem for completion and comparing
+ them to the partial word to be completed. The function should
+ either return its first argument (if no conversion takes place) or
+ newly-allocated memory. This can, for instance, convert filenames
+ between character sets for comparison against what's typed at the
+ keyboard. The returned value is what is added to the list of
+ matches. The second argument is the length of the filename to be
+ converted. */
+extern rl_dequote_func_t *rl_filename_rewrite_hook;
+
/* Backwards compatibility with previous versions of readline. */
#define rl_symbolic_link_hook rl_directory_completion_hook
@@ -713,6 +738,9 @@ extern int rl_attempted_completion_over;
functions. */
extern int rl_completion_type;
+/* Set to the last key used to invoke one of the completion functions */
+extern int rl_completion_invoking_key;
+
/* Up to this many items will be displayed in response to a
possible-completions call. After that, we ask the user if she
is sure she wants to see them all. The default value is 100. */
@@ -739,6 +767,9 @@ extern int rl_completion_found_quote;
application-specific completion function. */
extern int rl_completion_suppress_quote;
+/* If non-zero, readline will sort the completion matches. On by default. */
+extern int rl_sort_completion_matches;
+
/* If non-zero, a slash will be appended to completed filenames that are
symbolic links to directory names, subject to the value of the
mark-directories variable (which is user-settable). This exists so
@@ -797,8 +828,9 @@ extern int rl_inhibit_completion;
#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */
+#define RL_STATE_REDISPLAYING 0x800000 /* updating terminal display */
-#define RL_STATE_DONE 0x800000 /* done; accepted line */
+#define RL_STATE_DONE 0x1000000 /* done; accepted line */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
diff --git a/lib/readline/rlconf.h b/lib/readline/rlconf.h
index aa52b6d..39f94db 100644
--- a/lib/readline/rlconf.h
+++ b/lib/readline/rlconf.h
@@ -1,25 +1,23 @@
/* rlconf.h -- readline configuration definitions */
-/* Copyright (C) 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
- This file contains the Readline Library (the Library), a set of
- routines for providing Emacs style line input to programs that ask
- for it.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The Library is free software; you can redistribute it and/or modify
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RLCONF_H_)
#define _RLCONF_H_
@@ -39,7 +37,6 @@
/* The next-to-last-ditch effort file name for a user-specific init file. */
#define DEFAULT_INPUTRC "~/.inputrc"
-#define SYSTEM_INPUTRC "/etc/inputrc"
/* The ultimate last-ditch filenname for an init file -- system-wide. */
#define SYS_INPUTRC "/etc/inputrc"
diff --git a/lib/readline/rldefs.h b/lib/readline/rldefs.h
index 0f6c874..0257754 100644
--- a/lib/readline/rldefs.h
+++ b/lib/readline/rldefs.h
@@ -2,26 +2,24 @@
for readline. This should be included after any files that define
system-specific constants like _POSIX_VERSION or USG. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file contains the Readline Library (the Library), a set of
- routines for providing Emacs style line input to programs that ask
- for it.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The Library is free software; you can redistribute it and/or modify
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RLDEFS_H_)
#define _RLDEFS_H_
@@ -32,6 +30,10 @@
#include "rlstdc.h"
+#if defined (STRCOLL_BROKEN)
+# undef HAVE_STRCOLL
+#endif
+
#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
# define TERMIOS_TTY_DRIVER
#else
diff --git a/lib/readline/rlmbutil.h b/lib/readline/rlmbutil.h
index dd317e2..7716a70 100644
--- a/lib/readline/rlmbutil.h
+++ b/lib/readline/rlmbutil.h
@@ -1,24 +1,23 @@
/* rlmbutil.h -- utility functions for multibyte characters. */
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RL_MBUTIL_H_)
#define _RL_MBUTIL_H_
diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h
index 64aa7bd..819f127 100644
--- a/lib/readline/rlprivate.h
+++ b/lib/readline/rlprivate.h
@@ -1,25 +1,24 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
-/* Copyright (C) 1999-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RL_PRIVATE_H_)
#define _RL_PRIVATE_H_
@@ -30,6 +29,21 @@
/*************************************************************************
* *
+ * Convenience definitions *
+ * *
+ *************************************************************************/
+
+#define EMACS_MODE() (rl_editing_mode == emacs_mode)
+#define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
+#define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap)
+
+#define RL_CHECK_SIGNALS() \
+ do { \
+ if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
+ } while (0)
+
+/*************************************************************************
+ * *
* Global structs undocumented in texinfo manual and not in readline.h *
* *
*************************************************************************/
@@ -139,12 +153,9 @@ extern int rl_visible_stats;
extern int rl_line_buffer_len;
extern int rl_arg_sign;
extern int rl_visible_prompt_length;
-extern int readline_echoing_p;
extern int rl_key_sequence_length;
extern int rl_byte_oriented;
-extern _rl_keyseq_cxt *_rl_kscxt;
-
/* display.c */
extern int rl_display_fixed;
@@ -206,6 +217,7 @@ extern void _rl_callback_data_dispose PARAMS((_rl_callback_generic_arg *));
/* bind.c */
/* complete.c */
+extern void _rl_reset_completion_state PARAMS((void));
extern char _rl_find_completion_word PARAMS((int *, int *));
extern void _rl_free_match_list PARAMS((char **));
@@ -261,6 +273,8 @@ extern void _rl_start_using_history PARAMS((void));
extern int _rl_free_saved_history_line PARAMS((void));
extern void _rl_set_insert_mode PARAMS((int, int));
+extern void _rl_revert_all_lines PARAMS((void));
+
/* nls.c */
extern int _rl_init_eightbit PARAMS((void));
@@ -281,6 +295,14 @@ extern int _rl_restore_tty_signals PARAMS((void));
/* search.c */
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
+/* signals.c */
+extern void _rl_signal_handler PARAMS((int));
+
+extern void _rl_block_sigint PARAMS((void));
+extern void _rl_release_sigint PARAMS((void));
+extern void _rl_block_sigwinch PARAMS((void));
+extern void _rl_release_sigwinch PARAMS((void));
+
/* terminal.c */
extern void _rl_get_screen_size PARAMS((int, int));
extern int _rl_init_terminal_io PARAMS((const char *));
@@ -314,7 +336,20 @@ extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *));
extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *));
/* util.c */
+#if defined (USE_VARARGS) && defined (PREFER_STDARG)
+extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
+extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
+extern void _rl_trace (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
+#else
+extern void _rl_ttymsg ();
+extern void _rl_errmsg ();
+extern void _rl_trace ();
+#endif
+
+extern int _rl_tropen PARAMS((void));
+
extern int _rl_abort_internal PARAMS((void));
+extern int _rl_null_function PARAMS((int, int));
extern char *_rl_strindex PARAMS((const char *, const char *));
extern int _rl_qsort_string_compare PARAMS((char **, char **));
extern int (_rl_uppercase_p) PARAMS((int));
@@ -337,8 +372,8 @@ extern void _rl_vi_done_inserting PARAMS((void));
*************************************************************************/
/* bind.c */
-extern const char *_rl_possible_control_prefixes[];
-extern const char *_rl_possible_meta_prefixes[];
+extern const char * const _rl_possible_control_prefixes[];
+extern const char * const _rl_possible_meta_prefixes[];
/* callback.c */
extern _rl_callback_func_t *_rl_callback_func;
@@ -349,17 +384,18 @@ extern int _rl_complete_show_all;
extern int _rl_complete_show_unmodified;
extern int _rl_complete_mark_directories;
extern int _rl_complete_mark_symlink_dirs;
+extern int _rl_completion_prefix_display_length;
extern int _rl_print_completions_horizontally;
extern int _rl_completion_case_fold;
extern int _rl_match_hidden_files;
extern int _rl_page_completions;
+extern int _rl_skip_completed_text;
/* display.c */
extern int _rl_vis_botlin;
extern int _rl_last_c_pos;
extern int _rl_suppress_redisplay;
extern int _rl_want_redisplay;
-extern char *rl_display_prompt;
/* isearch.c */
extern char *_rl_isearch_terminators;
@@ -376,6 +412,7 @@ extern int _rl_history_saved_point;
extern _rl_arg_cxt _rl_argcxt;
/* readline.c */
+extern int _rl_echoing_p;
extern int _rl_horizontal_scroll_mode;
extern int _rl_mark_modified_lines;
extern int _rl_bell_preference;
@@ -383,6 +420,8 @@ extern int _rl_meta_flag;
extern int _rl_convert_meta_chars_to_ascii;
extern int _rl_output_meta_chars;
extern int _rl_bind_stty_chars;
+extern int _rl_revert_all_at_newline;
+extern int _rl_echo_control_chars;
extern char *_rl_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
@@ -390,11 +429,22 @@ extern FILE *_rl_in_stream;
extern FILE *_rl_out_stream;
extern int _rl_last_command_was_kill;
extern int _rl_eof_char;
-extern procenv_t readline_top_level;
+extern procenv_t _rl_top_level;
+extern _rl_keyseq_cxt *_rl_kscxt;
/* search.c */
extern _rl_search_cxt *_rl_nscxt;
+/* signals.c */
+extern int _rl_interrupt_immediately;
+extern int volatile _rl_caught_signal;
+
+extern int _rl_echoctl;
+
+extern int _rl_intr_char;
+extern int _rl_quit_char;
+extern int _rl_susp_char;
+
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
diff --git a/lib/readline/rlshell.h b/lib/readline/rlshell.h
index 3c03fba..3e17d8b 100644
--- a/lib/readline/rlshell.h
+++ b/lib/readline/rlshell.h
@@ -1,24 +1,23 @@
/* rlshell.h -- utility functions normally provided by bash. */
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RL_SHELL_H_)
#define _RL_SHELL_H_
diff --git a/lib/readline/rlstdc.h b/lib/readline/rlstdc.h
index 847fa9c..a6d2394 100644
--- a/lib/readline/rlstdc.h
+++ b/lib/readline/rlstdc.h
@@ -1,23 +1,23 @@
-/* stdc.h -- macros to make source compile on both ANSI C and K&R C
- compilers. */
+/* stdc.h -- macros to make source compile on both ANSI C and K&R C compilers. */
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
- This file is part of GNU Bash, the Bourne Again SHell.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- Bash is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- 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.
+ 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 Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RL_STDC_H_)
#define _RL_STDC_H_
diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c
index 0a570f8..0dd5d10 100644
--- a/lib/readline/rltty.c
+++ b/lib/readline/rltty.c
@@ -3,23 +3,23 @@
/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -52,77 +52,10 @@ extern int errno;
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
-static void block_sigint PARAMS((void));
-static void release_sigint PARAMS((void));
-
static void set_winsize PARAMS((int));
/* **************************************************************** */
/* */
-/* Signal Management */
-/* */
-/* **************************************************************** */
-
-#if defined (HAVE_POSIX_SIGNALS)
-static sigset_t sigint_set, sigint_oset;
-#else /* !HAVE_POSIX_SIGNALS */
-# if defined (HAVE_BSD_SIGNALS)
-static int sigint_oldmask;
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-
-static int sigint_blocked;
-
-/* Cause SIGINT to not be delivered until the corresponding call to
- release_sigint(). */
-static void
-block_sigint ()
-{
- if (sigint_blocked)
- return;
-
-#if defined (HAVE_POSIX_SIGNALS)
- sigemptyset (&sigint_set);
- sigemptyset (&sigint_oset);
- sigaddset (&sigint_set, SIGINT);
- sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
-#else /* !HAVE_POSIX_SIGNALS */
-# if defined (HAVE_BSD_SIGNALS)
- sigint_oldmask = sigblock (sigmask (SIGINT));
-# else /* !HAVE_BSD_SIGNALS */
-# if defined (HAVE_USG_SIGHOLD)
- sighold (SIGINT);
-# endif /* HAVE_USG_SIGHOLD */
-# endif /* !HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-
- sigint_blocked = 1;
-}
-
-/* Allow SIGINT to be delivered. */
-static void
-release_sigint ()
-{
- if (sigint_blocked == 0)
- return;
-
-#if defined (HAVE_POSIX_SIGNALS)
- sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
-#else
-# if defined (HAVE_BSD_SIGNALS)
- sigsetmask (sigint_oldmask);
-# else /* !HAVE_BSD_SIGNALS */
-# if defined (HAVE_USG_SIGHOLD)
- sigrelse (SIGINT);
-# endif /* HAVE_USG_SIGHOLD */
-# endif /* !HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-
- sigint_blocked = 0;
-}
-
-/* **************************************************************** */
-/* */
/* Saving and Restoring the TTY */
/* */
/* **************************************************************** */
@@ -204,8 +137,9 @@ save_tty_chars (tiop)
if (tiop->flags & TCHARS_SET)
{
- _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
- _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+ _rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+ _rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+
_rl_tty_chars.t_start = tiop->tchars.t_startc;
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
@@ -215,7 +149,8 @@ save_tty_chars (tiop)
if (tiop->flags & LTCHARS_SET)
{
- _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+ _rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+
_rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
_rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
_rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
@@ -268,7 +203,7 @@ set_tty_settings (tty, tiop)
ioctl (tty, TIOCSETN, &(tiop->sgttyb));
tiop->flags &= ~SGTTY_SET;
}
- readline_echoing_p = 1;
+ _rl_echoing_p = 1;
#if defined (TIOCLSET)
if (tiop->flags & LFLAG_SET)
@@ -302,7 +237,8 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
int meta_flag;
TIOTYPE oldtio, *tiop;
{
- readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
+ _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
+ _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
/* Copy the original settings to the structure we're going to use for
our settings. */
@@ -433,10 +369,10 @@ save_tty_chars (tiop)
#ifdef VREPRINT
_rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
#endif
- _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
- _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+ _rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+ _rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
#ifdef VSUSP
- _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
+ _rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
#endif
#ifdef VDSUSP
_rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
@@ -464,7 +400,7 @@ static void
rltty_warning (msg)
char *msg;
{
- fprintf (stderr, "readline: warning: %s\n", msg);
+ _rl_errmsg ("warning: %s", msg);
}
#endif
@@ -475,7 +411,7 @@ TIOTYPE *tp;
{
if ((tp->c_oflag & OPOST) == 0)
{
- rltty_warning ("turning on OPOST for terminal\r");
+ _rl_errmsg ("warning: turning on OPOST for terminal\r");
tp->c_oflag |= OPOST|ONLCR;
}
}
@@ -500,8 +436,8 @@ _get_tty_settings (tty, tiop)
}
if (OUTPUT_BEING_FLUSHED (tiop))
{
-#if defined (FLUSHO) && defined (_AIX41)
- rltty_warning ("turning off output flushing");
+#if defined (FLUSHO)
+ _rl_errmsg ("warning: turning off output flushing");
tiop->c_lflag &= ~FLUSHO;
break;
#else
@@ -580,7 +516,10 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
int meta_flag;
TIOTYPE oldtio, *tiop;
{
- readline_echoing_p = (oldtio.c_lflag & ECHO);
+ _rl_echoing_p = (oldtio.c_lflag & ECHO);
+#if defined (ECHOCTL)
+ _rl_echoctl = (oldtio.c_lflag & ECHOCTL);
+#endif
tiop->c_lflag &= ~(ICANON | ECHO);
@@ -643,7 +582,7 @@ void
rl_prep_terminal (meta_flag)
int meta_flag;
{
- readline_echoing_p = 1;
+ _rl_echoing_p = 1;
}
void
@@ -663,20 +602,22 @@ rl_prep_terminal (meta_flag)
return;
/* Try to keep this function from being INTerrupted. */
- block_sigint ();
+ _rl_block_sigint ();
tty = fileno (rl_instream);
if (get_tty_settings (tty, &tio) < 0)
{
#if defined (ENOTSUP)
- /* MacOS X, at least, lies about the value of errno if tcgetattr fails. */
- if (errno == ENOTTY || errno == ENOTSUP)
+ /* MacOS X and Linux, at least, lie about the value of errno if
+ tcgetattr fails. */
+ if (errno == ENOTTY || errno == EINVAL || errno == ENOTSUP)
#else
- if (errno == ENOTTY)
+ if (errno == ENOTTY || errno == EINVAL)
#endif
- readline_echoing_p = 1; /* XXX */
- release_sigint ();
+ _rl_echoing_p = 1; /* XXX */
+
+ _rl_release_sigint ();
return;
}
@@ -711,7 +652,7 @@ rl_prep_terminal (meta_flag)
if (set_tty_settings (tty, &tio) < 0)
{
- release_sigint ();
+ _rl_release_sigint ();
return;
}
@@ -722,7 +663,7 @@ rl_prep_terminal (meta_flag)
terminal_prepped = 1;
RL_SETSTATE(RL_STATE_TERMPREPPED);
- release_sigint ();
+ _rl_release_sigint ();
}
/* Restore the terminal's normal settings and modes. */
@@ -735,7 +676,7 @@ rl_deprep_terminal ()
return;
/* Try to keep this function from being interrupted. */
- block_sigint ();
+ _rl_block_sigint ();
tty = fileno (rl_instream);
@@ -746,14 +687,14 @@ rl_deprep_terminal ()
if (set_tty_settings (tty, &otio) < 0)
{
- release_sigint ();
+ _rl_release_sigint ();
return;
}
terminal_prepped = 0;
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
- release_sigint ();
+ _rl_release_sigint ();
}
#endif /* !NO_TTY_DRIVER */
@@ -862,7 +803,7 @@ set_special_char (kmap, tiop, sc, func)
}
#define RESET_SPECIAL(c) \
- if (c != -1 && kmap[(unsigned char)c].type == ISFUNC)
+ if (c != -1 && kmap[(unsigned char)c].type == ISFUNC) \
kmap[(unsigned char)c].function = rl_insert;
static void
diff --git a/lib/readline/rltty.h b/lib/readline/rltty.h
index 142e96b..5bcc946 100644
--- a/lib/readline/rltty.h
+++ b/lib/readline/rltty.h
@@ -1,25 +1,23 @@
/* rltty.h - tty driver-related definitions used by some library files. */
-/* Copyright (C) 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2009 Free Software Foundation, Inc.
- This file contains the Readline Library (the Library), a set of
- routines for providing Emacs style line input to programs that ask
- for it.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The Library is free software; you can redistribute it and/or modify
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RLTTY_H_)
#define _RLTTY_H_
diff --git a/lib/readline/rltypedefs.h b/lib/readline/rltypedefs.h
index 862bdb8..60f29a1 100644
--- a/lib/readline/rltypedefs.h
+++ b/lib/readline/rltypedefs.h
@@ -1,24 +1,23 @@
/* rltypedefs.h -- Type declarations for readline functions. */
-/* Copyright (C) 2000-2004 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#ifndef _RL_TYPEDEFS_H_
#define _RL_TYPEDEFS_H_
diff --git a/lib/readline/rlwinsize.h b/lib/readline/rlwinsize.h
index 7838154..d198fcf 100644
--- a/lib/readline/rlwinsize.h
+++ b/lib/readline/rlwinsize.h
@@ -1,26 +1,24 @@
/* rlwinsize.h -- an attempt to isolate some of the system-specific defines
for `struct winsize' and TIOCGWINSZ. */
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2009 Free Software Foundation, Inc.
- This file contains the Readline Library (the Library), a set of
- routines for providing Emacs style line input to programs that ask
- for it.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The Library is free software; you can redistribute it and/or modify
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RLWINSIZE_H_)
#define _RLWINSIZE_H_
@@ -53,5 +51,8 @@
# endif /* HAVE_SYS_PTE_H */
#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
-#endif /* _RL_WINSIZE_H */
+#if defined (M_UNIX) && !defined (_SCO_DS) && !defined (tcflow)
+# define tcflow(fd, action) ioctl(fd, TCXONC, action)
+#endif
+#endif /* _RL_WINSIZE_H */
diff --git a/lib/readline/savestring.c b/lib/readline/savestring.c
index 820428d..63f467a 100644
--- a/lib/readline/savestring.c
+++ b/lib/readline/savestring.c
@@ -1,24 +1,24 @@
-/* savestring.c */
+/* savestring.c - function version of savestring for backwards compatibility */
/* Copyright (C) 1998,2003 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#include <config.h>
diff --git a/lib/readline/search.c b/lib/readline/search.c
index 33cc4fc..82984f1 100644
--- a/lib/readline/search.c
+++ b/lib/readline/search.c
@@ -1,25 +1,24 @@
/* search.c - code for non-incremental searching in emacs and vi modes. */
-/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2009 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.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The Library is free software; you can redistribute it and/or modify
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
diff --git a/lib/readline/shell.c b/lib/readline/shell.c
index 346f811..18b4f03 100644
--- a/lib/readline/shell.c
+++ b/lib/readline/shell.c
@@ -1,25 +1,25 @@
/* shell.c -- readline utility functions that are normally provided by
bash when readline is linked as part of the shell. */
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
diff --git a/lib/readline/signals.c b/lib/readline/signals.c
index 54f2a64..4fbc019 100644
--- a/lib/readline/signals.c
+++ b/lib/readline/signals.c
@@ -1,24 +1,24 @@
/* signals.c -- signal handling support for readline. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -40,13 +40,14 @@
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL */
-#if defined (HANDLE_SIGNALS)
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
+#if defined (HANDLE_SIGNALS)
+
#if !defined (RETSIGTYPE)
# if defined (VOID_SIGHANDLER)
# define RETSIGTYPE void
@@ -80,6 +81,9 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
+static RETSIGTYPE rl_signal_handler PARAMS((int));
+static RETSIGTYPE _rl_handle_signal PARAMS((int));
+
/* Exported variables for use by applications. */
/* If non-zero, readline will install its own signal handlers for
@@ -93,6 +97,18 @@ int rl_catch_sigwinch = 1;
int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
#endif
+/* Private variables. */
+int _rl_interrupt_immediately = 0;
+int volatile _rl_caught_signal = 0; /* should be sig_atomic_t, but that requires including <signal.h> everywhere */
+
+/* If non-zero, print characters corresponding to received signals as long as
+ the user has indicated his desire to do so (_rl_echo_control_chars). */
+int _rl_echoctl = 0;
+
+int _rl_intr_char = 0;
+int _rl_quit_char = 0;
+int _rl_susp_char = 0;
+
static int signals_set_flag;
static int sigwinch_set_flag;
@@ -112,10 +128,35 @@ static sighandler_cxt old_winch;
/* Readline signal handler functions. */
+/* Called from RL_CHECK_SIGNALS() macro */
+RETSIGTYPE
+_rl_signal_handler (sig)
+{
+ _rl_caught_signal = 0; /* XXX */
+
+ _rl_handle_signal (sig);
+ SIGHANDLER_RETURN;
+}
+
static RETSIGTYPE
rl_signal_handler (sig)
int sig;
{
+ if (_rl_interrupt_immediately || RL_ISSTATE(RL_STATE_CALLBACK))
+ {
+ _rl_interrupt_immediately = 0;
+ _rl_handle_signal (sig);
+ }
+ else
+ _rl_caught_signal = sig;
+
+ SIGHANDLER_RETURN;
+}
+
+static RETSIGTYPE
+_rl_handle_signal (sig)
+ int sig;
+{
#if defined (HAVE_POSIX_SIGNALS)
sigset_t set;
#else /* !HAVE_POSIX_SIGNALS */
@@ -142,6 +183,7 @@ rl_signal_handler (sig)
switch (sig)
{
case SIGINT:
+ _rl_reset_completion_state ();
rl_free_line_state ();
/* FALLTHROUGH */
@@ -157,6 +199,7 @@ rl_signal_handler (sig)
#if defined (SIGQUIT)
case SIGQUIT:
#endif
+ rl_echo_signal_char (sig);
rl_cleanup_after_signal ();
#if defined (HAVE_POSIX_SIGNALS)
@@ -252,7 +295,11 @@ rl_set_sighandler (sig, handler, ohandler)
struct sigaction act;
act.sa_handler = handler;
+# if defined (SIGWINCH)
act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
+# else
+ act.sa_flags = 0;
+# endif /* SIGWINCH */
sigemptyset (&act.sa_mask);
sigemptyset (&ohandler->sa_mask);
sigaction (sig, &act, &old_handler);
@@ -300,7 +347,7 @@ rl_set_signals ()
sigemptyset (&bset);
sigaddset (&bset, SIGINT);
- sigaddset (&bset, SIGINT);
+ sigaddset (&bset, SIGTERM);
#if defined (SIGQUIT)
sigaddset (&bset, SIGQUIT);
#endif
@@ -464,3 +511,160 @@ rl_free_line_state ()
}
#endif /* HANDLE_SIGNALS */
+
+/* **************************************************************** */
+/* */
+/* SIGINT Management */
+/* */
+/* **************************************************************** */
+
+#if defined (HAVE_POSIX_SIGNALS)
+static sigset_t sigint_set, sigint_oset;
+static sigset_t sigwinch_set, sigwinch_oset;
+#else /* !HAVE_POSIX_SIGNALS */
+# if defined (HAVE_BSD_SIGNALS)
+static int sigint_oldmask;
+static int sigwinch_oldmask;
+# endif /* HAVE_BSD_SIGNALS */
+#endif /* !HAVE_POSIX_SIGNALS */
+
+static int sigint_blocked;
+static int sigwinch_blocked;
+
+/* Cause SIGINT to not be delivered until the corresponding call to
+ release_sigint(). */
+void
+_rl_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. */
+void
+_rl_release_sigint ()
+{
+ if (sigint_blocked == 0)
+ return;
+
+#if defined (HAVE_POSIX_SIGNALS)
+ sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
+#else
+# if defined (HAVE_BSD_SIGNALS)
+ sigsetmask (sigint_oldmask);
+# else /* !HAVE_BSD_SIGNALS */
+# if defined (HAVE_USG_SIGHOLD)
+ sigrelse (SIGINT);
+# endif /* HAVE_USG_SIGHOLD */
+# endif /* !HAVE_BSD_SIGNALS */
+#endif /* !HAVE_POSIX_SIGNALS */
+
+ sigint_blocked = 0;
+}
+
+/* Cause SIGWINCH to not be delivered until the corresponding call to
+ release_sigwinch(). */
+void
+_rl_block_sigwinch ()
+{
+ if (sigwinch_blocked)
+ return;
+
+#if defined (HAVE_POSIX_SIGNALS)
+ sigemptyset (&sigwinch_set);
+ sigemptyset (&sigwinch_oset);
+ sigaddset (&sigwinch_set, SIGWINCH);
+ sigprocmask (SIG_BLOCK, &sigwinch_set, &sigwinch_oset);
+#else /* !HAVE_POSIX_SIGNALS */
+# if defined (HAVE_BSD_SIGNALS)
+ sigwinch_oldmask = sigblock (sigmask (SIGWINCH));
+# else /* !HAVE_BSD_SIGNALS */
+# if defined (HAVE_USG_SIGHOLD)
+ sighold (SIGWINCH);
+# endif /* HAVE_USG_SIGHOLD */
+# endif /* !HAVE_BSD_SIGNALS */
+#endif /* !HAVE_POSIX_SIGNALS */
+
+ sigwinch_blocked = 1;
+}
+
+/* Allow SIGWINCH to be delivered. */
+void
+_rl_release_sigwinch ()
+{
+ if (sigwinch_blocked == 0)
+ return;
+
+#if defined (HAVE_POSIX_SIGNALS)
+ sigprocmask (SIG_SETMASK, &sigwinch_oset, (sigset_t *)NULL);
+#else
+# if defined (HAVE_BSD_SIGNALS)
+ sigsetmask (sigwinch_oldmask);
+# else /* !HAVE_BSD_SIGNALS */
+# if defined (HAVE_USG_SIGHOLD)
+ sigrelse (SIGWINCH);
+# endif /* HAVE_USG_SIGHOLD */
+# endif /* !HAVE_BSD_SIGNALS */
+#endif /* !HAVE_POSIX_SIGNALS */
+
+ sigwinch_blocked = 0;
+}
+
+/* **************************************************************** */
+/* */
+/* Echoing special control characters */
+/* */
+/* **************************************************************** */
+void
+rl_echo_signal_char (sig)
+ int sig;
+{
+ char cstr[3];
+ int cslen, c;
+
+ if (_rl_echoctl == 0 || _rl_echo_control_chars == 0)
+ return;
+
+ switch (sig)
+ {
+ case SIGINT: c = _rl_intr_char; break;
+#if defined (SIGQUIT)
+ case SIGQUIT: c = _rl_quit_char; break;
+#endif
+#if defined (SIGTSTP)
+ case SIGTSTP: c = _rl_susp_char; break;
+#endif
+ default: return;
+ }
+
+ if (CTRL_CHAR (c) || c == RUBOUT)
+ {
+ cstr[0] = '^';
+ cstr[1] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
+ cstr[cslen = 2] = '\0';
+ }
+ else
+ {
+ cstr[0] = c;
+ cstr[cslen = 1] = '\0';
+ }
+
+ _rl_output_some_chars (cstr, cslen);
+}
diff --git a/lib/readline/tcap.h b/lib/readline/tcap.h
index 58ab894..9d09b7a 100644
--- a/lib/readline/tcap.h
+++ b/lib/readline/tcap.h
@@ -1,25 +1,23 @@
/* tcap.h -- termcap library functions and variables. */
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
- This file contains the Readline Library (the Library), a set of
- routines for providing Emacs style line input to programs that ask
- for it.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The Library is free software; you can redistribute it and/or modify
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_RLTCAP_H_)
#define _RLTCAP_H_
diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c
index 547f6f5..ee13092 100644
--- a/lib/readline/terminal.c
+++ b/lib/readline/terminal.c
@@ -1,24 +1,24 @@
/* terminal.c -- controlling the terminal with termcap. */
-/* Copyright (C) 1996-2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -350,24 +350,24 @@ rl_reset_screen_size ()
void
rl_resize_terminal ()
{
- if (readline_echoing_p)
+ if (_rl_echoing_p)
{
_rl_get_screen_size (fileno (rl_instream), 1);
if (CUSTOM_REDISPLAY_FUNC ())
rl_forced_update_display ();
- else
+ else if (RL_ISSTATE(RL_STATE_REDISPLAYING) == 0)
_rl_redisplay_after_sigwinch ();
}
}
struct _tc_string {
- const char *tc_var;
+ const char * const tc_var;
char **tc_value;
};
/* This should be kept sorted, just in case we decide to change the
search algorithm to something smarter. */
-static struct _tc_string tc_strings[] =
+static const struct _tc_string tc_strings[] =
{
{ "@7", &_rl_term_at7 },
{ "DC", &_rl_term_DC },
@@ -528,8 +528,8 @@ _rl_init_terminal_io (terminal_name)
/* Check to see if this terminal has a meta key and clear the capability
variables if there is none. */
- term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
- if (!term_has_meta)
+ term_has_meta = tgetflag ("km") != 0;
+ if (term_has_meta == 0)
_rl_term_mm = _rl_term_mo = (char *)NULL;
/* Attempt to find and bind the arrow keys. Do not override already
@@ -641,10 +641,10 @@ _rl_backspace (count)
int
rl_crlf ()
{
-#if defined (NEW_TTY_DRIVER)
+#if defined (NEW_TTY_DRIVER) || defined (__MINT__)
if (_rl_term_cr)
tputs (_rl_term_cr, 1, _rl_output_character_function);
-#endif /* NEW_TTY_DRIVER */
+#endif /* NEW_TTY_DRIVER || __MINT__ */
putc ('\n', _rl_out_stream);
return 0;
}
@@ -653,7 +653,7 @@ rl_crlf ()
int
rl_ding ()
{
- if (readline_echoing_p)
+ if (_rl_echoing_p)
{
switch (_rl_bell_preference)
{
diff --git a/lib/readline/text.c b/lib/readline/text.c
index 399a48c..fc39189 100644
--- a/lib/readline/text.c
+++ b/lib/readline/text.c
@@ -1,24 +1,24 @@
/* text.c -- text handling commands for readline. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -67,6 +67,10 @@ static int _rl_insert_next_callback PARAMS((_rl_callback_generic_arg *));
static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *));
#endif
+/* The largest chunk of text that can be inserted in one call to
+ rl_insert_text. Text blocks larger than this are divided. */
+#define TEXT_COUNT_MAX 1024
+
/* **************************************************************** */
/* */
/* Insert and Delete */
@@ -185,10 +189,13 @@ _rl_replace_text (text, start, end)
{
int n;
+ n = 0;
rl_begin_undo_group ();
- rl_delete_text (start, end + 1);
+ if (start <= end)
+ rl_delete_text (start, end + 1);
rl_point = start;
- n = rl_insert_text (text);
+ if (*text)
+ n = rl_insert_text (text);
rl_end_undo_group ();
return n;
@@ -260,7 +267,7 @@ rl_forward_byte (count, key)
{
int end = rl_point + count;
#if defined (VI_MODE)
- int lend = rl_end > 0 ? rl_end - (rl_editing_mode == vi_mode) : rl_end;
+ int lend = rl_end > 0 ? rl_end - (VI_COMMAND_MODE()) : rl_end;
#else
int lend = rl_end;
#endif
@@ -296,10 +303,16 @@ rl_forward_char (count, key)
if (count > 0)
{
+ if (rl_point == rl_end && EMACS_MODE())
+ {
+ rl_ding ();
+ return 0;
+ }
+
point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
#if defined (VI_MODE)
- if (rl_end <= point && rl_editing_mode == vi_mode)
+ if (point >= rl_end && VI_COMMAND_MODE())
point = _rl_find_prev_mbchar (rl_line_buffer, rl_end, MB_FIND_NONZERO);
#endif
@@ -565,6 +578,21 @@ rl_clear_screen (count, key)
}
int
+rl_skip_csi_sequence (count, key)
+ int count, key;
+{
+ int ch;
+
+ RL_SETSTATE (RL_STATE_MOREINPUT);
+ do
+ ch = rl_read_key ();
+ while (ch >= 0x20 && ch < 0x40);
+ RL_UNSETSTATE (RL_STATE_MOREINPUT);
+
+ return 0;
+}
+
+int
rl_arrow_keys (count, c)
int count, c;
{
@@ -701,7 +729,7 @@ _rl_insert_char (count, c)
/* If we can optimize, then do it. But don't let people crash
readline because of extra large arguments. */
- if (count > 1 && count <= 1024)
+ if (count > 1 && count <= TEXT_COUNT_MAX)
{
#if defined (HANDLE_MULTIBYTE)
string_size = count * incoming_length;
@@ -729,11 +757,11 @@ _rl_insert_char (count, c)
return 0;
}
- if (count > 1024)
+ if (count > TEXT_COUNT_MAX)
{
int decreaser;
#if defined (HANDLE_MULTIBYTE)
- string_size = incoming_length * 1024;
+ string_size = incoming_length * TEXT_COUNT_MAX;
string = (char *)xmalloc (1 + string_size);
i = 0;
@@ -745,7 +773,7 @@ _rl_insert_char (count, c)
while (count)
{
- decreaser = (count > 1024) ? 1024 : count;
+ decreaser = (count > TEXT_COUNT_MAX) ? TEXT_COUNT_MAX : count;
string[decreaser*incoming_length] = '\0';
rl_insert_text (string);
count -= decreaser;
@@ -755,14 +783,14 @@ _rl_insert_char (count, c)
incoming_length = 0;
stored_count = 0;
#else /* !HANDLE_MULTIBYTE */
- char str[1024+1];
+ char str[TEXT_COUNT_MAX+1];
- for (i = 0; i < 1024; i++)
+ for (i = 0; i < TEXT_COUNT_MAX; i++)
str[i] = c;
while (count)
{
- decreaser = (count > 1024 ? 1024 : count);
+ decreaser = (count > TEXT_COUNT_MAX ? TEXT_COUNT_MAX : count);
str[decreaser] = '\0';
rl_insert_text (str);
count -= decreaser;
@@ -857,6 +885,9 @@ _rl_insert_next (count)
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+
#if defined (HANDLE_SIGNALS)
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
_rl_restore_tty_signals ();
@@ -940,7 +971,7 @@ rl_newline (count, key)
if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
return 0;
- if (readline_echoing_p)
+ if (_rl_echoing_p)
_rl_update_final ();
return 0;
}
@@ -1120,7 +1151,7 @@ int
rl_delete_horizontal_space (count, ignore)
int count, ignore;
{
- int start = rl_point;
+ int start;
while (rl_point && whitespace (rl_line_buffer[rl_point - 1]))
rl_point--;
@@ -1238,6 +1269,7 @@ rl_change_case (count, op)
wchar_t wc, nwc;
char mb[MB_LEN_MAX+1];
int mlen;
+ size_t m;
mbstate_t mps;
#endif
@@ -1290,7 +1322,11 @@ rl_change_case (count, op)
#if defined (HANDLE_MULTIBYTE)
else
{
- mbrtowc (&wc, rl_line_buffer + start, end - start, &mps);
+ m = mbrtowc (&wc, rl_line_buffer + start, end - start, &mps);
+ if (MB_INVALIDCH (m))
+ wc = (wchar_t)rl_line_buffer[start];
+ else if (MB_NULLWCH (m))
+ wc = L'\0';
nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc);
if (nwc != wc) /* just skip unchanged characters */
{
@@ -1520,6 +1556,9 @@ _rl_char_search (count, fdir, bdir)
mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
+ if (mb_len <= 0)
+ return -1;
+
if (count < 0)
return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
else
@@ -1536,6 +1575,9 @@ _rl_char_search (count, fdir, bdir)
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+
if (count < 0)
return (_rl_char_search_internal (-count, bdir, c));
else
diff --git a/lib/readline/tilde.c b/lib/readline/tilde.c
index 1b76c9f..088ff15 100644
--- a/lib/readline/tilde.c
+++ b/lib/readline/tilde.c
@@ -1,23 +1,23 @@
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1988-2009 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 (Readline), a library
+ for reading lines of text with interactive input and history editing.
- Readline is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Readline is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if defined (HAVE_CONFIG_H)
# include <config.h>
@@ -236,7 +236,7 @@ tilde_expand (string)
string += end;
expansion = tilde_expand_word (tilde_word);
- free (tilde_word);
+ xfree (tilde_word);
len = strlen (expansion);
#ifdef __CYGWIN__
@@ -251,7 +251,7 @@ tilde_expand (string)
strcpy (result + result_index, expansion);
result_index += len;
}
- free (expansion);
+ xfree (expansion);
}
result[result_index] = '\0';
@@ -377,7 +377,7 @@ tilde_expand_word (filename)
if (expansion)
{
dirname = glue_prefix_and_suffix (expansion, filename, user_len);
- free (username);
+ xfree (username);
free (expansion);
return (dirname);
}
@@ -414,7 +414,7 @@ tilde_expand_word (filename)
dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
#endif
- free (username);
+ xfree (username);
#if defined (HAVE_GETPWENT)
endpwent ();
#endif
diff --git a/lib/readline/tilde.h b/lib/readline/tilde.h
index c58ce20..e26dd04 100644
--- a/lib/readline/tilde.h
+++ b/lib/readline/tilde.h
@@ -1,25 +1,24 @@
/* tilde.h: Externally available variables and function in libtilde.a. */
-/* Copyright (C) 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
- This file contains the Readline Library (the Library), a set of
+ This file contains the Readline Library (Readline), 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
+ Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- The Library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_TILDE_H_)
# define _TILDE_H_
diff --git a/lib/readline/undo.c b/lib/readline/undo.c
index 9d9bd25..eb042b2 100644
--- a/lib/readline/undo.c
+++ b/lib/readline/undo.c
@@ -1,25 +1,25 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
-/* Copyright (C) 1987, 1989, 1992, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -114,9 +114,9 @@ rl_free_undo_list ()
rl_undo_list = rl_undo_list->next;
if (release->what == UNDO_DELETE)
- free (release->text);
+ xfree (release->text);
- free (release);
+ xfree (release);
}
rl_undo_list = (UNDO_LIST *)NULL;
replace_history_data (-1, (histdata_t *)orig_list, (histdata_t *)NULL);
@@ -139,6 +139,9 @@ _rl_copy_undo_list (head)
{
UNDO_LIST *list, *new, *roving, *c;
+ if (head == 0)
+ return head;
+
list = head;
new = 0;
while (list)
@@ -171,7 +174,7 @@ rl_do_undo ()
start = end = waiting_for_begin = 0;
do
{
- if (!rl_undo_list)
+ if (rl_undo_list == 0)
return (0);
_rl_doing_an_undo = 1;
@@ -191,7 +194,7 @@ rl_do_undo ()
case UNDO_DELETE:
rl_point = start;
rl_insert_text (rl_undo_list->text);
- free (rl_undo_list->text);
+ xfree (rl_undo_list->text);
break;
/* Undoing inserts means deleting some text. */
@@ -221,7 +224,7 @@ rl_do_undo ()
rl_undo_list = rl_undo_list->next;
replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list);
- free (release);
+ xfree (release);
}
while (waiting_for_begin);
@@ -291,7 +294,7 @@ int
rl_revert_line (count, key)
int count, key;
{
- if (!rl_undo_list)
+ if (rl_undo_list == 0)
rl_ding ();
else
{
diff --git a/lib/readline/util.c b/lib/readline/util.c
index e44ef64..6bb64c2 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -1,24 +1,24 @@
/* util.c -- readline utility functions */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -66,7 +66,7 @@
in words, or 1 if it is. */
int _rl_allow_pathname_alphabetic_chars = 0;
-static const char *pathname_alphabetic_chars = "/-_=~.#$";
+static const char * const pathname_alphabetic_chars = "/-_=~.#$";
int
rl_alphabetic (c)
@@ -81,8 +81,7 @@ rl_alphabetic (c)
#if defined (HANDLE_MULTIBYTE)
int
-_rl_walphabetic (wc)
- wchar_t wc;
+_rl_walphabetic (wchar_t wc)
{
int c;
@@ -109,7 +108,7 @@ _rl_abort_internal ()
_rl_pop_executing_macro ();
rl_last_func = (rl_command_func_t *)NULL;
- longjmp (readline_top_level, 1);
+ longjmp (_rl_top_level, 1);
return (0);
}
@@ -121,6 +120,13 @@ rl_abort (count, key)
}
int
+_rl_null_function (count, key)
+ int count, key;
+{
+ return 0;
+}
+
+int
rl_tty_status (count, key)
int count, key;
{
@@ -185,6 +191,7 @@ rl_tilde_expand (ignore, key)
{
homedir = tilde_expand ("~");
_rl_replace_text (homedir, start, end);
+ xfree (homedir);
return (0);
}
else if (rl_line_buffer[start] != '~')
@@ -212,14 +219,96 @@ rl_tilde_expand (ignore, key)
strncpy (temp, rl_line_buffer + start, len);
temp[len] = '\0';
homedir = tilde_expand (temp);
- free (temp);
+ xfree (temp);
_rl_replace_text (homedir, start, end);
+ xfree (homedir);
}
return (0);
}
+#if defined (USE_VARARGS)
+void
+#if defined (PREFER_STDARG)
+_rl_ttymsg (const char *format, ...)
+#else
+_rl_ttymsg (va_alist)
+ va_dcl
+#endif
+{
+ va_list args;
+#if defined (PREFER_VARARGS)
+ char *format;
+#endif
+
+#if defined (PREFER_STDARG)
+ va_start (args, format);
+#else
+ va_start (args);
+ format = va_arg (args, char *);
+#endif
+
+ fprintf (stderr, "readline: ");
+ vfprintf (stderr, format, args);
+ fprintf (stderr, "\n");
+ fflush (stderr);
+
+ va_end (args);
+
+ rl_forced_update_display ();
+}
+
+void
+#if defined (PREFER_STDARG)
+_rl_errmsg (const char *format, ...)
+#else
+_rl_errmsg (va_alist)
+ va_dcl
+#endif
+{
+ va_list args;
+#if defined (PREFER_VARARGS)
+ char *format;
+#endif
+
+#if defined (PREFER_STDARG)
+ va_start (args, format);
+#else
+ va_start (args);
+ format = va_arg (args, char *);
+#endif
+
+ fprintf (stderr, "readline: ");
+ vfprintf (stderr, format, args);
+ fprintf (stderr, "\n");
+ fflush (stderr);
+
+ va_end (args);
+}
+
+#else /* !USE_VARARGS */
+void
+_rl_ttymsg (format, arg1, arg2)
+ char *format;
+{
+ fprintf (stderr, "readline: ");
+ fprintf (stderr, format, arg1, arg2);
+ fprintf (stderr, "\n");
+
+ rl_forced_update_display ();
+}
+
+void
+_rl_errmsg (format, arg1, arg2)
+ char *format;
+{
+ fprintf (stderr, "readline: ");
+ fprintf (stderr, format, arg1, arg2);
+ fprintf (stderr, "\n");
+}
+#endif /* !USE_VARARGS */
+
/* **************************************************************** */
/* */
/* String Utility Functions */
@@ -344,6 +433,16 @@ FUNCTION_FOR_MACRO (_rl_to_lower)
FUNCTION_FOR_MACRO (_rl_to_upper)
FUNCTION_FOR_MACRO (_rl_uppercase_p)
+/* A convenience function, to force memory deallocation to be performed
+ by readline. DLLs on Windows apparently require this. */
+void
+rl_free (mem)
+ void *mem;
+{
+ if (mem)
+ free (mem);
+}
+
/* Backwards compatibility, now that savestring has been removed from
all `public' readline header files. */
#undef _rl_savestring
@@ -353,3 +452,60 @@ _rl_savestring (s)
{
return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
}
+
+#if defined (USE_VARARGS)
+static FILE *_rl_tracefp;
+
+void
+#if defined (PREFER_STDARG)
+_rl_trace (const char *format, ...)
+#else
+_rl_trace (va_alist)
+ va_dcl
+#endif
+{
+ va_list args;
+#if defined (PREFER_VARARGS)
+ char *format;
+#endif
+
+#if defined (PREFER_STDARG)
+ va_start (args, format);
+#else
+ va_start (args);
+ format = va_arg (args, char *);
+#endif
+
+ if (_rl_tracefp == 0)
+ _rl_tropen ();
+ vfprintf (_rl_tracefp, format, args);
+ fprintf (_rl_tracefp, "\n");
+ fflush (_rl_tracefp);
+
+ va_end (args);
+}
+
+int
+_rl_tropen ()
+{
+ char fnbuf[128];
+
+ if (_rl_tracefp)
+ fclose (_rl_tracefp);
+ sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid());
+ unlink(fnbuf);
+ _rl_tracefp = fopen (fnbuf, "w+");
+ return _rl_tracefp != 0;
+}
+
+int
+_rl_trclose ()
+{
+ int r;
+
+ r = fclose (_rl_tracefp);
+ _rl_tracefp = 0;
+ return r;
+}
+
+#endif
diff --git a/lib/readline/vi_keymap.c b/lib/readline/vi_keymap.c
index 4b48c75..ba5a27b 100644
--- a/lib/readline/vi_keymap.c
+++ b/lib/readline/vi_keymap.c
@@ -1,24 +1,23 @@
/* vi_keymap.c -- the keymap for vi_mode in readline (). */
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (BUFSIZ)
#include <stdio.h>
@@ -151,7 +150,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
{ ISFUNC, rl_vi_char_search }, /* f */
{ ISFUNC, (rl_command_func_t *)0x0 }, /* g */
{ ISFUNC, rl_backward_char }, /* h */
- { ISFUNC, rl_vi_insertion_mode }, /* i */
+ { ISFUNC, rl_vi_insert_mode }, /* i */
{ ISFUNC, rl_get_next_history }, /* j */
{ ISFUNC, rl_get_previous_history }, /* k */
{ ISFUNC, rl_forward_char }, /* l */
@@ -327,9 +326,9 @@ KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
{ ISFUNC, rl_insert }, /* Control-k */
{ ISFUNC, rl_insert }, /* Control-l */
{ ISFUNC, rl_newline }, /* Control-m */
- { ISFUNC, rl_insert }, /* Control-n */
+ { ISFUNC, rl_menu_complete}, /* Control-n */
{ ISFUNC, rl_insert }, /* Control-o */
- { ISFUNC, rl_insert }, /* Control-p */
+ { ISFUNC, rl_backward_menu_complete }, /* Control-p */
{ ISFUNC, rl_insert }, /* Control-q */
{ ISFUNC, rl_reverse_search_history }, /* Control-r */
{ ISFUNC, rl_forward_search_history }, /* Control-s */
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
index d0b7e33..2a120c0 100644
--- a/lib/readline/vi_mode.c
+++ b/lib/readline/vi_mode.c
@@ -1,25 +1,25 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
/* **************************************************************** */
@@ -69,7 +69,7 @@ int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
static int _rl_vi_doing_insert;
/* Command keys which do movement for xxx_to commands. */
-static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|";
+static const char * const vi_motion = " hl^$0ftFT;,%wbeWBE|`";
/* Keymap used for vi replace characters. Created dynamically since
rarely used. */
@@ -101,7 +101,7 @@ static int _rl_vi_last_key_before_insert;
static int vi_redoing;
/* Text modification commands. These are the `redoable' commands. */
-static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
+static const char * const vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
/* Arrays for the saved marks. */
static int vi_mark_chars['z' - 'a' + 1];
@@ -131,9 +131,10 @@ static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
void
_rl_vi_initialize_line ()
{
- register int i;
+ register int i, n;
- for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
+ n = sizeof (vi_mark_chars) / sizeof (vi_mark_chars[0]);
+ for (i = 0; i < n; i++)
vi_mark_chars[i] = -1;
RL_UNSETSTATE(RL_STATE_VICMDONCE);
@@ -211,6 +212,15 @@ rl_vi_redo (count, c)
if (rl_point > 0)
_rl_vi_backup ();
}
+ /* Ditto for redoing an insert with `I', but move to the beginning of the
+ line like the `I' command does. */
+ else if (_rl_vi_last_command == 'I' && vi_insert_buffer && *vi_insert_buffer)
+ {
+ rl_beg_of_line (1, 'I');
+ _rl_vi_stuff_insert (count);
+ if (rl_point > 0)
+ _rl_vi_backup ();
+ }
/* Ditto for redoing an insert with `a', but move forward a character first
like the `a' command does. */
else if (_rl_vi_last_command == 'a' && vi_insert_buffer && *vi_insert_buffer)
@@ -220,6 +230,15 @@ rl_vi_redo (count, c)
if (rl_point > 0)
_rl_vi_backup ();
}
+ /* Ditto for redoing an insert with `A', but move to the end of the line
+ like the `A' command does. */
+ else if (_rl_vi_last_command == 'A' && vi_insert_buffer && *vi_insert_buffer)
+ {
+ rl_end_of_line (1, 'A');
+ _rl_vi_stuff_insert (count);
+ if (rl_point > 0)
+ _rl_vi_backup ();
+ }
else
r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
vi_redoing = 0;
@@ -584,7 +603,7 @@ rl_vi_insert_beg (count, key)
int count, key;
{
rl_beg_of_line (1, key);
- rl_vi_insertion_mode (1, key);
+ rl_vi_insert_mode (1, key);
return (0);
}
@@ -647,6 +666,14 @@ rl_vi_insertion_mode (count, key)
return (0);
}
+int
+rl_vi_insert_mode (count, key)
+ int count, key;
+{
+ rl_vi_start_inserting (key, 1, rl_arg_sign);
+ return (0);
+}
+
static void
_rl_vi_save_insert (up)
UNDO_LIST *up;
@@ -690,7 +717,10 @@ _rl_vi_done_inserting ()
}
else
{
- if ((_rl_vi_last_key_before_insert == 'i' || _rl_vi_last_key_before_insert == 'a') && rl_undo_list)
+ if (rl_undo_list && (_rl_vi_last_key_before_insert == 'i' ||
+ _rl_vi_last_key_before_insert == 'a' ||
+ _rl_vi_last_key_before_insert == 'I' ||
+ _rl_vi_last_key_before_insert == 'A'))
_rl_vi_save_insert (rl_undo_list);
/* XXX - Other keys probably need to be checked. */
else if (_rl_vi_last_key_before_insert == 'C')
@@ -739,6 +769,7 @@ _rl_vi_change_mbchar_case (count)
wchar_t wc;
char mb[MB_LEN_MAX+1];
int mlen, p;
+ size_t m;
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
@@ -746,7 +777,11 @@ _rl_vi_change_mbchar_case (count)
count--;
while (count-- && rl_point < rl_end)
{
- mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
+ m = mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
+ if (MB_INVALIDCH (m))
+ wc = (wchar_t)rl_line_buffer[rl_point];
+ else if (MB_NULLWCH (m))
+ wc = L'\0';
if (iswupper (wc))
wc = towlower (wc);
else if (iswlower (wc))
@@ -886,6 +921,13 @@ rl_vi_domove (key, nextkey)
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+ if (c < 0)
+ {
+ *nextkey = 0;
+ return -1;
+ }
+
*nextkey = c;
if (!member (c, vi_motion))
@@ -902,6 +944,11 @@ rl_vi_domove (key, nextkey)
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key (); /* real command */
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ {
+ *nextkey = 0;
+ return -1;
+ }
*nextkey = c;
}
else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
@@ -1033,13 +1080,15 @@ int
rl_vi_delete_to (count, key)
int count, key;
{
- int c;
+ int c, start_pos;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
+ start_pos = rl_point;
+
if (rl_vi_domove (key, &c))
{
rl_ding ();
@@ -1048,7 +1097,8 @@ rl_vi_delete_to (count, key)
/* These are the motion commands that do not require adjusting the
mark. */
- if ((strchr (" l|h^0bB", c) == 0) && (rl_mark < rl_end))
+ if (((strchr (" l|h^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+ (rl_mark < rl_end))
rl_mark++;
rl_kill_text (rl_point, rl_mark);
@@ -1077,7 +1127,8 @@ rl_vi_change_to (count, key)
/* These are the motion commands that do not require adjusting the
mark. c[wW] are handled by special-case code in rl_vi_domove(),
and already leave the mark at the correct location. */
- if ((strchr (" l|hwW^0bB", c) == 0) && (rl_mark < rl_end))
+ if (((strchr (" l|hwW^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+ (rl_mark < rl_end))
rl_mark++;
/* The cursor never moves with c[wW]. */
@@ -1112,12 +1163,13 @@ int
rl_vi_yank_to (count, key)
int count, key;
{
- int c, save;
+ int c, start_pos;
- save = rl_point;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
+ start_pos = rl_point;
+
if (rl_vi_domove (key, &c))
{
rl_ding ();
@@ -1126,14 +1178,15 @@ rl_vi_yank_to (count, key)
/* These are the motion commands that do not require adjusting the
mark. */
- if ((strchr (" l|h^0%bB", c) == 0) && (rl_mark < rl_end))
+ if (((strchr (" l|h^0%bBFT`", c) == 0) && (rl_point >= start_pos)) &&
+ (rl_mark < rl_end))
rl_mark++;
rl_begin_undo_group ();
rl_kill_text (rl_point, rl_mark);
rl_end_undo_group ();
rl_do_undo ();
- rl_point = save;
+ rl_point = start_pos;
return (0);
}
@@ -1224,14 +1277,22 @@ static int
_rl_vi_callback_char_search (data)
_rl_callback_generic_arg *data;
{
+ int c;
#if defined (HANDLE_MULTIBYTE)
- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
#else
RL_SETSTATE(RL_STATE_MOREINPUT);
- _rl_vi_last_search_char = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#endif
+ if (c <= 0)
+ return -1;
+
+#if !defined (HANDLE_MULTIBYTE)
+ _rl_vi_last_search_char = c;
+#endif
+
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1247,6 +1308,7 @@ int
rl_vi_char_search (count, key)
int count, key;
{
+ int c;
#if defined (HANDLE_MULTIBYTE)
static char *target;
static int tlen;
@@ -1293,11 +1355,17 @@ rl_vi_char_search (count, key)
else
{
#if defined (HANDLE_MULTIBYTE)
- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ if (c <= 0)
+ return -1;
+ _rl_vi_last_search_mblen = c;
#else
RL_SETSTATE(RL_STATE_MOREINPUT);
- _rl_vi_last_search_char = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+ _rl_vi_last_search_char = c;
#endif
}
}
@@ -1467,6 +1535,9 @@ _rl_vi_callback_getchar (mb, mlen)
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, mlen);
@@ -1485,6 +1556,9 @@ _rl_vi_callback_change_char (data)
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
+
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1516,6 +1590,9 @@ rl_vi_change_char (count, key)
else
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
+
return (_rl_vi_change_char (count, c, mb));
}
@@ -1650,7 +1727,7 @@ _rl_vi_set_mark ()
ch = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
- if (ch < 'a' || ch > 'z')
+ if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
return -1;
@@ -1702,7 +1779,7 @@ _rl_vi_goto_mark ()
rl_point = rl_mark;
return 0;
}
- else if (ch < 'a' || ch > 'z')
+ else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
return -1;
diff --git a/lib/readline/xmalloc.c b/lib/readline/xmalloc.c
index 8985d34..97d8f2e 100644
--- a/lib/readline/xmalloc.c
+++ b/lib/readline/xmalloc.c
@@ -1,23 +1,24 @@
/* xmalloc.c -- safe versions of malloc and realloc */
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2009 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 (Readline), a library
+ for reading lines of text with interactive input and history editing.
- Readline is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Readline is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
diff --git a/lib/readline/xmalloc.h b/lib/readline/xmalloc.h
index 9cb08ba..f40d7a5 100644
--- a/lib/readline/xmalloc.h
+++ b/lib/readline/xmalloc.h
@@ -1,24 +1,23 @@
/* xmalloc.h -- memory allocation that aborts on errors. */
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
- This file is part of the GNU Readline Library, a library for
- reading lines of text with interactive input and history editing.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2, or
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- The GNU Readline Library is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_XMALLOC_H_)
#define _XMALLOC_H_