--- /dev/null
+Larry Wall wrote the original version of `patch'.
+
+Paul Eggert removed arbitrary limits; added support for binary
+files, setting file times, and deleting files; and made it conform
+better to POSIX.
+
+Wayne Davison added unidiff support.
+
+David MacKenzie added configuration and backup support.
+
+Andreas Gruenbacher added merge support.
--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ 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
+
+ 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
+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 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 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.
+
+ 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.
+
+ 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 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 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
+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
+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) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <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, 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>.
--- /dev/null
+2009-11-12 Andreas Gruenbacher <agruen@suse.de>
+
+ * NEWS: Version 2.6 released.
+
+2009-10-27 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.man: Fix typo (reported by Vytautas Å altenis).
+
+ * src/merge.c: Clarify the message when (part of) a hunk cannot be
+ merged.
+ * tests/merge: Adapt the test case.
+
+2009-09-04 Andreas Gruenbacher <agruen@suse.de>
+
+ * Makefile.in (LIBSRCS, LIBHDRS, LIBM4FILES): Add the gnulib which
+ were imported on 2009-06-05 here as well.
+
+ * src/partime.c (main): Try to preserve the owning group of patched
+ files.
+
+2009-07-19 Andreas Gruenbacher <agruen@suse.de>
+
+ * gl/lib/full-write.c, gl/lib/safe-write.c, gl/lib/full-write.h,
+ gl/lib/safe-write.h, gl/m4/safe-write.m4, gl/m4/ssize_t.m4:
+ Import full_write() and its prerequesites from gnulib.
+ * Makefile.in (LIBSRCS, LIBHDRS, LIBM4FILES): Add new files.
+ Add new dependencies.
+ * configure.ac (gl_SAFE_WRITE): Needef for full_write().
+ * src/util.c: Include full-write.h.
+ (copy_to_fd): use full_write() instead of write().
+
+ * src/partime.c: The -m option hasn't been officially allocated yet.
+ Use only the long form for now (--merge).
+
+2009-06-15 Andreas Gruenbacher <agruen@suse.de>
+
+ * src/util.c (move_file): Don't fail when removing nonexistent
+ files: this condition is already checked in maybe_reverse().
+
+2009-06-05 Andreas Gruenbacher <agruen@suse.de>
+
+ * gl/lib/getopt_int.h, gl/lib/strndup.c, gl/m4/strndup.m4: Add
+ some missing gnulib files.
+ * Makefile.in (GETOPT_H): Include subdirectory (gl/lib/) when
+ using the gnulib version.
+
+ * src/patch.c: When sending output to stdout, use dup2 to redirect
+ messages to stderr; simply assigning stderr to stdout doesn't work on
+ some platforms.
+ * gl/lib/dup2.c, gl/m4/dup2.m4: Import from gnulib.
+
+ * gl/lib/rename.c, gl/m4/rename.m4: Import from gnulib for platforms
+ like Mingw.
+
+2009-05-12 Andreas Gruenbacher <agruen@suse.de>
+
+ * src/merge.c (locate_merge): Make sure to return a line number
+ bigger than last_frozen_line.
+
+ * src/patch.c (explicit_inname): New variable.
+ (get_some_switches): Set to true when the filename to patch has been
+ specified on the command line.
+ (reinitialize_almost_everything): Do not reset the input filename
+ between patches when it has been specified on the command line.
+ * tests/inname: New test case.
+ * Makefile.in: Add test case.
+
+2009-04-11 Vincent Legoll <vincent.legoll@gmail.com>
+
+ * src/patch.c (main): Always set patch_get to 0 unless PATCH_GET is
+ set.
+ * patch.man: Update accordingly.
+
+2009-04-11 Andreas Gruenbacher <agruen@suse.de>
+
+ * update-version.sh, configure.ac, Makefile.in: Portability
+ improvements.
+
+2009-04-08 Andreas Gruenbacher <agruen@suse.de>
+
+ * src/patch.c (create_output_file): Add support for sending output
+ to standard output.
+ (main): Allow -o -. Remove redundant check.
+ * patch.man: Document the new use of -o.
+
+ * src/pch.c (there_is_another_patch): Allow special characters in
+ filenames read interactively.
+
+ * src/util.c (fetchname): Don't forget to NUL terminate ptimestr.
+
+2009-04-07 Andreas Gruenbacher <agruen@suse.de>
+
+ * src/util.c (file_id_hasher): Adapt to Gnulib type change.
+ * Makefile.in: Fix out-of-tree builds.
+ (dist): Optionally also create bzip2 and xz tarballs.
+ * NEWS: Update.
+
+ * patch.man: Replace "systems like DOS" with "Windows". Spelling.
+
+ Preserve timestamps in reject files.
+ * src/pch.c (p_timestr): New variable.
+ (intuit_diff_type): Set p_timestr here through fetchname().
+ (pch_timestr): New function.
+ * src/pch.h (pch_timestr): Declare.
+ * src/util.c (fetchname): Return the timestamp as string when asked to.
+ * src/util.h (fetchname): Update declaration.
+ * tests/preserve-c-function-names, tests/reject-format: Update.
+
+2009-04-06 Andreas Gruenbacher <agruen@suse.de>
+
+ Fix the "patch would create" fix from 2009-03-28.
+ * src/pch.c (maybe_reverse): New function.
+ (intuit_diff_type): Move the check back here from
+ there_is_another_patch(), but compute it using maybe_reverse(). If
+ an input file name has been specified, do this check here as well.
+ * src/patch.c (main): Only set outname if we are not skipping the
+ patch.
+ * src/inp.c (get_input_file): We may get here without a file to read
+ as well now; don't abort in this case.
+ * tests/create-delete: Add test cases covering the previously-broken
+ code paths.
+
+ * Makefile.in (MISC): Add config.guess and config.sub.
+
+ * src/partime.c (parse_pattern_letter): Fix for timestamps with
+ seconds > 59.5 from Christian Franke.
+
+2009-04-05 Andreas Gruenbacher <agruen@suse.de>
+
+ * util.c (create_backup): We also need to create base directories
+ with a --prefix without slashes and a filename with slashes. A
+ --suffix cannot contain slashes, though.
+ * merge.c (merge_hunk): Add missing outstate->zero_output = false.
+
+ Move all source and header files into src/.
+ * Makefile.in, tests/test-lib.sh, configure.ac: Update accordingly.
+ Move all Gnulib files below gl/, and all other source and header
+ files into src/.
+ * Makefile.in, tests/test-lib.sh, configure.ac, autogen.sh: Update
+ accordingly.
+ * m4/st_mtim.m4: Remove (obsolete since 2009-03-28).
+
+ Update to the latest version of Gnulib.
+ * config.guess, config.sub, gl/lib/getopt.hin, gl/lib/mbrtowc.c,
+ gl/lib/stripslash.c, gl/lib/verify.h, gl/lib/xstrndup.c,
+ gl/lib/xstrndup.h, gl/m4/argmatch.m4, gl/m4/double-slash-root.m4,
+ gl/m4/gettext.m4, gl/m4/inline.m4, gl/m4/minmax.m4,
+ gl/m4/xstrndup.m4: New files.
+ * gl/lib/argmatch.c, gl/lib/argmatch.h, gl/lib/backupfile.c,
+ gl/lib/backupfile.h, gl/lib/basename.c, gl/lib/dirname.c,
+ gl/lib/dirname.h, gl/lib/error.c, gl/lib/error.h, gl/lib/exitfail.c,
+ gl/lib/exitfail.h, gl/lib/getopt.c, gl/lib/getopt1.c, gl/lib/gettext.h,
+ gl/lib/hash.c, gl/lib/hash.h, gl/lib/malloc.c, gl/lib/memchr.c,
+ gl/lib/quote.c, gl/lib/quote.h, gl/lib/quotearg.c, gl/lib/quotearg.h,
+ gl/lib/realloc.c, gl/lib/strcasecmp.c, gl/lib/strncasecmp.c,
+ gl/lib/unlocked-io.h, gl/lib/xalloc.h, gl/lib/xmalloc.c: Modified.
+ * gl/m4/backupfile.m4, gl/m4/d-ino.m4, gl/m4/dirname.m4, gl/m4/dos.m4,
+ gl/m4/error.m4, gl/m4/exitfail.m4, gl/m4/extensions.m4,
+ gl/m4/getopt.m4, gl/m4/hash.m4, gl/m4/malloc.m4, gl/m4/mbrtowc.m4,
+ gl/m4/mbstate_t.m4, gl/m4/memchr.m4, gl/m4/onceonly.m4, gl/m4/quote.m4,
+ gl/m4/quotearg.m4, gl/m4/realloc.m4, gl/m4/stdbool.m4,
+ gl/m4/unlocked-io.m4, gl/m4/utimbuf.m4, gl/m4/xalloc.m4: Likewise.
+ * install-sh, mkinstalldirs: Likewise.
+ * gl/lib/stdbool.hin: Renamed from gl/lib/stdbool_.h.
+ * gl/lib/getopt.h: Removed (should be generated).
+ * gl/lib/addext.c: Removed from Gnulib.
+
+ Replace memory_fatal() with xalloc_die(). The FILESYSTEM_PREFIX_LEN()
+ macro has been renamed to FILE_SYSTEM_PREFIX_LEN().
+ * src/patch.c (main): Remove xalloc_fail_func (replaced by
+ xalloc_die()). Work around the missing addext() with
+ find_backup_file_name() plus hacks.
+ * src/util.c (create_backup, version_controller): The new versions of
+ base_name() and dir_name() return malloc'ed buffers. Adapt.
+ * src/util.h: Replace memory_fatal() with xalloc_die().
+ * src/pch.c: Don't leak memory with strlen (base_name (...)).
+
+ * src/util.c (create_file): Add to_dir_known_to_exist argument and
+ try to create parent directories when set and the create failed with
+ ENOENT.
+ (copy_file, create_backup_copy): Pass the new to_dir_known_to_exist
+ argument through.
+ (create_backup): Don't assume the target directory exists when making
+ a backup copy.
+ * src/util.h (create_file, copy_file): Change the declarations.
+ * src/patch.c, src/pch.c, src/inp.c: In the calls to create_file() and
+ copy_file(), assume the parent directory exists.
+ * tests/unmodified-files: Test the create_backup() fix.
+
+ * src/util.c (create_backup): The new dir_name() and base_name()
+ functions are really counter productive. Remove them and the bugs
+ that keepeing them here as introduced.
+ * tests/backup-prefix-suffix: Add more regression tests.
+
+ * src/patch.c (locate_hunk): Revert to the original asymmetric hunk
+ behavior (but only anchor hunks starting at line 0 to the start of the
+ file): there is not enough reason to change the historic behavior.
+ * src/merge.c (locate_merge): Add similar asymmetric hunk check here.
+ * tests/asymmetric-hunks: Update accordingly.
+ * patch.man: Document the asymmetric hunk behavior.
+ * NEWS: Update.
+
+ Copyright notice updates.
+ * README, AUTHORS: Updates.
+
+ * patch.man: Document that merging can be slow.
+ * tests/test-lib.sh: Also unset QUOTING_STYLE.
+
+2009-04-04 Andreas Gruenbacher <agruen@suse.de>
+
+ * pch.c (another_hunk): Add (back) the line number ranges to the
+ debug output.
+ * merge.c (merge_hunk): Likewise.
+ (locate_merge): Add a note about the algorithm's requirements.
+ * util.c (create_backup): Split from move_file. New LEAVE_ORIGINAL
+ argument for copying instead of renaming. Don't fail when rename
+ fails with errno == EXDEV; copy and unlink in that case instead.
+ (copy_file): Add debug message.
+ * util.h: Move including <utime.h> etc. here from patch.c.
+ (create_backup): Declare.
+ * patch.c (main): Create backup files even for files which did not
+ actually change; some users of patch rely on the presence of backup
+ files when patch says "patching file".
+ * tests/unmodified-files: Test the patch.c change. (The EXDEV fix in
+ create_mackup() was tested manually.)
+ * util.c (copy_to_fd, ask): The read() return type is ssize_t.
+
+2009-04-03 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.man: Document the -m or --merge option. Some minor other
+ changes.
+ * NEWS: Document the asymmetric hunk behavior and the -m or --merge
+ option.
+ * merge.c (locate_merge): Include the number of changes in the debug
+ message.
+ (print_linerange): New function.
+ (merge_result): No longer print line offsets: without exact matches,
+ line numbers are less meaningful. Output the entire messages here.
+ (merge_hunk): Be silent when merging exact matches unless in
+ --verbose mode.
+ * tests/merge: Add another interesting test case.
+
+ * tests/test-lib.sh: Add have_ed function for checking if ed is
+ available.
+ * tests/crlf-handling, tests/need-filename: Check for ed and skip the
+ ed related tests if we don't have it.
+ * tests/merge: Use sed instead of ed: sed is more readily available.
+
+ * patch.c (locate_hunk): If a hunk starts at a line > 1, it obviously
+ is not from the start of the file.
+ * tests/asymmetric-hunks: Add tests for all possible cases.
+
+2009-04-02 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c (locate_hunk): Revert the assymmetric hunk fix from
+ 2009-03-29. Instead, allow such hunks to apply only when no
+ more context remains.
+
+ * patch.c (main): Restructure to get rid of some code duplication.
+ (copy_till, similar): Export these functions.
+ * common.h (struct outstate, in_offset, out_offset,
+ last_frozen_line): Move here from patch.c.
+ (apply_hunk, copy_till, similar): Declare here.
+
+ Simple merge support:
+ * configure.ac (ENABLE_MERGE): New --disable-merge option.
+ * patch.c (merge): New variable.
+ (main): New -m and --merge options. When in merge mode, don't try
+ to reverse patches, and don't try to apply with fuzz.
+ * common.h (merge_hunk): Declare function.
+ * merge.c: New file containing all the merge code.
+ * tests/merge: New test case.
+ * Makefile.in (SRCS): Add merge.c.
+ (OBJS): Add merge.$(OBJEXT) when merge support is enabled.
+ (TESTS): Add test case.
+ (COMPILE): Define ENABLE_MERGE when merge support is enabled.
+
+ Locate hunks to merge more intelligently:
+ * bestmatch.h: Shortest Edit Sequence algorithm.
+ * merge.c (locate_merge, count_fuzz_lines): New functions.
+ (merge_hunk): Replace simple guessing with locate_merge().
+ * Makefile.in (HDRS): Add bestmatch.h.
+ * tests/merge: Only minor improvements up to now.
+
+ * diffseq.h: New file (Gnulib compareseq algorithm).
+ * minmax.h: New file (Gnulib MIN and MAX macros).
+ * Makefile.in (HDRS): Add diffseq.h and minmax.h.
+
+ * COPYING: Update to GPL version 3 because of diffseq.h.
+
+ * diffseq.h: When an EQUAL_IDX macro is defined, use that instead
+ of EQUAL. This macro takes vector indexes instead of elements as
+ arguments.
+
+ Better merge support:
+ * patch.c, common.h (apply_hunk): Make static again.
+ * merge.c (compute_changes): New function for computing the
+ difference between lines in a hunk and lines in the input file.
+ (merge_result): We may have more than one result per hunk now.
+ (merge_hunk): Merge the hunk with the compute_changes() result.
+ * tests/merge: Better results now.
+
+ * merge.c: Add license header.
+
+ * merge.c (locate_merge): The number of changes allowed permits a
+ higher maximum merge position (max_where).
+ * tests/merge: Add a test for this case.
+
+ * merge.c (merge_hunk): Add two missing checks that were leading into
+ failed assertions.
+ * tests/merge: Add test cases for each of these checks.
+
+ * Makefile.in (install, uninstall): DESTDIR specifies a prefix to
+ the root directory to install into.
+ (installdirs): Merge with install.
+
+2009-04-01 Andreas Gruenbacher <agruen@suse.de>
+
+ * tests/test-lib.sh: When $GDB is set, run patch in gdbserver
+ for debugging.
+ * pch.c (another_hunk): Make the debug output easier to read.
+
+2009-03-31 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c: Split last_offset into in_offset and out_offset and
+ count line numbers properly.
+ * tests/line-numbers: Without the fixes, this test case goes
+ horribly wrong.
+ * Makefile.in (TESTS): Add test case.
+
+2009-03-30 Jim Meyering <meyering@redhat.com>
+
+ tests: accommodate ls' "alternate access control method" indicator
+ ls can output an additional byte after a file's permissions string,
+ e.g., rather than "rwxr--r-- ..." it can output "rwxr--r--+ ..."
+ or "rwxr--r--. ..." to indicate the presence of an ACL.
+ * tests/create-delete: Adjust sed filter to accommodate that.
+ * tests/preserve-mode-and-timestamp: Likewise.
+
+2009-03-30 Andreas Gruenbacher <agruen@suse.de>
+
+ * tests/test-lib.sh: Unset environment variables that influence
+ the behavior of patch.
+ * util.c (move_file): Add debug message when files have been seen
+ already. Fix leftover "empty uneadable" debug message.
+
+ * patch.c (main): Print newline earlier.
+ * util.c (copy_file): Add debug message.
+
+2009-03-29 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c (locate_hunk): Hunks that have fewer or more lines of
+ context at the beginning than at the end can match anywhere; the
+ assumption that this can only occur at the beginning or end of the
+ file is wrong. Remove those checks.
+ * tests/asymmetric-hunks: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * util.c (move_file): Create backup files of nonexisting files with
+ the default mode instead of mode 0: files with mode 0 cause too many
+ problems with applications which do not expect unreadable files.
+ * tests/create-delete: Test for this.
+
+ * Makefile.in (BROKEN_TESTS): Test cases which fail.
+
+2009-03-28 Andreas Gruenbacher <agruen@suse.de>
+
+ * pch.c (intuit_diff_type): Rename need_filename argument to
+ need_header. Omit superfluous "missing header" warnings.
+
+ When remembering files including timestamps, we need to update the
+ timestamps after appending to a file. This causes problems on some
+ systems where the timestamps returned by fstat() after appending are
+ not up to date, yes. We only remember timestamps as a compatibility
+ hack with non-POSIX systems that do not have unique inode numbers;
+ drop this hack instead.
+ * timespec.h, m4/timespec.m4: Remove.
+ * util.c: Remove timespec.h and all uses of struct timespec.
+ (append_to_file): Remove REMEMBER argument; no need to update known
+ files anymore.
+ * util.h (append_to_file): Update definition.
+ * Makefile.in: Remove timespec.h and m4/timespec.m4.
+
+ * common.h (origsuff): New variable.
+ * patch.c (main): Remember when -z was used.
+ * util.c (contains_slash): New function.
+ (move_file): Enforce simple backup mode and compute the backup file
+ name here if -B, -Y, or -z is used. Fix the case where -B or -Y is
+ combined with -z.
+ * patch.man: Document this change.
+ * tests/backup-prefix-suffix: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * tests/munged-context-format: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * util.c (vsay): New function for use in say(), etc.
+ (ok_to_reverse): Use vsay() here instead of fprintf() to ensure
+ flushing.
+
+ * pch.c (there_is_another_patch): Move the "patch would create" test
+ here from intuit_diff_type() after asking for the filename to patch.
+ * inp.c (get_input_file): No need to report when the file is missing;
+ this is done in there_is_another_patch() already.
+ * patch.c (main): No need to report when a patch attempts to create
+ an exiting file, either.
+
+2009-03-25 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c (main): Avoid replacing files when nothing has changed.
+ * tests/unmodified-files: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * patch.c (main): New apply_empty_patch variable. When applying an
+ empty patch to a file and -o is given, copy the input file to the
+ output file.
+
+2009-03-24 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c (abort_hunk_unified, abort_hunk_context): Preserve
+ Index lines in reject files as well.
+ * tests/reject-format: Test this change.
+
+ * configure.ac (TEST_SHELL): New substitution.
+ * Makefile.in (TEST_SHELL): New variable.
+ (HAVE__BOOL): New variable.
+ (hash.$(OBJEXT)): Add $(STDBOOL_H) dependency.
+ * tests/test-lib.sh: Use expr for arithmetic operations. Check for
+ working "echo -n" and BASH_LINENO. Replace printf with echo.
+ * tests/preserve-mode-and-timestamp: Ignore leading "+" in ls output.
+ * tests: Remove !shebang line from tests and make them non-executable.
+ Replace printf with echo.
+
+2009-03-23 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c (intuit_diff_type): When looking for an ed or normal
+ patch, don't look for filename headers. (Those formats don't
+ have any.)
+ * pch.c (there_is_another_patch): Don't suggest to use -p with
+ normal format diffs for the same reason.
+
+2009-03-22 Andreas Gruenbacher <agruen@suse.de>
+
+ * NEWS: Update for alpha release.
+
+ * patch.c (main): Always initialize the known files table.
+ Move new reject files into place; append to known ones.
+ * util.c (file_already_seen): Export.
+ (move_file): Remember all files, not only backup files.
+ (append_to_file): When asked to remember a file, remember
+ the state *after* appending. (The timestamps will change!)
+ * tests/remember-reject-files: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * common.h (no_strip_trailing_cr): New variable.
+ * patch.c: Use no_strip_trailing_cr. Option --binary no longer
+ a no-op on POSIX systems.
+ * patch.man: Document change of --binary.
+ * pch.c (there_is_another_patch): Check no_strip_trailing_cr.
+ * tests/crlf-handling: Add --binary tests here.
+
+ * patch.c (apply_hunk): Use fputs() in simple fprintf()
+ situations.
+
+ * patch.c (main): Require filename in patch if none specified on
+ the command line and posixly_correct is false.
+ * pch.c (intuit_diff_type): While we still don't have a filename,
+ don't look for hunks.
+ (there_is_another_patch): Pass need_filename through.
+ * tests/need-filename: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * pch.c (intuit_diff_type): Check for garbage after what looks
+ like a normal format command.
+ * tests/normal-garbage: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * Makefile.in (bindir): Define as @bindir@.
+ (DISTFILES_CLEAN): Move DISTFILES here which must not be remade by
+ the dist target.
+ (MISC): Add missing tests/test-lib.sh and update-version.sh.
+ (check, $(TESTS)): Make each test depend on all so that they can be
+ run individually.
+ (maintainer-clean): Also remove patch-*.tar.gz and patch-*.tar.gz.sig.
+ (dist): Add PV directory level. Add reminder to self how to upload.
+ * configure.ac: Silence "missing datarootdir" warning.
+
+ * tests/crlf-handling: Add test for "diff -p" context with a CRLF
+ ine ending.
+
+2009-03-21 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c (main): With -r, instead of moving the global reject
+ file into place, copy the first reject into the file, and
+ append all the rest. Discard rejects with -r -.
+ * patch.man: Document the latter.
+ * util.c (copy_to_fd): New function.
+ (copy_file): Use that.
+ (append_to_file): New function.
+ * util.h (append_to_file): Add function declaration.
+ * tests/global-reject-files: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * patch.man: Minor fix.
+
+ * pch.c (another_hunk, pch_swap): Always add the '^' hunk end
+ marker: apply_hunk() and abort_hunk_unified() rely on it.
+ (pch_char): Explain when this returns '\n'.
+ * util.c: Remove unused include <version.h>.
+
+2009-03-20 Andreas Gruenbacher <agruen@suse.de>
+
+ * patch.c: New option --reject-format=FORMAT.
+ (abort_hunk_context): Rename from abort_hunk().
+ (abort_hunk_unified, abort_hunk, mangled_patch,
+ print_unidiff_range): New functions.
+ * patch.man: Document this.
+ * pch.c, pch.h (pch_normalize): New function.
+ * tests/reject-format: New test case.
+ * Makefile.in (TESTS): Add test case.
+ * tests/preserve-c-function-names: Update.
+
+ * pch.c (p_name): New variable.
+ (intuit_diff_type): Save the old, new, and index filenames.
+ (pch_char): Return either of the saved filenames.
+ * pch.h: Move enum nametype here from pch.c. Declare pch_name().
+ * patch.c (abort_hunk, abort_hunk_unified, abort_hunk_context):
+ New HEADER and REVERSE arguments.
+ (print_header_line): New function.
+ (abort_hunk_unified, abort_hunk_context): Use it.
+ * tests/corrupt-reject-files, tests/preserve-c-function-names,
+ tests/reject-format: Update.
+
+ * patch.c (main): No longer set reject file modes to the modes of the
+ files they are assiciated with: the previous behavior is inconsistent
+ with global reject files (-r), which are not associated with any
+ particular file.
+ * tests/preserve-mode-and-timestamp: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * Makefile.in (DISTFILES): Add the files from DISTFILES_M4,
+ DISTFILES_PC, DISTFILES_PC_DJGPP.
+ (DISTFILES_M4, DISTFILES_PC, DISTFILES_PC_DJGPP): Remove.
+ (distclean): Also remove config.hin~ and autom4te.cache/.
+ (maintainer-clean): Also remove aclocal.m4, config.hin, configure.
+ (dist): Make work for DISTFILES in subdirectories. Normalize and
+ sort DISTFILES.
+
+ * Makefile.in (MISC): Add VERSION.
+ (FORCE): New target.
+ (VERSION): Recompute automatically from repository.
+ (configure): Depend on VERSION. Regenerate with --force: autoconf
+ does not recognize the dependency between VERSION and ocnfigure.
+ (config.hin): Regenerate with --force.
+ (maintainer-clean): Also remove VERSION.
+ * configure.ac: Compute PACKAGE_VERSION from repository.
+ * update-version.sh: New file.
+
+ * README-alpha: New file.
+ * Makefile.in (dist): Add README-alpha when appropriate.
+
+ * Makefile.in (M4FILES): Rename from ACINCLUDE_INPUTS.
+ (aclocal.m4): Recompute with aclocal.
+
+ * tests/test-lib.sh: Add library for simple test scripts.
+ * tests/crlf-handling, tests/remember-backup-files: New test cases.
+ * Makefile.in (TESTS): New variable. Add test cases.
+ (check): Replace the dummy test target with running all TESTS.
+
+ * pch.c, pch.h (pch_c_function): New function.
+ * pch.c (p_c_function): New variable.
+ (another_hunk): Preserve the "diff -p" output.
+ * patch.c (abort_hunk): Use pch_c_function().
+ * tests/preserve-c-function-names: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * util.c (savebuf): Return NULL if size == 0.
+ * pch.c (another_hunk): Check size for size != 0 before checking
+ savebuf()'s return value.
+ * tests/no-newline-triggers-assert: New test case.
+ * Makefile.in (TESTS): Add test case.
+
+ * tests/corrupt-reject-files: new test case for Jim Meyering's
+ 2007-08-26 fix.
+ * Makefile.in (TESTS): Add test case.
+
+2009-03-19 Andreas Gruenbacher <agruen@suse.de>
+
+ Imported from Paul Eggert's working directory:
+ * exitfail.c, exitfail, m4/exitfail.m4: Import from gnulib.
+ * hash.c, hash.h, m4/hash.m4: Likewise.
+ * m4/extensions.m4: Likewise.
+ * timespec.h, m4/timespec.m4: Likewise.
+ * m4/st_mtim.m4: New file.
+ * configure.ac: Update.
+ * common.h: Include <limits.h> unconditionally. Include <stdint.h>
+ if we have it.
+ * inp.c (plan_b, ifetch): Remove unnecessary casts.
+ * maketime.c, partime.c: Include <limits.h>, <stdlib.h>, <time.h>
+ unconditionally. Convert from K&R to ANSI C.
+ * maketime.h, partime.h: Convert from K&R to ANSI C.
+ * pch.c (p_indent, pget_line, intuit_diff_type): Use size_t for
+ indents.
+ * util.c: Assume we have vfprintf().
+ (NUM_SIGS): Cast to int in.
+ (fatal_exit_handler): Replace obsolescent AC_RETSIGTYPE.
+ * Various files: Update copyright notices.
+
+2007-08-26 Jim Meyering <jim@meyering.net>
+
+ * pch.c (another_hunk): Avoid an off-by-one error that would
+ result in NUL bytes in .rej files.
+
+2004-07-21 Paul Eggert <eggert@twinsun.com>
+
+ * Makefile.in (SRCS): Move hash.c here from LIBSRCS.
+ (exitfail.$(OBJEXT), patch.$(OBJEXT), xmalloc.$(OBJEXT)):
+ Depend on exitfail.h.
+ (hash.$(OBJEXT), util.$(OBJEXT)): Depend on hash.h.
+ * util.c: Whitespace cleanup in file_id.
+
+2004-07-19 Stepan Kasal <kasal@ucw.cz>
+
+ * pch.c (get_ed_command_letter): Allow commands without address.
+
+2003-11-10 Manu B <manubee@users.sourceforge.net>
+
+ Trivial change to port to mingw, which declares mkdir in unistd.h.
+ * m4/mkdir.m4 (PATCH_FUNC_MKDIR_TAKES_ONE_ARG): Include unistd.h.
+ * common.h (mkdir): Define after including unistd.h.
+
+2003-09-11 Paul Eggert <eggert@twinsun.com>
+
+ * pch.c (do_ed_script): Adjust to copy_file signature change.
+
+ * Makefile.in (STDBOOL_H): New macro. All uses of @STDBOOL_H@ changed.
+ (SRCS): Add exitfail.c.
+ (OBJS): Add exitfail.$(OBJEXT).
+ (HDRS): Add exitfail.h.
+ (stdbool.h): Use $@, as gnulib now suggests.
+ (ACINCLUDE_INPUTS): Add exitfail.m4, extensions.m4.
+ * common.h: Include <string.h>, <stdlib.h> unconditionally.
+ * configure.ac (gl_USE_SYSTEM_EXTENSIONS): Use this instead
+ of AC_GNU_SOURCE.
+ (gl_EXITFAIL): Add.
+ * patch.c: Include exitfail.h.
+ (main): Set exit_failure, not xalloc_exit_failure.
+
+ * inp.c (get_input_file): Clear cs if dry run.
+
+ * util.c (fetchname): Handle missing timestamps better.
+
+ * Makefile.in (LIBSRCS): Add hash.c.
+ (OBJS): Add hash.$(OBJEXT).
+ (HDRS): Add hash.h.
+ (MISC): Add timespec.h.
+ (ACINCLUDE_INPUTS): Add hash.m4, st_mtim.m4, timespec.m4
+ (util.$(OBJEXT): Depend on timespec.h.
+ * configure.ac (gl_HASH, gl_TIMESPEC): Add.
+ * patch.c (spew_output): New output arg, to contain status of output
+ file.
+ (main): Use it to get status of output file, and pass this to
+ move_file as needed. Initialize hash table.
+ * util.c (file_id): New type.
+ (file_id_hasher, file_id_comparator, init_backup_hash_table,
+ insert_file, file_already_seen): New functions.
+ (file_id_table): New var.
+ (move_file): New arg FROMST; all uses changed.
+ Do not backup a file that's already been patched.
+ Keep track of files that have been patched.
+ (copy_file): New arg TOST; all uses changed.
+ * util.h (copy_file, move_file): Adjust decls as per above.
+ (init_backup_hash_table): New decl.
+
+
+2003-07-05 Paul Eggert <eggert@twinsun.com>
+
+ * Makefile.in (check): Add a trivial check that "patch --help" works.
+ From a suggestion by Ed Avis.
+
+2003-07-02 Paul Eggert <eggert@twinsun.com>
+
+ * pch.c (intuit_diff_type): If a unified-diff header line contains
+ trailing CR, strip CR from each body line. This corrects a bug
+ introduced in the 2003-05-18 patch. Bug reported by Andreas
+ Gruenbacher.
+
+ * mkdir.c, rmdir.c, m4/rmdir.m4: Remove; we no longer
+ need to worry about ancient hosts that lack these functions.
+
+ * addext.c, backupfile.c, backupfile.h, dirname.h, m4/backupfile.m4,
+ m4/onceonly.m4, m4/quote.m4, malloc.c, quote,c, quote.h, realloc.c,
+ strcasecmp.c, xalloc.h, xmalloc.c: Sync with gnulib.
+ * stdbool_.h: Renamed from stdbool.h.in; all uses changed.
+ This renaming is imported from gnulib.
+ * m4/strcase.m4: New file, imported from gnulib.
+
+ * Makefile.in (LIBSRCS): Remove mkdir.c and rmdir.c.
+ (stdbool.h): Put output into temporary file and then rename it;
+ this change is imported from gnulib.
+ (mostlyclean): Clean stdbool.h-t too.
+ (ACINCLUDE_INPUTS): Remove rmdir.m4. Add strcase.m4.
+ * configure.ac (gl_FUNC_RMDIR): Remove.
+ (jm_PREREQ_ADDEXT): Remove; now down by gl_BACKUPFILE.
+ (gl_STRCASE, gl_XALLOC): Add.
+ (AC_REPLACE_FUNCS): Remove mkdir, strcasecmp.
+
+2003-05-20 Paul Eggert <eggert@twinsun.com>
+
+ * NEWS, configure.ac (AC_INIT): Version 2.5.9 released.
+
+ * Makefile.in (HDRS): Add gettext.h.
+
+ Use bool, not int, for booleans.
+
+ * pch.c (pch_says_nonexistent): Returns int, not bool.
+
+ * configure.ac: Add AM_STDBOOL_H.
+
+ * Makefile.in (MISC): Add stdbool.h.in.
+ (stdbool.h): New rule.
+ (ACINCLUDE_INPUTS): Add stdbool.m4.
+ (mostlyclean): Remove stdbool.h.
+ (COMMON): New macro; use it instead of common.h for dependencies.
+
+ * common.h: Include <stdbool.h>.
+ Remove TRUE, FALSE, bool. All uses changed to standard names.
+
+ * common.h (reverse, set_time, set_utc):
+ Use bool, not int, for booleans.
+ * pch.c (p_strip_trailing_cr, p_pass_comments_through,
+ prefix_components, pget_line, re_patch,
+ there_is_another_patch, intuit_diff_type, scan_linenum,
+ another_hunk, pget_line, pch_timestamp): Likewise.
+ * inp.h (ifetch): Likewise.
+ * util.c (move_file, version_controller, version_get, ok_to_reverse,
+ set_signals): Likewise.
+ * inp.c (report_revision, get_input_file, plan_a, plan_b, ifetch):
+ Likewise.
+ * util.h (ok_to_reverse, version_controller, version_get,
+ move_file, set_signals): Likewise.
+ * pch.h (another_hunk, pch_says_nonexistent, pch_timestamp):
+ Likewise.
+ * patch.c (struct outstate, numeric_string, make_backups,
+ backup_if_mismatch, remove_empty_files,
+ reverse_flag_specified, main, reinitialize_almost_everything,
+ get_some_switches, apply_hunk, init_output, copy_till):
+ Likewise.
+
+2003-05-18 Paul Eggert <eggert@twinsun.com>
+
+ * pch.c (p_pass_comments_through): New var.
+ (pget_line): Accept new arg for pass_comments_through.
+ All callers changed.
+ (there_is_another_patch): Do not suggest -p for ed diffs.
+ (intuit_diff_type): Check ed command for correct syntax.
+ Do not set p_strip_trailing_cr merely because a -p line contains a CR.
+ (get_ed_command_letter): New function.
+ (do_ed_script): Use it. Do not treat '#' data lines as comments in ed
+ scripts.
+
+ * util.c (move_file):
+ Don't assume that when 'rename(A,B)' succeeds then A no
+ longer exists. This is not true of POSIX 1003.1-2001 rename when A
+ and B are links to the same file.
+ (fetchname): Fix test for file names with internal spaces.
+
+ * version.c: Don't include patchlevel.h.
+ (version): Use PACKAGE_NAME and PACKAGE_VERSION instead of obsolete
+ PROGRAM_NAME and PATCH_VERSION.
+ (copyright_string): Bump to 2003.
+
+ * common.h (FILESYSTEM_PREFIX_LEN, ISSLASH):
+ Remove; now done by 'configure'.
+ (PROGRAM_NAME): Remove; now done by 'configure' as PACKAGE_NAME.
+
+ * patch.c: Do not include <exitfail.h>.
+ (main): Set xalloc_exit_failure, not exit_failure.
+ Add "&& !skip_rest_of_patch" when deciding to continue ed scripts.
+ (option_help): Use PACKAGE_BUGREPORT rather than hardcoding.
+
+ * configure.ac (AC_PREREQ): Bump to 2.57.
+ (AC_GNU_SOURCE): Add, early on.
+ (gl_BACKUPFILE, gl_DIRNAME, gl_ERROR, gl_FUNC_MEMCHR, gl_FUNC_RMDIR,
+ gl_GETOPT, gl_PREREQ_XMALLOC, gl_QUOTE, gl_QUOTEARG): Add.
+ (jm_PREREQ_ADDEXT): Add, with definition.
+ (jm_PREREQ_DIRNAME, jm_PREREQ_ERROR, jm_PREREQ_MEMCHR,
+ jm_PREREQ_QUOTEARG): Remove.
+ (AC_REPLACE_FUNCS): Remove memchr, rename, rmdir).
+ (jm_FUNC_GLIBC_UNLOCKED_IO, jm_AC_DOS): Add.
+ (jm_CHECK_TYPE_STRUCT_DIRENT_D_INO): Do not call directly.
+ (AC_OUTPUT): Use new style, with AC_CONFIG_FILES.
+
+ Update to current CVS gnulib.
+
+ * exitfail.c, exitfail.h, patchlevel.h, rename.c, m4/c-bs-a.m4,
+ m4/jm-glibc-io.m4, m4/prereq.m4: Remove.
+ * m4/backupfile.m4, m4/dirname.m4, m4/dos.m4, m4/getopt.m4,
+ m4/memchr.m4, m4/onceonly.m4, m4/quote.m4, m4/quotearg.m4,
+ m4/rmdir.m4, m4/unlocked-io.m4, m4/xalloc.m4: New files.
+ * Makefile.in (LIBSRCS): Move error.c here from SRCS.
+ Remove rename.c.
+ (OBJS): Remove error.$(OBJEXT).
+ (HDRS): Remove exitfail.h, patchlevel.h.
+ (ACINCLUDE_INPUTS): Remove c-bs-a.m4, jm-glibc-io.m4, prereq.m4.
+ Add backupfile.m4, dirname.m4, dos.m4, getopt.m4, memchr.m4,
+ onceonly.m4, quote.m4, quotearg.m4, rmdir.m4, unlocked-io.m4,
+ xalloc.m4.
+ (patchlevel.h): Remove. All uses removed.
+ (argmatch.$(OBJEXT), error.$(OBJEXT), quotesys.$(OBJEXT)),
+ xmalloc.$(OBJEXT)): Depend on gettext.h.
+ (dirname.$(OBJEXT), quote.$(OBJEXT), strncasecmp.$(OBJEXT)): New rules.
+ (patch.$(OBJEXT), xmalloc.$(OBJEXT)): Remove exitfail.h.
+ (rename.$(OBJEXT)): Remove.
+ (version.$(OBJEXT)): Remove util.h.
+ (xmalloc.$(OBJEXT)): Add error.h.
+
+2002-11-23 Paul Eggert <eggert@twinsun.com>
+
+ * patch.c (main): Don't check for zero-sized file after 'ed'
+ when skipping patch. From Michael Fedrowitz.
+
+2002-06-03 Paul Eggert <eggert@twinsun.com>
+
+ * configure.ac (AC_OUTPUT): Use new form, with AC_CONFIG_FILES,
+ instead of obsolescent form. Patch from Art Haas.
+
+ * pch.c (intuit_diff_type): Do not warn about trailing white space
+ after Prereq: word. Bug reported by Mike Castle.
+
+2002-06-02 Paul Eggert <eggert@twinsun.com>
+
+ * NEWS, configure.ac (AC_INIT): Version 2.5.8 released.
+
+ * README: POSIX.2 -> POSIX.
+ * inp.c (report_revision): Don't modify 'revision', since
+ it gets freed later. Bug reported by Mike Castle.
+
+2002-05-30 Paul Eggert <eggert@twinsun.com>
+
+ * NEWS, configure.ac (AC_INIT): Version 2.5.7 released.
+
+ * Makefile.in (MISC): Remove README-alpha.
+ (patchlevel.h): Depend on configure, not configure.ac.
+
+ * INSTALL: Upgrade to Autoconf 2.53 version.
+
+2002-05-28 Paul Eggert <eggert@twinsun.com>
+
+ * patch.c (end_defined, apply_hunk): Output #endif without
+ the comment, as POSIX 1003.1-2001 requires.
+
+ * pch.c (there_is_another_patch): Flush stderr after perror.
+
+ * NEWS, configure.ac (AC_INIT): Version 2.5.6 released.
+
+ * strcasecmp.c, strncasecmp.c: New files, taken from fileutils.
+ * config.guess, config.sub: Remove.
+ * Makefile.in (LIBSRCS): Add strcasecmp.c, strncasecmp.c.
+ (MISC): Remove config.guess, config.sub.
+
+ The code already assumes C89 or better, so remove K&R stuff.
+ * common.h (volatile): Remove.
+ (GENERIC_OBJECT): Remove; all uses changed to 'void'.
+ (PARAMS): Remove; all uses changed to prototypes.
+ * configure.ac (AC_PROG_CC_STDC): Add.
+ * util.c (vararg_start): Remove. All uses changed to va_start.
+ Always include <stdarg.h>.
+
+ * configure.ac (AC_CANONICAL_HOST): Remove.
+ (AC_REPLACE_FUNCS): Add strncasecmp.
+ (AC_CHECK_DECLS): Add mktemp.
+
+ * patch.c (main): Remove useless prototype decl.
+ (mktemp): Don't declare if HAVE_DECL_MKTEMP || defined mktemp.
+ (make_temp): Now accepts char, not int.
+
+2002-05-26 Paul Eggert <eggert@twinsun.com>
+
+ * patch.c (not_defined): Prepend newline. All uses changed.
+ (apply_hunk): Fix bug: -D was outputting #ifdef when it should
+ have been outputting #ifndef. Bug report and partial fix by
+ Jason Short.
+
+ * pch.c (intuit_diff_type): When reading an ed diff, don't use
+ indent and trailing-CR-ness of "." line; instead, use that of the
+ command. Bug reported by Anthony Towns; partial fix by Michael
+ Fedrowitz.
+ (intuit_diff_type): If the index line exists, don't report a
+ missing header. Fix by Chip Salzenberg.
+
+2002-05-26 Alessandro Rubini <rubini@gnu.org>
+
+ * patch.c (locate_hunk): Fixed updating of last_offset.
+
+2002-05-25 Paul Eggert <eggert@twinsun.com>
+
+ * NEWS, README: Diffutils doc is up to date now.
+ Bug reporting address is now <bug-patch@gnu.org>.
+ * README: Describe '--disable-largefile'.
+
+ * NEWS-alpha, dirname.c, dirname.h, exitfail.c, exitfail.h,
+ quote.c, quote.h, unlocked-io.h: New files, taken from diffutils
+ and fileutils.
+
+ * argmatch.c: [STDC_HEADERS]: Include stdlib.h, for 'exit'.
+
+ * addext.c, argmatch.c, argmatch.h, backupfile.c, basename.c:
+ Update from diffutils and fileutils.
+
+ * ansi2knr.1, ansi2knr.c: Remove.
+
+ * common.h: HAVE_SETMODE && O_BINARY -> HAVE_SETMODE_DOS.
+ * patch.c (usage): Likewise.
+ * pch.c (open_patch_file): Likewise.
+
+ * configure.ac: Renamed from configure.in. Add copyright notice.
+ (AC_PREREQ): Bump to 2.53.
+ (AC_INIT): Use 2.5x style.
+ (AC_CONFIG_SRCDIR): Add.
+ (PACKAGE, VERSION): Remove.
+ (AC_C_PROTOTYPES): Use this instead of AM_C_PROTOTYPES.
+ (jm_CHECK_TYPE_STRUCT_UTIMBUF): Use this instead of jm_STRUCT_UTIMBUF.
+ (jm_PREREQ_ADDEXT, jm_PREREQ_DIRNAME, jm_PREREQ_ERROR,
+ jm_PREREQ_MEMCHR, jm_PREREQ_QUOTEARG): Add.
+ (AC_CHECK_DECLS): Add free, getenv, malloc.
+ (AC_CHECK_FUNCS): Remove setmode.
+ (AC_FUNC_SETMODE_DOS): Add.
+ (jm_CHECK_TYPE_STRUCT_DIRENT_D_INO): Use this instead of
+ jm_STRUCT_DIRENT_D_INO.
+
+ * Makefile.in (OBJEXT): New var.
+ (PACKAGE_NAME): Renamed from PACKAGE. All uses changed.
+ (PACKAGE_VERSION): Renamed from VERSION. All uses changed.
+ (U): Remove. All uses of "$U.o" changed to ".$(OBJEXT)".
+ (LIBSRCS): REmove getopt.c getopt1.c. Add mkdir.c, rmdir.c.
+ (SRCS): Add dirname.c, exitfail.c, getopt.c, getopt1.c, quote.c.
+ Remove mkdir.c.
+ (OBJS): Keep in sync with SRCS.
+ (HDRS): Remove basename.h.
+ Add dirname.h, exitfail.h, quote.h, unlocked-io.h.
+ (MISC, configure, config.hin, patchlevel.h):
+ configure.ac renamed from configure.in.
+ (MISC): Add README-alpha. Remove ansi2knr.1, ansi2knr.c.
+ (.c.$(OBJEXT)): Renamed from .c.o.
+ (ACINCLUDE_INPUTS): Add c-bs-a.m4, error.m4, jm-glibc-io.m4,
+ mbstate_t.m4, mkdir.m4, mbrtowc.m4, prereq.m4, setmode.m4.
+ Remove ccstdc.m4, inttypes_h.m4, largefile.m4, protos.m4.
+ (mostlyclean): Don't clean ansi2knr.
+ (ansi2knr.o, ansi2knr): Remove.
+ Redo dependencies.
+
+ * patch.c: Include <exitfail.h>.
+ (main): Initialize exit_failure.
+
+ * patch.man: Update copyright notice.
+
+ * pch.c, util.c: Include <dirname.h>, not <basename.h>.
+
+ * version.c (copyright_string): Update copyright notice.
+
+2002-02-17 Paul Eggert <eggert@twinsun.com>
+
+ * partime.c (parse_pattern_letter): Don't overrun buffer if it
+ contains only alphanumerics. Bug reported by Winni
+ <Winni470@gmx.net>.
+
+2001-07-28 Paul Eggert <eggert@sic.twinsun.com>
+
+ * util.c (fetchname), NEWS:
+ Allow file names with internal spaces, so long as they
+ don't contain tabs.
+
+ * pch.c (intuit_diff_type): Do not allow Prereq with multiple words.
+
+ * configure.in (AC_PREREQ): Bump to 2.50.
+ (AC_CHECK_FUNCS): Remove fseeko.
+ (AC_FUNC_FSEEKO): Add.
+ * Makefile.in (ACINCLUDE_INPUTS):
+ Remove largefile.m4; no longer needed with Autoconf 2.50.
+
+2001-02-07 "Tony E. Bennett" <tbennett@nvidia.com>
+
+ * util.c (PERFORCE_CO): New var.
+ (version_controller): Support Perforce.
+ * patch.man: Document this.
+
+2000-06-30 Paul Eggert <eggert@sic.twinsun.com>
+
+ * patch.man: Ignore comment lines.
+
+ * NEWS, pch.c: Ignore lines beginning with "#".
+
+1999-10-24 Paul Eggert <eggert@twinsun.com>
+
+ * pch.c (another_hunk): Report a fatal error if a regular
+ context hunk's pattern has a different number of unchanged
+ lines than the replacement.
+
+1999-10-18 Paul Eggert <eggert@twinsun.com>
+
+ * patch.c (main): If we skipped an ed patch, exit with nonzero status.
+
+1999-10-17 Paul Eggert <eggert@twinsun.com>
+
+ * patch.c (main): Apply do_ed_script even if dry_run, because
+ we need to make progress on the patch file.
+ * pch.c (do_ed_script): If skip_rest_of_patch is nonzero,
+ gobble up the patch without any other side effect.
+
+1999-10-12 Paul Eggert <eggert@twinsun.com>
+
+ * NEWS, README: New bug reporting address.
+ * NEWS: Report change in 2.5.4 that we forgot to document.
+ * README: Document `configure --disable-largefile'.
+
+ * basename.c, COPYING, getopt.c, getopt.h, getopt1.c, m4/largefile.m4:
+ Update to latest version.
+ * Makefile.in (basename$U.o): Depend on basename.h.
+ (config.hin): Depend on $(srcdir)/aclocal.m4.
+
+ * ansi2knr.c, maketime.c, mkinstalldirs, partime.c: Fix $Id.
+
+ FreeBSD has an unrelated setmode function; work around this.
+ * common.h (binary_transput): Don't declare unless O_BINARY.
+ * patch.c (option_help, get_some_switches):
+ Don't use setmode unless O_BINARY.
+ * pch.c (open_patch_file): Don't invoke setmode unless O_BINARY.
+
+ Fix incompatiblities with error.c.
+ * common.h (program_name): Now XTERN char *, for compatibility
+ with error.c. All uses changed.
+ (PROGRAM_NAME): New macro.
+ (PARAMS): Use ANSI C version only if defined PROTOTYPES
+ || (defined __STDC__ && __STDC__), for compatibilty with error.c.
+ * util.c (vararg_start): Likewise.
+ * patch.c (program_name): Remove.
+ (main): Initialize program_name.
+ * version.c (version): Print PROGRAM_NAME, not program_name.
+
+ Accommodate mingw32 port, which has one-argument mkdir (yuck!)
+ and no geteuid.
+ * m4/mkdir.m4: New file.
+ * Makefile.in (ACINCLUDE_INPUTS): Add $(M4DIR)/mkdir.m4.
+ * configure.in (AC_CHECK_FUNCS): Add geteuid, getuid.
+ (PATCH_FUNC_MKDIR_TAKES_ONE_ARG): Add.
+ * common.h (mkdir): Define if mkdir takes one arg.
+ (geteuid): New macro, if not already defined.
+
+1999-10-11 Christopher R. Gabriel <cgabriel@tin.it>
+
+ * patch.c (option_help): Updated bug report address
+ * configure.in (VERSION): Version 2.5.5 released.
+
+1999-09-01 Paul Eggert <eggert@twinsun.com>
+
+ * patch.c (main): Default simple_backup_suffix to ".orig".
+
+1999-10-08 Paul Eggert <eggert@twinsun.com>
+
+ * patch.man: Make it clear that `patch -o F' should not be
+ used if F is one of the files to be patched.
+
+1999-08-30 Paul Eggert <eggert@twinsun.com>
+
+ Version 2.5.4 fixes a few minor bugs, converts C sources to
+ ANSI prototypes, and modernizes auxiliary sources and autoconf
+ scripts.
+
+ * configure.in (VERSION): Version 2.5.4 released.
+ (AC_CANONICAL_HOST): Add.
+ (AC_SYS_LARGEFILE): Add, replacing inline code.
+ (AC_EXEEXT): Add.
+ (jm_AC_HEADER_INTTYPES_H): Add, replacing inline code.
+ (AC_TYPE_PID_T): Add.
+ (jm_STRUCT_UTIMBUF): Add, replacing inline code.
+ (HAVE_MEMCHR): Remove obsolescent test; nobody uses NetBSD 1.0 now.
+ (getopt_long): Append $U to object file basenames.
+ (AC_CHECK_FUNCS): Add fseeko, setmode. Remove mkdir.
+ (AC_REPLACE_FUNCS): Add mkdir, rmdir.
+ (jm_STRUCT_DIRENT_D_INO): Add, replacing inline code.
+
+ * Makefile.in (EXEEXT): New macro.
+ (mandir): New macro.
+ (man1dir): Define in terms of mandir.
+ (SRCS): Add mkdir.c, rmdir.c.
+ (OBJS): Change .o to $U.o for addext, argmatch, backupfile, basename,
+ error, inp, patch ,,pch, quotearg, util, version, xmalloc.
+ (HDRS): Add basename.h, patchlevel.h.
+ (MISC): Add ansi2knr.1, config.guess, config.sub.
+ (MISC, config.hin): Remove acconfig.h; no longer needed.
+ (DISTFILES_M4): New macro.
+ (all): patch -> patch$(EXEEXT).
+ (patch$(EXEEXT)): Renamed from patch. All uses changed.
+ (uninstall): Remove manual page.
+ (configure): Depend on aclocal.m4.
+ (M4DIR, ACINCLUDE_INPUTS): New macros.
+ ($(srcdir)/aclocal.m4): New rule.
+ (patchlevel.h): Depend on configure.in, not Makefile,
+ since we now distribute it.
+ (distclean): Don't remove patchlevel.h.
+ (dist): Distribute $(DISTFILES_M4).
+ (addext_.c argmatch_.c backupfile_.c basename_.c error_.c
+ getopt_.c getopt1_.c inp_.c malloc_.c mkdir_.c patch_.c pch_.c
+ rename_.c util_.c version_.c xmalloc_.c): Depend on ansi2knr.
+ Update dependencies to match sources.
+
+ * common.h (_LARGEFILE_SOURCE): Remove; now autoconfigured.
+ (file_offset): Depend on HAVE_FSEEKO, not _LFS_LARGEFILE.
+
+ * patch.c (version_control_context): New variable.
+ Convert to ANSI prototypes.
+ Adjust to new argmatch calling convention.
+ Similarly for get_version.
+ Complain about creating an existing file only if
+ pch_says_nonexistent returns 2 (not merely nonzero).
+ Similarly for time mismatch check.
+ (get_some_switches): Adjust to new get_version calling convention.
+ Similarly for argmatch.
+
+ * pch.c (<basename.h>): Include.
+ (intuit_diff_type): Improve quality of test for empty file.
+ (another_hunk): Don't assume off_t is no longer than long.
+
+ * util.h (backup_type): New decl.
+ * util.c (<basename.h>): Include.
+ (move_file): Adjust to new find_backup_file_name convention.
+ (doprogram, mkdir, rmdir): Remove; now in separate files.
+ (fetchame): Match "/dev/null", not NULL_DEVICE.
+ Ignore names that don't have enough slashes to strip off.
+
+ * version.c: Update copyright notice.
+
+1998-03-20 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.5.3.
+ * quotearg.h (quotearg_quoting_options):
+ Remove; it ran afoul of the Borland C compiler.
+ Its address is now represented by the null pointer.
+ * quotearg.c (default_quoting_options):
+ Renamed from quotearg_quoting_options,
+ and now static instead of extern.
+ (clone_quoting_options, get_quoting_style, set_quoting_style,
+ set_char_quoting, quotearg_buffer):
+ Use default_quoting_options when passed a null pointer.
+ * patch.c (main, get_some_switches):
+ Pass a null pointer instead of address of quotearg_quoting_options.
+
+1998-03-17 Paul Eggert <eggert@twinsun.com>
+
+ * patch.c (option_help): Update bug reporting address to gnu.org.
+ * patch.man: Fix copyright and bug reporting address.
+
+1998-03-16 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.5.2.
+ (AC_CHECK_FUNCS): Add strerror.
+ (jm_FUNC_MALLOC, jm_FUNC_REALLOC): Add.
+ (AM_C_PROTOTYPES): Add.
+
+ * NEWS, patch.c (longopts, get_some_switches), patch.man:
+ Add --quoting-style, --posix options.
+
+ * Makefile.in (LIBSRCS): Add malloc.c, realloc.c.
+ (SRCS): Add error.c, quotesys.c, xmalloc.c.
+ (OBJS): Likewise.
+ (HDRS): Add error.h, quotesys.h, xalloc.h.
+ (MISC): Add AUTHORS, aclocal.m4, ansi2knr.c.
+ (clean): Use mostlyclean rule.
+ (argmatch.o, inp.o, patch.o, pch.o): Now also depends on quotearg.h.
+ (inp.o, patch.o, util.o): Now also depends on xalloc.h.
+ (error.o, quotearg.o, quotesys.o, xmalloc.o,
+ ansi2knr.o, ansi2knr, quotearg_.c, .c_.c): New rules.
+ (U): New macro.
+ (OBJS, quotearg$U.o): Rename quotearg.o to quotearg$U.o.
+ (mostlyclean): Remove ansi2knr, *_.c.
+ (.SUFFIXES): Add _.c.
+
+ * acconfig.h (PROTOTYPES): New undef.
+
+ * acconfig.h, configure.in (HAVE_INTTYPES_H, malloc, realloc):
+ New macros.
+
+ * aclocal.m4, error.c, error.h, malloc.c,
+ quotearg.h, quotearg.c, realloc.c, xalloc.h, xmalloc.c: New files.
+
+ * argmatch.c: Include <sys/types.h> before <argmatch.h>.
+ Include <quotearg.h>.
+
+ * argmatch.c (invalid_arg),
+ inp.c (scan_input, report_revision, too_many_lines, get_input_file,
+ plan_a),
+ patch.c (main, get_some_switches, numeric_string),
+ pch.c (open_patch_file, intuit_diff_type, do_ed_script):
+ util.c (move_file, create_file, copy_file, version_get, removedirs):
+ Quote output operands properly.
+
+ * common.h: Include <inttypes.h> if available.
+ (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM,
+ CHAR_MAX, INT_MAX, LONG_MIN, SIZE_MAX, O_EXCL): New macros.
+ (TMPINNAME_needs_removal, TMPOUTNAME_needs_removal,
+ TMPPATNAME_needs_removal): New variables.
+ (xmalloc): Remove decl; now in xalloc.h.
+
+ * inp.c: Include <quotearg.h>, <xalloc.h>.
+
+ * inp.c (get_input_file),
+ pch.c (intuit_diff_type),
+ util.c (version_controller):
+ Don't do diff operation if diffbuf is null; used by ClearCase support.
+
+ * inp.c (plan_b),
+ patch.c (init_reject),
+ pch.c (open_patch_file, do_ed_script):
+ Create temporary file with O_EXCL to avoid races.
+
+ * patch.c: Include <quotearg.h>, <xalloc.h>.
+ (create_output_file, init_output): New open_flags arg.
+ All callers changed.
+ (init_reject): No longer takes filename arg. All callers changed.
+ (remove_if_needed): New function.
+ (cleanup): Use it to remove temporary files only if needed.
+ (TMPREJNAME_needs_removal): New var.
+ (main): Set xalloc_fail_func to memory_fatal; needed for xalloc.
+ Initialize quoting style from QUOTING_STYLE.
+ (longopts, get_some_switches): Offset longarg options by CHAR_MAX,
+ not 128; this is needed for EBCDIC ports.
+
+ * patch.c (main, locate_hunk, abort_hunk, spew_output),
+ pch.c (there_is_another_patch, intuit_diff_type, malformed,
+ another_hunk):
+ The LINENUM type now might be longer than long,
+ so print and read line numbers more carefully.
+
+ * patch.c (main),
+ pch.c (there_is_another_patch):
+ util.c (fetchname):
+ strippath now defaults to -1, so that we can distinguish unset
+ value from largest possible.
+
+ * patch.man: Clarify how file name is chosen from candidates.
+
+ * pch.c: Include <quotearg.h>.
+ (p_strip_trailing_cr): New variable.
+ (scan_linenum): New function.
+ (pget_line, re_patch, there_is_another_patch, intuit_diff_type,
+ get_line): Strip trailing CRs from context diffs that need this.
+ (best_name): Use SIZE_MAX instead of (size_t) -1 for max size_t.
+
+ * quotesys.c, quotearg.h: Renamed from quotearg.c and quotearg.h.
+ All uses changed.
+ * quotesys.h (__QUOTESYS_P): Renamed from __QUOTEARG_P.
+
+ * util.c: Include <quotearg.h>, <xalloc.h>.
+ (raise): Don't define if already defined.
+ (move_file): New arg from_needs_removal. All callers changed.
+ (copy_file): New arg to_flags. All callers changed.
+ (CLEARTOOL_CO): New constant.
+ (version_controller): Add ClearCase support.
+ (format_linenum): New function.
+ (fetchname): Allow any POSIX.1 time zone spec, which means
+ any local time offset in the range -25:00 < offset < +26:00.
+ Ignore the name if it doesn't have enough slashes to strip off.
+ (xmalloc): Remove; now in xmalloc.c.
+
+ * util.h (LINENUM_LENGTH_BOUND): New macro.
+ (format_linenum): New decl.
+
+ * version.c (copyright_string): Update years of copyrights.
+
+1997-09-03 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.5.1.
+ * inp.c (re_input): Don't free buffers twice when input is garbled.
+ * patch.c (main): If skipping patch and Plan A fails, don't
+ bother trying Plan B.
+
+1997-08-31 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Version 2.5 released.
+
+1997-07-21 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.4.4.
+ * pch.c (there_is_another_patch), NEWS: Report an error if the patch
+ input contains garbage but no patches.
+
+ * pch.c (open_patch_file):
+ Check for patch file too long (i.e., its size
+ doesn't fit in a `long', and LFS isn't available).
+
+ * inp.c (plan_a):
+ Cast malloc return value, in case malloc returns char *.
+
+1997-07-16 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.4.3.
+
+ * NEWS, patch.man, pch.c (intuit_diff_type, get_line, pget_line):
+ Now demangles RFC 934 encapsulation.
+ * pch.c (p_rfc934_nesting): New var.
+
+ * pch.c (intuit_diff_type): Don't bother to check file names carefully
+ if we're going to return NO_DIFF.
+
+ * inp.c (plan_a): Count the number of lines before allocating
+ pointer-to-line buffer; this reduces memory requirements
+ considerably (roughly by a factor of 5 on 32-bit hosts).
+ Decrease `size' only when read unexpectedly reports EOF.
+ (i_buffer): New var.
+ (too_many_lines): New fn.
+ (re_input): Free i_buffer if using plan A.
+ Free buffers unconditionally; they can't be zero.
+
+ * inp.c (plan_a, plan_b): Check for overflow of line counter.
+
+ * pch.c (malformed), util.h (memory_fatal, read_fatal, write_fatal):
+ Declare as noreturn.
+
+1997-07-10 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.4.2.
+
+ * util.c (ok_to_reverse), NEWS: The default answer is now `n';
+ this is better for Emacs.
+
+ * Makefile.in (dist): Use cp -p, not ln;
+ some hosts do the wrong thing with ln if the source is a symbolic link.
+
+ * patch.man: Fix typo: -y -> -Y.
+
+1997-07-05 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.4.1.
+
+ * patch.c: (main, get_some_switches), NEWS, patch.man:
+ Version control is now independent of whether backups are made.
+ * patch.c (option_help): Put version control options together.
+ (get_some_switches): With CVS 1.9 hack, treat -b foo like -b -z foo,
+ not just -z foo. This change is needed due to recent change in -z.
+ * backupfile.c (find_backup_file_name):
+ backup_type == none causes undefined behavior;
+ this undoes the previous change to this file.
+
+ * patch.c (locate_hunk): Fix bug when locating context diff hunks
+ near end of file with nonzero fuzz.
+
+ * util.c (move_file): Don't assume that ENOENT is reported when both
+ ENOENT and EXDEV apply; this isn't true with DJGPP, and
+ Posix doesn't require it.
+
+ * pch.c (there_is_another_patch):
+ Suggest -p when we can't intuit a file.
+
+1997-06-19 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Version 2.4 released.
+ * NEWS: Patch is now verbose when patches do not match exactly.
+
+1997-06-17 Paul Eggert <eggert@twinsun.com>
+
+ * pc/djgpp/configure.sed (config.h): Remove redundant $(srcdir).
+
+ * configure.in (VERSION): Bump to 2.3.9.
+ * patch.c (main): By default, warn about hunks that succeed
+ with nonzero offset.
+ * patch.man: Add LC_ALL=C advice for making patches.
+ * pc/djgpp/configure.sed (config.h): Fix paths to dependent files.
+
+1997-06-17 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.8.
+
+ * pch.c (open_patch_file): Test stdin for fseekability.
+ (intuit_diff_type): Missing context diff headers are now warnings,
+ not errors; some people use patches with them (e.g. when retrying
+ rejects).
+
+ * patch.c (struct outstate):
+ New type, collecting together some output state vars.
+ (apply_hunk, copy_till, spew_output, init_output): Use it.
+ Keep track of whether some output has been generated.
+ (backup_if_mismatch): New var.
+ (ofp): Remove, in favor of local struct outstate vars.
+ (main): Use struct outstate. Initialize backup_if_mismatch to
+ be the inverse of posixly_correct. Keep track of whether mismatches
+ occur, and use this to implement backup_if_mismatch.
+ Report files that are not empty after patching, but should be.
+ (longopts, option_help, get_some_switches): New options
+ --backup-if-mismatch, --no-backup-if-mismatch.
+ (get_some_switches): -B, -Y, -z no longer set backup_type.
+ * backupfile.c (find_backup_file_name):
+ Treat backup_type == none like simple.
+
+ * Makefile.in (CONFIG_HDRS):
+ Remove var; no longer needed by djgpp port.
+ (DISTFILES_PC_DJGPP): Rename pc/djgpp/config.sed to
+ pc/djgpp/configure.sed; remove pc/djgpp/config.h in favor of
+ new file that edits it, called pc/djgpp/config.sed.
+ * pc/djgpp/configure.bat: Rename config.sed to configure.sed.
+ * pc/djgpp/configure.sed (CONFIG_HDRS): Remove.
+ (config.h): Add rule to build this from config.hin and
+ pc/djgpp/config.sed.
+ * pc/djgpp/config.sed:
+ Convert from .h file to .sed script that generates .h file.
+
+ * NEWS: Describe --backup-if-mismatch, --no-backup-if-mismatch.
+ * patch.man:
+ Describe new options --backup-if-mismatch, --no-backup-if-mismatch
+ and their ramifications. Use unreadable backup to represent
+ nonexistent file.
+
+1997-06-12 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.7.
+ (AC_CHECK_FUNCS): Add `raise'.
+
+ * Makefile.in (inp.o): No longer depends on quotearg.h.
+
+ * common.h (outfile): New decl (was private var named `output').
+ (invc): New decl.
+ (GENERIC_OBJECT): Renamed from VOID.
+ (NULL_DEVICE, TTY_DEVICE): New macros.
+
+ * patch.c (output): Remove; renamed to `outfile' and moved to common.h.
+ (main): `failed' is count, not boolean.
+ Say "Skipping patch." when deciding to skip patch.
+ (get_some_switches): Set invc when setting inname.
+
+ * inp.c: Do not include <quotearg.h>.
+ (SCCSPREFIX, GET, GET_LOCKED, SCCSDIFF1, SCCSDIFF2, SCCSDIFF3,
+ RCSSUFFIX, CHECKOUT, CHECKOUT_LOCKED, RCSDIFF1, RCSDIFF2):
+ Move to util.c.
+ (get_input_file): Invoke new functions version_controller and
+ version_get to simplify this code.
+ (plan_b): "/dev/tty" -> NULL_DEVICE
+
+ * pch.h (pch_timestamp): New decl.
+ * pch.c (p_timestamp): New var; takes over from global timestamp array.
+ (pch_timestamp): New function to export p_timestamp.
+ (there_is_another_patch): Use blander wording when you can't intuit
+ the file name.
+ Say "Skipping patch." when deciding to skip patch.
+ (intuit_diff_type): Look for version-controlled but nonexistent files
+ when intuiting file names; set invc accordingly.
+ Ignore Index: line if either old or new line is present, and if
+ POSIXLY_CORRECT is not set.
+ (do_ed_script): Flush stdout before invoking popen, since it may
+ send output to stdout.
+
+ * util.h (version_controller, version_get): New decls.
+ * util.c: Include <quotearg.h> earlier.
+ (raise): New macro, if ! HAVE_RAISE.
+ (move_file): Create empty unreadable file when backing up a nonexistent
+ file.
+ (DEV_NULL): New constant.
+ (SCCSPREFIX, GET. GET_LOCKED, SCCSDIFF1, SCCSDIFF2,
+ RCSSUFFIX, CHECKOUT, CHECKOUT_LOCKED, RCSDIFF1): Moved here from inp.c.
+ (version_controller, version_get): New functions.
+ (ask): Look only at /dev/tty for answers; and when standard output is
+ not a terminal and ! posixly_correct, don't even look there.
+ Remove unnecessary fflushes of stdout.
+ (ok_to_reverse): Say "Skipping patch." when deciding to skip patch..
+ (sigs): SIGPIPE might not be defined.
+ (exit_with_signal): Use `raise' instead of `kill'.
+ (systemic): fflush stdout before invoking subsidiary command.
+
+ * patch.man: Document recent changes.
+ Add "COMPATIBILITY ISSUES" section.
+
+ * NEWS: New COMPATIBILITY ISSUES for man page.
+ Changed verbosity when fuzz is found.
+ File name intuition is changed, again.
+ Backups are made unreadable when the file did not exist.
+
+ * pc/djgpp/config.h (HAVE_STRUCT_UTIMBUF): Define.
+ (HAVE_RAISE): New macro.
+ (HAVE_UTIME_H): Define.
+ (TZ_is_unset): Do not define; it's not a serious problem with `patch'
+ to have TZ be unset in DOS.
+
+1997-06-08 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.6.
+ (AC_CHECK_HEADERS): Add utime.h.
+ * acconfig.h, configure.in, pc/djgpp/config.h (HAVE_STRUCT_UTIMBUF):
+ New macro.
+ * pc/djgpp/config.h (HAVE_UTIME_H, TZ_is_unset): New macros.
+
+ * NEWS, patch.man: Describe new -Z, -T options, new numeric
+ option for -G, retired -G, and more verbose default behavior
+ with fuzz.
+
+ * pch.c (intuit_diff_type): Record times reported for files in headers.
+ Remove head_says_nonexistent[x], since it's now equivalent to
+ !timestamp[x].
+ * util.h (fetchname): Change argument head_says_nonexistent to
+ timestamp.
+ * util.c: #include <partime.h> for TM_LOCAL_ZONE.
+ Don't include <time.h> since common.h now includes it.
+ (ok_to_reverse): noreverse and batch cases now output regardless of
+ verbosity.
+ (fetchname): Change argument head_says_nonexistent to pstamp, and
+ store header timestamp into *pstamp.
+ If -T or -Z option is given, match time stamps more precisely.
+ (ask): Remove unnecessary close of ttyfd.
+ When there is no terminal at all, output a newline to make the
+ output look nicer. After reporting EOF, flush stdout;
+ when an input error, report the error type.
+
+ * inp.c (get_input_file):
+ Ask user whether to get file if patch_get is negative.
+
+ * Makefile.in (clean): Don't clean */*.o; clean core* and *core.
+
+1997-06-04 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.5.
+
+ * util.c (ok_to_reverse):
+ Be less chatty if verbosity is SILENT and we don't
+ have to ask the user. If force is nonzero, apply the patch anyway.
+
+ * pch.c (there_is_another_patch):
+ Before skipping rest of patch, skip to
+ the patch start, so that another_hunk can skip it properly.
+ (intuit_diff_type): Slight wording change for missing headers, to
+ regularize with other diagnostics. Fix off-by-one error when setting
+ p_input_line when scanning the first hunk to check for deleted files.
+
+1997-06-03 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.4.
+
+ * NEWS: Now matches more generously against nonexistent or empty files.
+
+ * pch.c (there_is_another_patch): Move warning about not being
+ able to intuit file names here from skip_to.
+ (intuit_diff_type): Fatal error if we find a headless unified
+ or context diff.
+
+ * util.c (ask): Null-terminate buffer properly even if it grew.
+ (fetchname): No need to test for null first argument.
+
+1997-06-02 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.3.
+ * pch.c (p_says_nonexistent, pch_says_nonexistent): Is now 1 for empty,
+ 2 for nonexistent.
+ (intuit_diff_type): Set p_says_nonexistent according to new meaning.
+ Treat empty files like nonexistent files when reversing.
+ (skip_to): Output better diagnostic when we can't intuit a file name.
+ * patch.c (main):
+ Count bytes, not lines, when testing whether a file is empty,
+ since it may contain only non-newline chars.
+ pch_says_nonexistent now returns 2 for nonexistent files.
+
+1997-06-01 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.2.
+ * pch.c (open_patch_file):
+ Fix bug when computing size of patch read from a pipe.
+
+1997-05-30 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.3.1.
+
+ * Makefile.in (transform, patch_name): New vars,
+ for proper implementation of AC_ARG_PROGRAM.
+ (install, uninstall): Use them.
+ (install-strip): New rule.
+ * pc/djgpp/config.sed (program_transform_name): Set to empty.
+
+1997-05-30 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION), NEWS: Version 2.3 released.
+ * patch.man: Fix two font typos.
+ * util.c (doprogram): Fix misspelled decl.
+
+1997-05-26 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.2.93.
+
+ * pch.c (open_patch_file):
+ Fatal error if binary_transput and stdin is a tty.
+
+ * pc/djgpp/config.sed (chdirsaf.c):
+ Use sed instead of cp, since cp might not be installed.
+ * pc/djgpp/configure.bat:
+ Prepend %srcdir% to pathname of config.sed, for crosscompiles.
+
+1997-05-25 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.2.92.
+ (D_INO_IN_DIRENT): New macro.
+ * pc/djgpp/config.h, acconfig.h (D_INO_IN_DIRENT): New macro.
+ * backupfile.c (REAL_DIR_ENTRY):
+ Depend on D_INO_IN_DIRENT, not _POSIX_VERSION.
+
+ * addext.c (addext): Adjust slen when adjusting s for DOS 8.3 limit.
+ Do not use xxx.h -> xxxh~ hack.
+
+ * util.c: (move_file): Avoid makedirs test when possible even
+ if FILESYSTEM_PREFIX_LEN (p) is nonzero. Don't play
+ case-changing tricks to come up with backup file name; it's
+ not portable to case-insensitive file systems.
+ * common.h (ISLOWER): Remove.
+
+ * inp.c (scan_input): Don't use Plan A if (debug & 16).
+
+ * patch.c (shortopts): Add -g, -G.
+ (longopts): --help now maps to 132, not 'h', to avoid confusion.
+ (get_some_switches): Likewise.
+ Don't invoke setmode on input if --binary; wait until needed.
+ Don't ever invoke setmode on stdout.
+ * pch.c (open_patch_file): Setmode stdin to binary if binary_transput.
+
+ * patch.man: Fix documentation of backup file name to match behavior.
+ Add advice for ordering of patches of derived files.
+ Add /dev/tty to list of files used.
+ * README: Adjust instructions for building on DOS.
+ * pc/djgpp/README: Remove tentative wording.
+ * NEWS: The DOS port is now tested.
+ Backup file names are no longer computed by switching case.
+
+ * pc/chdirsaf.c (ERANGE): Include <errno.h> to define it.
+ (restore_wd): chdir unconditionally.
+ (chdir_safer): Invoke atexit successfully at most once.
+ * pc/djgpp/config.sed: Use chdirsaf.o, not pc/chdirsaf.o.
+ Replace CONFIG_HDRS, don't append.
+ Use $(srcdir) in CONFIG_STATUS.
+ Don't apply $(SHELL) to $(CONFIG_STATUS).
+ Append rules for chdirsaf.o, chdirsaf.c; clean chdirsaf.c at the end.
+ * pc/djgpp/configure.bat: Append CR to each line; DOS needs this.
+ Don't use | as sed s delimiter; DOS can't handle it.
+
+1997-05-21 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.2.91.
+
+ * pch.c (another_hunk):
+ Fix bug with computing size of prefix and suffix context
+ with ordinary context diffs. Report malformed patch if a unified diff
+ has nothing but context.
+
+ * inp.c (get_input_file):
+ Use patch_get, not backup_type, to decide whether to
+ get from RCS or SCCS. Use the word `get' in diagnostics.
+ * patch.c (main): Initialize patch_get from PATCH_GET.
+ Omit DEFAULT_VERSION_CONTROL hook; it just leads to nonstandarization.
+ (longopts, option_help, get_some_switches): Add support for -g, -G.
+ (option_help): Add bug report address.
+ * common.h (patch_get): New decl.
+ * patch.man: Add -g and -G options; use `get' instead of `check out'.
+ Add PATCH_GET. Recommend -Naur instead of -raNU2 for diff.
+ * NEWS: Describe -g, -G, PATCH_GET.
+
+ * version.c (copyright_string): Use only most recent copyright year,
+ as per GNU standards.
+
+ * Makefile.in (DISTFILES_PC): Remove pc/quotearg.c.
+ * pc/djgpp/config.sed: Remove unnecessary hooks for quotearg and SHELL.
+
+1997-05-18 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Increase to 2.2.9.
+ (AC_TYPE_MODE_T): Add.
+
+ * pch.h (another_hunk): New parameter REV.
+ * pch.c (hunkmax): Now of type LINENUM.
+ (malformed): Add decl.
+ (there_is_another_patch): Skip inname-detection if skip_rest_of_patch.
+ (intuit_diff_type): To determine whether file appears to have been
+ deleted, look at replacement, not pattern.
+ If there is a mismatch between existence of file and whether the
+ patch claims to change whether the file exists, ask whether to
+ reverse the patch.
+ (another_hunk): New parameter REV specifying whether to reverse the
+ hunk. All callers changed.
+ (do_ed_script): Add assertion to ensure input file exists.
+
+ * util.h (create_file): New function.
+ (copy_file): Now takes mode, not struct stat.
+ (makedirs): No longer exported.
+ (move_file): Now takes mode, not struct stat.
+ * util.c (makedirs): No longer exported.
+ (move_file): Accept mode of destination, not struct stat.
+ All callers changed.
+ Quote file names in diagnostics.
+ Create parent dir of destination if necessary.
+ Don't use ENOTDIR.
+ Don't unlink source; it will be unlinked later.
+ Unlink destination if FROM is zero.
+ (create_file): New function.
+ (copy_file): Accept mode of destination, not struct stat.
+ All callers changed.
+ Use create_file to create file.
+ (ok_to_reverse): Moved here from patch.c. Now accepts format and args;
+ all callers changed.
+ (mkdir): 2nd arg is now mode_t, for better compatibility.
+ (replace_slashes): Ignore slashes at the end of the filename.
+
+ * common.h (noreverse): New decl.
+ (ok_to_reverse): Remove decl.
+
+ * patch.c (noreverse): Now extern.
+ (main): New environment var PATCH_VERSION_CONTROL overrides VERSION_CONTROL.
+ Don't assert(hunk) if we're skipping the patch; we may not have any hunks.
+ When removing a file, back it up if backups are desired.
+ Don't chmod output file if input file did not exist.
+ chmod rej file to input file's mode minus executable bits.
+ (locate_hunk): Go back to old way of a single fuzz parameter, but
+ handle it more precisely: context diffs with partial contexts
+ can only match file ends, since the partial context can occur
+ only at the start or end of file.
+ All callers changed.
+ (create_output_file): Use create_file to create files.
+ (ok_to_reverse): Move to util.c.
+
+ * inp.c (scan_input, get_input_file): Quote file names in diagnostics.
+ (get_input_file): Set inerrno if it's not already set.
+ Don't create file; it's now the caller's responsibility.
+ (plan_b): Use /dev/null if input size is zero, since it might not exist.
+ Use create_file to create temporary file.
+
+ * NEWS: Add PATCH_VERSION_CONTROL; DOS port is untested.
+
+ * pc/djgpp/config.h: Add comment for mode_t.
+
+ * pc/djgpp/README: Note that it's not tested.
+
+ * patch.man: PATCH_VERSION_CONTROL overrides VERSION_CONTROL.
+
+1997-05-15 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in: Add AC_PREREQ(2.12).
+ (VERSION): Bump to 2.2.8.
+ (ed_PROGRAM): Rename from ED_PROGRAM.
+
+ * pch.c (prefix_components): Support DOS file names better.
+ Fix typo that caused fn to almost always yield 0.
+
+ * util.c (<time.h>, <maketime.h>): Include.
+ (move_file, copy_file): Add support for DOS filenames.
+ Preserve mode of input files when creating temp files.
+ Add binary file support.
+ (doprogram, rmdir): New functions.
+ (mkdir): Use doprogram.
+ (replace_slashes): Add support for DOS filenames.
+ (removedirs): New function.
+ (init_time)): New function.
+ (initial_time): New var.
+ (fetchname): Add support for deleted files, DOS filenames.
+
+ * basename.c (FILESYSTEM_PREFIX_LEN, ISSLASH):
+ New macros, for DOS port.
+ (base_name): Use them.
+
+ * addext.c (HAVE_DOS_FILE_NAMES): New macro.
+ <limits.h>: Include if HAVE_LIMITS_H.
+ (addext): Handle hosts with DOS file name limits.
+
+ * common.h (LONG_MIN): New macro.
+ (FILESYSTEM_PREFIX_LEN, ISSLASH): New macros, for DOS port.
+ (ok_to_create_file): Remove.
+ (reverse): Now int.
+ (ok_to_reverse): New function decl.
+ (O_WRONLY, _O_BINARY, O_BINARY, O_CREAT, O_TRUNC): New macros.
+ (binary_transput): New var decl.
+
+ * Makefile.in (ed_PROGRAM): Renamed from ED_PROGRAM.
+ (CONFIG_HDRS, CONFIG_STATUS): New vars.
+ (SRCS): Add maketime.c, partime.c.
+ (OBJS): Likewise.
+ (HDRS): Add maketime.h, partime.h.
+ (DISTFILES_PC, DISTFILES_PC_DJGPP): New vars.
+ (Makefile, config.status): Use CONFIG_STATUS, not config.status.
+ (clean): Remove */*.o.
+ (dist): Add pc and pc/djgpp subdirectories.
+ ($(OBJS)): Depend on $(CONFIG_HDRS) instead of config.h.
+ (maketime.o, partime.o): New rules.
+ (util.o): Depend on maketime.h.
+
+ * patch.c (main):
+ Call init_time. Add DEFAULT_VERSION_CONTROL hook for people who
+ prefer the old ways. Build temp file names before we might invoke cleanup.
+ Add support for deleted files and clean up the patch-swapping code a bit.
+ Delete empty ancestors of deleted files.
+ When creating temporaries, use file modes of original files.
+ (longopts, get_some_switches): New option --binary.
+ (get_some_switches): Report non-errno errors with `fatal', not `pfatal'.
+ (create_output_file): New function, which preserves modes of original files
+ and supports binary transput.
+ (init_output, init_reject): Use it.
+ (ok_to_reverse): New function.
+ (TMPDIR): New macro.
+ (make_temp): Use $TMPDIR, $TMP, $TEMP, or TMPDIR, whichever comes first.
+
+ * pch.c (p_says_nonexistent): New var.
+ (open_patch_file): Add binary transput support.
+ Apply stat to file names retrieved from user.
+ Reject them if they don't exist.
+ (intuit_diff_type): Add support for deleting files.
+ Don't treat trivial directories any differently.
+ Avoid stating the same file twice in common case of context diffs.
+ (prefix_components): Don't treat trivial directories any differently.
+ Add support for DOS filenames.
+ (pch_says_nonexistent): New function.
+ (do_ed_script): Preserve mode of input files when creating temp files.
+ Add support for binary transput.
+
+ * pch.h (pch_says_nonexistent): New decl.
+
+ * util.h (replace_slashes): No longer exported.
+ (fetchname): Add support for deleted files.
+ (copy_file, move_file): Add support for preserving file modes.
+ (init_time, removedirs): New functions.
+
+ * argmatch.c: Converge with fileutils.
+
+ * backupfile.c: Converge with fileutils.
+ (find_backup_file_name): Treat .~N~ suffix just like any other suffix
+ when handling file names that are too long.
+
+ * inp.c:
+ In messages, put quotes around file names and spaces around "--".
+ (get_input_file): Allow files to be deleted. Do the expense of
+ makedirs only if we can't create the file.
+ (plan_a, plan_b): Add support for binary transput.
+
+ * pc/chdirsaf.c, pc/djgpp/README, pc/djgpp/config.h, pc/djgpp/config.sed, pc/djgpp/configure.bat, pc/quotearg.c:
+ New file.
+
+ * NEWS:
+ New methods for removing files; adjust file name intuition again.
+ Add description of MS-DOS and MS-Windows ports.
+
+ * patch.man:
+ Simplify file name intuition slightly (no distinction for trivial dirs).
+ Add --binary. Describe how files and directories are deleted.
+ Suggest diff -a. Include caveats about what context diffs cannot represent.
+
+1997-05-06 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Now 2.2.7.
+ (CPPFLAGS, LDFLAGS, LIBS): If the user has not set any of these vars,
+ prefer support for large files if available.
+
+ * common.h (_LARGEFILE_SOURCE): Define.
+ (file_offset): New typedef.
+ (file_seek, file_tell): New macros.
+
+ * patch.c (main):
+ Remove empty files by default unless POSIXLY_CORRECT is set.
+
+ * util.c, util.h (Fseek):
+ Use file_offset instead of long, for portability to large-file hosts.
+
+ * pch.c: (p_base, p_start, next_intuit_at, skip_to, open_patch_file,
+ intuit_diff_type, another_hunk, incomplete_line, do_ed_script):
+ Use file_offset instead of long, for portability to large-file hosts.
+ (prefix_components): Renamed from path_name_components; count only
+ nontrivial prefix components, and take a 2nd EXISTING arg.
+ (existing_prefix_components): Remove; subsumed by prefix_components.
+ (intuit_diff_type): When creating files, try for the creation of the
+ fewest directories.
+
+ * configure.in (VERSION): Now 2.2.6.
+
+ * pch.c (existing_prefix_components): New function.
+ (intuit_diff_type): When creating a file, use a name whose existing
+ directory prefix contains the most nontrivial path name components.
+ (best_name): Don't check for null 2nd arg.
+
+ * util.h (replace_slashes): New decl.
+
+ * util.c (replace_slashes): Now external.
+ (fetchname): Don't assume chars are nonnegative.
+
+ * patch.man:
+ When creating a file, use a name whose existing directory prefix
+ contains the most nontrivial path name components.
+ Add advice for creating patches and applying them.
+
+1997-05-06 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Now 2.2.6.
+
+ * pch.c (existing_prefix_components): New function.
+ (intuit_diff_type): When creating a file, use a name whose existing
+ directory prefix contains the most nontrivial path name components.
+ (best_name): Don't check for null 2nd arg.
+
+ * util.h (replace_slashes): New decl.
+ * util.c (replace_slashes): Now external.
+ (fetchname): Don't assume chars are nonnegative.
+
+ * patch.man: Describe above change to pch.c.
+ Add advice for creating patches and applying them.
+
+1997-05-05 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Update to 2.2.5.
+
+ * quotearg.h, quotearg.c: New files.
+ * Makefile.in (SRCS, OBJS, HDRS): Mention new files.
+ (inp.o, util.o): Now depends on quotearg.h.
+ (quotearg.o): New makefile rule.
+
+ * common.h (posixly_correct): New var.
+ * patch.c (main): Initialize it.
+ If ! posixly_correct, default backup type is now `existing'.
+ SIMPLE_BACKUP_SUFFIX no longer affects backup type.
+ (backup): Remove var.
+
+ * util.h: (countdirs): Remove.
+ (systemic): New decl.
+ * util.c (move_file): Try making the parent directory of TO
+ if backup prefix or suffix contain a slash.
+ (ask): Remove arbitrary limit on size of result.
+ (systemic): New function.
+ (mkdir): Work even if arg contains shell metacharacters.
+ (replace_slashes): Return 0 if none were replaced.
+ Don't replace slash after . or .. since it's redundant.
+ (countdirs): Remove.
+ (makedirs): Ignore mkdir failures.
+
+ * NEWS, patch.man: More POSIXLY_CORRECT adjustments.
+ Describe new rules for how file names are intuited.
+
+1997-04-17 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Version 2.2 released.
+
+ * Makefile.in (config.hin):
+ Remove before building; we always want the timestamp updated.
+
+ * inp.c (get_input_file):
+ Look for RCS files only if backup_type == numbered_existing.
+
+ * NEWS, patch.man:
+ Remove mention of never-implemented -V rcs and -V sccs options.
+ * patch.man: `pathname' -> `file name'
+ Correct the description of how file names are found in diff headers.
+ Clarify the distinction between ordinary and unified context diffs.
+
+1997-04-13 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Update to 2.1.7.
+
+ * patch.c (numeric_optarg): New function.
+ (get_some_switches): Use it.
+
+ * pch.c (intuit_diff_type): When creating a file, prefer a name whose
+ existing dir prefix is the longest.
+
+ * util.h (countdirs): New function.
+ * util.c (replace_slashes, countdirs): New functions.
+ (makedirs): Use replace_slashes, to be more like countdirs.
+
+ * patch.man: Explain -pN vs -p N. Recommend --new-file.
+ Explain possible incompatibility with strip count.
+
+1997-04-10 Paul Eggert <eggert@twinsun.com>
+
+ * configure.in (VERSION): Bump to 2.1.6.
+ (AC_CHECK_HEADERS): Remove stdlib.h (i.e. remove HAVE_STDLIB_H).
+
+ * Makefile.in: (HDRS, patchlevel.h, TAGS, distclean, maintainer-clean):
+ Don't distribute patchlevel.h; let the user do it.
+ This works around some obscure (possibly nonexistent?) `make' bugs.
+
+ * common.h (program_name): extern, not XTERN.
+ (<stdlib.h>): Include if STDC_HEADERS, not if HAVE_STDLIB_H.
+ (atol, getenv, malloc, realloc): Don't worry whether they're #defined.
+
+ * patch.c (get_some_switches):
+ Add special hack for backwards compatibility with CVS 1.9.
+ (-B, -Y, -z): Now set backup_type = simple.
+
+ * NEWS: Fix misspellings; minor reformatting.
+ * README: Report POSIX.2 compliance.
+
+1997-04-06 Paul Eggert <eggert@twinsun.com>
+
+ Move all old RCS $Log entries into ChangeLog.
+ #include all files with < >, not " ".
+
+ * addext.c, argmatch.c, argmatch.h, memchr.c, install-sh:
+ New files.
+ * EXTERN.h, INTERN.h: Removed.
+ * config.hin: Renamed from config.h.in.
+
+ * acconfig.h (NODIR): Remove.
+ (HAVE_MEMCHR): Add.
+
+ * configure.in (AC_ARG_PROGRAM, AC_PROG_MAKE_SET, HAVE_MEMCHR): Add.
+ (AC_CHECK_HEADERS): Replaces obsolescent AC_HAVE_HEADERS.
+ Add stdlib.h, string.h, unistd.h, varargs.h.
+ Delete obsolete call to AC_UNISTD_H.
+ (AC_CONFIG_HEADER): Rename config.h.in to config.hin.
+ (AC_C_CONST): Replaces obsolescent AC_CONST.
+ (AC_CHECK_FUNC): Check for getopt_long; define LIBOBJS and substitute
+ for it accordingly.
+ (AC_CHECK_FUNCS): Replaces obsolescent AC_HAVE_FUNCS.
+ Add _doprintf, isascii, mktemp, sigaction, sigprocmask, sigsetmask.
+ Remove strerror.
+ (AC_FUNC_CLOSEDIR_VOID, AC_FUNC_VPRINTF): Add.
+ (AC_HEADER_DIRENT): Replaces obsolescent AC_DIR_HEADER.
+ (AC_HEADER_STDC): Replaces obsolescent AC_STDC_HEADERS.
+ (AC_SYS_LONG_FILE_NAMES): Replaces obsolescent AC_LONG_FILE_NAMES.
+ (AC_TYPE_OFF_T): Replaces obsolescent AC_OFF_T.
+ (AC_TYPE_SIGNAL): Replaces obsolescent AC_RETSIGTYPE.
+ (AC_TYPE_SIZE_T): Replaces obsolescent AC_SIZE_T.
+ (AC_XENIX_DIR): Remove.
+ (ED_PROGRAM): New var.
+ (NODIR): Remove.
+ (PACKAGE, VERSION): New vars; substitute them with AC_SUBST.
+
+ * Makefile.in: Conform to current GNU build standards.
+ Redo dependencies. Use library getopt_long if available.
+ Use `&&' instead of `;' inside shell commands where applicable;
+ GNU make requires this.
+ Use double-colon rules for actions that do not build files.
+ (@SET_MAKE@): Added.
+ (CFLAGS, LDFLAGS, prefix, exec_prefix): Base on @ versions of symbols.
+ (COMPILE, CPPFLAGS, DEFS, ED_PROGRAM, LIBOBJS, LIBSRCS, PACKAGE,
+ VERSION): New symbols.
+ (SRCS, OBJS, HDRS, MISC): Add new files.
+ (man1dir): Renamed from mandir.
+ (man1ext): Renamed from manext.
+ (patch): Put -o first.
+ (install): Use $(transform) to allow program to be renamed by configure.
+ (patchlevel.h): Build from $(VERSION).
+ (dist): Get version number from $(VERSION) and package name from
+ $(PACKAGE).
+ (TAGS): Scan $(HDRS).
+ (maintainer-clean): Renamed from realclean. Remove patchlevel.h.
+
+ * backupfile.h (simple_backup_suffix): Now const *.
+ (find_backup_file_name, base_name, get_version): Args are now const *.
+ (base_name): New decl.
+ * backupfile.c (<config.h>): Include only if HAVE_CONFIG_H.
+ (<argmatch.h>): Include.
+ (<string.h>): Include if HAVE_STRING_H, not if STDC_HEADERS.
+ (<strings.h>): Include if !HAVE_STRING_H.
+ (<unistd.h>): Do not include.
+ (<dirent.h>): Redo include as per current autoconf standards.
+ (<limits.h>): Include if HAVE_LIMITS_H. Define CHAR_BIT if not defined.
+ (NLENGTH): Now returns size_t.
+ (CLOSEDIR, INT_STRLEN_BOUND): New macros.
+ (ISDIGIT): Use faster method.
+ (find_backup_file_name): No longer depends on NODIR.
+ Remove redundant code.
+ (make_version_name): Remove; do it more portably.
+ (max_backup_version): Args are now const *.
+ (version_number): Simplify digit checking.
+ (basename, concat, dirname): Remove.
+ (argmatch, invalid_arg): Move to argmatch.c. Simplify test for
+ ambiguous args. When reporting an error, use program_name not "patch".
+ (addext): Move to addext.c. Treat all negative values from pathconf
+ like -1. Always use long extension if it fits, even if the filesystem
+ does not support long file names.
+ (backup_types): Now const.
+
+ * common.h, inp.h (XTERN): Renamed from EXT to avoid collision
+ with errno.h reserved name space.
+
+ * common.h (DEBUGGING): Now an integer; default is 1.
+ (enum diff): New type.
+ (diff_type): Use it instead of small integers.
+ (CONTEXT_DIFF, NORMAL_DIFF, ED_DIFF, NEW_CONTEXT_DIFF, UNI_DIFF):
+ Now enumerated values instead of macros.
+ (NO_DIFF): New enumerated value (used instead of 0).
+ (volatile): Default to the empty string if __STDC__ is not defined.
+ (<signal.h>): Do not include.
+ (Chmod, Close, Fclose, Fflush, Fputc, Signal, Sprintf, Strcat,
+ Strcpy, Unlink, Write): Remove these macros; casts to void are
+ not needed for GNU coding standards.
+ (INITHUNKMAX): Move to pch.c.
+ (malloc, realloc, INT_MIN, MAXLINELEN, strNE, strnNE,
+ Reg1, Reg2, Reg3, Reg4, Reg5, Reg6, Reg7, Reg8, Reg9, Reg10, Reg11,
+ Reg12, Reg13, Reg14, Reg15, Reg16): Remove these macros.
+ (S_IXOTH, S_IWOTH, S_IROTH, S_IXGRP, S_IWGRP,
+ S_IRGRP, S_IXUSR, S_IWUSR, S_IRUSR, O_RDONLY, O_RDWR):
+ Define these macros, if not defined.
+ (CTYPE_DOMAIN, ISLOWER, ISSPACE, ISDIGIT, PARAMS): New macros.
+ (instat): Renamed from filestat; used for input file now.
+ (bufsize, using_plan_a, debug, strippath): Not statically initialized.
+ (debug): #define to 0 if not DEBUGGING, so that users of `debug'
+ no longer need to be surrounded by `#if DEBUGGING'.
+ (out_of_mem, filec, filearg, outname, toutkeep, trejkeep): Remove.
+ (inname, inerrno, dry_run, origbase): New variables.
+ (origprae): Now const*.
+ (TMPOUTNAME, TMPINNAME, TMPPATNAME): Now const*volatile.
+ (verbosity): New variable; subsumes `verbose'.
+ (DEFAULT_VERBOSITY, SILENT, VERBOSE): Values in a new enum.
+ (verbose): Removed.
+ (VOID): Use `#ifdef __STDC__' instead of`#if __STDC__',
+ for consistency elsewhere.
+ (__attribute__): New macro (empty if not a recent GCC).
+ (fatal_exit): Renamed from my_exit.
+ (errno): Don't define if STDC_HEADERS.
+ (<string.h>): Include if either STDC_HEADERS or HAVE_STRING_H.
+ (memcmp, memcpy): Define if !STDC_HEADERS && !HAVE_STRING_H
+ && !HAVE_MEMCHR.
+ (<stdlib.h>): Include if HAVE_STDLIB_H, not if STDC_HEADERS.
+ (atol, getenv, malloc, realloc, lseek): Declare only if not defined
+ as a macro.
+ (popen, strcpy, strcat, mktemp): Do not declare.
+ (lseek): Declare to yield off_t, not long.
+ (<fcntl.h>): Include only if HAVE_FCNTL_H.
+
+ * inp.h (get_input_file): New decl.
+ * inp.c (SCCSPREFIX, GET, GET_LOCKED, SCCSDIFF, RCSSUFFIX, CHECKOUT,
+ CHECKOUT_LOCKED, RCSDIFF): Moved here from common.h.
+ (i_ptr): Now char const **.
+ (i_size): Remove.
+ (TIBUFSIZE_MINIMUM): Define only if not already defined.
+ (plan_a, plan_b): Arg is now const *.
+ (report_revision): Declare before use. It's now the caller's
+ responsibility to test whether revision is 0.
+ (scan_input, report_revision, get_input_file):
+ Be less chatty unless --verbose.
+ (get_input_file): New function, split off from plan_a.
+ Reuse file status gotten by pch if possible. Allow for dry run.
+ Use POSIX bits for creat, not number. Check for creation and
+ close failure, and use fstat not stat. Use memcpy not strncpy.
+ (plan_a): Rewrite for speed.
+ Caller now assigns result to using_plan_a.
+ Don't bother reading empty files; during dry runs they might not exist.
+ Use ISSPACE, not isspace.
+ (plan_b): Allow for dry runs. Use ISSPACE, and handle sign extension
+ correctly on arg. Use POSIX symbol for open arg.
+
+ * patch.c (backup, output, patchname, program_name): New vars.
+ (last_frozen_line): Moved here from inp.h.
+ (TMPREJNAME): Moved here from common.h.
+ (optind_last): Removed.
+ (do_defines, if_defined, not_defined, else_defined, end_defined):
+ Now char const. Prepend with \n (except for not_defined) to
+ allow for files ending in non-newline.
+ (Argv): Now char*const*.
+ (main, get_some_switches): Exit status 0 means success,
+ 1 means hunks were rejected, 2 means trouble.
+ (main, locate_hunk, patch_match): Keep track of patch prefix context
+ separately from suffix context; this fixes several bugs.
+ (main): Initialize bufsize, strippath.
+ Be less chatty unless --verbose.
+ No more NODIR; always have version control available.
+ Require environment variables to be nonempty to have effect.
+ Add support for --dry-run, --output, --verbose.
+ Invoke get_input_file first, before deciding among do_ed_script,
+ plan_a, or plan_b.
+ Clear ofp after closing it, to keep discipline that ofp is either
+ 0 or open, to avoid file descriptor leaks. Conversely, rejfp doesn't
+ need this trick since static analysis is enough to show when it
+ needs to be closed.
+ Don't allow file-creation patches to be applied to existing files.
+ Misordered hunks are now not fatal errors; just go on to the next file.
+ It's a fatal error to fall back on plan B when --output is given,
+ since the moving hand has writ.
+ Add support for binary files.
+ Check for I/O errors.
+ chmod output file ourselves, rather than letting move_file do it;
+ this saves global state.
+ Use better grammar when outputting hunks messages, e.g. avoid
+ `1 hunks'.
+ (main, reinitialize_almost_everything):
+ Remove support for multiple file arguments.
+ Move get_some_switches call from reinitialize_almost_everything
+ to main.
+ (reinitialize_almost_everything): No need to reinitialize things
+ that are no longer global variables, e.g. outname.
+ (shortopts): Remove leading "-"; it's no longer important to
+ return options and arguments in order. '-b' no longer takes operand.
+ -p's operand is no longer optional. Add -i, -Y, -z. Remove -S.
+ (longopts): --suffix is now pared with -z, not -b. --backup now
+ means -b. Add --input, --basename-prefix, --dry-run, --verbose.
+ Remove --skip. --strip's operand is now required.
+ (option_help): New variable. Use style of current coding standards.
+ Change to match current option set.
+ (usage): Use it.
+ (get_some_switches): Get all switches, since `+' is defunct.
+ New options -i, -Y, -z, --verbose, --dry-run.
+ Option -S removed.
+ -b now means backup (backup_type == simple), not simple_backup_suffix.
+ -B now implies backup, and requires nonempty operand.
+ -D no longer requires first char of argument to be an identifier.
+ `-o -' is now disallowed (formerly output to regular file named "-").
+ -p operand is now required.
+ -v no longer needs to cleanup (no temp files can exist at that point).
+ -V now implies backup.
+ Set inname, patchname from file name arguments, if any;
+ do not set filearg. It's now an error if extra operands are given.
+ (abort_junk): Check for write errors in reject file.
+ (apply_hunk, copy_till): Return error flag, so that failure to apply
+ out-of-order hunk is no longer fatal.
+ (apply_hunk): New arg after_newline,
+ for patching files not ending in newline.
+ Cache ofp for speed. Check for write errors.
+ (OUTSIDE, IN_IFNDEF, IN_IFDEF, IN_ELSE): Now part of an enumerated type
+ instead of being #defined to small integers.
+ Change while-do to do-while when copying !-part for R_do_defines,
+ since condition is always true the first time through the loop.
+ (init_output, init_reject): Arg is now const *.
+ (copy_till, spew_output): Do not insert ``missing'' newlines;
+ propagate them via new after_newline argument.
+ (spew_output): Nothing to copy if last_frozen_line == input lines.
+ Do not close (ofp) if it's null.
+ (dump_line): Remove.
+ (similar): Ignore presence or absence of trailing newlines.
+ Check for only ' ' or '\t', not isspace (as per POSIX.2).
+ (make_temp): Use tmpnam if mktemp is not available.
+ (cleanup): New function.
+ (fatal_exit): Use it. Renamed from my_exit.
+ Take signal to exit with, not exit status (which is now always 2).
+
+ * pch.h, pch.c (pch_prefix_context, pch_suffix_context):
+ New fns replacing pch_context.
+ (another_hunk): Now yields int, not bool; -1 means out of memory.
+ Now takes difftype as argument.
+ (pch_write_line): Now returns boolean indicating whether we're after
+ a newline just after the write, for supporting non-text files.
+ * pch.c (isdigit): Remove; use ISDIGIT instead.
+ (INITHUNKMAX): Moved here from common.h.
+ (p_context): Removed. We need to keep track of the pre- and post-
+ context separately, in:
+ (p_prefix_context, p_suffix_context): New variables.
+ (bestguess): Remove.
+ (open_patch_file): Arg is now char const *.
+ Copy file a buffer at a time, not a char at a time, for speed.
+ (grow_hunkmax): Now returns success indicator.
+ (there_is_another_patch, skip_to, another_hunk, do_ed_script):
+ Be less chatty unless --verbose.
+ (there_is_another_patch):
+ Avoid infinite loop if user input keeps yielding EOF.
+ (intuit_diff_type): New returns enum diff, not int.
+ Strip paths as they're being fetched.
+ Set ok_to_create_file correctly even if patch is reversed.
+ Set up file names correctly with unidiff output.
+ Use algorithm specified by POSIX 1003.2b/D11 to deduce
+ name of file to patch, with the exception of patches
+ that can create files.
+ (skip_to): Be verbose if !inname, since we're about to ask the
+ user for a file name and the context will help the user choose.
+ (another_hunk): Keep context as LINENUM, not int.
+ If the replacement is missing, calculate its context correctly.
+ Don't assume input ends in newline.
+ Keep track of patch prefix context separately from suffix context;
+ this fixes several bugs.
+ Don't assume blank lines got chopped if the replacement is missing.
+ Report poorly-formed hunks instead of aborting.
+ Do not use strcpy on overlapping strings; it's not portable.
+ Work even if lines are incomplete.
+ Fix bugs associated with context-less context hunks,
+ particularly when patching in reverse.
+ (pget_line): Now takes just 1 arg; instead of second arg,
+ just examine using_plan_a global. Return -1 if we ran out
+ of memory.
+ (do_ed_script): Now takes output FILE * argument.
+ Take name of editor from ED_PROGRAM instead of hardwiring /bin/ed.
+ Don't bother unlinking TMPOUTNAME.
+ Check for popen failure.
+ Flush pipe to check for output errors.
+ If ofp is nonzero, copy result to it, instead of trying to
+ move the result.
+
+ * util.h, util.c (say1, say2, say3, say4, fatal1, fatal2, fatal3,
+ fatal4, pfatal1, pfatal2, pfatal3, pfatal4, ask1, ask2, ask3, ask4):
+ Remove; replaced with following.
+ (ask, say, fatal, pfatal): New stdarg functions.
+ (fetchname): Remove last, `assume_exists' parameter.
+ (savebuf, savestr, move_file, copy_file): Args are now const *.
+ (exit_with_signal): New function, for proper process status if
+ a signal is received as per POSIX.2.
+ (basename): Rename to `base_name' and move to backupfile.
+ * util.c (<signal.h>): Include here, not in common.h.
+ (vararg_start): New macro.
+ (va_dcl, va_start, va_arg, va_end): Define if neither <stdarg.h>
+ nor <varargs.h> are available.
+ (SIGCHLD): Define to SIGCLD if SIGCLD is defined and
+ SIGCHLD isn't.
+ (private_strerror): Remove.
+ (move_file): Remove option of moving to stdout.
+ Add support for -Y, -z.
+ Don't assume chars in file name are nonnegative.
+ Use copy_file if rename fails due to EXDEV;
+ report failure if rename fails for any other reason.
+ (copy_file, makedirs): Use POSIX symbols for permissions.
+ (copy_file): Open source before destination.
+ (remove_prefix): New function.
+ (vfprintf): New function, if !HAVE_VPRINTF.
+ (afatal, apfatal, zfatal, zpfatal, errnum): Remove.
+ (fatal, pfatal, say): New functions that use stdarg.
+ All callers changed.
+ (zask): Renamed from `ask'. Now uses stdarg. Output to stdout,
+ and read from /dev/tty, or if that cannot be opened, from
+ stderr, stdout, stdin, whichever is first a tty.
+ Print "EOF" when an EOF is read. Do not echo input.
+ (sigs): New array.
+ (sigset_t, sigemptyset, sigmask, sigaddset, sigismember, SIG_BLOCK,
+ SIG_UNBLOCK, SIG_SETMASK, sigprocmask, sigblock, sigsetmask):
+ Define substitutes if not available.
+ (initial_signal_mask, signals_to_block): New vars.
+ (fatal_exit_handler): New function, if !HAVE_SIGACTION.
+ (set_signals, ignore_signals): Use sigaction and sigprocmask style
+ signal-handling if possible; it doesn't lose signals.
+ (set_signals): Default SIGCHLD to work around SysV fork+wait bug.
+ (mkdir): First arg is now const *.
+ (makedirs): Handle multiple adjacent slashes correctly.
+ (fetchname): Do not worry about whether the file exists
+ (that is now the caller's responsibility).
+ Treat a sequence of one or more slashes like one slash.
+ Do not unstrip leading directories if they all exist and if
+ no -p option was given; POSIX doesn't allow this.
+ (memcmp): Remove (now a macro in common.h).
+
+ * version.c (copyright_string, free_software_msgid, authorship_msgid):
+ New constants.
+ (version): Use them. Use program_name instead of hardwiring it.
+
+ * patch.man: Generate date from RCS Id.
+ Rewrite to match the above changes.
+
+Fri Jul 30 02:02:51 1993 Paul Eggert (eggert@twinsun.com)
+
+ * configure.in (AC_HAVE_FUNCS): Add mkdir.
+
+ * common.h (Chmod, Fputc, Write, VOID): New macros.
+ (malloc, realloc): Yield `VOID *', not `char *'.
+
+ * util.h (makedirs): Omit `striplast' argument. Remove `aask'.
+
+ * inp.c (plan_a): Remove fixed internal buffer. Remove lint.
+
+ * util.c (set_signals, ignore_signals): Trap SIGTERM, too.
+ (makedirs): Removed fixed internal buffer. Omit `striplast' argument.
+ (mkdir): New function, if !HAVE_MKDIR.
+ (fetchname): Remove fixed internal buffer.
+ Remove lint from various functions.
+
+ * patch.c, pch.c: Remove lint.
+
+Thu Jul 29 20:52:07 1993 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu)
+
+ * Makefile.in (config.status): Run config.status --recheck, not
+ configure, to get the right args passed.
+
+Thu Jul 29 07:46:16 1993 Paul Eggert (eggert@twinsun.com)
+
+ * The following changes remove all remaining fixed limits on memory,
+ and fix bugs in patch's handling of null bytes and files that do not
+ end in newline. `Patch' now works on binary files.
+
+ * backupfile.c (find_backup_file_name): Don't dump core if malloc fails.
+
+ * EXTERN.h, INTERN.h (EXITING): New macro.
+ * backupfile.[ch], patch.c, pch.c: Add PARAMS to function declarations.
+
+ * common.h (bool): Change to int, so ANSI C prototype promotion works.
+ (CANVARARG): Remove varargs hack; it wasn't portable.
+ (filearg): Now a pointer, not an array, so that it can be reallocated.
+ (GET*, SCCSDIFF, CHECKOUT*, RCSDIFF): Quote operands to commands.
+ (my_exit): Declare here.
+ (BUFFERSIZE, Ctl, filemode, Fseek, Fstat, Lseek, MAXFILEC, MAXHUNKSIZE,
+ Mktemp, myuid, Null, Nullch, Nullfp, Nulline, Pclose, VOIDUSED): Remove.
+ All invokers changed.
+ (Argc, Argv, *define[sd], last_offset, maxfuzz, noreverse, ofp,
+ optind_last, rejfp, rejname): No longer externally visible; all
+ definers changed.
+ (INT_MAX, INT_MIN, STD*_FILENO, SEEK_SET): Define if the underlying
+ system doesn't. Include <limits.h> for this.
+
+ * configure.in: Add limits.h, memcmp. Delete getline.
+
+ * inp.c (tibufsize): New variable; buffers grow as needed.
+ (TIBUFSIZE_MINIMUM): New macro.
+ (report_revision): New function.
+ (plan_a): Do not search patch as a big string, since that fails
+ if it contains null bytes.
+ Prepend `./' to filenames starting with `-', for RCS and SCCS.
+ If file does not match default RCS/SCCS version, go ahead and patch
+ it anyway; warn about the problem but do not report a fatal error.
+ (plan_b): Do not use a fixed buffer to read lines; read byte by byte
+ instead, so that the lines can be arbitrarily long. Do not search
+ lines as strings, since they may contain null bytes.
+ (plan_a, plan_b): Report I/O errors.
+
+ * inp.c, inp.h (rev_in_string): Remove.
+ (ifetch): Yield size of line too, since strlen no longer applies.
+ (plan_a, plan_b): No longer exported.
+
+ * patch.c (abort_hunk, apply_hunk, patch_match, similar):
+ Lines may contain NUL and need not end in newline.
+ (copy_till, dump_line): Insert newline if appending after partial line.
+ All invokers changed.
+ (main, get_some_switches, apply_hunk): Allocate *_define[ds], filearg,
+ rejname dynamically.
+ (make_temp): New function.
+ (main): Use it.
+ (main, spew_output, dump_line) Check for I/O errors.
+
+ * pch.c (open_patch_file): Don't copy stdin to a temporary file if
+ it's a regular file, since we can seek on it directly.
+ (open_patch_file, skip_to, another_hunk): The patch file may contain
+ NULs.
+ (another_hunk): The patch file may contain lines starting with '\',
+ which means the preceding line lacked a trailing newline.
+ (pgetline): Rename to pget_line.
+ (get_line, incomplete_line, pch_write_line): New functions.
+ (pch_line_len): Return size_t, not short; lines may be very long.
+ (do_ed_script): Check for I/O errors. Allow scripts to contain
+ 'i' and 's' commands, too.
+
+ * pch.h (pfp, grow_hunkmax, intuit_diff_type, next_intuit_at, skip_to,
+ pfetch, pgetline): No longer exported.
+ (pch_write_line): New declaration.
+ (getline): Removed.
+
+ * util.c (move_file, fetchname): Use private stat buffer, so that
+ filestat isn't lost. Check for I/O errors.
+ (savestr): Use savebuf.
+ (zask): Use STD*_FILENO instead of 0, 1, 2.
+ (fetchname): strip_leading defaults to INT_MAX instead of 957 (!).
+ (memcmp): Define if !HAVE_MEMCMP.
+
+ * util.c, util.h (say*, fatal*, pfatal*, ask*): Delete; these
+ pseudo-varargs functions weren't ANSI C. Replace by macros
+ that invoke [fs]printf directly, and invoke new functions
+ [az]{say,fatal,pfatal,ask} before and after.
+ (savebuf, read_fatal, write_fatal, memory_fatal, Fseek): New functions.
+ (fatal*): Output trailing newline after message. All invokers changed.
+
+ * version.c (version): Don't exit.
+
+ * Makefile.in (SRCS): Remove getline.c.
+
+Thu Jul 22 15:24:24 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
+
+ * EXTERN.h, INTERN.h (PARAMS): Define.
+ * backupfile.h, common.h, inp.h, pch.h, util.h: Use.
+ * backupfile.c: Include EXTERN.h.
+
+Wed Jul 21 13:14:05 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
+
+ * getline.c: New file.
+ * configure.in: Check for getline (GNU libc has it).
+ * pch.c: Use it instead of fgets.
+ (pgetline): Renamed from pgets. Change callers.
+ * pch.h: Change decl.
+
+ * pch.c (pgets): Tab adjusts by 8 - (indent % 8), not % 7.
+ Be consistent with similar code in pch.c::intuit_diff_type.
+
+ * common.h (MEM): Typedef removed.
+ inp.c, pch.c, util.c: Use size_t instead of MEM.
+ inp.c, pch.c: Use off_t.
+ configure.in: Add AC_SIZE_T and AC_OFF_T.
+
+ * common.h: Make buf a pointer and add a bufsize variable.
+ * util.c, pch.c, inp.c: Replace sizeof buf with bufsize.
+ * patch.c: malloc buf to bufsize bytes.
+
+Tue Jul 20 20:40:03 1993 Paul Eggert (eggert@twinsun.com)
+
+ * common.h (BUFFERSIZE): Grow it to 8k too, just in case.
+ (buf): Turn `buf' back into an array; making it a pointer broke
+ things seriously.
+ * patch.c (main): Likewise.
+
+Tue Jul 20 20:02:40 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
+
+ * Move Reg[1-16] and CANVARARG decls from config.h.in to common.h.
+ * acconfig.h: New file.
+ * Makefile (HDRS): Add it.
+
+Tue Jul 20 16:35:27 1993 Paul Eggert (eggert@twinsun.com)
+
+ * Makefile.in: Remove alloca.[co]; getopt no longer needs it.
+ * configure.in (AC_ALLOCA): Remove.
+
+ * util.c (set_signals, ignore_signals): Do nothing if SIGHUP
+ and SIGINT aren't defined.
+
+Tue Jul 20 17:59:56 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
+
+ * patch.c (main): Call xmalloc, not malloc. xmalloc buf.
+ * common.h: Declare xmalloc. Make buf a pointer, not an array.
+
+ * util.c (xmalloc): Call fatal1, not fatal.
+
+ * common.h [MAXLINELEN]: Bump from 1k to 8k.
+
+Thu Jul 8 19:56:16 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
+
+ * Makefile.in (installdirs): New target.
+ (install): Use it.
+ (Makefile, config.status, configure): New targets.
+
+Wed Jul 7 13:25:40 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
+
+ * patch.c (get_some_switches, longopts): Recognize --help
+ option, and call usage.
+ (usage): New function.
+
+Fri Jun 25 07:49:45 1993 Paul Eggert (eggert@twinsun.com)
+
+ * backupfile.c (find_backup_file_name): Don't use .orig if
+ numbered_existing with no existing numbered backup.
+ (addext): Don't use ext if !HAVE_LONG_FILE_NAMES,
+ even if it would fit. This matches patch's historical behavior.
+ (simple_backup_suffix): Default to ".orig".
+ * patch.c (main): Just use that default.
+
+Tue Jun 15 22:32:14 1993 Paul Eggert (eggert@twinsun.com)
+
+ * config.h.in (HAVE_ALLOCA_H): This #undef was missing.
+ * Makefile.in (info, check, installcheck): New rules.
+
+Sun Jun 13 14:31:29 1993 Paul Eggert (eggert@twinsun.com)
+
+ * config.h.in (index, rindex): Remove unused macro
+ definitions; they get in the way when porting to AIX.
+ * config.h.in, configure.in (HAVE_STRING_H): Remove unused defn.
+
+Thu Jun 10 21:13:47 1993 Paul Eggert (eggert@twinsun.com)
+
+ * patchlevel.h: PATCH_VERSION 2.1.
+ (The name `patch-2.0.12g12' is too long for traditional Unix.)
+
+ * patchlevel.h (PATCH_VERSION): Renamed from PATCHLEVEL.
+ Now contains the entire patch version number.
+ * version.c (version): Use it.
+
+Wed Jun 9 21:43:23 1993 Paul Eggert (eggert@twinsun.com)
+
+ * common.h: Remove declarations of index and rindex.
+ * backupfile.c: Likewise.
+ (addext, basename, dirname): Avoid rindex.
+
+Tue Jun 8 15:24:14 1993 Paul Eggert (eggert@twinsun.com)
+
+ * inp.c (plan_a): Check that RCS and working files are not the
+ same. This check is needed on hosts that do not report file
+ name length limits and have short limits.
+
+Sat Jun 5 22:56:07 1993 Paul Eggert (eggert@twinsun.com)
+
+ * Makefile.in (.c.o): Put $(CFLAGS) after other options.
+ (dist): Switch from .z to .gz.
+
+Wed Jun 2 10:37:15 1993 Paul Eggert (eggert@twinsun.com)
+
+ * backupfile.c (find_backup_file_name): Initialize copy of
+ file name properly.
+
+Mon May 31 21:55:21 1993 Paul Eggert (eggert@twinsun.com)
+
+ * patchlevel.h: Patch level 12g11.
+
+ * pch.c (p_Char): Renamed from p_char, which is a system type
+ in Tex XD88's <sys/types.h>.
+
+ * backupfile.c: Include "config.h" first, so that `const' is
+ treated consistently in system headers.
+
+Mon May 31 16:06:23 1993 Paul Eggert (eggert@twinsun.com)
+
+ * patchlevel.h: Patch level 12g10.
+
+ * configure.in: Add AC_CONST.
+ * config.h.in: Add `const'.
+ * Makefile.in (.c.o): Add -DHAVE_CONFIG_H.
+ (getopt.o getopt1.o): Depend on config.h.
+
+ * util.c (xmalloc): New function; alloca.c needs this.
+
+Mon May 31 00:49:40 1993 Paul Eggert (eggert@twinsun.com)
+
+ * patchlevel.h: PATCHLEVEL 12g9.
+
+ * backupfile.c, backupfile.h (addext): New function.
+ It uses pathconf(), if available, to determine maximum file
+ name length.
+ * patch.c (main): Use it for reject file name.
+ * common.h (ORIGEXT): Moved to patch.c.
+ * config.h.in (HAVE_PATHCONF): New macro.
+ * configure.in: Define it.
+
+ * Makefile.in (dist): Use gzip, not compress.
+
+Sat May 29 09:42:18 1993 Paul Eggert (eggert@twinsun.com)
+
+ * patch.c (main): Use pathconf to decide reject file name.
+ * common.h (REJEXT): Remove.
+
+ * inp.c (plan_a): Don't lock the checked-out file if `patch -o'
+ redirected the output elsewhere.
+ * common.h (CHECKOUT_LOCKED, GET_LOCKED): New macros. GET and
+ CHECKOUT now just checkout unlocked copies.
+
+Fri May 28 08:44:50 1993 Paul Eggert (eggert@twinsun.com)
+
+ * backupfile.c (basename): Define even if NODIR isn't defined.
+ * patch.c (main): Ask just once to apply a reversed patch.
+
+Tue Nov 24 08:09:04 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
+
+ * config.h.in, common.h: Use HAVE_FCNTL_H and HAVE_STRING_H
+ instead of USG.
+
+ * backupfile.c: Use SYSDIR and NDIR instead of USG.
+ Define direct as dirent, not vice-versa.
+
+Wed Sep 16 17:11:48 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * patch.c (get_some_switches): optc should be int, not char.
+
+Tue Sep 15 00:36:46 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * patchlevel.h: PATCHLEVEL 12g8.
+
+Mon Sep 14 22:01:23 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * Makefile.in: Add uninstall target.
+
+ * util.c (fatal, pfatal): Add some asterisks to make fatal
+ messages stand out more.
+
+Tue Aug 25 22:13:36 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * patch.c (main, get_some_switches), common.h, inp.c (plan_a,
+ plan_b), pch.c (there_is_another_patch): Add -t --batch
+ option, similar to -f --force.
+
+Mon Jul 27 11:27:07 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * common.h: Define SCCSDIFF and RCSDIFF.
+ * inp.c (plan_a): Use them to make sure it's safe to check out
+ the default RCS or SCCS version.
+ From Paul Eggert.
+
+Mon Jul 20 14:10:32 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * util.h: Declare basename.
+ * inp.c (plan_a), util.c (fetchname): Use it to isolate the
+ leading path when testing for RCS and SCCS files.
+
+Fri Jul 10 16:03:23 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * util.c (makedirs): Only make the directories that don't exist.
+ From chip@tct.com (Chip Salzenberg).
+
+Wed Jul 8 01:20:56 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * patch.c (main): Open ofp after checking for ed script.
+ Close ofp and rejfp before trying plan B.
+ From epang@sfu.ca (Eugene Pang).
+
+ * util.c (fatal, pfatal): Print "patch: " before message.
+ * pch.c, inp.c, patch.c, util.c: Remove "patch: " from the
+ callers that had it.
+
+ * common.h (myuid): New variable.
+ * patch.c (main): Initialize it.
+ * inp.c (myuid): Function removed.
+ (plan_a): Use the variable, not the function.
+
+ * patch.c: Add back -E --remove-empty-files option.
+
+Tue Jul 7 23:19:28 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * inp.c (myuid): New function.
+ (plan_a): Call it. Optimize stat calls. Be smarter about
+ detecting checked out RCS and SCCS files.
+ From Paul Eggert (eggert@twinsun.com).
+
+ * inp.c, util.c, patch.c: Don't bother checking for stat() > 0.
+
+Mon Jul 6 13:01:52 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * util.c (move_file): Use rename instead of link and copying.
+
+ * util.c (pfatal): New function.
+ * util.h: Declare it and pfatal[1-4] macros.
+ * various files: Use it instead of fatal where appropriate.
+
+ * common.h, patch.c: Replace Arg[cv]_last with optind_last.
+
+ * patch.c (main, get_some_switches): Use getopt_long. Update
+ usage message.
+ (nextarg): Function removed.
+
+ * Rename FLEXFILENAMES to HAVE_LONG_FILE_NAMES,
+ VOIDSIG to RETSIGTYPE.
+
+ * backupfile.c, common.h: Use STDC header files if available.
+ backupfile.h: Declare get_version.
+
+ * COPYING, COPYING.LIB, INSTALL, Makefile.in, alloca.c,
+ config.h.in, configure, configure.in, getopt.[ch], getopt1.c,
+ rename.c: New files.
+ * Configure, MANIFEST, Makefile.SH, config.H, config.h.SH,
+ malloc.c: Files removed.
+
+ * version.c (version): Don't print the RCS stuff, since we're
+ not updating it regularly.
+
+ * patchlevel.h: PATCHLEVEL 12u7.
+
+ * Makefile.SH (dist): New target.
+ Makedist: File removed.
+
+ * inp.c (plan_a): Check whether the user can write to the
+ file, not whether anyone can write to the file.
+
+Sat Jul 4 00:06:58 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * inp.c (plan_a): Try to check out read-only files from RCS or SCCS.
+
+ * util.c (move_file): If backing up by linking fails, try copying.
+ From cek@sdc.boeing.com (Conrad Kimball).
+
+ * patch.c (get_some_switches): Eliminate -E option; always
+ remove empty output files.
+
+ * util.c (fetchname): Only undo slash removal for relative
+ paths if -p was not given.
+
+ * Makefile.sh: Add mostlyclean target.
+
+Fri Jul 3 23:48:14 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
+
+ * util.c (fetchname): Accept whitespace between `Index:' and filename.
+ Also plug a small memory leak for diffs against /dev/null.
+ From eggert@twinsun.com (Paul Eggert).
+
+ * common.h: Don't define TRUE and FALSE if already defined.
+ From phk@data.fls.dk (Poul-Henning Kamp).
+
+Wed Apr 29 10:19:33 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu)
+
+ * backupfile.c (get_version): Exit if given a bad backup type.
+
+Fri Mar 27 09:57:14 1992 Karl Berry (karl at hayley)
+
+ * common.h (S_ISDIR, S_ISREG): define these.
+ * inp.c (plan_a): use S_ISREG, not S_IFREG.
+ * util.c (fetchname): use S_ISDIR, not S_IFDIR.
+
+Mon Mar 16 14:10:42 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu)
+
+ * patchlevel.h: PATCHLEVEL 12u6.
+
+Sat Mar 14 13:13:29 1992 David J. MacKenzie (djm at frob.eng.umd.edu)
+
+ * Configure, config.h.SH: Check for directory header and unistd.h.
+
+ * patch.c (main): If -E was given and output file is empty after
+ patching, remove it.
+ (get_some_switches): Recognize -E option.
+
+ * patch.c (copy_till): Make garbled output an error, not a warning
+ that doesn't change the exit status.
+
+ * common.h: Protect against system declarations of malloc and realloc.
+
+ * Makedist: Add backupfile.[ch].
+
+ * Configure: Look for C library where NeXT and SVR4 put it.
+ Look in /usr/ucb after /bin and /usr/bin for utilities,
+ and look in /usr/ccs/bin, to make SVR4 happier.
+ Recognize m68k predefine.
+
+ * util.c (fetchname): Test of stat return value was backward.
+ From csss@scheme.cs.ubc.ca.
+
+ * version.c (version): Exit with status 0, not 1.
+
+ * Makefile.SH: Add backupfile.[cho].
+ * patch.c (main): Initialize backup file generation.
+ (get_some_switches): Add -V option.
+ * common.h, util,c, patch.c: Replace origext with simple_backup_suffix.
+ * util.c (move_file): Use find_backup_file_name.
+
+Tue Dec 3 11:27:16 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
+
+ * patchlevel.h: PATCHLEVEL 12u5.
+
+ * Makefile.SH: Change clean, distclean, and realclean targets a
+ little so they agree with the GNU coding standards.
+ Add Makefile to addedbyconf, so distclean removes it.
+
+ * Configure: Recognize Domain/OS C library in /lib/libc.
+ From mmuegel@mot.com (Michael S. Muegel).
+
+ * pch.c: Fixes from Wayne Davison:
+ Patch now accepts no-context context diffs that are
+ specified with an assumed one line hunk (e.g. "*** 10 ****").
+ Fixed a bug in both context and unified diff processing that would
+ put a zero-context hunk in the wrong place (one line too soon).
+ Fixed a minor problem with p_max in unified diffs where it would
+ set p_max to hunkmax unnecessarily (the only adverse effect was to
+ not supply empty lines at eof by assuming they were truncated).
+
+Tue Jul 2 03:25:51 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
+
+ * Configure: Check for signal declaration in
+ /usr/include/sys/signal.h as well as /usr/include/signal.h.
+
+ * Configure, common.h, config.h.SH: Comment out the sprintf
+ declaration and tests to determine its return value type. It
+ conflicts with ANSI C systems' prototypes in stdio.h and the
+ return value of sprintf is never used anyway -- it's always cast
+ to void.
+
+Thu Jun 27 13:05:32 1991 David J. MacKenzie (djm at churchy.gnu.ai.mit.edu)
+
+ * patchlevel.h: PATCHLEVEL 12u4.
+
+Thu Feb 21 15:18:14 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
+
+ * pch.c (another_hunk): Fix off by 1 error. From
+ iverson@xstor.com (Tim Iverson).
+
+Sun Jan 20 20:18:58 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
+
+ * Makefile.SH (all): Don't make a dummy `all' file.
+
+ * patchlevel.h: PATCHLEVEL 12u3.
+
+ * patch.c (nextarg): New function.
+ (get_some_switches): Use it, to prevent dereferencing a null
+ pointer if an option that takes an arg is not given one (is last
+ on the command line). From Paul Eggert.
+
+ * pch.c (another_hunk): Fix from Wayne Davison to recognize
+ single-line hunks in unified diffs (with a single line number
+ instead of a range).
+
+ * inp.c (rev_in_string): Don't use `s' before defining it. From
+ Wayne Davison.
+
+Mon Jan 7 06:25:11 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
+
+ * patchlevel.h: PATCHLEVEL 12u2.
+
+ * pch.c (intuit_diff_type): Recognize `+++' in diff headers, for
+ unified diff format. From unidiff patch 1.
+
+Mon Dec 3 00:14:25 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
+
+ * patch.c (get_some_switches): Make the usage message more
+ informative.
+
+Sun Dec 2 23:20:18 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
+
+ * Configure: When checking for C preprocessor, look for 'abc.*xyz'
+ instead of 'abc.xyz', so ANSI C preprocessors work.
+
+ * Apply fix for -D from ksb@mentor.cc.purdue.edu (Kevin Braunsdorf).
+
+1990-05-01 Wayne Davison <davison@dri.com>
+ * patch.c, pch.c: unidiff support added
+
+Wed Mar 7 23:47:25 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
+
+ * pch.c: Call malformed instead of goto malformed
+ (just allows easier debugging).
+
+Tue Jan 23 21:27:00 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
+
+ * common.h (TMP*NAME): Make these char *, not char [].
+ patch.c (main): Use TMPDIR (if present) to set TMP*NAME.
+ common.h: Declare getenv.
+
+Sun Dec 17 17:29:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
+
+ * patch.c (reverse_flag_specified): New variable.
+ (get_some_switches, reinitialize_almost_everything): Use it.
+
+1988-06-22 Larry Wall <sdcrdcf!lwall>
+ patch12:
+ * common.h: sprintf was declared wrong
+ * patch.c: rindex() wasn't declared
+ * patch.man: now avoids Bell System Logo
+
+1988-06-03 Larry Wall <sdcrdcf!lwall>
+ patch10:
+ * common.h: support for shorter extensions.
+ * inp.c: made a little smarter about sccs files
+ * patch.c: exit code improved.
+ better support for non-flexfilenames.
+ * patch.man: -B switch was contributed.
+ * pch.c: Can now find patches in shar scripts.
+ Hunks that swapped and then swapped back could core dump.
+
+1987-06-04 Larry Wall <sdcrdcf!lwall>
+ * pch.c: pch_swap didn't swap p_bfake and p_efake.
+
+1987-02-16 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Short replacement caused spurious "Out of sync" message.
+
+1987-01-30 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Improved diagnostic on sync error.
+ Moved do_ed_script() to pch.c.
+ * pch.c: Improved responses to mangled patches.
+ * pch.h: Added do_ed_script().
+
+1987-01-05 Larry Wall <sdcrdcf!lwall>
+ * pch.c: New-style context diffs caused double call to free().
+
+1986-11-21 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Fuzz factor caused offset of installed lines.
+
+1986-11-14 Larry Wall <sdcrdcf!lwall>
+ * pch.c: Fixed problem where a long pattern wouldn't grow the hunk.
+ Also restored p_input_line when backtracking so error messages are
+ right.
+
+1986-11-03 Larry Wall <sdcrdcf!lwall>
+ * pch.c: New-style delete triggers spurious assertion error.
+
+1986-10-29 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Backwards search could terminate prematurely.
+ * pch.c: Could falsely report new-style context diff.
+
+1986-09-17 Larry Wall <sdcrdcf!lwall>
+ * common.h, inp.c, inp.h, patch.c, patch.man, pch.c, pch.h,
+ util.h, version.c, version.h: Baseline for netwide release.
+
+1986-08-01 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Fixes for machines that can't vararg.
+ Added fuzz factor. Generalized -p. General cleanup.
+ Changed some %d's to %ld's. Linted.
+ * patch.man: Documented -v, -p, -F.
+ Added notes to patch senders.
+
+1985-08-15 van%ucbmonet@berkeley
+ Changes for 4.3bsd diff -c.
+
+1985-03-26 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Frozen.
+ * patch.man: Frozen.
+
+1985-03-12 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Now checks for normalness of file to patch.
+ Check i_ptr and i_womp to make sure they aren't null before freeing.
+ Also allow ed output to be suppressed.
+ Changed pfp->_file to fileno(pfp).
+ Added -p option from jromine@uci-750a.
+ Added -D (#ifdef) option from joe@fluke.
+ * patch.man: Documented -p, -D.
+
+1984-12-06 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Made smarter about SCCS subdirectories.
+
+1984-12-05 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Added -l switch to do loose string comparison.
+ * patch.man: Added -l switch, and noted bistability bug.
+
+1984-12-04 Larry Wall <sdcrdcf!lwall>
+ Branch for sdcrdcf changes.
+ * patch.c: Failed hunk count not reset on multiple patch file.
+ * patch.man: Baseline version.
+
+1984-11-29 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Linted. Identifiers uniquified. Fixed i_ptr malloc() bug.
+ Fixed multiple calls to mktemp(). Will now work on machines that can
+ only read 32767 chars. Added -R option for diffs with new and old
+ swapped. Various cosmetic changes.
+
+1984-11-09 Larry Wall <sdcrdcf!lwall>
+ * patch.c: Initial revision
+
+
+Copyright (C) 1984, 1985, 1986, 1987, 1988 Larry Wall.
+
+Copyright (C) 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 2001,
+2002, 2009 Free Software Foundation, Inc.
+
+This file is part of GNU Patch.
+
+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 they 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; see the file COPYING. If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+MA 02110-1301, USA.
--- /dev/null
+Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
+Foundation, Inc.
+
+ This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+ These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for variables by setting
+them in the environment. You can do that on the command line like this:
+
+ ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory. After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the `--target=TYPE' option to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+will cause the specified gcc to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
--- /dev/null
+# Makefile for GNU patch.
+
+# Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003, 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 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; see the file COPYING.
+# If not, write to the Free Software Foundation,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+#### Start of system configuration section. ####
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+@SET_MAKE@
+
+CC = @CC@
+ed_PROGRAM = @ed_PROGRAM@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+TEST_SHELL = @TEST_SHELL@
+transform = @program_transform_name@
+
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+DEFS = @DEFS@
+EXEEXT = @EXEEXT@
+LDFLAGS = @LDFLAGS@
+LIBOBJDIR = gl/lib/
+LIBOBJS = @LIBOBJS@ ${LIBOBJDIR}full-write$U.o
+LIBS = @LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+STDBOOL_H = @STDBOOL_H@
+ifneq (@GETOPT_H@,)
+GETOPT_H = gl/lib/@GETOPT_H@
+endif
+HAVE__BOOL = @HAVE__BOOL@
+ENABLE_MERGE = @ENABLE_MERGE@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+
+# Where to put the manual pages.
+datarootdir = @datarootdir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+# Extension (including `.') for the manual page filenames.
+man1ext = .1
+
+# Hook for nonstandard builds.
+CONFIG_STATUS = config.status
+
+#### End of system configuration section. ####
+
+SHELL = /bin/sh
+
+LIBSRCS = \
+ gl/lib/argmatch.c \
+ gl/lib/backupfile.c \
+ gl/lib/basename.c \
+ gl/lib/dirname.c \
+ gl/lib/error.c \
+ gl/lib/exitfail.c \
+ gl/lib/full-write.c \
+ gl/lib/getopt1.c \
+ gl/lib/getopt.c \
+ gl/lib/hash.c \
+ gl/lib/malloc.c \
+ gl/lib/mbrtowc.c \
+ gl/lib/memchr.c \
+ gl/lib/quotearg.c \
+ gl/lib/quote.c \
+ gl/lib/realloc.c \
+ gl/lib/rename.c \
+ gl/lib/safe-read.c \
+ gl/lib/safe-write.c \
+ gl/lib/strcasecmp.c \
+ gl/lib/stripslash.c \
+ gl/lib/strncasecmp.c \
+ gl/lib/strndup.c \
+ gl/lib/xmalloc.c \
+ gl/lib/xstrndup.c
+
+SRCS = $(LIBSRCS) \
+ src/inp.c \
+ src/maketime.c \
+ src/merge.c \
+ src/partime.c \
+ src/patch.c \
+ src/pch.c \
+ src/quotesys.c \
+ src/util.c \
+ src/version.c
+
+ifeq ($(ENABLE_MERGE),1)
+MERGEOBJ = src/merge.$(OBJEXT)
+endif
+
+OBJS = $(LIBOBJS) $(MERGEOBJ) \
+ src/inp.$(OBJEXT) \
+ src/maketime.$(OBJEXT) \
+ src/partime.$(OBJEXT) \
+ src/patch.$(OBJEXT) \
+ src/pch.$(OBJEXT) \
+ src/quotesys.$(OBJEXT) \
+ src/util.$(OBJEXT) \
+ src/version.$(OBJEXT)
+
+LIBHDRS = \
+ gl/lib/argmatch.h \
+ gl/lib/backupfile.h \
+ gl/lib/dirname.h \
+ gl/lib/error.h \
+ gl/lib/exitfail.h \
+ gl/lib/full-write.h \
+ gl/lib/getopt.hin \
+ gl/lib/getopt_int.h \
+ gl/lib/gettext.h \
+ gl/lib/hash.h \
+ gl/lib/minmax.h \
+ gl/lib/quotearg.h \
+ gl/lib/quote.h \
+ gl/lib/safe-write.h \
+ gl/lib/stdbool.hin \
+ gl/lib/unlocked-io.h \
+ gl/lib/verify.h \
+ gl/lib/xalloc.h \
+ gl/lib/xstrndup.h
+
+HDRS = $(LIBHDRS) \
+ src/bestmatch.h \
+ src/common.h \
+ src/diffseq.h \
+ src/inp.h \
+ src/maketime.h \
+ src/partime.h \
+ src/pch.h \
+ src/quotesys.h \
+ src/util.h \
+ src/version.h
+
+MISC = \
+ AUTHORS \
+ COPYING \
+ ChangeLog \
+ INSTALL \
+ Makefile.in \
+ NEWS \
+ README \
+ VERSION \
+ aclocal.m4 \
+ config.guess\
+ config.hin \
+ config.sub \
+ configure \
+ configure.ac \
+ install-sh \
+ mkinstalldirs \
+ patch.man \
+ tests/test-lib.sh \
+ update-version.sh
+
+DISTFILES = $(MISC) $(SRCS) $(HDRS) $(M4FILES) \
+ pc/chdirsaf.c \
+ pc/djgpp/config.sed \
+ pc/djgpp/configure.bat \
+ pc/djgpp/configure.sed \
+ pc/djgpp/README
+
+MORE_DISTFILES = $(TESTS) $(BROKEN_TESTS)
+
+patch_name = `echo patch | sed '$(transform)'`
+
+all:: src/patch$(EXEEXT)
+
+info::
+installcheck::
+
+TESTS = \
+ tests/asymmetric-hunks \
+ tests/backup-prefix-suffix \
+ tests/corrupt-reject-files \
+ tests/create-delete \
+ tests/crlf-handling \
+ tests/global-reject-files \
+ tests/inname \
+ tests/line-numbers \
+ tests/merge \
+ tests/munged-context-format \
+ tests/need-filename \
+ tests/no-newline-triggers-assert \
+ tests/preserve-c-function-names \
+ tests/preserve-mode-and-timestamp \
+ tests/reject-format \
+ tests/remember-backup-files \
+ tests/remember-reject-files \
+ tests/unmodified-files
+
+BROKEN_TESTS = \
+ tests/dash-o-append
+
+check:: $(TESTS)
+ @echo All tests succeeded!
+
+.PHONY: $(TESTS) $(BROKEN_TESTS)
+$(TESTS) $(BROKEN_TESTS): all
+ @echo "[$@]"
+ @srcdir=$(srcdir)/tests $(TEST_SHELL) $@
+
+ifeq ($(ENABLE_MERGE),1)
+DEFINE_ENABLE_MERGE = -DENABLE_MERGE
+endif
+COMPILE = $(CC) -c $(CPPFLAGS) $(DEFS) -Ded_PROGRAM=\"$(ed_PROGRAM)\" \
+ $(DEFINE_ENABLE_MERGE) -I. -I$(srcdir)/src -I$(srcdir)/gl/lib $(CFLAGS)
+
+.c.$(OBJEXT):
+ @mkdir -p $(@D)
+ $(COMPILE) -o $@ $<
+
+src/patch$(EXEEXT): $(OBJS)
+ $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS)
+
+install:: all
+ $(SHELL) $(srcdir)/mkinstalldirs $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
+ $(INSTALL_PROGRAM) src/patch$(EXEEXT) $(DESTDIR)$(bindir)/$(patch_name)$(EXEEXT)
+ $(INSTALL_DATA) $(srcdir)/patch.man $(DESTDIR)$(man1dir)/$(patch_name)$(man1ext)
+
+install-strip::
+ $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
+
+uninstall::
+ rm -f $(DESTDIR)$(bindir)/$(patch_name)$(EXEEXT) \
+ $(DESTDIR)$(man1dir)/$(patch_name)$(man1ext)
+
+Makefile: Makefile.in $(CONFIG_STATUS)
+ $(SHELL) $(CONFIG_STATUS)
+FORCE:
+VERSION: FORCE
+ @cd $(srcdir) && $(SHELL) ./update-version.sh VERSION
+config.status: configure
+ $(SHELL) $(CONFIG_STATUS) --recheck
+configure: configure.ac $(srcdir)/aclocal.m4 $(srcdir)/VERSION
+ cd $(srcdir) && autoconf --force
+config.hin: configure.ac $(srcdir)/aclocal.m4
+ cd $(srcdir) && autoheader --force
+
+# We need the following in order to create <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+gl/lib/getopt.h: gl/lib/getopt.hin
+ rm -f $@-t $@
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/gl/lib/getopt.hin; \
+ } > $@-t
+ mv -f $@-t $@
+
+# We need the following in order to create <stdbool.h> when the system
+# doesn't have one that works.
+gl/lib/stdbool.h: gl/lib/stdbool.hin
+ rm -f $@-t $@
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' \
+ < $(srcdir)/gl/lib/stdbool.hin; \
+ } > $@-t
+ mv $@-t $@
+
+LIBM4FILES = \
+ gl/m4/argmatch.m4 \
+ gl/m4/backupfile.m4 \
+ gl/m4/d-ino.m4 \
+ gl/m4/dirname.m4 \
+ gl/m4/dos.m4 \
+ gl/m4/double-slash-root.m4 \
+ gl/m4/error.m4 \
+ gl/m4/exitfail.m4 \
+ gl/m4/extensions.m4 \
+ gl/m4/getopt.m4 \
+ gl/m4/gettext.m4 \
+ gl/m4/hash.m4 \
+ gl/m4/inline.m4 \
+ gl/m4/malloc.m4 \
+ gl/m4/mbrtowc.m4 \
+ gl/m4/mbstate_t.m4 \
+ gl/m4/memchr.m4 \
+ gl/m4/minmax.m4 \
+ gl/m4/onceonly.m4 \
+ gl/m4/quotearg.m4 \
+ gl/m4/quote.m4 \
+ gl/m4/realloc.m4 \
+ gl/m4/rename.m4 \
+ gl/m4/safe-write.m4 \
+ gl/m4/ssize_t.m4 \
+ gl/m4/stdbool.m4 \
+ gl/m4/strcase.m4 \
+ gl/m4/strndup.m4 \
+ gl/m4/unlocked-io.m4 \
+ gl/m4/utimbuf.m4 \
+ gl/m4/xalloc.m4 \
+ gl/m4/xstrndup.m4
+
+M4FILES = $(LIBM4FILES) \
+ m4/mkdir.m4 \
+ m4/setmode.m4
+
+$(srcdir)/aclocal.m4: $(M4FILES)
+ aclocal -I m4 -I gl/m4
+
+TAGS: $(HDRS) $(SRCS)
+ etags $(HDRS) $(SRCS)
+
+mostlyclean::
+ rm -f core* *core src/*.$(OBJEXT) gl/lib/*.$(OBJEXT) \
+ gl/lib/stdbool.h gl/lib/getopt.h gl/lib/*.h-t
+
+clean:: mostlyclean
+ rm -f src/patch$(EXEEXT)
+
+distclean:: clean
+ rm -f Makefile config.cache config.hin~ config.log config.status \
+ config.h
+ rm -rf autom4te.cache/
+
+maintainer-clean::
+ @echo "This command is intended for maintainers to use;"
+ @echo "rebuilding the deleted files requires special tools."
+ $(MAKE) distclean
+ rm -f TAGS VERSION aclocal.m4 config.hin configure \
+ patch-*.tar.gz patch-*.tar.gz.sig
+
+PV = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
+
+dist:: $(DISTFILES)
+ @rm -rf $(PV)
+ @ln -s . $(PV)
+ @tar -cf - `( printf "%s\n" $(DISTFILES) $(MORE_DISTFILES); \
+ grep -q -E -- '-[0-9]+-[0-9a-z]+(-dirty)?$$' VERSION \
+ && echo README-alpha \
+ ) | sed -e 's,^$(srcdir)/,,' -e "s,^,$(PV)/," \
+ | LC_ALL=C sort` \
+ | gzip -9 > $(PV).tar.gz
+ @if which bzip2 >/dev/null 2>/dev/null; then \
+ gzip -d < $(PV).tar.gz | bzip2 -9 > $(PV).tar.bz2; fi
+ @if which xz >/dev/null 2>/dev/null; then \
+ gzip -d < $(PV).tar.gz | xz -9 > $(PV).tar.xz; fi
+ @rm -rf $(PV)
+ @whereto=$$(if grep -q -E -- '-[0-9]+-[0-9a-z]+(-dirty)?$$' VERSION; \
+ then echo alpha; else echo ftp; fi); \
+ echo; \
+ echo "# gnupload --to $$whereto.gnu.org:patch $(PV).tar.gz"; \
+ test ! -e $(PV).tar.bz2 || echo "# gnupload" \
+ "--to $$whereto.gnu.org:patch $(PV).tar.bz2"; \
+ test ! -e $(PV).tar.xz || echo "# gnupload" \
+ "--to $$whereto.gnu.org:patch $(PV).tar.xz"; \
+ echo
+
+$(OBJS): config.h
+COMMON = src/common.h $(STDBOOL_H)
+
+gl/lib/addext.$(OBJEXT): gl/lib/backupfile.h gl/lib/dirname.h
+gl/lib/argmatch.$(OBJEXT): gl/lib/argmatch.h gl/lib/gettext.h gl/lib/error.h \
+ gl/lib/quote.h gl/lib/quotearg.h gl/lib/unlocked-io.h
+gl/lib/backupfile.$(OBJEXT): gl/lib/argmatch.h gl/lib/backupfile.h \
+ gl/lib/dirname.h
+gl/lib/basename.$(OBJEXT): gl/lib/dirname.h
+gl/lib/dirname.$(OBJEXT): gl/lib/dirname.h gl/lib/xalloc.h
+gl/lib/error.$(OBJEXT): gl/lib/error.h gl/lib/gettext.h gl/lib/unlocked-io.h
+gl/lib/exitfail.$(OBJEXT): gl/lib/exitfail.h
+gl/lib/full-write.$(OBJEXT): gl/lib/full-write.h gl/lib/safe-write.h
+gl/lib/getopt.$(OBJEXT) gl/lib/getopt1.$(OBJEXT): gl/lib/getopt.h
+gl/lib/hash.$(OBJEXT): $(STDBOOL_H) gl/lib/hash.h
+gl/lib/safe-read.$(OBJEXT): gl/lib/safe-write.h
+gl/lib/safe-write.$(OBJEXT): gl/lib/safe-read.c
+
+src/inp.$(OBJEXT): gl/lib/backupfile.h $(COMMON) src/inp.h src/pch.h \
+ gl/lib/quotearg.h src/util.h gl/lib/xalloc.h
+src/maketime.$(OBJEXT): src/maketime.h src/partime.h
+src/partime.$(OBJEXT): src/partime.h
+src/patch.$(OBJEXT): gl/lib/argmatch.h gl/lib/backupfile.h $(COMMON) \
+ gl/lib/exitfail.h $(GETOPT_H) src/inp.h src/pch.h \
+ gl/lib/quotearg.h src/util.h src/version.h gl/lib/xalloc.h
+src/pch.$(OBJEXT): gl/lib/backupfile.h $(COMMON) gl/lib/dirname.h src/inp.h \
+ src/pch.h gl/lib/quotearg.h src/util.h
+gl/lib/quote.$(OBJECT): gl/lib/quote.h gl/lib/quotearg.h
+gl/lib/quotearg.$(OBJEXT): gl/lib/gettext.h gl/lib/quotearg.h gl/lib/xalloc.h
+src/quotesys.$(OBJEXT): src/quotesys.h
+gl/lib/strncasecmp.$(OBJEXT): gl/lib/strcasecmp.c
+src/util.$(OBJEXT): gl/lib/backupfile.h $(COMMON) gl/lib/dirname.h gl/lib/full-write.h \
+ gl/lib/hash.h src/maketime.h src/partime.h gl/lib/quotearg.h \
+ src/quotesys.h src/util.h src/version.h gl/lib/xalloc.h
+src/version.$(OBJEXT): $(COMMON) src/version.h
+gl/lib/xmalloc.$(OBJEXT): gl/lib/error.h gl/lib/exitfail.h gl/lib/gettext.h \
+ gl/lib/xalloc.h
--- /dev/null
+Changes in version 2.6:
+
+* A regression test suite has been added ("make check").
+* A --merge option has been added which will merge a patch file into
+ the original files similar to merge(1). See the patch(1) manual page for
+ documentation.
+* Unless a filename has been specified on the command line, look only
+ for filenames in the patch until one has been found. This prevents
+ patch from tripping over garbage that isn't a patch. When conforming
+ to POSIX, this behavior is turned off and patch will ask for a
+ filename if none is found.
+* All reject files have file name headers, which allows them to be used as
+ regular patches.
+* When a patch file modifies the same file more than once, patch makes
+ sure it backs up the original version of the file rather than any
+ intermediary versions.
+* In the above situation, if there are rejects in more than one of those
+ patches, they all go into the same reject file.
+* When the file to be patched is specified on the command line, all patches
+ are applied to that file. (Previously, the first patch was applied to the
+ file specified on the command line, and the names of additional files to
+ patch were taken from header lines in the patch file.)
+* The -r option now works correctly even if there are rejects in more than
+ one file. Use the - argument to discard rejects.
+* Rejected hunks come out in unified diff format if the input patch was of
+ that format, otherwise in ordinary context diff form. Use the
+ --reject-format option to enforce either "context" or "unified" format.
+ Timestamps and the "diff -p" (--show-c-function) output are preserved.
+ Changed lines in context format reject files are correctly indicated
+ with '!' markers as the format defines. Added and removed lines are
+ still marked with '+' and '-', respectively.
+* The file permissions of reject files are no longer set to match the files
+ they modify. Instead, they retain the default permissions. This is
+ consistent with reject files produced with the -r option.
+* The --binary option disables the heuristic for stripping CRs from
+ line endings in patches. This allows to preserve CRs even in mangled
+ patches, or in patches generated on non-POSIX systems and without the
+ --binary option.
+* Backup files for nonexisting files are now created with default
+ permissions rather than with mode 0: backup files with mode 0 were
+ causing problems with applications which do not expect unreadable
+ files.
+* The -B, -Y, and -z options (--prefix, --basename-prefix, --suffix) now
+ imply the simple version control mode, and can be combined.
+* Patch rejects more malformed normal format commands and checks for trailing
+ garbage. It now recognizes ed commands without addresses.
+* Change the default value of PATCH_GET to 0. (Previously, the default was 0
+ under POSIXLY_CORRECT and negative otherwise; this is causing problems
+ particularly with Perforce.)
+* Handle missing timestamps better.
+* Various bug fixes.
+
+Changes in versions 2.5.8 and 2.5.9: bug fixes only.
+
+Changes in version 2.5.7:
+
+* patch -D now outputs preprocessor lines without comments, as required
+ by POSIX 1003.1-2001.
+
+Changes in version 2.5.6:
+
+* File names in context patches may now contain spaces, so long
+ as the context patch headers use a tab to separate the file name
+ from the time stamp.
+* Perforce is now supported.
+* Patch lines beginning with "#" are comments and are ignored.
+
+Changes in version 2.5.5:
+
+* The bug reporting address is now <bug-patch@gnu.org>.
+
+Changes in version 2.5.4:
+
+* A security hole has been closed.
+ It involved race conditions with temporary files.
+
+* The default quoting style is 'shell', which causes `patch' to quote
+ file names with funny characters like `$'. This prevents their
+ misinterpretation if you cut them from its output and paste them into
+ the shell.
+
+* `patch' now works correctly with large files on Large File Summit
+ hosts like Solaris 2.6.
+
+* `patch' now ignores trailing carriage returns in lines of context diffs
+ if the context diff headers end in carriage return.
+
+* `patch' now ignores context diff header file names that have fewer slashes
+ than the count specified by the -p or --strip option.
+
+* New options:
+ --posix
+ --quoting-style=WORD
+
+* New environment variables:
+ QUOTING_STYLE
+
+* `patch' now supports ClearCase version management.
+
+Changes in version 2.5:
+
+* Version control is now independent of whether backups are made.
+ The -V or --version-control option and the VERSION_CONTROL and
+ PATCH_VERSION_CONTROL environment variables no longer affect whether
+ backups are made; they affect only the names of the backup files.
+
+* When asking the user whether to reverse a patch,
+ the default answer is now `no' instead of `yes'.
+
+* `patch' can now recognize context diffs that have been encapsulated
+ by prepending "- " to lines beginning with "-" (as per Internet RFC 934).
+
+* `patch' now reports an error if the input contains garbage and no patches.
+
+Changes in version 2.4:
+
+* New options:
+ -Z or --set-utc sets times of patched files, assuming diff uses UTC (GMT).
+ -T or --set-time is similar, assuming local time (not recommended).
+ --backup-if-mismatch makes a backup if the patch does not match exactly
+ --no-backup-if-mismatch makes a backup only if otherwise requested
+
+* The default is now --backup-if-mismatch unless POSIXLY_CORRECT is set.
+
+* The -B or --prefix, -Y or --basename-prefix, and -z or --suffix options
+ no longer affect whether backups are made (as they did in patch 2.2 and 2.3);
+ they now merely specify the file names used when simple backups are made.
+
+* When patching a nonexistent file and making backups, an empty backup file
+ is now made (just as with traditional patch); but the backup file is
+ unreadable, as a way of indicating that it represents a nonexistent file.
+
+* `patch' now matches against empty and nonexistent files more generously.
+ A patch against an empty file applies to a nonexistent file, and vice versa.
+
+* -g or --get and PATCH_GET now have a numeric value that specifies
+ whether `patch' is getting files.
+ If the value is positive, working files are gotten from RCS or SCCS files;
+ if zero, `patch' ignores RCS and SCCS and working files are not gotten;
+ and if negative, `patch' asks the user whether to get each file.
+ The default is normally negative, but it is zero if POSIXLY_CORRECT is set.
+
+* The -G or --no-get option introduced in GNU patch 2.3 has been removed;
+ use -g0 instead.
+
+* The method used to intuit names of files to be patched is changed again:
+ `Index:' lines are normally ignored for context diffs,
+ and RCS and SCCS files are normally looked for when files do not exist.
+ The complete new method is described in the man page.
+
+* By default, `patch' is now more verbose when patches do not match exactly.
+
+* The manual page has a new COMPATIBILITY ISSUES section.
+\f
+Changes in version 2.3:
+
+* Unless the POSIXLY_CORRECT environment variable is set:
+
+ - `patch' now distinguishes more accurately between empty and
+ nonexistent files if the input is a context diff.
+ A file is assumed to not exist if its context diff header
+ suggests that it is empty, and if the header timestamp
+ looks like it might be equivalent to 1970-01-01 00:00:00 UTC.
+ - Files that ``become nonexistent'' after patching are now removed.
+ When a file is removed, any empty ancestor directories are also removed.
+
+* Files are now automatically gotten from RCS and SCCS
+ if the -g or --get option is specified.
+ (The -G or --no-get option, also introduced in 2.3, was withdrawn in 2.4.)
+
+* If the PATCH_VERSION_CONTROL environment variable is set,
+ it overrides the VERSION_CONTROL environment variable.
+
+* The method used to intuit names of files to be patched is changed.
+ (It was further revised in 2.4; see above.)
+
+* The new --binary option makes `patch' read and write files in binary mode.
+ This option has no effect on POSIX-compliant hosts;
+ it is useful only in on operating systems like DOS
+ that distinguish between text and binary I/O.
+
+* The environment variables TMP and TEMP are consulted for the name of
+ the temporary directory if TMPDIR is not set.
+
+* A port to MS-DOS and MS-Windows is available; see the `pc' directory.
+
+* Backup file names are no longer ever computed by uppercasing characters,
+ since this isn't portable to systems with case-insensitive file names.
+\f
+Changes in version 2.2:
+
+* Arbitrary limits removed (e.g. line length, file name length).
+
+* On POSIX.1-compliant hosts, you can now patch binary files using the output
+ of GNU `diff -a'.
+
+* New options:
+ --dry-run
+ --help
+ --verbose
+ -i FILE or --input=FILE
+ -Y PREF or --basename-prefix=PREF
+
+* patch is now quieter by default; use --verbose for the old chatty behavior.
+
+* Patch now complies better with POSIX.2 if your host complies with POSIX.1.
+
+ Therefore:
+ - By default, no backups are made.
+ (But this was changed again in patch 2.4; see above.)
+ - The simple backup file name for F defaults to F.orig
+ regardless of whether the file system supports long file names,
+ and F~ is used only if F.orig is too long for that particular file.
+ - Similarly for the reject file names F.rej and F#.
+
+ Also:
+ - The pseudo-option `+' has been withdrawn.
+ - -b is equivalent to --version-control=simple;
+ `-z SUFF' has the meaning that `-b SUFF' used to.
+ - Names of files to be patched are taken first from *** line and then from
+ --- line of context diffs; then from Index: line; /dev/tty is
+ consulted if none of the above files exist. However, if the patch
+ appears to create a file, the file does not have to exist: instead,
+ the first name with the longest existing directory prefix is taken.
+ (These rules were changed again in patch 2.3 and 2.4; see above.)
+ - Exit status 0 means success, 1 means hunks were rejected, 2 means trouble.
+ - `-l' ignores changes only in spaces and tabs, not in other white space.
+ - If no `-p' option is given, `-pINFINITY' is assumed, instead of trying
+ to guess the proper value.
+ - `-p' now requires an operand; use `-p 0' to get the effect of the old plain
+ `-p' option.
+ - `-p' treats two or more adjacent slashes as if it were one slash.
+ - The TERM signal is caught.
+ - New option `-i F' reads patch from F instead of stdin.
+
+* The `patch' options and build procedure conform to current GNU standards.
+ For example, the `--version' option now outputs copyright information.
+
+* When the patch is creating a file, but a nonempty file of that name already
+ exists, `patch' now asks for confirmation before patching.
+
+* RCS is used only if the version control method is `existing'
+ and there is already an RCS file. Similarly for SCCS.
+ (But this was changed again in patch 2.3 and 2.4; see above.)
+
+* Copyright notices have been clarified. Every file in this version of `patch'
+ can be distributed under the GNU General Public License. See README for
+ details.
+\f
+Changes in version 2.1:
+
+* A few more portability bugs have been fixed. The version number has
+ been changed from 2.0.12g11 to 2.1, because the name
+ `patch-2.0.12g10' was too long for traditional Unix file systems.
+\f
+Versions 2.0.12g9 through 2.0.12g11 fix various portability bugs.
+\f
+Changes in version 2.0.12g8:
+
+* Start of the 12g series, with a GNU-style configure script and
+ long-named options.
+* Added the -t --batch option, similar to -f.
+* Improved detection of files that are locked under RCS or SCCS.
+* Reinstate the -E option to remove output files that are empty after
+ being patched.
+* Print the system error message when system calls fail.
+* Fixed various bugs and portability problems.
+
+\f
+
+Copyright (C) 1992, 1993, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2009
+Free Software Foundation, Inc.
+
+This file is part of GNU Patch.
+
+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 they 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; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
--- /dev/null
+This version of `patch' has many changes made by the Free Software Foundation.
+They add support for:
+ * handling arbitrary binary data and large files
+ * the unified context diff format that GNU diff can produce
+ * merging into files instead of creating reject files
+ * making GNU Emacs-style backup files
+ * improved interaction with RCS and SCCS
+ * the GNU conventions for option parsing and configuring and compilation.
+ * better POSIX compliance
+They also fix some bugs. See the NEWS and ChangeLog files for details.
+
+Tutorial-style documentation for patch is included in the GNU
+Diffutils package; get GNU Diffutils 2.8 or later for up-to-date
+documentation for patch.
+
+For GNU and Unix build and installation instructions, see the file INSTALL.
+Use `configure --disable-largefile' to disable large file support;
+this is reportedly necessary on Red Hat GNU/Linux 6.0 to avoid a C library bug.
+For MS-DOS using DJGPP tools, see the file pc/djgpp/README.
+For other systems, copy config.hin to config.h and change
+#undef statements in it to #define as appropriate for your system,
+and copy Makefile.in to Makefile and set the variables that are
+enclosed in @ signs as appropriate for your system.
+
+Please send bug reports for this version of patch to
+<bug-patch@gnu.org>.
+
+The Free Software Foundation is distributing this version of patch
+independently because as of this writing, Larry Wall has not released a
+new version of patch since mid-1988. We have heard that he has been
+too busy working on other things, like Perl. He has graciously agreed
+to let GNU `patch' be distributed under the terms of the GNU General
+Public License.
+
+------
+
+Copyright (C) 1984, 1985, 1986, 1987, 1988 Larry Wall
+
+Copyright (C) 1989, 1990, 1991, 1992, 1993, 1997, 1999, 2002, 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 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 file; see the file COPYING.
+If not, write to the Free Software Foundation,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--- /dev/null
+# generated automatically by aclocal 1.11 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_include([gl/m4/argmatch.m4])
+m4_include([gl/m4/backupfile.m4])
+m4_include([gl/m4/d-ino.m4])
+m4_include([gl/m4/dirname.m4])
+m4_include([gl/m4/dos.m4])
+m4_include([gl/m4/double-slash-root.m4])
+m4_include([gl/m4/error.m4])
+m4_include([gl/m4/exitfail.m4])
+m4_include([gl/m4/extensions.m4])
+m4_include([gl/m4/getopt.m4])
+m4_include([gl/m4/hash.m4])
+m4_include([gl/m4/inline.m4])
+m4_include([gl/m4/malloc.m4])
+m4_include([gl/m4/memchr.m4])
+m4_include([gl/m4/onceonly.m4])
+m4_include([gl/m4/quote.m4])
+m4_include([gl/m4/quotearg.m4])
+m4_include([gl/m4/realloc.m4])
+m4_include([gl/m4/safe-read.m4])
+m4_include([gl/m4/safe-write.m4])
+m4_include([gl/m4/ssize_t.m4])
+m4_include([gl/m4/stdbool.m4])
+m4_include([gl/m4/strcase.m4])
+m4_include([gl/m4/unlocked-io.m4])
+m4_include([gl/m4/utimbuf.m4])
+m4_include([gl/m4/xalloc.m4])
+m4_include([gl/m4/xstrndup.m4])
+m4_include([m4/mkdir.m4])
+m4_include([m4/setmode.m4])
--- /dev/null
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+
+timestamp='2009-02-03'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ eval $set_cc_for_build
+ SUN_ARCH="i386"
+ # If there is a compiler, see if it is configured for 64-bit objects.
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+ # This test works for both compilers.
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH="x86_64"
+ fi
+ fi
+ echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[456])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ *:Interix*:[3456]*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T | authenticamd | genuineintel)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ padre:Linux:*:*)
+ echo sparc-unknown-linux-gnu
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+ OS_REL='.3'
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
+ echo i586-pc-haiku
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+ i*86:AROS:*:*)
+ echo ${UNAME_MACHINE}-pc-aros
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null
+/* config.hin. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if the `closedir' function returns void instead of `int'. */
+#undef CLOSEDIR_VOID
+
+/* Define to 1 if // is a file system root distinct from /. */
+#undef DOUBLE_SLASH_IS_DISTINCT_ROOT
+
+/* Define if struct dirent has a member d_ino that actually works. */
+#undef D_INO_IN_DIRENT
+
+/* Define on systems for which file names may have a so-called `drive letter'
+ prefix, define this to compute the length of that prefix, including the
+ colon. */
+#undef FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
+
+/* Define if the backslash character may also serve as a file name component
+ separator. */
+#undef FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
+
+/* Define if a drive letter prefix denotes a relative path if it is not
+ followed by a file name component separator. */
+#undef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+
+/* Define to 1 if you have the <bp-sym.h> header file. */
+#undef HAVE_BP_SYM_H
+
+/* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_CLEARERR_UNLOCKED
+
+/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you
+ don't. */
+#undef HAVE_DECL_FEOF_UNLOCKED
+
+/* Define to 1 if you have the declaration of `ferror_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_FERROR_UNLOCKED
+
+/* Define to 1 if you have the declaration of `fflush_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_FFLUSH_UNLOCKED
+
+/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_FGETS_UNLOCKED
+
+/* Define to 1 if you have the declaration of `fputc_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_FPUTC_UNLOCKED
+
+/* Define to 1 if you have the declaration of `fputs_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_FPUTS_UNLOCKED
+
+/* Define to 1 if you have the declaration of `fread_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_FREAD_UNLOCKED
+
+/* Define to 1 if you have the declaration of `fwrite_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_FWRITE_UNLOCKED
+
+/* Define to 1 if you have the declaration of `getchar_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_GETCHAR_UNLOCKED
+
+/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you
+ don't. */
+#undef HAVE_DECL_GETC_UNLOCKED
+
+/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't.
+ */
+#undef HAVE_DECL_GETENV
+
+/* Define to 1 if you have the declaration of `mktemp', and to 0 if you don't.
+ */
+#undef HAVE_DECL_MKTEMP
+
+/* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if
+ you don't. */
+#undef HAVE_DECL_PUTCHAR_UNLOCKED
+
+/* Define to 1 if you have the declaration of `putc_unlocked', and to 0 if you
+ don't. */
+#undef HAVE_DECL_PUTC_UNLOCKED
+
+/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRERROR_R
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+#undef HAVE_DOPRNT
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#undef HAVE_FSEEKO
+
+/* Define to 1 if you have the `geteuid' function. */
+#undef HAVE_GETEUID
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long_only' function. */
+#undef HAVE_GETOPT_LONG_ONLY
+
+/* Define to 1 if you have the `getuid' function. */
+#undef HAVE_GETUID
+
+/* Define to 1 if the compiler supports one of the keywords 'inline',
+ '__inline__', '__inline' and effectively inlines functions marked as such.
+ */
+#undef HAVE_INLINE
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you support file names longer than 14 characters. */
+#undef HAVE_LONG_FILE_NAMES
+
+/* Define if the 'malloc' function is POSIX compliant. */
+#undef HAVE_MALLOC_POSIX
+
+/* Define to 1 if you have the `memchr' function. */
+#undef HAVE_MEMCHR
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `mkdir' function. */
+#undef HAVE_MKDIR
+
+/* Define to 1 if you have the `mktemp' function. */
+#undef HAVE_MKTEMP
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if you have the `pathconf' function. */
+#undef HAVE_PATHCONF
+
+/* Define to 1 if you have the `raise' function. */
+#undef HAVE_RAISE
+
+/* Define if the 'realloc' function is POSIX compliant. */
+#undef HAVE_REALLOC_POSIX
+
+/* Define to 1 if you have the DOS-style `setmode' function. */
+#undef HAVE_SETMODE_DOS
+
+/* Define to 1 if you have the `sigaction' function. */
+#undef HAVE_SIGACTION
+
+/* Define to 1 if you have the `sigprocmask' function. */
+#undef HAVE_SIGPROCMASK
+
+/* Define to 1 if you have the `sigsetmask' function. */
+#undef HAVE_SIGSETMASK
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#undef HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strerror_r' function. */
+#undef HAVE_STRERROR_R
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define if struct utimbuf is declared -- usually in <utime.h>. Some systems
+ have utime.h but don't declare the struct anywhere. */
+#undef HAVE_STRUCT_UTIMBUF
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
+
+/* Define to 1 if you have the `vprintf' function. */
+#undef HAVE_VPRINTF
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#else
+# define ISSLASH(C) ((C) == '/')
+#endif
+
+/* Define if mkdir takes only one argument. */
+#undef MKDIR_TAKES_ONE_ARG
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if strerror_r returns char *. */
+#undef STRERROR_R_CHAR_P
+
+/* Define to 1 if you want getc etc. to use unlocked I/O if available.
+ Unlocked I/O can improve performance in unithreaded apps, but it is not
+ safe for multithreaded apps. */
+#undef USE_UNLOCKED_IO
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#undef _LARGEFILE_SOURCE
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define to 500 only on HP-UX. */
+#undef _XOPEN_SOURCE
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Define to rpl_ if the getopt replacement functions and variables should be
+ used. */
+#undef __GETOPT_PREFIX
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
+/* Define to `long int' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define as a signed type of the same size as size_t. */
+#undef ssize_t
--- /dev/null
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+
+timestamp='2009-02-03'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | lm32 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep | metag \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k | z80)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64octeon-* | mips64octeonel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64r5900-* | mips64r5900el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-* | z80-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ os=-aros
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=-cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ os=-dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tile*)
+ basic_machine=tile-unknown
+ os=-linux-gnu
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ z80-*-coff)
+ basic_machine=z80-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -kopensolaris* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* | -aros* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -dicos*)
+ os=-dicos
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mep-*)
+ os=-elf
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.63 for patch 2.6.
+#
+# Report bugs to <bug-patch@gnu.org>.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+ if (eval ":") 2>/dev/null; then
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+
+ if test $as_have_required = yes && (eval ":
+(as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=\$LINENO
+ as_lineno_2=\$LINENO
+ test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+ test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+ :
+else
+ as_candidate_shells=
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ case $as_dir in
+ /*)
+ for as_base in sh bash ksh sh5; do
+ as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+ done;;
+ esac
+done
+IFS=$as_save_IFS
+
+
+ for as_shell in $as_candidate_shells $SHELL; do
+ # Try only shells that exist, to save several forks.
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+ CONFIG_SHELL=$as_shell
+ as_have_required=yes
+ if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+ (exit $1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+ break
+fi
+
+fi
+
+ done
+
+ if test "x$CONFIG_SHELL" != x; then
+ for as_var in BASH_ENV ENV
+ do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ done
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+ if test $as_have_required = no; then
+ echo This script requires a shell more modern than all the
+ echo shells that I found on your system. Please install a
+ echo modern shell, or manually run the script under such a
+ echo shell if you do have one.
+ { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+ echo No shell found that supports shell functions.
+ echo Please tell bug-autoconf@gnu.org about your system,
+ echo including any error possibly output before this message.
+ echo This can help us improve future autoconf versions.
+ echo Configuration will now proceed without shell functions.
+}
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -p'
+ fi
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+exec 7<&0 </dev/null 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Identity of this package.
+PACKAGE_NAME='patch'
+PACKAGE_TARNAME='patch'
+PACKAGE_VERSION='2.6'
+PACKAGE_STRING='patch 2.6'
+PACKAGE_BUGREPORT='bug-patch@gnu.org'
+
+ac_unique_file="src/patch.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+gl_header_list=
+gl_func_list=
+ac_subst_vars='LTLIBOBJS
+ENABLE_MERGE
+HAVE_REALLOC_POSIX
+HAVE_MALLOC_POSIX
+GETOPT_H
+LIBOBJS
+HAVE__BOOL
+STDBOOL_H
+EGREP
+GREP
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+TEST_SHELL
+ed_PROGRAM
+SET_MAKE
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+CPP
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_largefile
+enable_merge
+'
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { $as_echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { $as_echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+ fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
+ { (exit 1); exit 1; }; } ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; }
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ { $as_echo "$as_me: error: working directory cannot be determined" >&2
+ { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
+ { (exit 1); exit 1; }; }
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
+ { (exit 1); exit 1; }; }
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures patch 2.6 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/patch]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of patch 2.6:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --disable-largefile omit support for large files
+ --disable-merge disable support for merging
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <bug-patch@gnu.org>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+patch configure 2.6
+generated by GNU Autoconf 2.63
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by patch $as_me 2.6, which was
+generated by GNU Autoconf 2.63. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test -r "$ac_site_file"; then
+ { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+gl_header_list="$gl_header_list sys/time.h"
+gl_header_list="$gl_header_list utime.h"
+gl_func_list="$gl_func_list pathconf"
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_config_headers="$ac_config_headers config.h:config.hin"
+
+test "$program_prefix" != NONE &&
+ program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compiler --version >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compiler -v >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compiler -V >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+if test -z "$ac_file"; then
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_compiler_gnu=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ CFLAGS=""
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_c89=$ac_arg
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
+$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ rm -rf conftest.one conftest.two conftest.dir
+ echo one > conftest.one
+ echo two > conftest.two
+ mkdir conftest.dir
+ if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+ test -s conftest.one && test -s conftest.two &&
+ test -s conftest.dir/conftest.one &&
+ test -s conftest.dir/conftest.two
+ then
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+
+done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ INSTALL=$ac_install_sh
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+ @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+ *@@@%%%=?*=@@@%%%*)
+ eval ac_cv_prog_make_${ac_make}_set=yes;;
+ *)
+ eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+ { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+ SET_MAKE=
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+# Use ed_PROGRAM, not ED_PROGRAM,
+# because <errno.h> reserves symbols starting with `E'.
+# Extract the first word of "ed", so it can be a program name with args.
+set dummy ed; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ed_PROGRAM+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ case $ed_PROGRAM in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_ed_PROGRAM="$ed_PROGRAM" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_ed_PROGRAM="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_ed_PROGRAM" && ac_cv_path_ed_PROGRAM="ed"
+ ;;
+esac
+fi
+ed_PROGRAM=$ac_cv_path_ed_PROGRAM
+if test -n "$ed_PROGRAM"; then
+ { $as_echo "$as_me:$LINENO: result: $ed_PROGRAM" >&5
+$as_echo "$ed_PROGRAM" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+# Extract the first word of "bash sh", so it can be a program name with args.
+set dummy bash sh; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_TEST_SHELL+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ case $TEST_SHELL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_TEST_SHELL="$TEST_SHELL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_TEST_SHELL="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+TEST_SHELL=$ac_cv_path_TEST_SHELL
+if test -n "$TEST_SHELL"; then
+ { $as_echo "$as_me:$LINENO: result: $TEST_SHELL" >&5
+$as_echo "$TEST_SHELL" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+{ $as_echo "$as_me:$LINENO: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+$as_echo "$as_me: error: invalid value of canonical build" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:$LINENO: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+$as_echo "$as_me: error: invalid value of canonical host" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_header_stdc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ eval "$as_ac_Header=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+ if test "${ac_cv_header_minix_config_h+set}" = set; then
+ { $as_echo "$as_me:$LINENO: checking for minix/config.h" >&5
+$as_echo_n "checking for minix/config.h... " >&6; }
+if test "${ac_cv_header_minix_config_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5
+$as_echo "$ac_cv_header_minix_config_h" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking minix/config.h usability" >&5
+$as_echo_n "checking minix/config.h usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <minix/config.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking minix/config.h presence" >&5
+$as_echo_n "checking minix/config.h presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <minix/config.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: minix/config.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: minix/config.h: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: minix/config.h: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: minix/config.h: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: minix/config.h: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to bug-patch@gnu.org ##
+## -------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for minix/config.h" >&5
+$as_echo_n "checking for minix/config.h... " >&6; }
+if test "${ac_cv_header_minix_config_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_header_minix_config_h=$ac_header_preproc
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5
+$as_echo "$ac_cv_header_minix_config_h" >&6; }
+
+fi
+if test "x$ac_cv_header_minix_config_h" = x""yes; then
+ MINIX=yes
+else
+ MINIX=
+fi
+
+
+ if test "$MINIX" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define _POSIX_SOURCE 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define _POSIX_1_SOURCE 2
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define _MINIX 1
+_ACEOF
+
+ fi
+
+ case "$host_os" in
+ hpux*)
+
+cat >>confdefs.h <<\_ACEOF
+#define _XOPEN_SOURCE 500
+_ACEOF
+
+ ;;
+ esac
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether it is safe to define __EXTENSIONS__" >&5
+$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
+if test "${ac_cv_safe_to_define___extensions__+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+# define __EXTENSIONS__ 1
+ $ac_includes_default
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_safe_to_define___extensions__=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_safe_to_define___extensions__=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_safe_to_define___extensions__" >&5
+$as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
+ test $ac_cv_safe_to_define___extensions__ = yes &&
+ cat >>confdefs.h <<\_ACEOF
+#define __EXTENSIONS__ 1
+_ACEOF
+
+ cat >>confdefs.h <<\_ACEOF
+#define _ALL_SOURCE 1
+_ACEOF
+
+ cat >>confdefs.h <<\_ACEOF
+#define _GNU_SOURCE 1
+_ACEOF
+
+ cat >>confdefs.h <<\_ACEOF
+#define _POSIX_PTHREAD_SEMANTICS 1
+_ACEOF
+
+ cat >>confdefs.h <<\_ACEOF
+#define _TANDEM_SOURCE 1
+_ACEOF
+
+
+
+
+
+
+
+ case $ac_cv_prog_cc_stdc in
+ no) ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;;
+ *) { $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C99" >&5
+$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
+if test "${ac_cv_prog_cc_c99+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <stdio.h>
+
+// Check varargs macros. These examples are taken from C99 6.10.3.5.
+#define debug(...) fprintf (stderr, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+ int x = 1234;
+ int y = 5678;
+ debug ("Flag");
+ debug ("X = %d\n", x);
+ showlist (The first, second, and third items.);
+ report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+ your preprocessor is broken;
+#endif
+#if BIG_OK
+#else
+ your preprocessor is broken;
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+ int datasize;
+ double data[];
+};
+
+struct named_init {
+ int number;
+ const wchar_t *name;
+ double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+ // See if C++-style comments work.
+ // Iterate through items via the restricted pointer.
+ // Also check for declarations in for loops.
+ for (unsigned int i = 0; *(text+i) != '\0'; ++i)
+ continue;
+ return 0;
+}
+
+// Check varargs and va_copy.
+static void
+test_varargs (const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ va_list args_copy;
+ va_copy (args_copy, args);
+
+ const char *str;
+ int number;
+ float fnumber;
+
+ while (*format)
+ {
+ switch (*format++)
+ {
+ case 's': // string
+ str = va_arg (args_copy, const char *);
+ break;
+ case 'd': // int
+ number = va_arg (args_copy, int);
+ break;
+ case 'f': // float
+ fnumber = va_arg (args_copy, double);
+ break;
+ default:
+ break;
+ }
+ }
+ va_end (args_copy);
+ va_end (args);
+}
+
+int
+main ()
+{
+
+ // Check bool.
+ _Bool success = false;
+
+ // Check restrict.
+ if (test_restrict ("String literal") == 0)
+ success = true;
+ char *restrict newvar = "Another string";
+
+ // Check varargs.
+ test_varargs ("s, d' f .", "string", 65, 34.234);
+ test_varargs_macros ();
+
+ // Check flexible array members.
+ struct incomplete_array *ia =
+ malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+ ia->datasize = 10;
+ for (int i = 0; i < ia->datasize; ++i)
+ ia->data[i] = i * 1.234;
+
+ // Check named initializers.
+ struct named_init ni = {
+ .number = 34,
+ .name = L"Test wide string",
+ .average = 543.34343,
+ };
+
+ ni.number = 58;
+
+ int dynamic_array[ni.number];
+ dynamic_array[ni.number - 1] = 543;
+
+ // work around unused variable warnings
+ return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
+ || dynamic_array[ni.number - 1] != 543);
+
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_c99=$ac_arg
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c99" in
+ x)
+ { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c99"
+ { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c99" >&5
+$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c99" != xno; then
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+else
+ { $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_c89=$ac_arg
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+else
+ ac_cv_prog_cc_stdc=no
+fi
+
+
+fi
+
+ ;;
+esac
+ { $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO Standard C" >&5
+$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; }
+ if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ $as_echo_n "(cached) " >&6
+fi
+
+ case $ac_cv_prog_cc_stdc in
+ no) { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ '') { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ *) { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;;
+esac
+
+
+# Check whether --enable-largefile was given.
+if test "${enable_largefile+set}" = set; then
+ enableval=$enable_largefile;
+fi
+
+if test "$enable_largefile" != no; then
+
+ { $as_echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
+$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
+if test "${ac_cv_sys_largefile_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_sys_largefile_CC=no
+ if test "$GCC" != yes; then
+ ac_save_CC=$CC
+ while :; do
+ # IRIX 6.2 and later do not support large files by default,
+ # so use the C compiler's -n32 option if that helps.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ CC="$CC -n32"
+ rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_sys_largefile_CC=' -n32'; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ break
+ done
+ CC=$ac_save_CC
+ rm -f conftest.$ac_ext
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
+$as_echo "$ac_cv_sys_largefile_CC" >&6; }
+ if test "$ac_cv_sys_largefile_CC" != no; then
+ CC=$CC$ac_cv_sys_largefile_CC
+ fi
+
+ { $as_echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
+if test "${ac_cv_sys_file_offset_bits+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_sys_file_offset_bits=no; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_sys_file_offset_bits=64; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cv_sys_file_offset_bits=unknown
+ break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
+$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
+case $ac_cv_sys_file_offset_bits in #(
+ no | unknown) ;;
+ *)
+cat >>confdefs.h <<_ACEOF
+#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
+_ACEOF
+;;
+esac
+rm -rf conftest*
+ if test $ac_cv_sys_file_offset_bits = unknown; then
+ { $as_echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
+$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
+if test "${ac_cv_sys_large_files+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_sys_large_files=no; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#define _LARGE_FILES 1
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_sys_large_files=1; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cv_sys_large_files=unknown
+ break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
+$as_echo "$ac_cv_sys_large_files" >&6; }
+case $ac_cv_sys_large_files in #(
+ no | unknown) ;;
+ *)
+cat >>confdefs.h <<_ACEOF
+#define _LARGE_FILES $ac_cv_sys_large_files
+_ACEOF
+;;
+esac
+rm -rf conftest*
+ fi
+fi
+
+
+
+{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_header_stdc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+
+
+for ac_header in fcntl.h utime.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to bug-patch@gnu.org ##
+## -------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+{ $as_echo "$as_me:$LINENO: checking for mode_t" >&5
+$as_echo_n "checking for mode_t... " >&6; }
+if test "${ac_cv_type_mode_t+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_type_mode_t=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof (mode_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof ((mode_t)))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_mode_t=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
+$as_echo "$ac_cv_type_mode_t" >&6; }
+if test "x$ac_cv_type_mode_t" = x""yes; then
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define mode_t int
+_ACEOF
+
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for off_t" >&5
+$as_echo_n "checking for off_t... " >&6; }
+if test "${ac_cv_type_off_t+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_type_off_t=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof (off_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof ((off_t)))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_off_t=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
+$as_echo "$ac_cv_type_off_t" >&6; }
+if test "x$ac_cv_type_off_t" = x""yes; then
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define off_t long int
+_ACEOF
+
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5
+$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
+if test "${ac_cv_header_stdbool_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ #include <stdbool.h>
+ #ifndef bool
+ "error: bool is not defined"
+ #endif
+ #ifndef false
+ "error: false is not defined"
+ #endif
+ #if false
+ "error: false is not 0"
+ #endif
+ #ifndef true
+ "error: true is not defined"
+ #endif
+ #if true != 1
+ "error: true is not 1"
+ #endif
+ #ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+ #endif
+
+ struct s { _Bool s: 1; _Bool t; } s;
+
+ char a[true == 1 ? 1 : -1];
+ char b[false == 0 ? 1 : -1];
+ char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+ char d[(bool) 0.5 == true ? 1 : -1];
+ bool e = &s;
+ char f[(_Bool) 0.0 == false ? 1 : -1];
+ char g[true];
+ char h[sizeof (_Bool)];
+ char i[sizeof s.t];
+ enum { j = false, k = true, l = false * true, m = true * 256 };
+ _Bool n[m];
+ char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+ char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+ #if defined __xlc__ || defined __GNUC__
+ /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+ reported by James Lemley on 2005-10-05; see
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+ This test is not quite right, since xlc is allowed to
+ reject this program, as the initializer for xlcbug is
+ not one of the forms that C requires support for.
+ However, doing the test right would require a run-time
+ test, and that would make cross-compilation harder.
+ Let us hope that IBM fixes the xlc bug, and also adds
+ support for this kind of constant expression. In the
+ meantime, this test will reject xlc, which is OK, since
+ our stdbool.h substitute should suffice. We also test
+ this with GCC, where it should work, to detect more
+ quickly whether someone messes up the test in the
+ future. */
+ char digs[] = "0123456789";
+ int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+ #endif
+ /* Catch a bug in an HP-UX C compiler. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ */
+ _Bool q = true;
+ _Bool *pq = &q;
+
+int
+main ()
+{
+
+ *pq |= q;
+ *pq |= ! q;
+ /* Refer to every declared value, to avoid compiler optimizations. */
+ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ + !m + !n + !o + !p + !q + !pq);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_header_stdbool_h=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_header_stdbool_h=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5
+$as_echo "$ac_cv_header_stdbool_h" >&6; }
+ { $as_echo "$as_me:$LINENO: checking for _Bool" >&5
+$as_echo_n "checking for _Bool... " >&6; }
+if test "${ac_cv_type__Bool+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_type__Bool=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof (_Bool))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof ((_Bool)))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type__Bool=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
+$as_echo "$ac_cv_type__Bool" >&6; }
+if test "x$ac_cv_type__Bool" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__BOOL 1
+_ACEOF
+
+
+fi
+
+ if test $ac_cv_header_stdbool_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_STDBOOL_H 1
+_ACEOF
+
+ fi
+
+
+
+ # Define two additional variables used in the Makefile substitution.
+
+ if test "$ac_cv_header_stdbool_h" = yes; then
+ STDBOOL_H=''
+ else
+ STDBOOL_H='stdbool.h'
+ fi
+
+
+ if test "$ac_cv_type__Bool" = yes; then
+ HAVE__BOOL=1
+ else
+ HAVE__BOOL=0
+ fi
+
+
+
+
+
+
+
+for ac_header in $gl_header_list
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to bug-patch@gnu.org ##
+## -------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking for struct utimbuf" >&5
+$as_echo_n "checking for struct utimbuf... " >&6; }
+if test "${gl_cv_sys_struct_utimbuf+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#if HAVE_SYS_TIME_H
+ #include <sys/time.h>
+ #endif
+ #include <time.h>
+ #ifdef HAVE_UTIME_H
+ #include <utime.h>
+ #endif
+
+int
+main ()
+{
+static struct utimbuf x; x.actime = x.modtime;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ gl_cv_sys_struct_utimbuf=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ gl_cv_sys_struct_utimbuf=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $gl_cv_sys_struct_utimbuf" >&5
+$as_echo "$gl_cv_sys_struct_utimbuf" >&6; }
+
+ if test $gl_cv_sys_struct_utimbuf = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_STRUCT_UTIMBUF 1
+_ACEOF
+
+ fi
+
+
+
+ case " $LIBOBJS " in
+ *" argmatch.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS argmatch.$ac_objext"
+ ;;
+esac
+
+
+{ $as_echo "$as_me:$LINENO: checking for d_ino member in directory struct" >&5
+$as_echo_n "checking for d_ino member in directory struct... " >&6; }
+if test "${gl_cv_struct_dirent_d_ino+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then
+ gl_cv_struct_dirent_d_ino=no
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <dirent.h>
+
+int
+main ()
+{
+DIR *dp = opendir (".");
+ struct dirent *e;
+ struct stat st;
+ if (! dp)
+ return 1;
+ e = readdir (dp);
+ return ! (e
+ && stat (e->d_name, &st) == 0
+ && e->d_ino == st.st_ino);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ gl_cv_struct_dirent_d_ino=yes
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+gl_cv_struct_dirent_d_ino=no
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $gl_cv_struct_dirent_d_ino" >&5
+$as_echo "$gl_cv_struct_dirent_d_ino" >&6; }
+ if test $gl_cv_struct_dirent_d_ino = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define D_INO_IN_DIRENT 1
+_ACEOF
+
+ fi
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether system is Windows or MSDOS" >&5
+$as_echo_n "checking whether system is Windows or MSDOS... " >&6; }
+if test "${ac_cv_win_or_dos+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
+neither MSDOS nor Windows
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_win_or_dos=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_win_or_dos=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_win_or_dos" >&5
+$as_echo "$ac_cv_win_or_dos" >&6; }
+
+ if test x"$ac_cv_win_or_dos" = xyes; then
+ ac_fs_accepts_drive_letter_prefix=1
+ ac_fs_backslash_is_file_name_separator=1
+ { $as_echo "$as_me:$LINENO: checking whether drive letter can start relative path" >&5
+$as_echo_n "checking whether drive letter can start relative path... " >&6; }
+if test "${ac_cv_drive_letter_can_be_relative+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#if defined __CYGWIN__
+drive letters are always absolute
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_drive_letter_can_be_relative=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_drive_letter_can_be_relative=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_drive_letter_can_be_relative" >&5
+$as_echo "$ac_cv_drive_letter_can_be_relative" >&6; }
+ if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
+ ac_fs_drive_letter_can_be_relative=1
+ else
+ ac_fs_drive_letter_can_be_relative=0
+ fi
+ else
+ ac_fs_accepts_drive_letter_prefix=0
+ ac_fs_backslash_is_file_name_separator=0
+ ac_fs_drive_letter_can_be_relative=0
+ fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX $ac_fs_accepts_drive_letter_prefix
+_ACEOF
+
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR $ac_fs_backslash_is_file_name_separator
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE $ac_fs_drive_letter_can_be_relative
+_ACEOF
+
+
+{ $as_echo "$as_me:$LINENO: checking for long file names" >&5
+$as_echo_n "checking for long file names... " >&6; }
+if test "${ac_cv_sys_long_file_names+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_sys_long_file_names=yes
+# Test for long file names in all the places we know might matter:
+# . the current directory, where building will happen
+# $prefix/lib where we will be installing things
+# $exec_prefix/lib likewise
+# $TMPDIR if set, where it might want to write temporary files
+# /tmp where it might want to write temporary files
+# /var/tmp likewise
+# /usr/tmp likewise
+for ac_dir in . "$TMPDIR" /tmp /var/tmp /usr/tmp "$prefix/lib" "$exec_prefix/lib"; do
+ # Skip $TMPDIR if it is empty or bogus, and skip $exec_prefix/lib
+ # in the usual case where exec_prefix is '${prefix}'.
+ case $ac_dir in #(
+ . | /* | ?:[\\/]*) ;; #(
+ *) continue;;
+ esac
+ test -w "$ac_dir/." || continue # It is less confusing to not echo anything here.
+ ac_xdir=$ac_dir/cf$$
+ (umask 077 && mkdir "$ac_xdir" 2>/dev/null) || continue
+ ac_tf1=$ac_xdir/conftest9012345
+ ac_tf2=$ac_xdir/conftest9012346
+ touch "$ac_tf1" 2>/dev/null && test -f "$ac_tf1" && test ! -f "$ac_tf2" ||
+ ac_cv_sys_long_file_names=no
+ rm -f -r "$ac_xdir" 2>/dev/null
+ test $ac_cv_sys_long_file_names = no && break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_long_file_names" >&5
+$as_echo "$ac_cv_sys_long_file_names" >&6; }
+if test $ac_cv_sys_long_file_names = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LONG_FILE_NAMES 1
+_ACEOF
+
+fi
+
+
+
+
+
+
+for ac_func in $gl_func_list
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+
+
+
+
+ case " $LIBOBJS " in
+ *" backupfile.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS backupfile.$ac_objext"
+ ;;
+esac
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether // is distinct from /" >&5
+$as_echo_n "checking whether // is distinct from /... " >&6; }
+if test "${gl_cv_double_slash_root+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test x"$cross_compiling" = xyes ; then
+ # When cross-compiling, there is no way to tell whether // is special
+ # short of a list of hosts. However, the only known hosts to date
+ # that have a distinct // are Apollo DomainOS (too old to port to),
+ # Cygwin, and z/OS. If anyone knows of another system for which // has
+ # special semantics and is distinct from /, please report it to
+ # <bug-gnulib@gnu.org>.
+ case $host in
+ *-cygwin | i370-ibm-openedition)
+ gl_cv_double_slash_root=yes ;;
+ *)
+ # Be optimistic and assume that / and // are the same when we
+ # don't know.
+ gl_cv_double_slash_root='unknown, assuming no' ;;
+ esac
+ else
+ set x `ls -di / // 2>/dev/null`
+ if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then
+ gl_cv_double_slash_root=no
+ else
+ gl_cv_double_slash_root=yes
+ fi
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $gl_cv_double_slash_root" >&5
+$as_echo "$gl_cv_double_slash_root" >&6; }
+ if test "$gl_cv_double_slash_root" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define DOUBLE_SLASH_IS_DISTINCT_ROOT 1
+_ACEOF
+
+ fi
+
+
+ case " $LIBOBJS " in
+ *" basename.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS basename.$ac_objext"
+ ;;
+esac
+
+ case " $LIBOBJS " in
+ *" dirname.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS dirname.$ac_objext"
+ ;;
+esac
+
+ case " $LIBOBJS " in
+ *" stripslash.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS stripslash.$ac_objext"
+ ;;
+esac
+
+
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking whether strerror_r is declared" >&5
+$as_echo_n "checking whether strerror_r is declared... " >&6; }
+if test "${ac_cv_have_decl_strerror_r+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef strerror_r
+ (void) strerror_r;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_strerror_r=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_strerror_r=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_strerror_r" >&5
+$as_echo "$ac_cv_have_decl_strerror_r" >&6; }
+if test "x$ac_cv_have_decl_strerror_r" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRERROR_R 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRERROR_R 0
+_ACEOF
+
+
+fi
+
+
+
+for ac_func in strerror_r
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+{ $as_echo "$as_me:$LINENO: checking whether strerror_r returns char *" >&5
+$as_echo_n "checking whether strerror_r returns char *... " >&6; }
+if test "${ac_cv_func_strerror_r_char_p+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_cv_func_strerror_r_char_p=no
+ if test $ac_cv_have_decl_strerror_r = yes; then
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+
+ char buf[100];
+ char x = *strerror_r (0, buf, sizeof buf);
+ char *p = strerror_r (0, buf, sizeof buf);
+ return !p || x;
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_func_strerror_r_char_p=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ else
+ # strerror_r is not declared. Choose between
+ # systems that have relatively inaccessible declarations for the
+ # function. BeOS and DEC UNIX 4.0 fall in this category, but the
+ # former has a strerror_r that returns char*, while the latter
+ # has a strerror_r that returns `int'.
+ # This test should segfault on the DEC system.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+ extern char *strerror_r ();
+int
+main ()
+{
+char buf[100];
+ char x = *strerror_r (0, buf, sizeof buf);
+ return ! isalpha (x);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_strerror_r_char_p=yes
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+ fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_strerror_r_char_p" >&5
+$as_echo "$ac_cv_func_strerror_r_char_p" >&6; }
+if test $ac_cv_func_strerror_r_char_p = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STRERROR_R_CHAR_P 1
+_ACEOF
+
+fi
+
+
+ { $as_echo "$as_me:$LINENO: checking for error_at_line" >&5
+$as_echo_n "checking for error_at_line... " >&6; }
+if test "${ac_cv_lib_error_at_line+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <error.h>
+int
+main ()
+{
+error_at_line (0, 0, "", 0, "an error occurred");
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_lib_error_at_line=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_error_at_line=no
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_error_at_line" >&5
+$as_echo "$ac_cv_lib_error_at_line" >&6; }
+if test $ac_cv_lib_error_at_line = no; then
+ case " $LIBOBJS " in
+ *" error.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS error.$ac_objext"
+ ;;
+esac
+
+fi
+
+
+
+ :
+
+
+
+ case " $LIBOBJS " in
+ *" exitfail.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS exitfail.$ac_objext"
+ ;;
+esac
+
+
+ :
+
+
+
+for ac_func in memchr
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ case " $LIBOBJS " in
+ *" $ac_func.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+ if test $ac_cv_func_memchr = no; then
+
+
+for ac_header in bp-sym.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to bug-patch@gnu.org ##
+## -------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+ fi
+
+
+ if test -z "$GETOPT_H"; then
+
+for ac_header in getopt.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to bug-patch@gnu.org ##
+## -------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ GETOPT_H=getopt.h
+fi
+
+done
+
+ fi
+
+ if test -z "$GETOPT_H"; then
+
+for ac_func in getopt_long_only
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ GETOPT_H=getopt.h
+fi
+done
+
+ fi
+
+ if test -z "$GETOPT_H"; then
+ { $as_echo "$as_me:$LINENO: checking whether optreset is declared" >&5
+$as_echo_n "checking whether optreset is declared... " >&6; }
+if test "${ac_cv_have_decl_optreset+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <getopt.h>
+
+int
+main ()
+{
+#ifndef optreset
+ (void) optreset;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_optreset=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_optreset=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_optreset" >&5
+$as_echo "$ac_cv_have_decl_optreset" >&6; }
+if test "x$ac_cv_have_decl_optreset" = x""yes; then
+ GETOPT_H=getopt.h
+fi
+
+ fi
+
+ if test -z "$GETOPT_H"; then
+ { $as_echo "$as_me:$LINENO: checking for working GNU getopt function" >&5
+$as_echo_n "checking for working GNU getopt function... " >&6; }
+if test "${gl_cv_func_gnu_getopt+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then
+ { $as_echo "$as_me:$LINENO: checking whether getopt_clip is declared" >&5
+$as_echo_n "checking whether getopt_clip is declared... " >&6; }
+if test "${ac_cv_have_decl_getopt_clip+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <getopt.h>
+
+int
+main ()
+{
+#ifndef getopt_clip
+ (void) getopt_clip;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_getopt_clip=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_getopt_clip=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_getopt_clip" >&5
+$as_echo "$ac_cv_have_decl_getopt_clip" >&6; }
+if test "x$ac_cv_have_decl_getopt_clip" = x""yes; then
+ gl_cv_func_gnu_getopt=no
+else
+ gl_cv_func_gnu_getopt=yes
+fi
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <getopt.h>
+int
+main ()
+{
+
+ char *myargv[3];
+ myargv[0] = "conftest";
+ myargv[1] = "-+";
+ myargv[2] = 0;
+ return getopt (2, myargv, "+a") != '?';
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ gl_cv_func_gnu_getopt=yes
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+gl_cv_func_gnu_getopt=no
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $gl_cv_func_gnu_getopt" >&5
+$as_echo "$gl_cv_func_gnu_getopt" >&6; }
+ if test "$gl_cv_func_gnu_getopt" = "no"; then
+ GETOPT_H=getopt.h
+ fi
+ fi
+
+
+ { $as_echo "$as_me:$LINENO: checking whether getenv is declared" >&5
+$as_echo_n "checking whether getenv is declared... " >&6; }
+if test "${ac_cv_have_decl_getenv+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef getenv
+ (void) getenv;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_getenv=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_getenv=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_getenv" >&5
+$as_echo "$ac_cv_have_decl_getenv" >&6; }
+if test "x$ac_cv_have_decl_getenv" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETENV 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETENV 0
+_ACEOF
+
+
+fi
+
+
+
+
+
+ if test -n "$GETOPT_H"; then
+
+ case " $LIBOBJS " in
+ *" getopt.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getopt.$ac_objext"
+ ;;
+esac
+
+ case " $LIBOBJS " in
+ *" getopt1.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getopt1.$ac_objext"
+ ;;
+esac
+
+
+ GETOPT_H=getopt.h
+
+cat >>confdefs.h <<\_ACEOF
+#define __GETOPT_PREFIX rpl_
+_ACEOF
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+fi
+
+
+
+ case " $LIBOBJS " in
+ *" hash.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS hash.$ac_objext"
+ ;;
+esac
+
+
+
+
+
+ :
+
+
+ case " $LIBOBJS " in
+ *" quote.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS quote.$ac_objext"
+ ;;
+esac
+
+
+
+
+ case " $LIBOBJS " in
+ *" quotearg.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS quotearg.$ac_objext"
+ ;;
+esac
+
+
+
+ { $as_echo "$as_me:$LINENO: checking for ssize_t" >&5
+$as_echo_n "checking for ssize_t... " >&6; }
+if test "${gt_cv_ssize_t+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+int
+main ()
+{
+int x = sizeof (ssize_t *) + sizeof (ssize_t);
+ return !x;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ gt_cv_ssize_t=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ gt_cv_ssize_t=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $gt_cv_ssize_t" >&5
+$as_echo "$gt_cv_ssize_t" >&6; }
+ if test $gt_cv_ssize_t = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define ssize_t int
+_ACEOF
+
+ fi
+
+
+ case " $LIBOBJS " in
+ *" safe-write.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS safe-write.$ac_objext"
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+for ac_func in strcasecmp
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ case " $LIBOBJS " in
+ *" $ac_func.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+ if test $ac_cv_func_strcasecmp = no; then
+
+ :
+
+ fi
+
+
+
+for ac_func in strncasecmp
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ case " $LIBOBJS " in
+ *" $ac_func.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+ if test $ac_cv_func_strncasecmp = no; then
+
+ :
+
+ fi
+
+
+{ $as_echo "$as_me:$LINENO: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if test "${ac_cv_c_inline+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_c_inline=$ac_kw
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+
+case $ac_cv_c_inline in
+ inline | yes) ;;
+ *)
+ case $ac_cv_c_inline in
+ no) ac_val=;;
+ *) ac_val=$ac_cv_c_inline;;
+ esac
+ cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+ ;;
+esac
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether the compiler generally respects inline" >&5
+$as_echo_n "checking whether the compiler generally respects inline... " >&6; }
+if test "${gl_cv_c_inline_effective+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test $ac_cv_c_inline = no; then
+ gl_cv_c_inline_effective=no
+ else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifdef __NO_INLINE__
+ #error "inline is not effective"
+ #endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ gl_cv_c_inline_effective=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ gl_cv_c_inline_effective=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $gl_cv_c_inline_effective" >&5
+$as_echo "$gl_cv_c_inline_effective" >&6; }
+ if test $gl_cv_c_inline_effective = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INLINE 1
+_ACEOF
+
+ fi
+
+
+ case " $LIBOBJS " in
+ *" xmalloc.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS xmalloc.$ac_objext"
+ ;;
+esac
+
+
+
+
+ :
+
+
+ :
+
+
+
+
+ :
+
+
+
+case " $LIBOBJS " in
+ *" xstrndup.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS xstrndup.$ac_objext"
+ ;;
+esac
+
+
+case " $LIBOBJS " in
+ *" error.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS error.$ac_objext"
+ ;;
+esac
+
+
+{ $as_echo "$as_me:$LINENO: checking whether mktemp is declared" >&5
+$as_echo_n "checking whether mktemp is declared... " >&6; }
+if test "${ac_cv_have_decl_mktemp+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef mktemp
+ (void) mktemp;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_mktemp=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_mktemp=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_mktemp" >&5
+$as_echo "$ac_cv_have_decl_mktemp" >&6; }
+if test "x$ac_cv_have_decl_mktemp" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKTEMP 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKTEMP 0
+_ACEOF
+
+
+fi
+
+
+
+
+
+
+
+
+
+for ac_func in geteuid getuid mktemp raise sigaction sigprocmask sigsetmask
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+{ $as_echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5
+$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
+if test "${ac_cv_sys_largefile_source+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h> /* for off_t */
+ #include <stdio.h>
+int
+main ()
+{
+int (*fp) (FILE *, off_t, int) = fseeko;
+ return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_sys_largefile_source=no; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#define _LARGEFILE_SOURCE 1
+#include <sys/types.h> /* for off_t */
+ #include <stdio.h>
+int
+main ()
+{
+int (*fp) (FILE *, off_t, int) = fseeko;
+ return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_sys_largefile_source=1; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ ac_cv_sys_largefile_source=unknown
+ break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5
+$as_echo "$ac_cv_sys_largefile_source" >&6; }
+case $ac_cv_sys_largefile_source in #(
+ no | unknown) ;;
+ *)
+cat >>confdefs.h <<_ACEOF
+#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
+_ACEOF
+;;
+esac
+rm -rf conftest*
+
+# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
+# in glibc 2.1.3, but that breaks too many other things.
+# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
+if test $ac_cv_sys_largefile_source != unknown; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FSEEKO 1
+_ACEOF
+
+fi
+
+
+ { $as_echo "$as_me:$LINENO: checking whether clearerr_unlocked is declared" >&5
+$as_echo_n "checking whether clearerr_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_clearerr_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef clearerr_unlocked
+ (void) clearerr_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_clearerr_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_clearerr_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_clearerr_unlocked" >&5
+$as_echo "$ac_cv_have_decl_clearerr_unlocked" >&6; }
+if test "x$ac_cv_have_decl_clearerr_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CLEARERR_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CLEARERR_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether feof_unlocked is declared" >&5
+$as_echo_n "checking whether feof_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_feof_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef feof_unlocked
+ (void) feof_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_feof_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_feof_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_feof_unlocked" >&5
+$as_echo "$ac_cv_have_decl_feof_unlocked" >&6; }
+if test "x$ac_cv_have_decl_feof_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FEOF_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FEOF_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether ferror_unlocked is declared" >&5
+$as_echo_n "checking whether ferror_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_ferror_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef ferror_unlocked
+ (void) ferror_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_ferror_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_ferror_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_ferror_unlocked" >&5
+$as_echo "$ac_cv_have_decl_ferror_unlocked" >&6; }
+if test "x$ac_cv_have_decl_ferror_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FERROR_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FERROR_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether fflush_unlocked is declared" >&5
+$as_echo_n "checking whether fflush_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_fflush_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef fflush_unlocked
+ (void) fflush_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_fflush_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_fflush_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_fflush_unlocked" >&5
+$as_echo "$ac_cv_have_decl_fflush_unlocked" >&6; }
+if test "x$ac_cv_have_decl_fflush_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FFLUSH_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FFLUSH_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether fgets_unlocked is declared" >&5
+$as_echo_n "checking whether fgets_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_fgets_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef fgets_unlocked
+ (void) fgets_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_fgets_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_fgets_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_fgets_unlocked" >&5
+$as_echo "$ac_cv_have_decl_fgets_unlocked" >&6; }
+if test "x$ac_cv_have_decl_fgets_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FGETS_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FGETS_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether fputc_unlocked is declared" >&5
+$as_echo_n "checking whether fputc_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_fputc_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef fputc_unlocked
+ (void) fputc_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_fputc_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_fputc_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_fputc_unlocked" >&5
+$as_echo "$ac_cv_have_decl_fputc_unlocked" >&6; }
+if test "x$ac_cv_have_decl_fputc_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FPUTC_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FPUTC_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether fputs_unlocked is declared" >&5
+$as_echo_n "checking whether fputs_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_fputs_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef fputs_unlocked
+ (void) fputs_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_fputs_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_fputs_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_fputs_unlocked" >&5
+$as_echo "$ac_cv_have_decl_fputs_unlocked" >&6; }
+if test "x$ac_cv_have_decl_fputs_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FPUTS_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FPUTS_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether fread_unlocked is declared" >&5
+$as_echo_n "checking whether fread_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_fread_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef fread_unlocked
+ (void) fread_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_fread_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_fread_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_fread_unlocked" >&5
+$as_echo "$ac_cv_have_decl_fread_unlocked" >&6; }
+if test "x$ac_cv_have_decl_fread_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FREAD_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FREAD_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether fwrite_unlocked is declared" >&5
+$as_echo_n "checking whether fwrite_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_fwrite_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef fwrite_unlocked
+ (void) fwrite_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_fwrite_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_fwrite_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_fwrite_unlocked" >&5
+$as_echo "$ac_cv_have_decl_fwrite_unlocked" >&6; }
+if test "x$ac_cv_have_decl_fwrite_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FWRITE_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FWRITE_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether getc_unlocked is declared" >&5
+$as_echo_n "checking whether getc_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_getc_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef getc_unlocked
+ (void) getc_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_getc_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_getc_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_getc_unlocked" >&5
+$as_echo "$ac_cv_have_decl_getc_unlocked" >&6; }
+if test "x$ac_cv_have_decl_getc_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETC_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETC_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether getchar_unlocked is declared" >&5
+$as_echo_n "checking whether getchar_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_getchar_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef getchar_unlocked
+ (void) getchar_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_getchar_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_getchar_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_getchar_unlocked" >&5
+$as_echo "$ac_cv_have_decl_getchar_unlocked" >&6; }
+if test "x$ac_cv_have_decl_getchar_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETCHAR_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETCHAR_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether putc_unlocked is declared" >&5
+$as_echo_n "checking whether putc_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_putc_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef putc_unlocked
+ (void) putc_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_putc_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_putc_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_putc_unlocked" >&5
+$as_echo "$ac_cv_have_decl_putc_unlocked" >&6; }
+if test "x$ac_cv_have_decl_putc_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PUTC_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PUTC_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether putchar_unlocked is declared" >&5
+$as_echo_n "checking whether putchar_unlocked is declared... " >&6; }
+if test "${ac_cv_have_decl_putchar_unlocked+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+#ifndef putchar_unlocked
+ (void) putchar_unlocked;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_have_decl_putchar_unlocked=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_have_decl_putchar_unlocked=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_putchar_unlocked" >&5
+$as_echo "$ac_cv_have_decl_putchar_unlocked" >&6; }
+if test "x$ac_cv_have_decl_putchar_unlocked" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PUTCHAR_UNLOCKED 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PUTCHAR_UNLOCKED 0
+_ACEOF
+
+
+fi
+
+
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_UNLOCKED_IO 1
+_ACEOF
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether malloc, realloc, calloc are POSIX compliant" >&5
+$as_echo_n "checking whether malloc, realloc, calloc are POSIX compliant... " >&6; }
+if test "${gl_cv_func_malloc_posix+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ choke me
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ gl_cv_func_malloc_posix=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ gl_cv_func_malloc_posix=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $gl_cv_func_malloc_posix" >&5
+$as_echo "$gl_cv_func_malloc_posix" >&6; }
+
+
+
+ if test $gl_cv_func_malloc_posix = yes; then
+ HAVE_MALLOC_POSIX=1
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MALLOC_POSIX 1
+_ACEOF
+
+ else
+ case " $LIBOBJS " in
+ *" malloc.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS malloc.$ac_objext"
+ ;;
+esac
+
+ HAVE_MALLOC_POSIX=0
+ fi
+
+
+
+
+ if test $gl_cv_func_malloc_posix = yes; then
+ HAVE_REALLOC_POSIX=1
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_REALLOC_POSIX 1
+_ACEOF
+
+ else
+ case " $LIBOBJS " in
+ *" realloc.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS realloc.$ac_objext"
+ ;;
+esac
+
+ HAVE_REALLOC_POSIX=0
+ fi
+
+
+
+
+
+
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+ as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ eval "$as_ac_Header=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+ { $as_echo "$as_me:$LINENO: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_search_opendir=$ac_res
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext
+ if test "${ac_cv_search_opendir+set}" = set; then
+ break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then
+ :
+else
+ ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+ { $as_echo "$as_me:$LINENO: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_search_opendir=$ac_res
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext
+ if test "${ac_cv_search_opendir+set}" = set; then
+ break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then
+ :
+else
+ ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+{ $as_echo "$as_me:$LINENO: checking whether closedir returns void" >&5
+$as_echo_n "checking whether closedir returns void... " >&6; }
+if test "${ac_cv_func_closedir_void+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_closedir_void=yes
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header_dirent>
+#ifndef __cplusplus
+int closedir ();
+#endif
+
+int
+main ()
+{
+return closedir (opendir (".")) != 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_closedir_void=no
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_closedir_void=yes
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_closedir_void" >&5
+$as_echo "$ac_cv_func_closedir_void" >&6; }
+if test $ac_cv_func_closedir_void = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define CLOSEDIR_VOID 1
+_ACEOF
+
+fi
+
+
+
+for ac_header in fcntl.h unistd.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## -------------------------------- ##
+## Report this to bug-patch@gnu.org ##
+## -------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+ { $as_echo "$as_me:$LINENO: checking for DOS-style setmode" >&5
+$as_echo_n "checking for DOS-style setmode... " >&6; }
+if test "${ac_cv_func_setmode_dos+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <io.h>
+ #if HAVE_FCNTL_H
+ # include <fcntl.h>
+ #endif
+ #if HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif
+int
+main ()
+{
+int ret = setmode && setmode (1, O_BINARY);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_func_setmode_dos=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_func_setmode_dos=no
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_setmode_dos" >&5
+$as_echo "$ac_cv_func_setmode_dos" >&6; }
+ if test $ac_cv_func_setmode_dos = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SETMODE_DOS 1
+_ACEOF
+
+ fi
+
+for ac_func in vprintf
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+{ $as_echo "$as_me:$LINENO: checking for _doprnt" >&5
+$as_echo_n "checking for _doprnt... " >&6; }
+if test "${ac_cv_func__doprnt+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define _doprnt to an innocuous variant, in case <limits.h> declares _doprnt.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define _doprnt innocuous__doprnt
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char _doprnt (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef _doprnt
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char _doprnt ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub__doprnt || defined __stub____doprnt
+choke me
+#endif
+
+int
+main ()
+{
+return _doprnt ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_func__doprnt=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_func__doprnt=no
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5
+$as_echo "$ac_cv_func__doprnt" >&6; }
+if test "x$ac_cv_func__doprnt" = x""yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DOPRNT 1
+_ACEOF
+
+fi
+
+fi
+done
+
+
+
+for ac_func in mkdir
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'`
+ if test "x$as_val" = x""yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+ { $as_echo "$as_me:$LINENO: checking whether mkdir takes only one argument" >&5
+$as_echo_n "checking whether mkdir takes only one argument... " >&6; }
+if test "${patch_cv_mkdir_takes_one_arg+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ patch_cv_mkdir_takes_one_arg=no
+ if test $ac_cv_func_mkdir = yes; then
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+int
+main ()
+{
+mkdir (".", 0);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+int
+main ()
+{
+mkdir (".");
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ patch_cv_mkdir_takes_one_arg=yes
+
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $patch_cv_mkdir_takes_one_arg" >&5
+$as_echo "$patch_cv_mkdir_takes_one_arg" >&6; }
+ if test $patch_cv_mkdir_takes_one_arg = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define MKDIR_TAKES_ONE_ARG 1
+_ACEOF
+
+ fi
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether system is Windows or MSDOS" >&5
+$as_echo_n "checking whether system is Windows or MSDOS... " >&6; }
+if test "${ac_cv_win_or_dos+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
+neither MSDOS nor Windows
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_win_or_dos=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_win_or_dos=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_win_or_dos" >&5
+$as_echo "$ac_cv_win_or_dos" >&6; }
+
+ if test x"$ac_cv_win_or_dos" = xyes; then
+ ac_fs_accepts_drive_letter_prefix=1
+ ac_fs_backslash_is_file_name_separator=1
+ { $as_echo "$as_me:$LINENO: checking whether drive letter can start relative path" >&5
+$as_echo_n "checking whether drive letter can start relative path... " >&6; }
+if test "${ac_cv_drive_letter_can_be_relative+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#if defined __CYGWIN__
+drive letters are always absolute
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_drive_letter_can_be_relative=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_drive_letter_can_be_relative=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_drive_letter_can_be_relative" >&5
+$as_echo "$ac_cv_drive_letter_can_be_relative" >&6; }
+ if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
+ ac_fs_drive_letter_can_be_relative=1
+ else
+ ac_fs_drive_letter_can_be_relative=0
+ fi
+ else
+ ac_fs_accepts_drive_letter_prefix=0
+ ac_fs_backslash_is_file_name_separator=0
+ ac_fs_drive_letter_can_be_relative=0
+ fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX $ac_fs_accepts_drive_letter_prefix
+_ACEOF
+
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR $ac_fs_backslash_is_file_name_separator
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE $ac_fs_drive_letter_can_be_relative
+_ACEOF
+
+
+{ $as_echo "$as_me:$LINENO: checking for long file names" >&5
+$as_echo_n "checking for long file names... " >&6; }
+if test "${ac_cv_sys_long_file_names+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_sys_long_file_names=yes
+# Test for long file names in all the places we know might matter:
+# . the current directory, where building will happen
+# $prefix/lib where we will be installing things
+# $exec_prefix/lib likewise
+# $TMPDIR if set, where it might want to write temporary files
+# /tmp where it might want to write temporary files
+# /var/tmp likewise
+# /usr/tmp likewise
+for ac_dir in . "$TMPDIR" /tmp /var/tmp /usr/tmp "$prefix/lib" "$exec_prefix/lib"; do
+ # Skip $TMPDIR if it is empty or bogus, and skip $exec_prefix/lib
+ # in the usual case where exec_prefix is '${prefix}'.
+ case $ac_dir in #(
+ . | /* | ?:[\\/]*) ;; #(
+ *) continue;;
+ esac
+ test -w "$ac_dir/." || continue # It is less confusing to not echo anything here.
+ ac_xdir=$ac_dir/cf$$
+ (umask 077 && mkdir "$ac_xdir" 2>/dev/null) || continue
+ ac_tf1=$ac_xdir/conftest9012345
+ ac_tf2=$ac_xdir/conftest9012346
+ touch "$ac_tf1" 2>/dev/null && test -f "$ac_tf1" && test ! -f "$ac_tf2" ||
+ ac_cv_sys_long_file_names=no
+ rm -f -r "$ac_xdir" 2>/dev/null
+ test $ac_cv_sys_long_file_names = no && break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_long_file_names" >&5
+$as_echo "$ac_cv_sys_long_file_names" >&6; }
+if test $ac_cv_sys_long_file_names = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LONG_FILE_NAMES 1
+_ACEOF
+
+fi
+
+
+# Check whether --enable-merge was given.
+if test "${enable_merge+set}" = set; then
+ enableval=$enable_merge;
+fi
+
+if test "$enableval" != no ; then
+ ENABLE_MERGE=1
+
+fi
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ test "x$cache_file" != "x/dev/null" &&
+ { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ cat confcache >$cache_file
+ else
+ { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -p'
+ fi
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by patch $as_me 2.6, which was
+generated by GNU Autoconf 2.63. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTION]... [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to <bug-autoconf@gnu.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_version="\\
+patch config.status 2.6
+configured by $0, generated by GNU Autoconf 2.63,
+ with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ { $as_echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { $as_echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;;
+ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+ *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp=
+ trap 'exit_status=$?
+ { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} ||
+{
+ $as_echo "$as_me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr='\r'
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\).*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\).*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = "\a"
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+ || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
+$as_echo "$as_me: error: could not setup config files machinery" >&2;}
+ { (exit 1); exit 1; }; }
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[ ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+ ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_t"; then
+ break
+ elif $ac_last_try; then
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
+ { (exit 1); exit 1; }; }
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any. Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[ ]*#[ ]*define[ ][ ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ for (key in D) D_is_set[key] = 1
+ FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+ line = \$ 0
+ split(line, arg, " ")
+ if (arg[1] == "#") {
+ defundef = arg[2]
+ mac1 = arg[3]
+ } else {
+ defundef = substr(arg[1], 2)
+ mac1 = arg[2]
+ }
+ split(mac1, mac2, "(") #)
+ macro = mac2[1]
+ prefix = substr(line, 1, index(line, defundef) - 1)
+ if (D_is_set[macro]) {
+ # Preserve the white space surrounding the "#".
+ print prefix "define", macro P[macro] D[macro]
+ next
+ } else {
+ # Replace #undef with comments. This is necessary, for example,
+ # in the case of _POSIX_SOURCE, which is predefined and required
+ # on some systems where configure will not decide to define it.
+ if (defundef == "undef") {
+ print "/*", prefix defundef, macro, "*/"
+ next
+ }
+ }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
+$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
+ { (exit 1); exit 1; }; }
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
+$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
+ { (exit 1); exit 1; }; };;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ ac_file_inputs="$ac_file_inputs '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:$LINENO: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$tmp/stdin" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ { as_dir="$ac_dir"
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
+ { (exit 1); exit 1; }; }; }
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+ esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&2;}
+
+ rm -f "$tmp/stdin"
+ case $ac_file in
+ -) cat "$tmp/out" && rm -f "$tmp/out";;
+ *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+ esac \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+ if test x"$ac_file" != x-; then
+ {
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+ } >"$tmp/config.h" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+ if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+ { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f "$ac_file"
+ mv "$tmp/config.h" "$ac_file" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ else
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
+$as_echo "$as_me: error: could not create -" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ ;;
+
+
+ esac
+
+done # for ac_tag
+
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
--- /dev/null
+# Configure `patch'.
+
+# Copyright (C) 1993, 1997, 1998, 1999, 2002, 2003, 2006, 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 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., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+AC_PREREQ(2.57)
+define(AC_PACKAGE_VERSION, m4_normalize(esyscmd(
+[
+ . ./update-version.sh VERSION
+ cat VERSION
+])))
+AC_INIT(patch, AC_PACKAGE_VERSION, bug-patch@gnu.org)
+AC_CONFIG_SRCDIR(src/patch.c)
+AC_CONFIG_HEADER(config.h:config.hin)
+AC_ARG_PROGRAM
+
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+# Use ed_PROGRAM, not ED_PROGRAM,
+# because <errno.h> reserves symbols starting with `E'.
+AC_PATH_PROG(ed_PROGRAM, ed, ed)
+
+AC_PATH_PROG(TEST_SHELL, [bash sh])
+
+gl_USE_SYSTEM_EXTENSIONS
+AC_PROG_CC_STDC
+AC_SYS_LARGEFILE
+AC_EXEEXT
+
+AC_HEADER_STDC
+AC_CHECK_HEADERS(fcntl.h utime.h)
+
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AM_STDBOOL_H
+gl_CHECK_TYPE_STRUCT_UTIMBUF
+
+gl_ARGMATCH
+gl_BACKUPFILE
+gl_DIRNAME
+gl_ERROR
+gl_EXITFAIL
+gl_FUNC_MEMCHR
+gl_GETOPT
+gl_HASH
+gl_PREREQ_XMALLOC
+gl_QUOTE
+gl_QUOTEARG
+gl_SAFE_WRITE
+gl_STRCASE
+gl_XALLOC
+gl_XSTRNDUP
+
+dnl lib/basename.c requires xstrndup.
+AC_LIBOBJ([xstrndup])
+
+dnl m4/error.m4 does not do this:
+AC_LIBOBJ([error])
+
+AC_CHECK_DECLS([mktemp])
+AC_CHECK_FUNCS(geteuid getuid mktemp raise sigaction sigprocmask sigsetmask)
+AC_FUNC_FSEEKO
+gl_FUNC_GLIBC_UNLOCKED_IO
+gl_FUNC_MALLOC_POSIX
+gl_FUNC_REALLOC_POSIX
+AC_FUNC_CLOSEDIR_VOID
+AC_FUNC_SETMODE_DOS
+AC_FUNC_VPRINTF
+PATCH_FUNC_MKDIR_TAKES_ONE_ARG
+
+gl_AC_DOS
+AC_SYS_LONG_FILE_NAMES
+
+AC_ARG_ENABLE([merge],
+ [AS_HELP_STRING([--disable-merge],
+ [disable support for merging])])
+if test "$enableval" != no ; then
+ AC_SUBST(ENABLE_MERGE, 1)
+fi
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
--- /dev/null
+/* argmatch.c -- find a match for a string in an array
+
+ Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ 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 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/>. */
+
+/* Written by David MacKenzie <djm@ai.mit.edu>
+ Modified by Akim Demaille <demaille@inf.enst.fr> */
+
+#include <config.h>
+
+/* Specification. */
+#include "argmatch.h"
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+#include "error.h"
+#include "quotearg.h"
+#include "quote.h"
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+#endif
+
+/* When reporting an invalid argument, show nonprinting characters
+ by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
+ literal_quoting_style. */
+#ifndef ARGMATCH_QUOTING_STYLE
+# define ARGMATCH_QUOTING_STYLE locale_quoting_style
+#endif
+
+/* Non failing version of argmatch call this function after failing. */
+#ifndef ARGMATCH_DIE
+# include "exitfail.h"
+# define ARGMATCH_DIE exit (exit_failure)
+#endif
+
+#ifdef ARGMATCH_DIE_DECL
+ARGMATCH_DIE_DECL;
+#endif
+
+static void
+__argmatch_die (void)
+{
+ ARGMATCH_DIE;
+}
+
+/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
+ Default to __argmatch_die, but allow caller to change this at run-time. */
+argmatch_exit_fn argmatch_die = __argmatch_die;
+
+\f
+/* If ARG is an unambiguous match for an element of the
+ NULL-terminated array ARGLIST, return the index in ARGLIST
+ of the matched element, else -1 if it does not match any element
+ or -2 if it is ambiguous (is a prefix of more than one element).
+
+ If VALLIST is none null, use it to resolve ambiguities limited to
+ synonyms, i.e., for
+ "yes", "yop" -> 0
+ "no", "nope" -> 1
+ "y" is a valid argument, for `0', and "n" for `1'. */
+
+ptrdiff_t
+argmatch (const char *arg, const char *const *arglist,
+ const char *vallist, size_t valsize)
+{
+ size_t i; /* Temporary index in ARGLIST. */
+ size_t arglen; /* Length of ARG. */
+ ptrdiff_t matchind = -1; /* Index of first nonexact match. */
+ bool ambiguous = false; /* If true, multiple nonexact match(es). */
+
+ arglen = strlen (arg);
+
+ /* Test all elements for either exact match or abbreviated matches. */
+ for (i = 0; arglist[i]; i++)
+ {
+ if (!strncmp (arglist[i], arg, arglen))
+ {
+ if (strlen (arglist[i]) == arglen)
+ /* Exact match found. */
+ return i;
+ else if (matchind == -1)
+ /* First nonexact match found. */
+ matchind = i;
+ else
+ {
+ /* Second nonexact match found. */
+ if (vallist == NULL
+ || memcmp (vallist + valsize * matchind,
+ vallist + valsize * i, valsize))
+ {
+ /* There is a real ambiguity, or we could not
+ disambiguate. */
+ ambiguous = true;
+ }
+ }
+ }
+ }
+ if (ambiguous)
+ return -2;
+ else
+ return matchind;
+}
+
+/* Error reporting for argmatch.
+ CONTEXT is a description of the type of entity that was being matched.
+ VALUE is the invalid value that was given.
+ PROBLEM is the return value from argmatch. */
+
+void
+argmatch_invalid (const char *context, const char *value, ptrdiff_t problem)
+{
+ char const *format = (problem == -1
+ ? _("invalid argument %s for %s")
+ : _("ambiguous argument %s for %s"));
+
+ error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
+ quote_n (1, context));
+}
+
+/* List the valid arguments for argmatch.
+ ARGLIST is the same as in argmatch.
+ VALLIST is a pointer to an array of values.
+ VALSIZE is the size of the elements of VALLIST */
+void
+argmatch_valid (const char *const *arglist,
+ const char *vallist, size_t valsize)
+{
+ size_t i;
+ const char *last_val = NULL;
+
+ /* We try to put synonyms on the same line. The assumption is that
+ synonyms follow each other */
+ fprintf (stderr, _("Valid arguments are:"));
+ for (i = 0; arglist[i]; i++)
+ if ((i == 0)
+ || memcmp (last_val, vallist + valsize * i, valsize))
+ {
+ fprintf (stderr, "\n - `%s'", arglist[i]);
+ last_val = vallist + valsize * i;
+ }
+ else
+ {
+ fprintf (stderr, ", `%s'", arglist[i]);
+ }
+ putc ('\n', stderr);
+}
+
+/* Never failing versions of the previous functions.
+
+ CONTEXT is the context for which argmatch is called (e.g.,
+ "--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
+ calls the (supposed never to return) function EXIT_FN. */
+
+ptrdiff_t
+__xargmatch_internal (const char *context,
+ const char *arg, const char *const *arglist,
+ const char *vallist, size_t valsize,
+ argmatch_exit_fn exit_fn)
+{
+ ptrdiff_t res = argmatch (arg, arglist, vallist, valsize);
+ if (res >= 0)
+ /* Success. */
+ return res;
+
+ /* We failed. Explain why. */
+ argmatch_invalid (context, arg, res);
+ argmatch_valid (arglist, vallist, valsize);
+ (*exit_fn) ();
+
+ return -1; /* To please the compilers. */
+}
+
+/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
+ return the first corresponding argument in ARGLIST */
+const char *
+argmatch_to_argument (const char *value,
+ const char *const *arglist,
+ const char *vallist, size_t valsize)
+{
+ size_t i;
+
+ for (i = 0; arglist[i]; i++)
+ if (!memcmp (value, vallist + valsize * i, valsize))
+ return arglist[i];
+ return NULL;
+}
+
+#ifdef TEST
+/*
+ * Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
+ */
+char *program_name;
+
+/* When to make backup files. */
+enum backup_type
+{
+ /* Never make backups. */
+ no_backups,
+
+ /* Make simple backups of every file. */
+ simple_backups,
+
+ /* Make numbered backups of files that already have numbered backups,
+ and simple backups of the others. */
+ numbered_existing_backups,
+
+ /* Make numbered backups of every file. */
+ numbered_backups
+};
+
+/* Two tables describing arguments (keys) and their corresponding
+ values */
+static const char *const backup_args[] =
+{
+ "no", "none", "off",
+ "simple", "never",
+ "existing", "nil",
+ "numbered", "t",
+ 0
+};
+
+static const enum backup_type backup_vals[] =
+{
+ no_backups, no_backups, no_backups,
+ simple_backups, simple_backups,
+ numbered_existing_backups, numbered_existing_backups,
+ numbered_backups, numbered_backups
+};
+
+int
+main (int argc, const char *const *argv)
+{
+ const char *cp;
+ enum backup_type backup_type = no_backups;
+
+ program_name = (char *) argv[0];
+
+ if (argc > 2)
+ {
+ fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
+ exit (1);
+ }
+
+ if ((cp = getenv ("VERSION_CONTROL")))
+ backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
+ backup_args, backup_vals);
+
+ if (argc == 2)
+ backup_type = XARGMATCH (program_name, argv[1],
+ backup_args, backup_vals);
+
+ printf ("The version control is `%s'\n",
+ ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
+
+ return 0;
+}
+#endif
--- /dev/null
+/* argmatch.h -- definitions and prototypes for argmatch.c
+
+ Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005 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 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/>. */
+
+/* Written by David MacKenzie <djm@ai.mit.edu>
+ Modified by Akim Demaille <demaille@inf.enst.fr> */
+
+#ifndef ARGMATCH_H_
+# define ARGMATCH_H_ 1
+
+# include <stddef.h>
+
+# include "verify.h"
+
+# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
+
+/* Assert there are as many real arguments as there are values
+ (argument list ends with a NULL guard). */
+
+# define ARGMATCH_VERIFY(Arglist, Vallist) \
+ verify (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1)
+
+/* Return the index of the element of ARGLIST (NULL terminated) that
+ matches with ARG. If VALLIST is not NULL, then use it to resolve
+ false ambiguities (i.e., different matches of ARG but corresponding
+ to the same values in VALLIST). */
+
+ptrdiff_t argmatch (char const *arg, char const *const *arglist,
+ char const *vallist, size_t valsize);
+
+# define ARGMATCH(Arg, Arglist, Vallist) \
+ argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist))
+
+/* xargmatch calls this function when it fails. This function should not
+ return. By default, this is a function that calls ARGMATCH_DIE which
+ in turn defaults to `exit (exit_failure)'. */
+typedef void (*argmatch_exit_fn) (void);
+extern argmatch_exit_fn argmatch_die;
+
+/* Report on stderr why argmatch failed. Report correct values. */
+
+void argmatch_invalid (char const *context, char const *value,
+ ptrdiff_t problem);
+
+/* Left for compatibility with the old name invalid_arg */
+
+# define invalid_arg(Context, Value, Problem) \
+ argmatch_invalid (Context, Value, Problem)
+
+
+
+/* Report on stderr the list of possible arguments. */
+
+void argmatch_valid (char const *const *arglist,
+ char const *vallist, size_t valsize);
+
+# define ARGMATCH_VALID(Arglist, Vallist) \
+ argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist))
+
+
+
+/* Same as argmatch, but upon failure, reports a explanation on the
+ failure, and exits using the function EXIT_FN. */
+
+ptrdiff_t __xargmatch_internal (char const *context,
+ char const *arg, char const *const *arglist,
+ char const *vallist, size_t valsize,
+ argmatch_exit_fn exit_fn);
+
+/* Programmer friendly interface to __xargmatch_internal. */
+
+# define XARGMATCH(Context, Arg, Arglist, Vallist) \
+ ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \
+ (char const *) (Vallist), \
+ sizeof *(Vallist), \
+ argmatch_die)])
+
+/* Convert a value into a corresponding argument. */
+
+char const *argmatch_to_argument (char const *value,
+ char const *const *arglist,
+ char const *vallist, size_t valsize);
+
+# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
+ argmatch_to_argument (Value, Arglist, \
+ (char const *) (Vallist), sizeof *(Vallist))
+
+#endif /* ARGMATCH_H_ */
--- /dev/null
+/* backupfile.c -- make Emacs style backup file names
+
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 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 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/>. */
+
+/* Written by Paul Eggert and David MacKenzie.
+ Some algorithms adapted from GNU Emacs. */
+
+#include <config.h>
+
+#include "backupfile.h"
+
+#include "argmatch.h"
+#include "dirname.h"
+#include "xalloc.h"
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <limits.h>
+
+#include <unistd.h>
+
+#include <dirent.h>
+#ifndef _D_EXACT_NAMLEN
+# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
+#endif
+#if D_INO_IN_DIRENT
+# define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
+#else
+# define REAL_DIR_ENTRY(dp) 1
+#endif
+
+#if ! (HAVE_PATHCONF && defined _PC_NAME_MAX)
+# define pathconf(file, option) (errno = -1)
+#endif
+
+#ifndef _POSIX_NAME_MAX
+# define _POSIX_NAME_MAX 14
+#endif
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+#if defined _XOPEN_NAME_MAX
+# define NAME_MAX_MINIMUM _XOPEN_NAME_MAX
+#else
+# define NAME_MAX_MINIMUM _POSIX_NAME_MAX
+#endif
+
+#ifndef HAVE_DOS_FILE_NAMES
+# define HAVE_DOS_FILE_NAMES 0
+#endif
+#ifndef HAVE_LONG_FILE_NAMES
+# define HAVE_LONG_FILE_NAMES 0
+#endif
+
+/* ISDIGIT differs from isdigit, as follows:
+ - Its arg may be any int or unsigned int; it need not be an unsigned char
+ or EOF.
+ - It's typically faster.
+ POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
+ ISDIGIT unless it's important to use the locale's definition
+ of `digit' even when the host does not conform to POSIX. */
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
+
+/* The results of opendir() in this file are not used with dirfd and fchdir,
+ therefore save some unnecessary work in fchdir.c. */
+#undef opendir
+#undef closedir
+
+/* The extension added to file names to produce a simple (as opposed
+ to numbered) backup file name. */
+char const *simple_backup_suffix = "~";
+
+
+/* If FILE (which was of length FILELEN before an extension was
+ appended to it) is too long, replace the extension with the single
+ char E. If the result is still too long, remove the char just
+ before E. */
+
+static void
+check_extension (char *file, size_t filelen, char e)
+{
+ char *base = last_component (file);
+ size_t baselen = base_len (base);
+ size_t baselen_max = HAVE_LONG_FILE_NAMES ? 255 : NAME_MAX_MINIMUM;
+
+ if (HAVE_DOS_FILE_NAMES || NAME_MAX_MINIMUM < baselen)
+ {
+ /* The new base name is long enough to require a pathconf check. */
+ long name_max;
+
+ /* Temporarily modify the buffer into its parent directory name,
+ invoke pathconf on the directory, and then restore the buffer. */
+ char tmp[sizeof "."];
+ memcpy (tmp, base, sizeof ".");
+ strcpy (base, ".");
+ errno = 0;
+ name_max = pathconf (file, _PC_NAME_MAX);
+ if (0 <= name_max || errno == 0)
+ {
+ long size = baselen_max = name_max;
+ if (name_max != size)
+ baselen_max = SIZE_MAX;
+ }
+ memcpy (base, tmp, sizeof ".");
+ }
+
+ if (HAVE_DOS_FILE_NAMES && baselen_max <= 12)
+ {
+ /* Live within DOS's 8.3 limit. */
+ char *dot = strchr (base, '.');
+ if (!dot)
+ baselen_max = 8;
+ else
+ {
+ char const *second_dot = strchr (dot + 1, '.');
+ baselen_max = (second_dot
+ ? second_dot - base
+ : dot + 1 - base + 3);
+ }
+ }
+
+ if (baselen_max < baselen)
+ {
+ baselen = file + filelen - base;
+ if (baselen_max <= baselen)
+ baselen = baselen_max - 1;
+ base[baselen] = e;
+ base[baselen + 1] = '\0';
+ }
+}
+
+/* Returned values for NUMBERED_BACKUP. */
+
+enum numbered_backup_result
+ {
+ /* The new backup name is the same length as an existing backup
+ name, so it's valid for that directory. */
+ BACKUP_IS_SAME_LENGTH,
+
+ /* Some backup names already exist, but the returned name is longer
+ than any of them, and its length should be checked. */
+ BACKUP_IS_LONGER,
+
+ /* There are no existing backup names. The new name's length
+ should be checked. */
+ BACKUP_IS_NEW
+ };
+
+/* *BUFFER contains a file name. Store into *BUFFER the next backup
+ name for the named file, with a version number greater than all the
+ existing numbered backups. Reallocate *BUFFER as necessary; its
+ initial allocated size is BUFFER_SIZE, which must be at least 4
+ bytes longer than the file name to make room for the initially
+ appended ".~1". FILELEN is the length of the original file name.
+ The returned value indicates what kind of backup was found. If an
+ I/O or other read error occurs, use the highest backup number that
+ was found. */
+
+static enum numbered_backup_result
+numbered_backup (char **buffer, size_t buffer_size, size_t filelen)
+{
+ enum numbered_backup_result result = BACKUP_IS_NEW;
+ DIR *dirp;
+ struct dirent *dp;
+ char *buf = *buffer;
+ size_t versionlenmax = 1;
+ char *base = last_component (buf);
+ size_t base_offset = base - buf;
+ size_t baselen = base_len (base);
+
+ /* Temporarily modify the buffer into its parent directory name,
+ open the directory, and then restore the buffer. */
+ char tmp[sizeof "."];
+ memcpy (tmp, base, sizeof ".");
+ strcpy (base, ".");
+ dirp = opendir (buf);
+ memcpy (base, tmp, sizeof ".");
+ strcpy (base + baselen, ".~1~");
+
+ if (!dirp)
+ return result;
+
+ while ((dp = readdir (dirp)) != NULL)
+ {
+ char const *p;
+ char *q;
+ bool all_9s;
+ size_t versionlen;
+ size_t new_buflen;
+
+ if (! REAL_DIR_ENTRY (dp) || _D_EXACT_NAMLEN (dp) < baselen + 4)
+ continue;
+
+ if (memcmp (buf + base_offset, dp->d_name, baselen + 2) != 0)
+ continue;
+
+ p = dp->d_name + baselen + 2;
+
+ /* Check whether this file has a version number and if so,
+ whether it is larger. Use string operations rather than
+ integer arithmetic, to avoid problems with integer overflow. */
+
+ if (! ('1' <= *p && *p <= '9'))
+ continue;
+ all_9s = (*p == '9');
+ for (versionlen = 1; ISDIGIT (p[versionlen]); versionlen++)
+ all_9s &= (p[versionlen] == '9');
+
+ if (! (p[versionlen] == '~' && !p[versionlen + 1]
+ && (versionlenmax < versionlen
+ || (versionlenmax == versionlen
+ && memcmp (buf + filelen + 2, p, versionlen) <= 0))))
+ continue;
+
+ /* This directory has the largest version number seen so far.
+ Append this highest numbered extension to the file name,
+ prepending '0' to the number if it is all 9s. */
+
+ versionlenmax = all_9s + versionlen;
+ result = (all_9s ? BACKUP_IS_LONGER : BACKUP_IS_SAME_LENGTH);
+ new_buflen = filelen + 2 + versionlenmax + 1;
+ if (buffer_size <= new_buflen)
+ {
+ buf = xnrealloc (buf, 2, new_buflen);
+ buffer_size = new_buflen * 2;
+ }
+ q = buf + filelen;
+ *q++ = '.';
+ *q++ = '~';
+ *q = '0';
+ q += all_9s;
+ memcpy (q, p, versionlen + 2);
+
+ /* Add 1 to the version number. */
+
+ q += versionlen;
+ while (*--q == '9')
+ *q = '0';
+ ++*q;
+ }
+
+ closedir (dirp);
+ *buffer = buf;
+ return result;
+}
+
+/* Return the name of the new backup file for the existing file FILE,
+ allocated with malloc. Report an error and fail if out of memory.
+ Do not call this function if backup_type == no_backups. */
+
+char *
+find_backup_file_name (char const *file, enum backup_type backup_type)
+{
+ size_t filelen = strlen (file);
+ char *s;
+ size_t ssize;
+ bool simple = true;
+
+ /* Allow room for simple or ".~N~" backups. The guess must be at
+ least sizeof ".~1~", but otherwise will be adjusted as needed. */
+ size_t simple_backup_suffix_size = strlen (simple_backup_suffix) + 1;
+ size_t backup_suffix_size_guess = simple_backup_suffix_size;
+ enum { GUESS = sizeof ".~12345~" };
+ if (backup_suffix_size_guess < GUESS)
+ backup_suffix_size_guess = GUESS;
+
+ ssize = filelen + backup_suffix_size_guess + 1;
+ s = xmalloc (ssize);
+ memcpy (s, file, filelen + 1);
+
+ if (backup_type != simple_backups)
+ switch (numbered_backup (&s, ssize, filelen))
+ {
+ case BACKUP_IS_SAME_LENGTH:
+ return s;
+
+ case BACKUP_IS_LONGER:
+ simple = false;
+ break;
+
+ case BACKUP_IS_NEW:
+ simple = (backup_type == numbered_existing_backups);
+ break;
+ }
+
+ if (simple)
+ memcpy (s + filelen, simple_backup_suffix, simple_backup_suffix_size);
+ check_extension (s, filelen, '~');
+ return s;
+}
+
+static char const * const backup_args[] =
+{
+ /* In a series of synonyms, present the most meaningful first, so
+ that argmatch_valid be more readable. */
+ "none", "off",
+ "simple", "never",
+ "existing", "nil",
+ "numbered", "t",
+ NULL
+};
+
+static const enum backup_type backup_types[] =
+{
+ no_backups, no_backups,
+ simple_backups, simple_backups,
+ numbered_existing_backups, numbered_existing_backups,
+ numbered_backups, numbered_backups
+};
+
+/* Ensure that these two vectors have the same number of elements,
+ not counting the final NULL in the first one. */
+ARGMATCH_VERIFY (backup_args, backup_types);
+
+/* Return the type of backup specified by VERSION.
+ If VERSION is NULL or the empty string, return numbered_existing_backups.
+ If VERSION is invalid or ambiguous, fail with a diagnostic appropriate
+ for the specified CONTEXT. Unambiguous abbreviations are accepted. */
+
+enum backup_type
+get_version (char const *context, char const *version)
+{
+ if (version == 0 || *version == 0)
+ return numbered_existing_backups;
+ else
+ return XARGMATCH (context, version, backup_args, backup_types);
+}
+
+
+/* Return the type of backup specified by VERSION.
+ If VERSION is NULL, use the value of the envvar VERSION_CONTROL.
+ If the specified string is invalid or ambiguous, fail with a diagnostic
+ appropriate for the specified CONTEXT.
+ Unambiguous abbreviations are accepted. */
+
+enum backup_type
+xget_version (char const *context, char const *version)
+{
+ if (version && *version)
+ return get_version (context, version);
+ else
+ return get_version ("$VERSION_CONTROL", getenv ("VERSION_CONTROL"));
+}
--- /dev/null
+/* backupfile.h -- declarations for making Emacs style backup file names
+
+ Copyright (C) 1990, 1991, 1992, 1997, 1998, 1999, 2003, 2004 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 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/>. */
+
+#ifndef BACKUPFILE_H_
+# define BACKUPFILE_H_
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+
+/* When to make backup files. */
+enum backup_type
+{
+ /* Never make backups. */
+ no_backups,
+
+ /* Make simple backups of every file. */
+ simple_backups,
+
+ /* Make numbered backups of files that already have numbered backups,
+ and simple backups of the others. */
+ numbered_existing_backups,
+
+ /* Make numbered backups of every file. */
+ numbered_backups
+};
+
+# define VALID_BACKUP_TYPE(Type) \
+ ((unsigned int) (Type) <= numbered_backups)
+
+extern char const *simple_backup_suffix;
+
+char *find_backup_file_name (char const *, enum backup_type);
+enum backup_type get_version (char const *context, char const *arg);
+enum backup_type xget_version (char const *context, char const *arg);
+void addext (char *, char const *, int);
+
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif /* ! BACKUPFILE_H_ */
--- /dev/null
+/* basename.c -- return the last element in a file name
+
+ Copyright (C) 1990, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 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 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/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+#include <string.h>
+#include "xalloc.h"
+#include "xstrndup.h"
+
+/* Return the address of the last file name component of NAME. If
+ NAME has no relative file name components because it is a file
+ system root, return the empty string. */
+
+char *
+last_component (char const *name)
+{
+ char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
+ char const *p;
+ bool saw_slash = false;
+
+ while (ISSLASH (*base))
+ base++;
+
+ for (p = base; *p; p++)
+ {
+ if (ISSLASH (*p))
+ saw_slash = true;
+ else if (saw_slash)
+ {
+ base = p;
+ saw_slash = false;
+ }
+ }
+
+ return (char *) base;
+}
+
+
+/* In general, we can't use the builtin `basename' function if available,
+ since it has different meanings in different environments.
+ In some environments the builtin `basename' modifies its argument.
+
+ Return the last file name component of NAME, allocated with
+ xmalloc. On systems with drive letters, a leading "./"
+ distinguishes relative names that would otherwise look like a drive
+ letter. Unlike POSIX basename(), NAME cannot be NULL,
+ base_name("") returns "", and the first trailing slash is not
+ stripped.
+
+ If lstat (NAME) would succeed, then { chdir (dir_name (NAME));
+ lstat (base_name (NAME)); } will access the same file. Likewise,
+ if the sequence { chdir (dir_name (NAME));
+ rename (base_name (NAME), "foo"); } succeeds, you have renamed NAME
+ to "foo" in the same directory NAME was in. */
+
+char *
+base_name (char const *name)
+{
+ char const *base = last_component (name);
+ size_t length;
+
+ /* If there is no last component, then name is a file system root or the
+ empty string. */
+ if (! *base)
+ return xstrndup (name, base_len (name));
+
+ /* Collapse a sequence of trailing slashes into one. */
+ length = base_len (base);
+ if (ISSLASH (base[length]))
+ length++;
+
+ /* On systems with drive letters, `a/b:c' must return `./b:c' rather
+ than `b:c' to avoid confusion with a drive letter. On systems
+ with pure POSIX semantics, this is not an issue. */
+ if (FILE_SYSTEM_PREFIX_LEN (base))
+ {
+ char *p = xmalloc (length + 3);
+ p[0] = '.';
+ p[1] = '/';
+ memcpy (p + 2, base, length);
+ p[length + 2] = '\0';
+ return p;
+ }
+
+ /* Finally, copy the basename. */
+ return xstrndup (base, length);
+}
+
+/* Return the length of the basename NAME. Typically NAME is the
+ value returned by base_name or last_component. Act like strlen
+ (NAME), except omit all trailing slashes. */
+
+size_t
+base_len (char const *name)
+{
+ size_t len;
+ size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
+
+ for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
+ continue;
+
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
+ && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
+ return 2;
+
+ if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
+ && len == prefix_len && ISSLASH (name[prefix_len]))
+ return prefix_len + 1;
+
+ return len;
+}
--- /dev/null
+/* dirname.c -- return all but the last element in a file name
+
+ Copyright (C) 1990, 1998, 2000, 2001, 2003, 2004, 2005, 2006 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 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/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+#include <string.h>
+#include "xalloc.h"
+
+/* Return the length of the prefix of FILE that will be used by
+ dir_name. If FILE is in the working directory, this returns zero
+ even though `dir_name (FILE)' will return ".". Works properly even
+ if there are trailing slashes (by effectively ignoring them). */
+
+size_t
+dir_len (char const *file)
+{
+ size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
+ size_t length;
+
+ /* Advance prefix_length beyond important leading slashes. */
+ prefix_length += (prefix_length != 0
+ ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+ && ISSLASH (file[prefix_length]))
+ : (ISSLASH (file[0])
+ ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
+ && ISSLASH (file[1]) && ! ISSLASH (file[2])
+ ? 2 : 1))
+ : 0));
+
+ /* Strip the basename and any redundant slashes before it. */
+ for (length = last_component (file) - file;
+ prefix_length < length; length--)
+ if (! ISSLASH (file[length - 1]))
+ break;
+ return length;
+}
+
+
+/* In general, we can't use the builtin `dirname' function if available,
+ since it has different meanings in different environments.
+ In some environments the builtin `dirname' modifies its argument.
+
+ Return the leading directories part of FILE, allocated with xmalloc.
+ Works properly even if there are trailing slashes (by effectively
+ ignoring them). Unlike POSIX dirname(), FILE cannot be NULL.
+
+ If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
+ lstat (base_name (FILE)); } will access the same file. Likewise,
+ if the sequence { chdir (dir_name (FILE));
+ rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
+ to "foo" in the same directory FILE was in. */
+
+char *
+dir_name (char const *file)
+{
+ size_t length = dir_len (file);
+ bool append_dot = (length == 0
+ || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+ && length == FILE_SYSTEM_PREFIX_LEN (file)
+ && file[2] != '\0' && ! ISSLASH (file[2])));
+ char *dir = xmalloc (length + append_dot + 1);
+ memcpy (dir, file, length);
+ if (append_dot)
+ dir[length++] = '.';
+ dir[length] = '\0';
+ return dir;
+}
--- /dev/null
+/* Take file names apart into directory and base names.
+
+ Copyright (C) 1998, 2001, 2003-2006 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 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/>. */
+
+#ifndef DIRNAME_H_
+# define DIRNAME_H_ 1
+
+# include <stdbool.h>
+# include <stddef.h>
+
+# ifndef DIRECTORY_SEPARATOR
+# define DIRECTORY_SEPARATOR '/'
+# endif
+
+# ifndef ISSLASH
+# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
+# endif
+
+# ifndef FILE_SYSTEM_PREFIX_LEN
+# if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
+ /* This internal macro assumes ASCII, but all hosts that support drive
+ letters use ASCII. */
+# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
+ <= 'z' - 'a')
+# define FILE_SYSTEM_PREFIX_LEN(Filename) \
+ (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
+# else
+# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
+# endif
+# endif
+
+# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
+# endif
+
+# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
+# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
+# endif
+
+# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
+# else
+# define IS_ABSOLUTE_FILE_NAME(F) \
+ (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
+# endif
+# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
+
+char *base_name (char const *file);
+char *dir_name (char const *file);
+size_t base_len (char const *file);
+size_t dir_len (char const *file);
+char *last_component (char const *file);
+
+bool strip_trailing_slashes (char *file);
+
+#endif /* not DIRNAME_H_ */
--- /dev/null
+/* Error handler for noninteractive utilities
+ Copyright (C) 1990-1998, 2000-2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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/>. */
+
+/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
+
+#if !_LIBC
+# include <config.h>
+#endif
+
+#include "error.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !_LIBC && ENABLE_NLS
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+# include <stdbool.h>
+# include <stdint.h>
+# include <wchar.h>
+# define mbsrtowcs __mbsrtowcs
+#endif
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+#endif
+
+#ifndef _
+# define _(String) String
+#endif
+
+/* If NULL, error will flush stdout, then print on stderr the program
+ name, a colon and a space. Otherwise, error will call this
+ function without parameters instead. */
+void (*error_print_progname) (void);
+
+/* This variable is incremented each time `error' is called. */
+unsigned int error_message_count;
+
+#ifdef _LIBC
+/* In the GNU C library, there is a predefined variable for this. */
+
+# define program_name program_invocation_name
+# include <errno.h>
+# include <limits.h>
+# include <libio/libioP.h>
+
+/* In GNU libc we want do not want to use the common name `error' directly.
+ Instead make it a weak alias. */
+extern void __error (int status, int errnum, const char *message, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+extern void __error_at_line (int status, int errnum, const char *file_name,
+ unsigned int line_number, const char *message,
+ ...)
+ __attribute__ ((__format__ (__printf__, 5, 6)));;
+# define error __error
+# define error_at_line __error_at_line
+
+# include <libio/iolibio.h>
+# define fflush(s) INTUSE(_IO_fflush) (s)
+# undef putc
+# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
+
+# include <bits/libc-lock.h>
+
+#else /* not _LIBC */
+
+# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
+# ifndef HAVE_DECL_STRERROR_R
+"this configure-time declaration test was not run"
+# endif
+char *strerror_r ();
+# endif
+
+/* The calling program should define program_name and set it to the
+ name of the executing program. */
+extern char *program_name;
+
+# if HAVE_STRERROR_R || defined strerror_r
+# define __strerror_r strerror_r
+# endif /* HAVE_STRERROR_R || defined strerror_r */
+#endif /* not _LIBC */
+
+static void
+print_errno_message (int errnum)
+{
+ char const *s;
+
+#if defined HAVE_STRERROR_R || _LIBC
+ char errbuf[1024];
+# if STRERROR_R_CHAR_P || _LIBC
+ s = __strerror_r (errnum, errbuf, sizeof errbuf);
+# else
+ if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
+ s = errbuf;
+ else
+ s = 0;
+# endif
+#else
+ s = strerror (errnum);
+#endif
+
+#if !_LIBC
+ if (! s)
+ s = _("Unknown system error");
+#endif
+
+#if _LIBC
+ __fxprintf (NULL, ": %s", s);
+#else
+ fprintf (stderr, ": %s", s);
+#endif
+}
+
+static void
+error_tail (int status, int errnum, const char *message, va_list args)
+{
+#if _LIBC
+ if (_IO_fwide (stderr, 0) > 0)
+ {
+# define ALLOCA_LIMIT 2000
+ size_t len = strlen (message) + 1;
+ wchar_t *wmessage = NULL;
+ mbstate_t st;
+ size_t res;
+ const char *tmp;
+ bool use_malloc = false;
+
+ while (1)
+ {
+ if (__libc_use_alloca (len * sizeof (wchar_t)))
+ wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
+ else
+ {
+ if (!use_malloc)
+ wmessage = NULL;
+
+ wchar_t *p = (wchar_t *) realloc (wmessage,
+ len * sizeof (wchar_t));
+ if (p == NULL)
+ {
+ free (wmessage);
+ fputws_unlocked (L"out of memory\n", stderr);
+ return;
+ }
+ wmessage = p;
+ use_malloc = true;
+ }
+
+ memset (&st, '\0', sizeof (st));
+ tmp = message;
+
+ res = mbsrtowcs (wmessage, &tmp, len, &st);
+ if (res != len)
+ break;
+
+ if (__builtin_expect (len >= SIZE_MAX / 2, 0))
+ {
+ /* This really should not happen if everything is fine. */
+ res = (size_t) -1;
+ break;
+ }
+
+ len *= 2;
+ }
+
+ if (res == (size_t) -1)
+ {
+ /* The string cannot be converted. */
+ if (use_malloc)
+ {
+ free (wmessage);
+ use_malloc = false;
+ }
+ wmessage = (wchar_t *) L"???";
+ }
+
+ __vfwprintf (stderr, wmessage, args);
+
+ if (use_malloc)
+ free (wmessage);
+ }
+ else
+#endif
+ vfprintf (stderr, message, args);
+ va_end (args);
+
+ ++error_message_count;
+ if (errnum)
+ print_errno_message (errnum);
+#if _LIBC
+ __fxprintf (NULL, "\n");
+#else
+ putc ('\n', stderr);
+#endif
+ fflush (stderr);
+ if (status)
+ exit (status);
+}
+
+
+/* Print the program name and error message MESSAGE, which is a printf-style
+ format string with optional args.
+ If ERRNUM is nonzero, print its corresponding system error message.
+ Exit with status STATUS if it is nonzero. */
+void
+error (int status, int errnum, const char *message, ...)
+{
+ va_list args;
+
+#if defined _LIBC && defined __libc_ptf_call
+ /* We do not want this call to be cut short by a thread
+ cancellation. Therefore disable cancellation for now. */
+ int state = PTHREAD_CANCEL_ENABLE;
+ __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+ 0);
+#endif
+
+ fflush (stdout);
+#ifdef _LIBC
+ _IO_flockfile (stderr);
+#endif
+ if (error_print_progname)
+ (*error_print_progname) ();
+ else
+ {
+#if _LIBC
+ __fxprintf (NULL, "%s: ", program_name);
+#else
+ fprintf (stderr, "%s: ", program_name);
+#endif
+ }
+
+ va_start (args, message);
+ error_tail (status, errnum, message, args);
+
+#ifdef _LIBC
+ _IO_funlockfile (stderr);
+# ifdef __libc_ptf_call
+ __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+# endif
+#endif
+}
+\f
+/* Sometimes we want to have at most one error per line. This
+ variable controls whether this mode is selected or not. */
+int error_one_per_line;
+
+void
+error_at_line (int status, int errnum, const char *file_name,
+ unsigned int line_number, const char *message, ...)
+{
+ va_list args;
+
+ if (error_one_per_line)
+ {
+ static const char *old_file_name;
+ static unsigned int old_line_number;
+
+ if (old_line_number == line_number
+ && (file_name == old_file_name
+ || strcmp (old_file_name, file_name) == 0))
+ /* Simply return and print nothing. */
+ return;
+
+ old_file_name = file_name;
+ old_line_number = line_number;
+ }
+
+#if defined _LIBC && defined __libc_ptf_call
+ /* We do not want this call to be cut short by a thread
+ cancellation. Therefore disable cancellation for now. */
+ int state = PTHREAD_CANCEL_ENABLE;
+ __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+ 0);
+#endif
+
+ fflush (stdout);
+#ifdef _LIBC
+ _IO_flockfile (stderr);
+#endif
+ if (error_print_progname)
+ (*error_print_progname) ();
+ else
+ {
+#if _LIBC
+ __fxprintf (NULL, "%s:", program_name);
+#else
+ fprintf (stderr, "%s:", program_name);
+#endif
+ }
+
+#if _LIBC
+ __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
+ file_name, line_number);
+#else
+ fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
+ file_name, line_number);
+#endif
+
+ va_start (args, message);
+ error_tail (status, errnum, message, args);
+
+#ifdef _LIBC
+ _IO_funlockfile (stderr);
+# ifdef __libc_ptf_call
+ __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+# endif
+#endif
+}
+
+#ifdef _LIBC
+/* Make the weak alias. */
+# undef error
+# undef error_at_line
+weak_alias (__error, error)
+weak_alias (__error_at_line, error_at_line)
+#endif
--- /dev/null
+/* Declaration for error-reporting function
+ Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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/>. */
+
+#ifndef _ERROR_H
+#define _ERROR_H 1
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+# define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+ are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __format__ format
+# define __printf__ printf
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Print a message with `fprintf (stderr, FORMAT, ...)';
+ if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
+ If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
+
+extern void error (int __status, int __errnum, const char *__format, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+
+extern void error_at_line (int __status, int __errnum, const char *__fname,
+ unsigned int __lineno, const char *__format, ...)
+ __attribute__ ((__format__ (__printf__, 5, 6)));
+
+/* If NULL, error will flush stdout, then print on stderr the program
+ name, a colon and a space. Otherwise, error will call this
+ function without parameters instead. */
+extern void (*error_print_progname) (void);
+
+/* This variable is incremented each time `error' is called. */
+extern unsigned int error_message_count;
+
+/* Sometimes we want to have at most one error per line. This
+ variable controls whether this mode is selected or not. */
+extern int error_one_per_line;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* error.h */
--- /dev/null
+/* Failure exit status
+
+ Copyright (C) 2002, 2003, 2005, 2006, 2007 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 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/>. */
+
+#include <config.h>
+
+#include "exitfail.h"
+
+#include <stdlib.h>
+
+int volatile exit_failure = EXIT_FAILURE;
--- /dev/null
+/* Failure exit status
+
+ Copyright (C) 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 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/>. */
+
+extern int volatile exit_failure;
--- /dev/null
+/* An interface to read and write that retries (if necessary) until complete.
+
+ Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+ 2004, 2005, 2006 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 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/>. */
+
+#include <config.h>
+
+/* Specification. */
+#ifdef FULL_READ
+# include "full-read.h"
+#else
+# include "full-write.h"
+#endif
+
+#include <errno.h>
+
+#ifdef FULL_READ
+# include "safe-read.h"
+# define safe_rw safe_read
+# define full_rw full_read
+# undef const
+# define const /* empty */
+#else
+# include "safe-write.h"
+# define safe_rw safe_write
+# define full_rw full_write
+#endif
+
+#ifdef FULL_READ
+/* Set errno to zero upon EOF. */
+# define ZERO_BYTE_TRANSFER_ERRNO 0
+#else
+/* Some buggy drivers return 0 when one tries to write beyond
+ a device's end. (Example: Linux 1.2.13 on /dev/fd0.)
+ Set errno to ENOSPC so they get a sensible diagnostic. */
+# define ZERO_BYTE_TRANSFER_ERRNO ENOSPC
+#endif
+
+/* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if
+ interrupted or if a partial write(read) occurs. Return the number
+ of bytes transferred.
+ When writing, set errno if fewer than COUNT bytes are written.
+ When reading, if fewer than COUNT bytes are read, you must examine
+ errno to distinguish failure from EOF (errno == 0). */
+size_t
+full_rw (int fd, const void *buf, size_t count)
+{
+ size_t total = 0;
+ const char *ptr = (const char *) buf;
+
+ while (count > 0)
+ {
+ size_t n_rw = safe_rw (fd, ptr, count);
+ if (n_rw == (size_t) -1)
+ break;
+ if (n_rw == 0)
+ {
+ errno = ZERO_BYTE_TRANSFER_ERRNO;
+ break;
+ }
+ total += n_rw;
+ ptr += n_rw;
+ count -= n_rw;
+ }
+
+ return total;
+}
--- /dev/null
+/* An interface to write() that writes all it is asked to write.
+
+ Copyright (C) 2002-2003 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 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/>. */
+
+#include <stddef.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Write COUNT bytes at BUF to descriptor FD, retrying if interrupted
+ or if partial writes occur. Return the number of bytes successfully
+ written, setting errno if that is less than COUNT. */
+extern size_t full_write (int fd, const void *buf, size_t count);
+
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/* Getopt for GNU.
+ NOTE: getopt is now part of the C library, so if you don't know what
+ "Keep this file name-space clean" means, talk to drepper@gnu.org
+ before changing it!
+ Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006,2008
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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/>. */
+\f
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include "getopt.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+#endif
+
+#ifndef attribute_hidden
+# define attribute_hidden
+#endif
+
+/* Unlike standard Unix `getopt', functions like `getopt_long'
+ let the user intersperse the options with the other arguments.
+
+ As `getopt_long' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+
+ Using `getopt' or setting the environment variable POSIXLY_CORRECT
+ disables permutation.
+ Then the application's behavior is completely standard.
+
+ GNU application programs can use a third alternative mode in which
+ they can distinguish the relative order of options and other arguments. */
+
+#include "getopt_int.h"
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+/* 1003.2 says this must be 1 before any call. */
+int optind = 1;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
+/* Keep a global copy of all internal members of getopt_data. */
+
+static struct _getopt_data getopt_data;
+
+\f
+#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV
+extern char *getenv ();
+#endif
+\f
+#ifdef _LIBC
+/* Stored original parameters.
+ XXX This is no good solution. We should rather copy the args so
+ that we can compare them later. But we must not use malloc(3). */
+extern int __libc_argc;
+extern char **__libc_argv;
+
+/* Bash 2.0 gives us an environment variable containing flags
+ indicating ARGV elements that should not be considered arguments. */
+
+# ifdef USE_NONOPTION_FLAGS
+/* Defined in getopt_init.c */
+extern char *__getopt_nonoption_flags;
+# endif
+
+# ifdef USE_NONOPTION_FLAGS
+# define SWAP_FLAGS(ch1, ch2) \
+ if (d->__nonoption_flags_len > 0) \
+ { \
+ char __tmp = __getopt_nonoption_flags[ch1]; \
+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
+ __getopt_nonoption_flags[ch2] = __tmp; \
+ }
+# else
+# define SWAP_FLAGS(ch1, ch2)
+# endif
+#else /* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif /* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+static void
+exchange (char **argv, struct _getopt_data *d)
+{
+ int bottom = d->__first_nonopt;
+ int middle = d->__last_nonopt;
+ int top = d->optind;
+ char *tem;
+
+ /* Exchange the shorter segment with the far end of the longer segment.
+ That puts the shorter segment into the right place.
+ It leaves the longer segment in the right place overall,
+ but it consists of two parts that need to be swapped next. */
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ /* First make sure the handling of the `__getopt_nonoption_flags'
+ string can work normally. Our top argument must be in the range
+ of the string. */
+ if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
+ {
+ /* We must extend the array. The user plays games with us and
+ presents new arguments. */
+ char *new_str = malloc (top + 1);
+ if (new_str == NULL)
+ d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
+ else
+ {
+ memset (__mempcpy (new_str, __getopt_nonoption_flags,
+ d->__nonoption_flags_max_len),
+ '\0', top + 1 - d->__nonoption_flags_max_len);
+ d->__nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
+ }
+ }
+#endif
+
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS (bottom + i, middle + i);
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+
+ /* Update records for the slots the non-options now occupy. */
+
+ d->__first_nonopt += (d->optind - d->__last_nonopt);
+ d->__last_nonopt = d->optind;
+}
+
+/* Initialize the internal data when the first call is made. */
+
+static const char *
+_getopt_initialize (int argc, char **argv, const char *optstring,
+ int posixly_correct, struct _getopt_data *d)
+{
+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+
+ d->__first_nonopt = d->__last_nonopt = d->optind;
+
+ d->__nextchar = NULL;
+
+ d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT");
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+
+ if (optstring[0] == '-')
+ {
+ d->__ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ d->__ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (d->__posixly_correct)
+ d->__ordering = REQUIRE_ORDER;
+ else
+ d->__ordering = PERMUTE;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ if (!d->__posixly_correct
+ && argc == __libc_argc && argv == __libc_argv)
+ {
+ if (d->__nonoption_flags_max_len == 0)
+ {
+ if (__getopt_nonoption_flags == NULL
+ || __getopt_nonoption_flags[0] == '\0')
+ d->__nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str = __getopt_nonoption_flags;
+ int len = d->__nonoption_flags_max_len = strlen (orig_str);
+ if (d->__nonoption_flags_max_len < argc)
+ d->__nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags =
+ (char *) malloc (d->__nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ d->__nonoption_flags_max_len = -1;
+ else
+ memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+ '\0', d->__nonoption_flags_max_len - len);
+ }
+ }
+ d->__nonoption_flags_len = d->__nonoption_flags_max_len;
+ }
+ else
+ d->__nonoption_flags_len = 0;
+#endif
+
+ return optstring;
+}
+\f
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If `getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If `getopt' finds another option character, it returns that character,
+ updating `optind' and `nextchar' so that the next call to `getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, `getopt' returns -1.
+ Then `optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return '?' after printing an error message. If you set `opterr' to
+ zero, the error message is suppressed but we still return '?'.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following
+ ARGV-element, is returned in `optarg'. Two colons mean an option that
+ wants an optional arg; if there is text in the current ARGV-element,
+ it is returned in `optarg', otherwise `optarg' is set to zero.
+
+ If OPTSTRING starts with `-' or `+', it requests different methods of
+ handling the non-option ARGV-elements.
+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+ Long-named options begin with `--' instead of `-'.
+ Their names may be abbreviated as long as the abbreviation is unique
+ or is an exact match for some defined option. If they have an
+ argument, it follows the option name in the same ARGV-element, separated
+ from the option name by a `=', or else the in next ARGV-element.
+ When `getopt' finds a long-named option, it returns 0 if that option's
+ `flag' field is nonzero, the value of the option's `val' field
+ if the `flag' field is zero.
+
+ LONGOPTS is a vector of `struct option' terminated by an
+ element containing a name which is zero.
+
+ LONGIND returns the index in LONGOPT of the long-named option found.
+ It is only valid when a long-named option has been found by the most
+ recent call.
+
+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+ long-named options.
+
+ If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT
+ environment variable were set. */
+
+int
+_getopt_internal_r (int argc, char **argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ int long_only, int posixly_correct, struct _getopt_data *d)
+{
+ int print_errors = d->opterr;
+ if (optstring[0] == ':')
+ print_errors = 0;
+
+ if (argc < 1)
+ return -1;
+
+ d->optarg = NULL;
+
+ if (d->optind == 0 || !d->__initialized)
+ {
+ if (d->optind == 0)
+ d->optind = 1; /* Don't scan ARGV[0], the program name. */
+ optstring = _getopt_initialize (argc, argv, optstring,
+ posixly_correct, d);
+ d->__initialized = 1;
+ }
+
+ /* Test whether ARGV[optind] points to a non-option argument.
+ Either it does not have option syntax, or there is an environment flag
+ from the shell indicating it is not an option. The later information
+ is only used when the used in the GNU libc. */
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
+ || (d->optind < d->__nonoption_flags_len \
+ && __getopt_nonoption_flags[d->optind] == '1'))
+#else
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
+#endif
+
+ if (d->__nextchar == NULL || *d->__nextchar == '\0')
+ {
+ /* Advance to the next ARGV-element. */
+
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ moved back by the user (who may also have changed the arguments). */
+ if (d->__last_nonopt > d->optind)
+ d->__last_nonopt = d->optind;
+ if (d->__first_nonopt > d->optind)
+ d->__first_nonopt = d->optind;
+
+ if (d->__ordering == PERMUTE)
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if (d->__first_nonopt != d->__last_nonopt
+ && d->__last_nonopt != d->optind)
+ exchange ((char **) argv, d);
+ else if (d->__last_nonopt != d->optind)
+ d->__first_nonopt = d->optind;
+
+ /* Skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (d->optind < argc && NONOPTION_P)
+ d->optind++;
+ d->__last_nonopt = d->optind;
+ }
+
+ /* The special ARGV-element `--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if (d->optind != argc && !strcmp (argv[d->optind], "--"))
+ {
+ d->optind++;
+
+ if (d->__first_nonopt != d->__last_nonopt
+ && d->__last_nonopt != d->optind)
+ exchange ((char **) argv, d);
+ else if (d->__first_nonopt == d->__last_nonopt)
+ d->__first_nonopt = d->optind;
+ d->__last_nonopt = argc;
+
+ d->optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (d->optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (d->__first_nonopt != d->__last_nonopt)
+ d->optind = d->__first_nonopt;
+ return -1;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if (NONOPTION_P)
+ {
+ if (d->__ordering == REQUIRE_ORDER)
+ return -1;
+ d->optarg = argv[d->optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Skip the initial punctuation. */
+
+ d->__nextchar = (argv[d->optind] + 1
+ + (longopts != NULL && argv[d->optind][1] == '-'));
+ }
+
+ /* Decode the current option-ARGV-element. */
+
+ /* Check whether the ARGV-element is a long option.
+
+ If long_only and the ARGV-element has the form "-f", where f is
+ a valid short option, don't consider it an abbreviated form of
+ a long option that starts with f. Otherwise there would be no
+ way to give the -f short option.
+
+ On the other hand, if there's a long option "fubar" and
+ the ARGV-element is "-fu", do consider that an abbreviation of
+ the long option, just like "--fu", and not "-f" with arg "u".
+
+ This distinction seems to be the most useful approach. */
+
+ if (longopts != NULL
+ && (argv[d->optind][1] == '-'
+ || (long_only && (argv[d->optind][2]
+ || !strchr (optstring, argv[d->optind][1])))))
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = -1;
+ int option_index;
+
+ for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+ {
+ if ((unsigned int) (nameend - d->__nextchar)
+ == (unsigned int) strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else if (long_only
+ || pfound->has_arg != p->has_arg
+ || pfound->flag != p->flag
+ || pfound->val != p->val)
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+
+ if (ambig && !exact)
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[d->optind]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[d->optind]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ d->optind++;
+ d->optopt = 0;
+ return '?';
+ }
+
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ d->optind++;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ d->optarg = nameend + 1;
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+ int n;
+#endif
+
+ if (argv[d->optind - 1][1] == '-')
+ {
+ /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#else
+ fprintf (stderr, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#endif
+ }
+ else
+ {
+ /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[d->optind - 1][0],
+ pfound->name);
+#else
+ fprintf (stderr, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[d->optind - 1][0],
+ pfound->name);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (n >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#endif
+ }
+
+ d->__nextchar += strlen (d->__nextchar);
+
+ d->optopt = pfound->val;
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (d->optind < argc)
+ d->optarg = argv[d->optind++];
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ d->optopt = pfound->val;
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
+ if (!long_only || argv[d->optind][1] == '-'
+ || strchr (optstring, *d->__nextchar) == NULL)
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+ int n;
+#endif
+
+ if (argv[d->optind][1] == '-')
+ {
+ /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
+ argv[0], d->__nextchar);
+#else
+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+ argv[0], d->__nextchar);
+#endif
+ }
+ else
+ {
+ /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[d->optind][0], d->__nextchar);
+#else
+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[d->optind][0], d->__nextchar);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (n >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#endif
+ }
+ d->__nextchar = (char *) "";
+ d->optind++;
+ d->optopt = 0;
+ return '?';
+ }
+ }
+
+ /* Look at and handle the next short option-character. */
+
+ {
+ char c = *d->__nextchar++;
+ char *temp = strchr (optstring, c);
+
+ /* Increment `optind' when we start to process its last character. */
+ if (*d->__nextchar == '\0')
+ ++d->optind;
+
+ if (temp == NULL || c == ':')
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+ int n;
+#endif
+
+ if (d->__posixly_correct)
+ {
+ /* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
+ argv[0], c);
+#else
+ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
+#endif
+ }
+ else
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
+ argv[0], c);
+#else
+ fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
+#endif
+ }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ if (n >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#endif
+ }
+ d->optopt = c;
+ return '?';
+ }
+ /* Convenience. Treat POSIX -W foo same as long option --foo */
+ if (temp[0] == 'W' && temp[1] == ';')
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = 0;
+ int option_index;
+
+ /* This is an option that requires an argument. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ d->optind++;
+ }
+ else if (d->optind == argc)
+ {
+ if (print_errors)
+ {
+ /* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+#endif
+ }
+ d->optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ /* We already incremented `d->optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ d->optarg = argv[d->optind++];
+
+ /* optarg is now the argument, see if it's in the
+ table of longopts. */
+
+ for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
+ nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+ {
+ if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+ if (ambig && !exact)
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[d->optind]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[d->optind]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ d->optind++;
+ return '?';
+ }
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ d->optarg = nameend + 1;
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+#endif
+ }
+
+ d->__nextchar += strlen (d->__nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (d->optind < argc)
+ d->optarg = argv[d->optind++];
+ else
+ {
+ if (print_errors)
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2
+ |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[d->optind - 1]);
+#endif
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ d->__nextchar += strlen (d->__nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ d->__nextchar = NULL;
+ return 'W'; /* Let the application handle it. */
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ d->optind++;
+ }
+ else
+ d->optarg = NULL;
+ d->__nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ d->optind++;
+ }
+ else if (d->optind == argc)
+ {
+ if (print_errors)
+ {
+ /* 1003.2 specifies the format of this message. */
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (__asprintf (&buf, _("\
+%s: option requires an argument -- %c\n"),
+ argv[0], c) >= 0)
+ {
+ _IO_flockfile (stderr);
+
+ int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+ ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+ __fxprintf (NULL, "%s", buf);
+
+ ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+ _IO_funlockfile (stderr);
+
+ free (buf);
+ }
+#else
+ fprintf (stderr,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+#endif
+ }
+ d->optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ d->optarg = argv[d->optind++];
+ d->__nextchar = NULL;
+ }
+ }
+ return c;
+ }
+}
+
+int
+_getopt_internal (int argc, char **argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ int long_only, int posixly_correct)
+{
+ int result;
+
+ getopt_data.optind = optind;
+ getopt_data.opterr = opterr;
+
+ result = _getopt_internal_r (argc, argv, optstring, longopts, longind,
+ long_only, posixly_correct, &getopt_data);
+
+ optind = getopt_data.optind;
+ optarg = getopt_data.optarg;
+ optopt = getopt_data.optopt;
+
+ return result;
+}
+
+/* glibc gets a LSB-compliant getopt.
+ Standalone applications get a POSIX-compliant getopt. */
+#if _LIBC
+enum { POSIXLY_CORRECT = 0 };
+#else
+enum { POSIXLY_CORRECT = 1 };
+#endif
+
+int
+getopt (int argc, char *const *argv, const char *optstring)
+{
+ return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
+ POSIXLY_CORRECT);
+}
+
+\f
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+ the above definition of `getopt'. */
+
+int
+main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
--- /dev/null
+/* Declarations for getopt.
+ Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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/>. */
+
+#ifndef _GETOPT_H
+
+#ifndef __need_getopt
+# define _GETOPT_H 1
+#endif
+
+/* Standalone applications should #define __GETOPT_PREFIX to an
+ identifier that prefixes the external functions and variables
+ defined in this header. When this happens, include the
+ headers that might declare getopt so that they will not cause
+ confusion if included after this file. Then systematically rename
+ identifiers so that they do not collide with the system functions
+ and variables. Renaming avoids problems with some compilers and
+ linkers. */
+#if defined __GETOPT_PREFIX && !defined __need_getopt
+# include <stdlib.h>
+# include <stdio.h>
+# include <unistd.h>
+# undef __need_getopt
+# undef getopt
+# undef getopt_long
+# undef getopt_long_only
+# undef optarg
+# undef opterr
+# undef optind
+# undef optopt
+# define __GETOPT_CONCAT(x, y) x ## y
+# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
+# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
+# define getopt __GETOPT_ID (getopt)
+# define getopt_long __GETOPT_ID (getopt_long)
+# define getopt_long_only __GETOPT_ID (getopt_long_only)
+# define optarg __GETOPT_ID (optarg)
+# define opterr __GETOPT_ID (opterr)
+# define optind __GETOPT_ID (optind)
+# define optopt __GETOPT_ID (optopt)
+#endif
+
+/* Standalone applications get correct prototypes for getopt_long and
+ getopt_long_only; they declare "char **argv". libc uses prototypes
+ with "char *const *argv" that are incorrect because getopt_long and
+ getopt_long_only can permute argv; this is required for backward
+ compatibility (e.g., for LSB 2.0.1).
+
+ This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
+ but it caused redefinition warnings if both unistd.h and getopt.h were
+ included, since unistd.h includes getopt.h having previously defined
+ __need_getopt.
+
+ The only place where __getopt_argv_const is used is in definitions
+ of getopt_long and getopt_long_only below, but these are visible
+ only if __need_getopt is not defined, so it is quite safe to rewrite
+ the conditional as follows:
+*/
+#if !defined __need_getopt
+# if defined __GETOPT_PREFIX
+# define __getopt_argv_const /* empty */
+# else
+# define __getopt_argv_const const
+# endif
+#endif
+
+/* If __GNU_LIBRARY__ is not already defined, either we are being used
+ standalone, or this is the first header included in the source file.
+ If we are being used with glibc, we need to include <features.h>, but
+ that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
+ not defined, include <ctype.h>, which will pull in <features.h> for us
+ if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
+ doesn't flood the namespace with stuff the way some other headers do.) */
+#if !defined __GNU_LIBRARY__
+# include <ctype.h>
+#endif
+
+#ifndef __THROW
+# ifndef __GNUC_PREREQ
+# define __GNUC_PREREQ(maj, min) (0)
+# endif
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# else
+# define __THROW
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+
+#ifndef __need_getopt
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+struct option
+{
+ const char *name;
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+# define no_argument 0
+# define required_argument 1
+# define optional_argument 2
+#endif /* need getopt */
+
+
+/* Get definitions and prototypes for functions to process the
+ arguments in ARGV (ARGC of them, minus the program name) for
+ options given in OPTS.
+
+ Return the option character from OPTS just read. Return -1 when
+ there are no more options. For unrecognized options, or options
+ missing arguments, `optopt' is set to the option letter, and '?' is
+ returned.
+
+ The OPTS string is a list of characters which are recognized option
+ letters, optionally followed by colons, specifying that that letter
+ takes an argument, to be placed in `optarg'.
+
+ If a letter in OPTS is followed by two colons, its argument is
+ optional. This behavior is specific to the GNU `getopt'.
+
+ The argument `--' causes premature termination of argument
+ scanning, explicitly telling `getopt' that there are no more
+ options.
+
+ If OPTS begins with `-', then non-option arguments are treated as
+ arguments to the option '\1'. This behavior is specific to the GNU
+ `getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in
+ the environment, then do not permute arguments. */
+
+extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
+ __THROW;
+
+#ifndef __need_getopt
+extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind)
+ __THROW;
+extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind)
+ __THROW;
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Make sure we later can get all the definitions and declarations. */
+#undef __need_getopt
+
+#endif /* getopt.h */
--- /dev/null
+/* getopt_long and getopt_long_only entry points for GNU getopt.
+ Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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/>. */
+\f
+#ifdef _LIBC
+# include <getopt.h>
+#else
+# include <config.h>
+# include "getopt.h"
+#endif
+#include "getopt_int.h"
+
+#include <stdio.h>
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+#include <stdlib.h>
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+int
+getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
+ const struct option *long_options, int *opt_index)
+{
+ return _getopt_internal (argc, (char **) argv, options, long_options,
+ opt_index, 0, 0);
+}
+
+int
+_getopt_long_r (int argc, char **argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+ 0, 0, d);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+ If an option that starts with '-' (not '--') doesn't match a long option,
+ but does match a short option, it is parsed as a short option
+ instead. */
+
+int
+getopt_long_only (int argc, char *__getopt_argv_const *argv,
+ const char *options,
+ const struct option *long_options, int *opt_index)
+{
+ return _getopt_internal (argc, (char **) argv, options, long_options,
+ opt_index, 1, 0);
+}
+
+int
+_getopt_long_only_r (int argc, char **argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+ 1, 0, d);
+}
+
+\f
+#ifdef TEST
+
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] =
+ {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
--- /dev/null
+/* Internal declarations for getopt.
+ Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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/>. */
+
+#ifndef _GETOPT_INT_H
+#define _GETOPT_INT_H 1
+
+extern int _getopt_internal (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only, int __posixly_correct);
+
+\f
+/* Reentrant versions which can handle parsing multiple argument
+ vectors at the same time. */
+
+/* Data type for reentrant functions. */
+struct _getopt_data
+{
+ /* These have exactly the same meaning as the corresponding global
+ variables, except that they are used for the reentrant
+ versions of getopt. */
+ int optind;
+ int opterr;
+ int optopt;
+ char *optarg;
+
+ /* Internal members. */
+
+ /* True if the internal members have been initialized. */
+ int __initialized;
+
+ /* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+ char *__nextchar;
+
+ /* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters, or by calling getopt.
+
+ PERMUTE is the default. We permute the contents of ARGV as we
+ scan, so that eventually all the non-options are at the end.
+ This allows options to be given in any order, even with programs
+ that were not written to expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were
+ written to expect options and other ARGV-elements in any order
+ and that care about the ordering of the two. We describe each
+ non-option ARGV-element as if it were the argument of an option
+ with character code 1. Using `-' as the first character of the
+ list of option characters selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
+
+ enum
+ {
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+ } __ordering;
+
+ /* If the POSIXLY_CORRECT environment variable is set
+ or getopt was called. */
+ int __posixly_correct;
+
+
+ /* Handle permutation of arguments. */
+
+ /* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first
+ of them; `last_nonopt' is the index after the last of them. */
+
+ int __first_nonopt;
+ int __last_nonopt;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ int __nonoption_flags_max_len;
+ int __nonoption_flags_len;
+# endif
+};
+
+/* The initializer is necessary to set OPTIND and OPTERR to their
+ default values and to clear the initialization flag. */
+#define _GETOPT_DATA_INITIALIZER { 1, 1 }
+
+extern int _getopt_internal_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only, int __posixly_correct,
+ struct _getopt_data *__data);
+
+extern int _getopt_long_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ struct _getopt_data *__data);
+
+extern int _getopt_long_only_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts,
+ int *__longind,
+ struct _getopt_data *__data);
+
+#endif /* getopt_int.h */
--- /dev/null
+/* Convenience header for conditional use of GNU <libintl.h>.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option. */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+ the gettext() and ngettext() macros. This is an alternative to calling
+ textdomain(), and is useful for libraries. */
+# ifdef DEFAULT_TEXT_DOMAIN
+# undef gettext
+# define gettext(Msgid) \
+ dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+ <libintl.h>, which chokes if dcgettext is defined as a macro. So include
+ it now, to make later inclusions of <libintl.h> a NOP. */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
+# include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+# define gettext(Msgid) ((const char *) (Msgid))
+# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
+# define dcgettext(Domainname, Msgid, Category) \
+ ((void) (Category), dgettext (Domainname, Msgid))
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 \
+ ? ((void) (Msgid2), (const char *) (Msgid1)) \
+ : ((void) (Msgid1), (const char *) (Msgid2)))
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
+# define textdomain(Domainname) ((const char *) (Domainname))
+# define bindtextdomain(Domainname, Dirname) \
+ ((void) (Domainname), (const char *) (Dirname))
+# define bind_textdomain_codeset(Domainname, Codeset) \
+ ((void) (Domainname), (const char *) (Codeset))
+
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+/* The separator between msgctxt and msgid in a .mo file. */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+ MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
+ short and rarely need to change.
+ The letter 'p' stands for 'particular' or 'special'. */
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+pgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
+{
+ const char *translation = dcgettext (domain, msg_ctxt_id, category);
+ if (translation == msg_ctxt_id)
+ return msgid;
+ else
+ return translation;
+}
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+npgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ const char *translation =
+ dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ if (translation == msg_ctxt_id || translation == msgid_plural)
+ return (n == 1 ? msgid : msgid_plural);
+ else
+ return translation;
+}
+
+/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+ can be arbitrary expressions. But for string literals these macros are
+ less efficient than those above. */
+
+#include <string.h>
+
+#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+ (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+ /* || __STDC_VERSION__ >= 199901L */ )
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+ dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcgettext (domain, msg_ctxt_id, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (translation != msg_ctxt_id)
+ return translation;
+ }
+ return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcnpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ return translation;
+ }
+ return (n == 1 ? msgid : msgid_plural);
+}
+
+#endif /* _LIBGETTEXT_H */
--- /dev/null
+/* hash - hashing table processing.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007 Free
+ Software Foundation, Inc.
+
+ Written by Jim Meyering, 1992.
+
+ 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/>. */
+
+/* A generic hash table package. */
+
+/* Define USE_OBSTACK to 1 if you want the allocator to use obstacks instead
+ of malloc. If you change USE_OBSTACK, you have to recompile! */
+
+#include <config.h>
+
+#include "hash.h"
+#include "xalloc.h"
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#if USE_OBSTACK
+# include "obstack.h"
+# ifndef obstack_chunk_alloc
+# define obstack_chunk_alloc malloc
+# endif
+# ifndef obstack_chunk_free
+# define obstack_chunk_free free
+# endif
+#endif
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+struct hash_table
+ {
+ /* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
+ for a possibility of N_BUCKETS. Among those, N_BUCKETS_USED buckets
+ are not empty, there are N_ENTRIES active entries in the table. */
+ struct hash_entry *bucket;
+ struct hash_entry const *bucket_limit;
+ size_t n_buckets;
+ size_t n_buckets_used;
+ size_t n_entries;
+
+ /* Tuning arguments, kept in a physicaly separate structure. */
+ const Hash_tuning *tuning;
+
+ /* Three functions are given to `hash_initialize', see the documentation
+ block for this function. In a word, HASHER randomizes a user entry
+ into a number up from 0 up to some maximum minus 1; COMPARATOR returns
+ true if two user entries compare equally; and DATA_FREER is the cleanup
+ function for a user entry. */
+ Hash_hasher hasher;
+ Hash_comparator comparator;
+ Hash_data_freer data_freer;
+
+ /* A linked list of freed struct hash_entry structs. */
+ struct hash_entry *free_entry_list;
+
+#if USE_OBSTACK
+ /* Whenever obstacks are used, it is possible to allocate all overflowed
+ entries into a single stack, so they all can be freed in a single
+ operation. It is not clear if the speedup is worth the trouble. */
+ struct obstack entry_stack;
+#endif
+ };
+
+/* A hash table contains many internal entries, each holding a pointer to
+ some user provided data (also called a user entry). An entry indistinctly
+ refers to both the internal entry and its associated user entry. A user
+ entry contents may be hashed by a randomization function (the hashing
+ function, or just `hasher' for short) into a number (or `slot') between 0
+ and the current table size. At each slot position in the hash table,
+ starts a linked chain of entries for which the user data all hash to this
+ slot. A bucket is the collection of all entries hashing to the same slot.
+
+ A good `hasher' function will distribute entries rather evenly in buckets.
+ In the ideal case, the length of each bucket is roughly the number of
+ entries divided by the table size. Finding the slot for a data is usually
+ done in constant time by the `hasher', and the later finding of a precise
+ entry is linear in time with the size of the bucket. Consequently, a
+ larger hash table size (that is, a larger number of buckets) is prone to
+ yielding shorter chains, *given* the `hasher' function behaves properly.
+
+ Long buckets slow down the lookup algorithm. One might use big hash table
+ sizes in hope to reduce the average length of buckets, but this might
+ become inordinate, as unused slots in the hash table take some space. The
+ best bet is to make sure you are using a good `hasher' function (beware
+ that those are not that easy to write! :-), and to use a table size
+ larger than the actual number of entries. */
+
+/* If an insertion makes the ratio of nonempty buckets to table size larger
+ than the growth threshold (a number between 0.0 and 1.0), then increase
+ the table size by multiplying by the growth factor (a number greater than
+ 1.0). The growth threshold defaults to 0.8, and the growth factor
+ defaults to 1.414, meaning that the table will have doubled its size
+ every second time 80% of the buckets get used. */
+#define DEFAULT_GROWTH_THRESHOLD 0.8
+#define DEFAULT_GROWTH_FACTOR 1.414
+
+/* If a deletion empties a bucket and causes the ratio of used buckets to
+ table size to become smaller than the shrink threshold (a number between
+ 0.0 and 1.0), then shrink the table by multiplying by the shrink factor (a
+ number greater than the shrink threshold but smaller than 1.0). The shrink
+ threshold and factor default to 0.0 and 1.0, meaning that the table never
+ shrinks. */
+#define DEFAULT_SHRINK_THRESHOLD 0.0
+#define DEFAULT_SHRINK_FACTOR 1.0
+
+/* Use this to initialize or reset a TUNING structure to
+ some sensible values. */
+static const Hash_tuning default_tuning =
+ {
+ DEFAULT_SHRINK_THRESHOLD,
+ DEFAULT_SHRINK_FACTOR,
+ DEFAULT_GROWTH_THRESHOLD,
+ DEFAULT_GROWTH_FACTOR,
+ false
+ };
+
+/* Information and lookup. */
+
+/* The following few functions provide information about the overall hash
+ table organization: the number of entries, number of buckets and maximum
+ length of buckets. */
+
+/* Return the number of buckets in the hash table. The table size, the total
+ number of buckets (used plus unused), or the maximum number of slots, are
+ the same quantity. */
+
+size_t
+hash_get_n_buckets (const Hash_table *table)
+{
+ return table->n_buckets;
+}
+
+/* Return the number of slots in use (non-empty buckets). */
+
+size_t
+hash_get_n_buckets_used (const Hash_table *table)
+{
+ return table->n_buckets_used;
+}
+
+/* Return the number of active entries. */
+
+size_t
+hash_get_n_entries (const Hash_table *table)
+{
+ return table->n_entries;
+}
+
+/* Return the length of the longest chain (bucket). */
+
+size_t
+hash_get_max_bucket_length (const Hash_table *table)
+{
+ struct hash_entry const *bucket;
+ size_t max_bucket_length = 0;
+
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ if (bucket->data)
+ {
+ struct hash_entry const *cursor = bucket;
+ size_t bucket_length = 1;
+
+ while (cursor = cursor->next, cursor)
+ bucket_length++;
+
+ if (bucket_length > max_bucket_length)
+ max_bucket_length = bucket_length;
+ }
+ }
+
+ return max_bucket_length;
+}
+
+/* Do a mild validation of a hash table, by traversing it and checking two
+ statistics. */
+
+bool
+hash_table_ok (const Hash_table *table)
+{
+ struct hash_entry const *bucket;
+ size_t n_buckets_used = 0;
+ size_t n_entries = 0;
+
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ if (bucket->data)
+ {
+ struct hash_entry const *cursor = bucket;
+
+ /* Count bucket head. */
+ n_buckets_used++;
+ n_entries++;
+
+ /* Count bucket overflow. */
+ while (cursor = cursor->next, cursor)
+ n_entries++;
+ }
+ }
+
+ if (n_buckets_used == table->n_buckets_used && n_entries == table->n_entries)
+ return true;
+
+ return false;
+}
+
+void
+hash_print_statistics (const Hash_table *table, FILE *stream)
+{
+ size_t n_entries = hash_get_n_entries (table);
+ size_t n_buckets = hash_get_n_buckets (table);
+ size_t n_buckets_used = hash_get_n_buckets_used (table);
+ size_t max_bucket_length = hash_get_max_bucket_length (table);
+
+ fprintf (stream, "# entries: %lu\n", (unsigned long int) n_entries);
+ fprintf (stream, "# buckets: %lu\n", (unsigned long int) n_buckets);
+ fprintf (stream, "# buckets used: %lu (%.2f%%)\n",
+ (unsigned long int) n_buckets_used,
+ (100.0 * n_buckets_used) / n_buckets);
+ fprintf (stream, "max bucket length: %lu\n",
+ (unsigned long int) max_bucket_length);
+}
+
+/* If ENTRY matches an entry already in the hash table, return the
+ entry from the table. Otherwise, return NULL. */
+
+void *
+hash_lookup (const Hash_table *table, const void *entry)
+{
+ struct hash_entry const *bucket
+ = table->bucket + table->hasher (entry, table->n_buckets);
+ struct hash_entry const *cursor;
+
+ if (! (bucket < table->bucket_limit))
+ abort ();
+
+ if (bucket->data == NULL)
+ return NULL;
+
+ for (cursor = bucket; cursor; cursor = cursor->next)
+ if (table->comparator (entry, cursor->data))
+ return cursor->data;
+
+ return NULL;
+}
+
+/* Walking. */
+
+/* The functions in this page traverse the hash table and process the
+ contained entries. For the traversal to work properly, the hash table
+ should not be resized nor modified while any particular entry is being
+ processed. In particular, entries should not be added or removed. */
+
+/* Return the first data in the table, or NULL if the table is empty. */
+
+void *
+hash_get_first (const Hash_table *table)
+{
+ struct hash_entry const *bucket;
+
+ if (table->n_entries == 0)
+ return NULL;
+
+ for (bucket = table->bucket; ; bucket++)
+ if (! (bucket < table->bucket_limit))
+ abort ();
+ else if (bucket->data)
+ return bucket->data;
+}
+
+/* Return the user data for the entry following ENTRY, where ENTRY has been
+ returned by a previous call to either `hash_get_first' or `hash_get_next'.
+ Return NULL if there are no more entries. */
+
+void *
+hash_get_next (const Hash_table *table, const void *entry)
+{
+ struct hash_entry const *bucket
+ = table->bucket + table->hasher (entry, table->n_buckets);
+ struct hash_entry const *cursor;
+
+ if (! (bucket < table->bucket_limit))
+ abort ();
+
+ /* Find next entry in the same bucket. */
+ for (cursor = bucket; cursor; cursor = cursor->next)
+ if (cursor->data == entry && cursor->next)
+ return cursor->next->data;
+
+ /* Find first entry in any subsequent bucket. */
+ while (++bucket < table->bucket_limit)
+ if (bucket->data)
+ return bucket->data;
+
+ /* None found. */
+ return NULL;
+}
+
+/* Fill BUFFER with pointers to active user entries in the hash table, then
+ return the number of pointers copied. Do not copy more than BUFFER_SIZE
+ pointers. */
+
+size_t
+hash_get_entries (const Hash_table *table, void **buffer,
+ size_t buffer_size)
+{
+ size_t counter = 0;
+ struct hash_entry const *bucket;
+ struct hash_entry const *cursor;
+
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ if (bucket->data)
+ {
+ for (cursor = bucket; cursor; cursor = cursor->next)
+ {
+ if (counter >= buffer_size)
+ return counter;
+ buffer[counter++] = cursor->data;
+ }
+ }
+ }
+
+ return counter;
+}
+
+/* Call a PROCESSOR function for each entry of a hash table, and return the
+ number of entries for which the processor function returned success. A
+ pointer to some PROCESSOR_DATA which will be made available to each call to
+ the processor function. The PROCESSOR accepts two arguments: the first is
+ the user entry being walked into, the second is the value of PROCESSOR_DATA
+ as received. The walking continue for as long as the PROCESSOR function
+ returns nonzero. When it returns zero, the walking is interrupted. */
+
+size_t
+hash_do_for_each (const Hash_table *table, Hash_processor processor,
+ void *processor_data)
+{
+ size_t counter = 0;
+ struct hash_entry const *bucket;
+ struct hash_entry const *cursor;
+
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ if (bucket->data)
+ {
+ for (cursor = bucket; cursor; cursor = cursor->next)
+ {
+ if (!(*processor) (cursor->data, processor_data))
+ return counter;
+ counter++;
+ }
+ }
+ }
+
+ return counter;
+}
+
+/* Allocation and clean-up. */
+
+/* Return a hash index for a NUL-terminated STRING between 0 and N_BUCKETS-1.
+ This is a convenience routine for constructing other hashing functions. */
+
+#if USE_DIFF_HASH
+
+/* About hashings, Paul Eggert writes to me (FP), on 1994-01-01: "Please see
+ B. J. McKenzie, R. Harries & T. Bell, Selecting a hashing algorithm,
+ Software--practice & experience 20, 2 (Feb 1990), 209-224. Good hash
+ algorithms tend to be domain-specific, so what's good for [diffutils'] io.c
+ may not be good for your application." */
+
+size_t
+hash_string (const char *string, size_t n_buckets)
+{
+# define ROTATE_LEFT(Value, Shift) \
+ ((Value) << (Shift) | (Value) >> ((sizeof (size_t) * CHAR_BIT) - (Shift)))
+# define HASH_ONE_CHAR(Value, Byte) \
+ ((Byte) + ROTATE_LEFT (Value, 7))
+
+ size_t value = 0;
+ unsigned char ch;
+
+ for (; (ch = *string); string++)
+ value = HASH_ONE_CHAR (value, ch);
+ return value % n_buckets;
+
+# undef ROTATE_LEFT
+# undef HASH_ONE_CHAR
+}
+
+#else /* not USE_DIFF_HASH */
+
+/* This one comes from `recode', and performs a bit better than the above as
+ per a few experiments. It is inspired from a hashing routine found in the
+ very old Cyber `snoop', itself written in typical Greg Mansfield style.
+ (By the way, what happened to this excellent man? Is he still alive?) */
+
+size_t
+hash_string (const char *string, size_t n_buckets)
+{
+ size_t value = 0;
+ unsigned char ch;
+
+ for (; (ch = *string); string++)
+ value = (value * 31 + ch) % n_buckets;
+ return value;
+}
+
+#endif /* not USE_DIFF_HASH */
+
+/* Return true if CANDIDATE is a prime number. CANDIDATE should be an odd
+ number at least equal to 11. */
+
+static bool
+is_prime (size_t candidate)
+{
+ size_t divisor = 3;
+ size_t square = divisor * divisor;
+
+ while (square < candidate && (candidate % divisor))
+ {
+ divisor++;
+ square += 4 * divisor;
+ divisor++;
+ }
+
+ return (candidate % divisor ? true : false);
+}
+
+/* Round a given CANDIDATE number up to the nearest prime, and return that
+ prime. Primes lower than 10 are merely skipped. */
+
+static size_t
+next_prime (size_t candidate)
+{
+ /* Skip small primes. */
+ if (candidate < 10)
+ candidate = 10;
+
+ /* Make it definitely odd. */
+ candidate |= 1;
+
+ while (!is_prime (candidate))
+ candidate += 2;
+
+ return candidate;
+}
+
+void
+hash_reset_tuning (Hash_tuning *tuning)
+{
+ *tuning = default_tuning;
+}
+
+/* For the given hash TABLE, check the user supplied tuning structure for
+ reasonable values, and return true if there is no gross error with it.
+ Otherwise, definitively reset the TUNING field to some acceptable default
+ in the hash table (that is, the user loses the right of further modifying
+ tuning arguments), and return false. */
+
+static bool
+check_tuning (Hash_table *table)
+{
+ const Hash_tuning *tuning = table->tuning;
+
+ /* Be a bit stricter than mathematics would require, so that
+ rounding errors in size calculations do not cause allocations to
+ fail to grow or shrink as they should. The smallest allocation
+ is 11 (due to next_prime's algorithm), so an epsilon of 0.1
+ should be good enough. */
+ float epsilon = 0.1f;
+
+ if (epsilon < tuning->growth_threshold
+ && tuning->growth_threshold < 1 - epsilon
+ && 1 + epsilon < tuning->growth_factor
+ && 0 <= tuning->shrink_threshold
+ && tuning->shrink_threshold + epsilon < tuning->shrink_factor
+ && tuning->shrink_factor <= 1
+ && tuning->shrink_threshold + epsilon < tuning->growth_threshold)
+ return true;
+
+ table->tuning = &default_tuning;
+ return false;
+}
+
+/* Allocate and return a new hash table, or NULL upon failure. The initial
+ number of buckets is automatically selected so as to _guarantee_ that you
+ may insert at least CANDIDATE different user entries before any growth of
+ the hash table size occurs. So, if have a reasonably tight a-priori upper
+ bound on the number of entries you intend to insert in the hash table, you
+ may save some table memory and insertion time, by specifying it here. If
+ the IS_N_BUCKETS field of the TUNING structure is true, the CANDIDATE
+ argument has its meaning changed to the wanted number of buckets.
+
+ TUNING points to a structure of user-supplied values, in case some fine
+ tuning is wanted over the default behavior of the hasher. If TUNING is
+ NULL, the default tuning parameters are used instead.
+
+ The user-supplied HASHER function should be provided. It accepts two
+ arguments ENTRY and TABLE_SIZE. It computes, by hashing ENTRY contents, a
+ slot number for that entry which should be in the range 0..TABLE_SIZE-1.
+ This slot number is then returned.
+
+ The user-supplied COMPARATOR function should be provided. It accepts two
+ arguments pointing to user data, it then returns true for a pair of entries
+ that compare equal, or false otherwise. This function is internally called
+ on entries which are already known to hash to the same bucket index.
+
+ The user-supplied DATA_FREER function, when not NULL, may be later called
+ with the user data as an argument, just before the entry containing the
+ data gets freed. This happens from within `hash_free' or `hash_clear'.
+ You should specify this function only if you want these functions to free
+ all of your `data' data. This is typically the case when your data is
+ simply an auxiliary struct that you have malloc'd to aggregate several
+ values. */
+
+Hash_table *
+hash_initialize (size_t candidate, const Hash_tuning *tuning,
+ Hash_hasher hasher, Hash_comparator comparator,
+ Hash_data_freer data_freer)
+{
+ Hash_table *table;
+
+ if (hasher == NULL || comparator == NULL)
+ return NULL;
+
+ table = malloc (sizeof *table);
+ if (table == NULL)
+ return NULL;
+
+ if (!tuning)
+ tuning = &default_tuning;
+ table->tuning = tuning;
+ if (!check_tuning (table))
+ {
+ /* Fail if the tuning options are invalid. This is the only occasion
+ when the user gets some feedback about it. Once the table is created,
+ if the user provides invalid tuning options, we silently revert to
+ using the defaults, and ignore further request to change the tuning
+ options. */
+ goto fail;
+ }
+
+ if (!tuning->is_n_buckets)
+ {
+ float new_candidate = candidate / tuning->growth_threshold;
+ if (SIZE_MAX <= new_candidate)
+ goto fail;
+ candidate = new_candidate;
+ }
+
+ if (xalloc_oversized (candidate, sizeof *table->bucket))
+ goto fail;
+ table->n_buckets = next_prime (candidate);
+ if (xalloc_oversized (table->n_buckets, sizeof *table->bucket))
+ goto fail;
+
+ table->bucket = calloc (table->n_buckets, sizeof *table->bucket);
+ if (table->bucket == NULL)
+ goto fail;
+ table->bucket_limit = table->bucket + table->n_buckets;
+ table->n_buckets_used = 0;
+ table->n_entries = 0;
+
+ table->hasher = hasher;
+ table->comparator = comparator;
+ table->data_freer = data_freer;
+
+ table->free_entry_list = NULL;
+#if USE_OBSTACK
+ obstack_init (&table->entry_stack);
+#endif
+ return table;
+
+ fail:
+ free (table);
+ return NULL;
+}
+
+/* Make all buckets empty, placing any chained entries on the free list.
+ Apply the user-specified function data_freer (if any) to the datas of any
+ affected entries. */
+
+void
+hash_clear (Hash_table *table)
+{
+ struct hash_entry *bucket;
+
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ if (bucket->data)
+ {
+ struct hash_entry *cursor;
+ struct hash_entry *next;
+
+ /* Free the bucket overflow. */
+ for (cursor = bucket->next; cursor; cursor = next)
+ {
+ if (table->data_freer)
+ (*table->data_freer) (cursor->data);
+ cursor->data = NULL;
+
+ next = cursor->next;
+ /* Relinking is done one entry at a time, as it is to be expected
+ that overflows are either rare or short. */
+ cursor->next = table->free_entry_list;
+ table->free_entry_list = cursor;
+ }
+
+ /* Free the bucket head. */
+ if (table->data_freer)
+ (*table->data_freer) (bucket->data);
+ bucket->data = NULL;
+ bucket->next = NULL;
+ }
+ }
+
+ table->n_buckets_used = 0;
+ table->n_entries = 0;
+}
+
+/* Reclaim all storage associated with a hash table. If a data_freer
+ function has been supplied by the user when the hash table was created,
+ this function applies it to the data of each entry before freeing that
+ entry. */
+
+void
+hash_free (Hash_table *table)
+{
+ struct hash_entry *bucket;
+ struct hash_entry *cursor;
+ struct hash_entry *next;
+
+ /* Call the user data_freer function. */
+ if (table->data_freer && table->n_entries)
+ {
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ if (bucket->data)
+ {
+ for (cursor = bucket; cursor; cursor = cursor->next)
+ {
+ (*table->data_freer) (cursor->data);
+ }
+ }
+ }
+ }
+
+#if USE_OBSTACK
+
+ obstack_free (&table->entry_stack, NULL);
+
+#else
+
+ /* Free all bucket overflowed entries. */
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ for (cursor = bucket->next; cursor; cursor = next)
+ {
+ next = cursor->next;
+ free (cursor);
+ }
+ }
+
+ /* Also reclaim the internal list of previously freed entries. */
+ for (cursor = table->free_entry_list; cursor; cursor = next)
+ {
+ next = cursor->next;
+ free (cursor);
+ }
+
+#endif
+
+ /* Free the remainder of the hash table structure. */
+ free (table->bucket);
+ free (table);
+}
+
+/* Insertion and deletion. */
+
+/* Get a new hash entry for a bucket overflow, possibly by reclying a
+ previously freed one. If this is not possible, allocate a new one. */
+
+static struct hash_entry *
+allocate_entry (Hash_table *table)
+{
+ struct hash_entry *new;
+
+ if (table->free_entry_list)
+ {
+ new = table->free_entry_list;
+ table->free_entry_list = new->next;
+ }
+ else
+ {
+#if USE_OBSTACK
+ new = obstack_alloc (&table->entry_stack, sizeof *new);
+#else
+ new = malloc (sizeof *new);
+#endif
+ }
+
+ return new;
+}
+
+/* Free a hash entry which was part of some bucket overflow,
+ saving it for later recycling. */
+
+static void
+free_entry (Hash_table *table, struct hash_entry *entry)
+{
+ entry->data = NULL;
+ entry->next = table->free_entry_list;
+ table->free_entry_list = entry;
+}
+
+/* This private function is used to help with insertion and deletion. When
+ ENTRY matches an entry in the table, return a pointer to the corresponding
+ user data and set *BUCKET_HEAD to the head of the selected bucket.
+ Otherwise, return NULL. When DELETE is true and ENTRY matches an entry in
+ the table, unlink the matching entry. */
+
+static void *
+hash_find_entry (Hash_table *table, const void *entry,
+ struct hash_entry **bucket_head, bool delete)
+{
+ struct hash_entry *bucket
+ = table->bucket + table->hasher (entry, table->n_buckets);
+ struct hash_entry *cursor;
+
+ if (! (bucket < table->bucket_limit))
+ abort ();
+
+ *bucket_head = bucket;
+
+ /* Test for empty bucket. */
+ if (bucket->data == NULL)
+ return NULL;
+
+ /* See if the entry is the first in the bucket. */
+ if ((*table->comparator) (entry, bucket->data))
+ {
+ void *data = bucket->data;
+
+ if (delete)
+ {
+ if (bucket->next)
+ {
+ struct hash_entry *next = bucket->next;
+
+ /* Bump the first overflow entry into the bucket head, then save
+ the previous first overflow entry for later recycling. */
+ *bucket = *next;
+ free_entry (table, next);
+ }
+ else
+ {
+ bucket->data = NULL;
+ }
+ }
+
+ return data;
+ }
+
+ /* Scan the bucket overflow. */
+ for (cursor = bucket; cursor->next; cursor = cursor->next)
+ {
+ if ((*table->comparator) (entry, cursor->next->data))
+ {
+ void *data = cursor->next->data;
+
+ if (delete)
+ {
+ struct hash_entry *next = cursor->next;
+
+ /* Unlink the entry to delete, then save the freed entry for later
+ recycling. */
+ cursor->next = next->next;
+ free_entry (table, next);
+ }
+
+ return data;
+ }
+ }
+
+ /* No entry found. */
+ return NULL;
+}
+
+/* For an already existing hash table, change the number of buckets through
+ specifying CANDIDATE. The contents of the hash table are preserved. The
+ new number of buckets is automatically selected so as to _guarantee_ that
+ the table may receive at least CANDIDATE different user entries, including
+ those already in the table, before any other growth of the hash table size
+ occurs. If TUNING->IS_N_BUCKETS is true, then CANDIDATE specifies the
+ exact number of buckets desired. */
+
+bool
+hash_rehash (Hash_table *table, size_t candidate)
+{
+ Hash_table *new_table;
+ struct hash_entry *bucket;
+ struct hash_entry *cursor;
+ struct hash_entry *next;
+
+ new_table = hash_initialize (candidate, table->tuning, table->hasher,
+ table->comparator, table->data_freer);
+ if (new_table == NULL)
+ return false;
+
+ /* Merely reuse the extra old space into the new table. */
+#if USE_OBSTACK
+ obstack_free (&new_table->entry_stack, NULL);
+ new_table->entry_stack = table->entry_stack;
+#endif
+ new_table->free_entry_list = table->free_entry_list;
+
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ if (bucket->data)
+ for (cursor = bucket; cursor; cursor = next)
+ {
+ void *data = cursor->data;
+ struct hash_entry *new_bucket
+ = (new_table->bucket
+ + new_table->hasher (data, new_table->n_buckets));
+
+ if (! (new_bucket < new_table->bucket_limit))
+ abort ();
+
+ next = cursor->next;
+
+ if (new_bucket->data)
+ {
+ if (cursor == bucket)
+ {
+ /* Allocate or recycle an entry, when moving from a bucket
+ header into a bucket overflow. */
+ struct hash_entry *new_entry = allocate_entry (new_table);
+
+ if (new_entry == NULL)
+ return false;
+
+ new_entry->data = data;
+ new_entry->next = new_bucket->next;
+ new_bucket->next = new_entry;
+ }
+ else
+ {
+ /* Merely relink an existing entry, when moving from a
+ bucket overflow into a bucket overflow. */
+ cursor->next = new_bucket->next;
+ new_bucket->next = cursor;
+ }
+ }
+ else
+ {
+ /* Free an existing entry, when moving from a bucket
+ overflow into a bucket header. Also take care of the
+ simple case of moving from a bucket header into a bucket
+ header. */
+ new_bucket->data = data;
+ new_table->n_buckets_used++;
+ if (cursor != bucket)
+ free_entry (new_table, cursor);
+ }
+ }
+
+ free (table->bucket);
+ table->bucket = new_table->bucket;
+ table->bucket_limit = new_table->bucket_limit;
+ table->n_buckets = new_table->n_buckets;
+ table->n_buckets_used = new_table->n_buckets_used;
+ table->free_entry_list = new_table->free_entry_list;
+ /* table->n_entries already holds its value. */
+#if USE_OBSTACK
+ table->entry_stack = new_table->entry_stack;
+#endif
+ free (new_table);
+
+ return true;
+}
+
+/* If ENTRY matches an entry already in the hash table, return the pointer
+ to the entry from the table. Otherwise, insert ENTRY and return ENTRY.
+ Return NULL if the storage required for insertion cannot be allocated. */
+
+void *
+hash_insert (Hash_table *table, const void *entry)
+{
+ void *data;
+ struct hash_entry *bucket;
+
+ /* The caller cannot insert a NULL entry. */
+ if (! entry)
+ abort ();
+
+ /* If there's a matching entry already in the table, return that. */
+ if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL)
+ return data;
+
+ /* ENTRY is not matched, it should be inserted. */
+
+ if (bucket->data)
+ {
+ struct hash_entry *new_entry = allocate_entry (table);
+
+ if (new_entry == NULL)
+ return NULL;
+
+ /* Add ENTRY in the overflow of the bucket. */
+
+ new_entry->data = (void *) entry;
+ new_entry->next = bucket->next;
+ bucket->next = new_entry;
+ table->n_entries++;
+ return (void *) entry;
+ }
+
+ /* Add ENTRY right in the bucket head. */
+
+ bucket->data = (void *) entry;
+ table->n_entries++;
+ table->n_buckets_used++;
+
+ /* If the growth threshold of the buckets in use has been reached, increase
+ the table size and rehash. There's no point in checking the number of
+ entries: if the hashing function is ill-conditioned, rehashing is not
+ likely to improve it. */
+
+ if (table->n_buckets_used
+ > table->tuning->growth_threshold * table->n_buckets)
+ {
+ /* Check more fully, before starting real work. If tuning arguments
+ became invalid, the second check will rely on proper defaults. */
+ check_tuning (table);
+ if (table->n_buckets_used
+ > table->tuning->growth_threshold * table->n_buckets)
+ {
+ const Hash_tuning *tuning = table->tuning;
+ float candidate =
+ (tuning->is_n_buckets
+ ? (table->n_buckets * tuning->growth_factor)
+ : (table->n_buckets * tuning->growth_factor
+ * tuning->growth_threshold));
+
+ if (SIZE_MAX <= candidate)
+ return NULL;
+
+ /* If the rehash fails, arrange to return NULL. */
+ if (!hash_rehash (table, candidate))
+ entry = NULL;
+ }
+ }
+
+ return (void *) entry;
+}
+
+/* If ENTRY is already in the table, remove it and return the just-deleted
+ data (the user may want to deallocate its storage). If ENTRY is not in the
+ table, don't modify the table and return NULL. */
+
+void *
+hash_delete (Hash_table *table, const void *entry)
+{
+ void *data;
+ struct hash_entry *bucket;
+
+ data = hash_find_entry (table, entry, &bucket, true);
+ if (!data)
+ return NULL;
+
+ table->n_entries--;
+ if (!bucket->data)
+ {
+ table->n_buckets_used--;
+
+ /* If the shrink threshold of the buckets in use has been reached,
+ rehash into a smaller table. */
+
+ if (table->n_buckets_used
+ < table->tuning->shrink_threshold * table->n_buckets)
+ {
+ /* Check more fully, before starting real work. If tuning arguments
+ became invalid, the second check will rely on proper defaults. */
+ check_tuning (table);
+ if (table->n_buckets_used
+ < table->tuning->shrink_threshold * table->n_buckets)
+ {
+ const Hash_tuning *tuning = table->tuning;
+ size_t candidate =
+ (tuning->is_n_buckets
+ ? table->n_buckets * tuning->shrink_factor
+ : (table->n_buckets * tuning->shrink_factor
+ * tuning->growth_threshold));
+
+ hash_rehash (table, candidate);
+ }
+ }
+ }
+
+ return data;
+}
+
+/* Testing. */
+
+#if TESTING
+
+void
+hash_print (const Hash_table *table)
+{
+ struct hash_entry const *bucket;
+
+ for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
+ {
+ struct hash_entry *cursor;
+
+ if (bucket)
+ printf ("%lu:\n", (unsigned long int) (bucket - table->bucket));
+
+ for (cursor = bucket; cursor; cursor = cursor->next)
+ {
+ char const *s = cursor->data;
+ /* FIXME */
+ if (s)
+ printf (" %s\n", s);
+ }
+ }
+}
+
+#endif /* TESTING */
--- /dev/null
+/* hash - hashing table processing.
+ Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
+ Written by Jim Meyering <meyering@ascend.com>, 1998.
+
+ 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/>. */
+
+/* A generic hash table package. */
+
+/* Make sure USE_OBSTACK is defined to 1 if you want the allocator to use
+ obstacks instead of malloc, and recompile `hash.c' with same setting. */
+
+#ifndef HASH_H_
+# define HASH_H_
+
+# include <stdio.h>
+# include <stdbool.h>
+
+typedef size_t (*Hash_hasher) (const void *, size_t);
+typedef bool (*Hash_comparator) (const void *, const void *);
+typedef void (*Hash_data_freer) (void *);
+typedef bool (*Hash_processor) (void *, void *);
+
+struct hash_entry
+ {
+ void *data;
+ struct hash_entry *next;
+ };
+
+struct hash_tuning
+ {
+ /* This structure is mainly used for `hash_initialize', see the block
+ documentation of `hash_reset_tuning' for more complete comments. */
+
+ float shrink_threshold; /* ratio of used buckets to trigger a shrink */
+ float shrink_factor; /* ratio of new smaller size to original size */
+ float growth_threshold; /* ratio of used buckets to trigger a growth */
+ float growth_factor; /* ratio of new bigger size to original size */
+ bool is_n_buckets; /* if CANDIDATE really means table size */
+ };
+
+typedef struct hash_tuning Hash_tuning;
+
+struct hash_table;
+
+typedef struct hash_table Hash_table;
+
+/* Information and lookup. */
+size_t hash_get_n_buckets (const Hash_table *);
+size_t hash_get_n_buckets_used (const Hash_table *);
+size_t hash_get_n_entries (const Hash_table *);
+size_t hash_get_max_bucket_length (const Hash_table *);
+bool hash_table_ok (const Hash_table *);
+void hash_print_statistics (const Hash_table *, FILE *);
+void *hash_lookup (const Hash_table *, const void *);
+
+/* Walking. */
+void *hash_get_first (const Hash_table *);
+void *hash_get_next (const Hash_table *, const void *);
+size_t hash_get_entries (const Hash_table *, void **, size_t);
+size_t hash_do_for_each (const Hash_table *, Hash_processor, void *);
+
+/* Allocation and clean-up. */
+size_t hash_string (const char *, size_t);
+void hash_reset_tuning (Hash_tuning *);
+Hash_table *hash_initialize (size_t, const Hash_tuning *,
+ Hash_hasher, Hash_comparator,
+ Hash_data_freer);
+void hash_clear (Hash_table *);
+void hash_free (Hash_table *);
+
+/* Insertion and deletion. */
+bool hash_rehash (Hash_table *, size_t);
+void *hash_insert (Hash_table *, const void *);
+void *hash_delete (Hash_table *, const void *);
+
+#endif
--- /dev/null
+/* malloc() function that is glibc compatible.
+
+ Copyright (C) 1997, 1998, 2006, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* written by Jim Meyering and Bruno Haible */
+
+#include <config.h>
+/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
+#ifdef malloc
+# define NEED_MALLOC_GNU
+# undef malloc
+#endif
+
+/* Specification. */
+#include <stdlib.h>
+
+#include <errno.h>
+
+/* Call the system's malloc below. */
+#undef malloc
+
+/* Allocate an N-byte block of memory from the heap.
+ If N is zero, allocate a 1-byte block. */
+
+void *
+rpl_malloc (size_t n)
+{
+ void *result;
+
+#ifdef NEED_MALLOC_GNU
+ if (n == 0)
+ n = 1;
+#endif
+
+ result = malloc (n);
+
+#if !HAVE_MALLOC_POSIX
+ if (result == NULL)
+ errno = ENOMEM;
+#endif
+
+ return result;
+}
--- /dev/null
+/* Convert multibyte character to wide character.
+ Copyright (C) 1999-2002, 2005-2009 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+#if GNULIB_defined_mbstate_t
+/* Implement mbrtowc() on top of mbtowc(). */
+
+# include <errno.h>
+# include <stdlib.h>
+
+# include "localcharset.h"
+# include "streq.h"
+# include "verify.h"
+
+
+verify (sizeof (mbstate_t) >= 4);
+
+static char internal_state[4];
+
+size_t
+mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+ char *pstate = (char *)ps;
+
+ if (pstate == NULL)
+ pstate = internal_state;
+
+ if (s == NULL)
+ {
+ pwc = NULL;
+ s = "";
+ n = 1;
+ }
+
+ if (n == 0)
+ return (size_t)(-2);
+
+ /* Here n > 0. */
+ {
+ size_t nstate = pstate[0];
+ char buf[4];
+ const char *p;
+ size_t m;
+
+ switch (nstate)
+ {
+ case 0:
+ p = s;
+ m = n;
+ break;
+ case 3:
+ buf[2] = pstate[3];
+ /*FALLTHROUGH*/
+ case 2:
+ buf[1] = pstate[2];
+ /*FALLTHROUGH*/
+ case 1:
+ buf[0] = pstate[1];
+ p = buf;
+ m = nstate;
+ buf[m++] = s[0];
+ if (n >= 2 && m < 4)
+ {
+ buf[m++] = s[1];
+ if (n >= 3 && m < 4)
+ buf[m++] = s[2];
+ }
+ break;
+ default:
+ errno = EINVAL;
+ return (size_t)(-1);
+ }
+
+ /* Here m > 0. */
+
+# if __GLIBC__
+ /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
+ mbtowc (NULL, NULL, 0);
+# endif
+ {
+ int res = mbtowc (pwc, p, m);
+
+ if (res >= 0)
+ {
+ if (pwc != NULL && ((*pwc == 0) != (res == 0)))
+ abort ();
+ if (nstate >= (res > 0 ? res : 1))
+ abort ();
+ res -= nstate;
+ pstate[0] = 0;
+ return res;
+ }
+
+ /* mbtowc does not distinguish between invalid and incomplete multibyte
+ sequences. But mbrtowc needs to make this distinction.
+ There are two possible approaches:
+ - Use iconv() and its return value.
+ - Use built-in knowledge about the possible encodings.
+ Given the low quality of implementation of iconv() on the systems that
+ lack mbrtowc(), we use the second approach.
+ The possible encodings are:
+ - 8-bit encodings,
+ - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
+ - UTF-8.
+ Use specialized code for each. */
+ if (m >= 4 || m >= MB_CUR_MAX)
+ goto invalid;
+ /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
+ {
+ const char *encoding = locale_charset ();
+
+ if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+ {
+ /* Cf. unistr/u8-mblen.c. */
+ unsigned char c = (unsigned char) p[0];
+
+ if (c >= 0xc2)
+ {
+ if (c < 0xe0)
+ {
+ if (m == 1)
+ goto incomplete;
+ }
+ else if (c < 0xf0)
+ {
+ if (m == 1)
+ goto incomplete;
+ if (m == 2)
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if ((c2 ^ 0x80) < 0x40
+ && (c >= 0xe1 || c2 >= 0xa0)
+ && (c != 0xed || c2 < 0xa0))
+ goto incomplete;
+ }
+ }
+ else if (c <= 0xf4)
+ {
+ if (m == 1)
+ goto incomplete;
+ else /* m == 2 || m == 3 */
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if ((c2 ^ 0x80) < 0x40
+ && (c >= 0xf1 || c2 >= 0x90)
+ && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
+ {
+ if (m == 2)
+ goto incomplete;
+ else /* m == 3 */
+ {
+ unsigned char c3 = (unsigned char) p[2];
+
+ if ((c3 ^ 0x80) < 0x40)
+ goto incomplete;
+ }
+ }
+ }
+ }
+ }
+ goto invalid;
+ }
+
+ /* As a reference for this code, you can use the GNU libiconv
+ implementation. Look for uses of the RET_TOOFEW macro. */
+
+ if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
+ goto incomplete;
+ }
+ if (m == 2)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c == 0x8f)
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if (c2 >= 0xa1 && c2 < 0xff)
+ goto incomplete;
+ }
+ }
+ goto invalid;
+ }
+ if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+ || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+ || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c >= 0xa1 && c < 0xff)
+ goto incomplete;
+ }
+ goto invalid;
+ }
+ if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
+ goto incomplete;
+ }
+ else /* m == 2 || m == 3 */
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c == 0x8e)
+ goto incomplete;
+ }
+ goto invalid;
+ }
+ if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
+ goto incomplete;
+ }
+ else /* m == 2 || m == 3 */
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c >= 0x90 && c <= 0xe3)
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if (c2 >= 0x30 && c2 <= 0x39)
+ {
+ if (m == 2)
+ goto incomplete;
+ else /* m == 3 */
+ {
+ unsigned char c3 = (unsigned char) p[2];
+
+ if (c3 >= 0x81 && c3 <= 0xfe)
+ goto incomplete;
+ }
+ }
+ }
+ }
+ goto invalid;
+ }
+ if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
+ || (c >= 0xf0 && c <= 0xf9))
+ goto incomplete;
+ }
+ goto invalid;
+ }
+
+ /* An unknown multibyte encoding. */
+ goto incomplete;
+ }
+
+ incomplete:
+ {
+ size_t k = nstate;
+ /* Here 0 <= k < m < 4. */
+ pstate[++k] = s[0];
+ if (k < m)
+ {
+ pstate[++k] = s[1];
+ if (k < m)
+ pstate[++k] = s[2];
+ }
+ if (k != m)
+ abort ();
+ }
+ pstate[0] = m;
+ return (size_t)(-2);
+
+ invalid:
+ errno = EILSEQ;
+ /* The conversion state is undefined, says POSIX. */
+ return (size_t)(-1);
+ }
+ }
+}
+
+#else
+/* Override the system's mbrtowc() function. */
+
+# undef mbrtowc
+
+size_t
+rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG
+ if (s == NULL)
+ {
+ pwc = NULL;
+ s = "";
+ n = 1;
+ }
+# endif
+
+# if MBRTOWC_RETVAL_BUG
+ {
+ static mbstate_t internal_state;
+
+ /* Override mbrtowc's internal state. We can not call mbsinit() on the
+ hidden internal state, but we can call it on our variable. */
+ if (ps == NULL)
+ ps = &internal_state;
+
+ if (!mbsinit (ps))
+ {
+ /* Parse the rest of the multibyte character byte for byte. */
+ size_t count = 0;
+ for (; n > 0; s++, n--)
+ {
+ wchar_t wc;
+ size_t ret = mbrtowc (&wc, s, 1, ps);
+
+ if (ret == (size_t)(-1))
+ return (size_t)(-1);
+ count++;
+ if (ret != (size_t)(-2))
+ {
+ /* The multibyte character has been completed. */
+ if (pwc != NULL)
+ *pwc = wc;
+ return (wc == 0 ? 0 : count);
+ }
+ }
+ return (size_t)(-2);
+ }
+ }
+# endif
+
+# if MBRTOWC_NUL_RETVAL_BUG
+ {
+ wchar_t wc;
+ size_t ret = mbrtowc (&wc, s, n, ps);
+
+ if (ret != (size_t)(-1) && ret != (size_t)(-2))
+ {
+ if (pwc != NULL)
+ *pwc = wc;
+ if (wc == 0)
+ ret = 0;
+ }
+ return ret;
+ }
+# else
+ return mbrtowc (pwc, s, n, ps);
+# endif
+}
+
+#endif
--- /dev/null
+/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008
+ Free Software Foundation, Inc.
+
+ Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+NOTE: The canonical source of this file is maintained with the GNU C Library.
+Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or 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/>. */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include <string.h>
+
+#include <stddef.h>
+
+#if defined _LIBC
+# include <memcopy.h>
+#else
+# define reg_char char
+#endif
+
+#include <limits.h>
+
+#if HAVE_BP_SYM_H || defined _LIBC
+# include <bp-sym.h>
+#else
+# define BP_SYM(sym) sym
+#endif
+
+#undef __memchr
+#ifdef _LIBC
+# undef memchr
+#endif
+
+#ifndef weak_alias
+# define __memchr memchr
+#endif
+
+/* Search no more than N bytes of S for C. */
+void *
+__memchr (void const *s, int c_in, size_t n)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned reg_char c;
+
+ c = (unsigned char) c_in;
+
+ /* Handle the first few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s;
+ n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
+ --n, ++char_ptr)
+ if (*char_ptr == c)
+ return (void *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will test a
+ longword at a time. The tricky part is testing if *any of the four*
+ bytes in the longword in question are equal to c. We first use an xor
+ with repeated_c. This reduces the task to testing whether *any of the
+ four* bytes in longword1 is zero.
+
+ We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ So, the test whether any byte in longword1 is zero is equivalent to
+ testing whether tmp is nonzero. */
+
+ while (n >= sizeof (longword))
+ {
+ longword longword1 = *longword_ptr ^ repeated_c;
+
+ if ((((longword1 - repeated_one) & ~longword1)
+ & (repeated_one << 7)) != 0)
+ break;
+ longword_ptr++;
+ n -= sizeof (longword);
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that either n < sizeof (longword), or one of the
+ sizeof (longword) bytes starting at char_ptr is == c. On little-endian
+ machines, we could determine the first such byte without any further
+ memory accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines. Choose code
+ that works in both cases. */
+
+ for (; n > 0; --n, ++char_ptr)
+ {
+ if (*char_ptr == c)
+ return (void *) char_ptr;
+ }
+
+ return NULL;
+}
+#ifdef weak_alias
+weak_alias (__memchr, BP_SYM (memchr))
+#endif
--- /dev/null
+/* MIN, MAX macros.
+ Copyright (C) 1995, 1998, 2001, 2003, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _MINMAX_H
+#define _MINMAX_H
+
+/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
+ (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
+ MIN, MAX macro redefinitions on some systems; the workaround is to
+ #include this file as the last one among the #include list. */
+
+/* Before we define the following symbols we get the <limits.h> file
+ since otherwise we get redefinitions on some systems if <limits.h> is
+ included after this file. Likewise for <sys/param.h>.
+ If more than one of these system headers define MIN and MAX, pick just
+ one of the headers (because the definitions most likely are the same). */
+#if HAVE_MINMAX_IN_LIMITS_H
+# include <limits.h>
+#elif HAVE_MINMAX_IN_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+/* Note: MIN and MAX should be used with two arguments of the
+ same type. They might not return the minimum and maximum of their two
+ arguments, if the arguments have different types or have unusual
+ floating-point values. For example, on a typical host with 32-bit 'int',
+ 64-bit 'long long', and 64-bit IEEE 754 'double' types:
+
+ MAX (-1, 2147483648) returns 4294967295.
+ MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
+ MAX (NaN, 0.0) returns 0.0.
+ MAX (+0.0, -0.0) returns -0.0.
+
+ and in each case the answer is in some sense bogus. */
+
+/* MAX(a,b) returns the maximum of A and B. */
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+/* MIN(a,b) returns the minimum of A and B. */
+#ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#endif /* _MINMAX_H */
--- /dev/null
+/* quote.c - quote arguments for output
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 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 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/>. */
+
+/* Written by Paul Eggert <eggert@twinsun.com> */
+
+#include <config.h>
+
+#include "quotearg.h"
+#include "quote.h"
+
+/* Return an unambiguous printable representation of NAME,
+ allocated in slot N, suitable for diagnostics. */
+char const *
+quote_n (int n, char const *name)
+{
+ return quotearg_n_style (n, locale_quoting_style, name);
+}
+
+/* Return an unambiguous printable representation of NAME,
+ suitable for diagnostics. */
+char const *
+quote (char const *name)
+{
+ return quote_n (0, name);
+}
--- /dev/null
+/* quote.h - prototypes for quote.c
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2003 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 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/>. */
+
+
+char const *quote_n (int n, char const *name);
+char const *quote (char const *name);
--- /dev/null
+/* quotearg.c - quote arguments for output
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007,
+ 2008 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 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/>. */
+
+/* Written by Paul Eggert <eggert@twinsun.com> */
+
+#include <config.h>
+
+#include "quotearg.h"
+
+#include "xalloc.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#include <wctype.h>
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+#define INT_BITS (sizeof (int) * CHAR_BIT)
+
+struct quoting_options
+{
+ /* Basic quoting style. */
+ enum quoting_style style;
+
+ /* Additional flags. Bitwise combination of enum quoting_flags. */
+ int flags;
+
+ /* Quote the characters indicated by this bit vector even if the
+ quoting style would not normally require them to be quoted. */
+ unsigned int quote_these_too[(UCHAR_MAX / INT_BITS) + 1];
+};
+
+/* Names of quoting styles. */
+char const *const quoting_style_args[] =
+{
+ "literal",
+ "shell",
+ "shell-always",
+ "c",
+ "c-maybe",
+ "escape",
+ "locale",
+ "clocale",
+ 0
+};
+
+/* Correspondences to quoting style names. */
+enum quoting_style const quoting_style_vals[] =
+{
+ literal_quoting_style,
+ shell_quoting_style,
+ shell_always_quoting_style,
+ c_quoting_style,
+ c_maybe_quoting_style,
+ escape_quoting_style,
+ locale_quoting_style,
+ clocale_quoting_style
+};
+
+/* The default quoting options. */
+static struct quoting_options default_quoting_options;
+
+/* Allocate a new set of quoting options, with contents initially identical
+ to O if O is not null, or to the default if O is null.
+ It is the caller's responsibility to free the result. */
+struct quoting_options *
+clone_quoting_options (struct quoting_options *o)
+{
+ int e = errno;
+ struct quoting_options *p = xmemdup (o ? o : &default_quoting_options,
+ sizeof *o);
+ errno = e;
+ return p;
+}
+
+/* Get the value of O's quoting style. If O is null, use the default. */
+enum quoting_style
+get_quoting_style (struct quoting_options *o)
+{
+ return (o ? o : &default_quoting_options)->style;
+}
+
+/* In O (or in the default if O is null),
+ set the value of the quoting style to S. */
+void
+set_quoting_style (struct quoting_options *o, enum quoting_style s)
+{
+ (o ? o : &default_quoting_options)->style = s;
+}
+
+/* In O (or in the default if O is null),
+ set the value of the quoting options for character C to I.
+ Return the old value. Currently, the only values defined for I are
+ 0 (the default) and 1 (which means to quote the character even if
+ it would not otherwise be quoted). */
+int
+set_char_quoting (struct quoting_options *o, char c, int i)
+{
+ unsigned char uc = c;
+ unsigned int *p =
+ (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS;
+ int shift = uc % INT_BITS;
+ int r = (*p >> shift) & 1;
+ *p ^= ((i & 1) ^ r) << shift;
+ return r;
+}
+
+/* In O (or in the default if O is null),
+ set the value of the quoting options flag to I, which can be a
+ bitwise combination of enum quoting_flags, or 0 for default
+ behavior. Return the old value. */
+int
+set_quoting_flags (struct quoting_options *o, int i)
+{
+ int r;
+ if (!o)
+ o = &default_quoting_options;
+ r = o->flags;
+ o->flags = i;
+ return r;
+}
+
+/* Return quoting options for STYLE, with no extra quoting. */
+static struct quoting_options
+quoting_options_from_style (enum quoting_style style)
+{
+ struct quoting_options o;
+ o.style = style;
+ o.flags = 0;
+ memset (o.quote_these_too, 0, sizeof o.quote_these_too);
+ return o;
+}
+
+/* MSGID approximates a quotation mark. Return its translation if it
+ has one; otherwise, return either it or "\"", depending on S. */
+static char const *
+gettext_quote (char const *msgid, enum quoting_style s)
+{
+ char const *translation = _(msgid);
+ if (translation == msgid && s == clocale_quoting_style)
+ translation = "\"";
+ return translation;
+}
+
+/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
+ argument ARG (of size ARGSIZE), using QUOTING_STYLE, FLAGS, and
+ QUOTE_THESE_TOO to control quoting.
+ Terminate the output with a null character, and return the written
+ size of the output, not counting the terminating null.
+ If BUFFERSIZE is too small to store the output string, return the
+ value that would have been returned had BUFFERSIZE been large enough.
+ If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE.
+
+ This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG,
+ ARGSIZE, O), except it breaks O into its component pieces and is
+ not careful about errno. */
+
+static size_t
+quotearg_buffer_restyled (char *buffer, size_t buffersize,
+ char const *arg, size_t argsize,
+ enum quoting_style quoting_style, int flags,
+ unsigned int const *quote_these_too)
+{
+ size_t i;
+ size_t len = 0;
+ char const *quote_string = 0;
+ size_t quote_string_len = 0;
+ bool backslash_escapes = false;
+ bool unibyte_locale = MB_CUR_MAX == 1;
+ bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0;
+
+#define STORE(c) \
+ do \
+ { \
+ if (len < buffersize) \
+ buffer[len] = (c); \
+ len++; \
+ } \
+ while (0)
+
+ switch (quoting_style)
+ {
+ case c_maybe_quoting_style:
+ quoting_style = c_quoting_style;
+ elide_outer_quotes = true;
+ /* Fall through. */
+ case c_quoting_style:
+ if (!elide_outer_quotes)
+ STORE ('"');
+ backslash_escapes = true;
+ quote_string = "\"";
+ quote_string_len = 1;
+ break;
+
+ case escape_quoting_style:
+ backslash_escapes = true;
+ elide_outer_quotes = false;
+ break;
+
+ case locale_quoting_style:
+ case clocale_quoting_style:
+ {
+ /* TRANSLATORS:
+ Get translations for open and closing quotation marks.
+
+ The message catalog should translate "`" to a left
+ quotation mark suitable for the locale, and similarly for
+ "'". If the catalog has no translation,
+ locale_quoting_style quotes `like this', and
+ clocale_quoting_style quotes "like this".
+
+ For example, an American English Unicode locale should
+ translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
+ should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
+ MARK). A British English Unicode locale should instead
+ translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and
+ U+2019 (RIGHT SINGLE QUOTATION MARK), respectively.
+
+ If you don't know what to put here, please see
+ <http://en.wikipedia.org/wiki/Quotation_mark#Glyphs>
+ and use glyphs suitable for your language. */
+
+ char const *left = gettext_quote (N_("`"), quoting_style);
+ char const *right = gettext_quote (N_("'"), quoting_style);
+ if (!elide_outer_quotes)
+ for (quote_string = left; *quote_string; quote_string++)
+ STORE (*quote_string);
+ backslash_escapes = true;
+ quote_string = right;
+ quote_string_len = strlen (quote_string);
+ }
+ break;
+
+ case shell_quoting_style:
+ quoting_style = shell_always_quoting_style;
+ elide_outer_quotes = true;
+ /* Fall through. */
+ case shell_always_quoting_style:
+ if (!elide_outer_quotes)
+ STORE ('\'');
+ quote_string = "'";
+ quote_string_len = 1;
+ break;
+
+ case literal_quoting_style:
+ elide_outer_quotes = false;
+ break;
+
+ default:
+ abort ();
+ }
+
+ for (i = 0; ! (argsize == SIZE_MAX ? arg[i] == '\0' : i == argsize); i++)
+ {
+ unsigned char c;
+ unsigned char esc;
+
+ if (backslash_escapes
+ && quote_string_len
+ && i + quote_string_len <= argsize
+ && memcmp (arg + i, quote_string, quote_string_len) == 0)
+ {
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ STORE ('\\');
+ }
+
+ c = arg[i];
+ switch (c)
+ {
+ case '\0':
+ if (backslash_escapes)
+ {
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ STORE ('\\');
+ if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9')
+ {
+ STORE ('0');
+ STORE ('0');
+ }
+ c = '0';
+ }
+ else if (flags & QA_ELIDE_NULL_BYTES)
+ continue;
+ break;
+
+ case '?':
+ switch (quoting_style)
+ {
+ case shell_always_quoting_style:
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ break;
+
+ case c_quoting_style:
+ if ((flags & QA_SPLIT_TRIGRAPHS)
+ && i + 2 < argsize && arg[i + 1] == '?')
+ switch (arg[i + 2])
+ {
+ case '!': case '\'':
+ case '(': case ')': case '-': case '/':
+ case '<': case '=': case '>':
+ /* Escape the second '?' in what would otherwise be
+ a trigraph. */
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ c = arg[i + 2];
+ i += 2;
+ STORE ('?');
+ STORE ('"');
+ STORE ('"');
+ STORE ('?');
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case '\a': esc = 'a'; goto c_escape;
+ case '\b': esc = 'b'; goto c_escape;
+ case '\f': esc = 'f'; goto c_escape;
+ case '\n': esc = 'n'; goto c_and_shell_escape;
+ case '\r': esc = 'r'; goto c_and_shell_escape;
+ case '\t': esc = 't'; goto c_and_shell_escape;
+ case '\v': esc = 'v'; goto c_escape;
+ case '\\': esc = c;
+ /* No need to escape the escape if we are trying to elide
+ outer quotes and nothing else is problematic. */
+ if (backslash_escapes && elide_outer_quotes && quote_string_len)
+ goto store_c;
+
+ c_and_shell_escape:
+ if (quoting_style == shell_always_quoting_style
+ && elide_outer_quotes)
+ goto force_outer_quoting_style;
+ /* Fall through. */
+ c_escape:
+ if (backslash_escapes)
+ {
+ c = esc;
+ goto store_escape;
+ }
+ break;
+
+ case '{': case '}': /* sometimes special if isolated */
+ if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1))
+ break;
+ /* Fall through. */
+ case '#': case '~':
+ if (i != 0)
+ break;
+ /* Fall through. */
+ case ' ':
+ case '!': /* special in bash */
+ case '"': case '$': case '&':
+ case '(': case ')': case '*': case ';':
+ case '<':
+ case '=': /* sometimes special in 0th or (with "set -k") later args */
+ case '>': case '[':
+ case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
+ case '`': case '|':
+ /* A shell special character. In theory, '$' and '`' could
+ be the first bytes of multibyte characters, which means
+ we should check them with mbrtowc, but in practice this
+ doesn't happen so it's not worth worrying about. */
+ if (quoting_style == shell_always_quoting_style
+ && elide_outer_quotes)
+ goto force_outer_quoting_style;
+ break;
+
+ case '\'':
+ if (quoting_style == shell_always_quoting_style)
+ {
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ STORE ('\'');
+ STORE ('\\');
+ STORE ('\'');
+ }
+ break;
+
+ case '%': case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9': case ':':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z': case ']': case '_': case 'a': case 'b':
+ case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
+ case 'o': case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
+ /* These characters don't cause problems, no matter what the
+ quoting style is. They cannot start multibyte sequences. */
+ break;
+
+ default:
+ /* If we have a multibyte sequence, copy it until we reach
+ its end, find an error, or come back to the initial shift
+ state. For C-like styles, if the sequence has
+ unprintable characters, escape the whole sequence, since
+ we can't easily escape single characters within it. */
+ {
+ /* Length of multibyte sequence found so far. */
+ size_t m;
+
+ bool printable;
+
+ if (unibyte_locale)
+ {
+ m = 1;
+ printable = isprint (c) != 0;
+ }
+ else
+ {
+ mbstate_t mbstate;
+ memset (&mbstate, 0, sizeof mbstate);
+
+ m = 0;
+ printable = true;
+ if (argsize == SIZE_MAX)
+ argsize = strlen (arg);
+
+ do
+ {
+ wchar_t w;
+ size_t bytes = mbrtowc (&w, &arg[i + m],
+ argsize - (i + m), &mbstate);
+ if (bytes == 0)
+ break;
+ else if (bytes == (size_t) -1)
+ {
+ printable = false;
+ break;
+ }
+ else if (bytes == (size_t) -2)
+ {
+ printable = false;
+ while (i + m < argsize && arg[i + m])
+ m++;
+ break;
+ }
+ else
+ {
+ /* Work around a bug with older shells that "see" a '\'
+ that is really the 2nd byte of a multibyte character.
+ In practice the problem is limited to ASCII
+ chars >= '@' that are shell special chars. */
+ if ('[' == 0x5b && elide_outer_quotes
+ && quoting_style == shell_always_quoting_style)
+ {
+ size_t j;
+ for (j = 1; j < bytes; j++)
+ switch (arg[i + m + j])
+ {
+ case '[': case '\\': case '^':
+ case '`': case '|':
+ goto force_outer_quoting_style;
+
+ default:
+ break;
+ }
+ }
+
+ if (! iswprint (w))
+ printable = false;
+ m += bytes;
+ }
+ }
+ while (! mbsinit (&mbstate));
+ }
+
+ if (1 < m || (backslash_escapes && ! printable))
+ {
+ /* Output a multibyte sequence, or an escaped
+ unprintable unibyte character. */
+ size_t ilim = i + m;
+
+ for (;;)
+ {
+ if (backslash_escapes && ! printable)
+ {
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ STORE ('\\');
+ STORE ('0' + (c >> 6));
+ STORE ('0' + ((c >> 3) & 7));
+ c = '0' + (c & 7);
+ }
+ if (ilim <= i + 1)
+ break;
+ STORE (c);
+ c = arg[++i];
+ }
+
+ goto store_c;
+ }
+ }
+ }
+
+ if (! ((backslash_escapes || elide_outer_quotes)
+ && quote_these_too
+ && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
+ goto store_c;
+
+ store_escape:
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ STORE ('\\');
+
+ store_c:
+ STORE (c);
+ }
+
+ if (len == 0 && quoting_style == shell_always_quoting_style
+ && elide_outer_quotes)
+ goto force_outer_quoting_style;
+
+ if (quote_string && !elide_outer_quotes)
+ for (; *quote_string; quote_string++)
+ STORE (*quote_string);
+
+ if (len < buffersize)
+ buffer[len] = '\0';
+ return len;
+
+ force_outer_quoting_style:
+ /* Don't reuse quote_these_too, since the addition of outer quotes
+ sufficiently quotes the specified characters. */
+ return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
+ quoting_style,
+ flags & ~QA_ELIDE_OUTER_QUOTES, NULL);
+}
+
+/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
+ argument ARG (of size ARGSIZE), using O to control quoting.
+ If O is null, use the default.
+ Terminate the output with a null character, and return the written
+ size of the output, not counting the terminating null.
+ If BUFFERSIZE is too small to store the output string, return the
+ value that would have been returned had BUFFERSIZE been large enough.
+ If ARGSIZE is SIZE_MAX, use the string length of the argument for
+ ARGSIZE. */
+size_t
+quotearg_buffer (char *buffer, size_t buffersize,
+ char const *arg, size_t argsize,
+ struct quoting_options const *o)
+{
+ struct quoting_options const *p = o ? o : &default_quoting_options;
+ int e = errno;
+ size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
+ p->style, p->flags, p->quote_these_too);
+ errno = e;
+ return r;
+}
+
+/* Equivalent to quotearg_alloc (ARG, ARGSIZE, NULL, O). */
+char *
+quotearg_alloc (char const *arg, size_t argsize,
+ struct quoting_options const *o)
+{
+ return quotearg_alloc_mem (arg, argsize, NULL, o);
+}
+
+/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly
+ allocated storage containing the quoted string, and store the
+ resulting size into *SIZE, if non-NULL. The result can contain
+ embedded null bytes only if ARGSIZE is not SIZE_MAX, SIZE is not
+ NULL, and set_quoting_flags has not set the null byte elision
+ flag. */
+char *
+quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size,
+ struct quoting_options const *o)
+{
+ struct quoting_options const *p = o ? o : &default_quoting_options;
+ int e = errno;
+ /* Elide embedded null bytes if we can't return a size. */
+ int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES);
+ size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style,
+ flags, p->quote_these_too) + 1;
+ char *buf = xcharalloc (bufsize);
+ quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags,
+ p->quote_these_too);
+ errno = e;
+ if (size)
+ *size = bufsize - 1;
+ return buf;
+}
+
+/* A storage slot with size and pointer to a value. */
+struct slotvec
+{
+ size_t size;
+ char *val;
+};
+
+/* Preallocate a slot 0 buffer, so that the caller can always quote
+ one small component of a "memory exhausted" message in slot 0. */
+static char slot0[256];
+static unsigned int nslots = 1;
+static struct slotvec slotvec0 = {sizeof slot0, slot0};
+static struct slotvec *slotvec = &slotvec0;
+
+void
+quotearg_free (void)
+{
+ struct slotvec *sv = slotvec;
+ unsigned int i;
+ for (i = 1; i < nslots; i++)
+ free (sv[i].val);
+ if (sv[0].val != slot0)
+ {
+ free (sv[0].val);
+ slotvec0.size = sizeof slot0;
+ slotvec0.val = slot0;
+ }
+ if (sv != &slotvec0)
+ {
+ free (sv);
+ slotvec = &slotvec0;
+ }
+ nslots = 1;
+}
+
+/* Use storage slot N to return a quoted version of argument ARG.
+ ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a
+ null-terminated string.
+ OPTIONS specifies the quoting options.
+ The returned value points to static storage that can be
+ reused by the next call to this function with the same value of N.
+ N must be nonnegative. N is deliberately declared with type "int"
+ to allow for future extensions (using negative values). */
+static char *
+quotearg_n_options (int n, char const *arg, size_t argsize,
+ struct quoting_options const *options)
+{
+ int e = errno;
+
+ unsigned int n0 = n;
+ struct slotvec *sv = slotvec;
+
+ if (n < 0)
+ abort ();
+
+ if (nslots <= n0)
+ {
+ /* FIXME: technically, the type of n1 should be `unsigned int',
+ but that evokes an unsuppressible warning from gcc-4.0.1 and
+ older. If gcc ever provides an option to suppress that warning,
+ revert to the original type, so that the test in xalloc_oversized
+ is once again performed only at compile time. */
+ size_t n1 = n0 + 1;
+ bool preallocated = (sv == &slotvec0);
+
+ if (xalloc_oversized (n1, sizeof *sv))
+ xalloc_die ();
+
+ slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv);
+ if (preallocated)
+ *sv = slotvec0;
+ memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv);
+ nslots = n1;
+ }
+
+ {
+ size_t size = sv[n].size;
+ char *val = sv[n].val;
+ /* Elide embedded null bytes since we don't return a size. */
+ int flags = options->flags | QA_ELIDE_NULL_BYTES;
+ size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize,
+ options->style, flags,
+ options->quote_these_too);
+
+ if (size <= qsize)
+ {
+ sv[n].size = size = qsize + 1;
+ if (val != slot0)
+ free (val);
+ sv[n].val = val = xcharalloc (size);
+ quotearg_buffer_restyled (val, size, arg, argsize, options->style,
+ flags, options->quote_these_too);
+ }
+
+ errno = e;
+ return val;
+ }
+}
+
+char *
+quotearg_n (int n, char const *arg)
+{
+ return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options);
+}
+
+char *
+quotearg_n_mem (int n, char const *arg, size_t argsize)
+{
+ return quotearg_n_options (n, arg, argsize, &default_quoting_options);
+}
+
+char *
+quotearg (char const *arg)
+{
+ return quotearg_n (0, arg);
+}
+
+char *
+quotearg_mem (char const *arg, size_t argsize)
+{
+ return quotearg_n_mem (0, arg, argsize);
+}
+
+char *
+quotearg_n_style (int n, enum quoting_style s, char const *arg)
+{
+ struct quoting_options const o = quoting_options_from_style (s);
+ return quotearg_n_options (n, arg, SIZE_MAX, &o);
+}
+
+char *
+quotearg_n_style_mem (int n, enum quoting_style s,
+ char const *arg, size_t argsize)
+{
+ struct quoting_options const o = quoting_options_from_style (s);
+ return quotearg_n_options (n, arg, argsize, &o);
+}
+
+char *
+quotearg_style (enum quoting_style s, char const *arg)
+{
+ return quotearg_n_style (0, s, arg);
+}
+
+char *
+quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize)
+{
+ return quotearg_n_style_mem (0, s, arg, argsize);
+}
+
+char *
+quotearg_char_mem (char const *arg, size_t argsize, char ch)
+{
+ struct quoting_options options;
+ options = default_quoting_options;
+ set_char_quoting (&options, ch, 1);
+ return quotearg_n_options (0, arg, argsize, &options);
+}
+
+char *
+quotearg_char (char const *arg, char ch)
+{
+ return quotearg_char_mem (arg, SIZE_MAX, ch);
+}
+
+char *
+quotearg_colon (char const *arg)
+{
+ return quotearg_char (arg, ':');
+}
+
+char *
+quotearg_colon_mem (char const *arg, size_t argsize)
+{
+ return quotearg_char_mem (arg, argsize, ':');
+}
--- /dev/null
+/* quotearg.h - quote arguments for output
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008 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 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/>. */
+
+/* Written by Paul Eggert <eggert@twinsun.com> */
+
+#ifndef QUOTEARG_H_
+# define QUOTEARG_H_ 1
+
+# include <stddef.h>
+
+/* Basic quoting styles. For each style, an example is given on the
+ input strings "simple", "\0 \t\n'\"\033?""?/\\", and "a:b", using
+ quotearg_buffer, quotearg_mem, and quotearg_colon_mem with that
+ style and the default flags and quoted characters. Note that the
+ examples are shown here as valid C strings rather than what
+ displays on a terminal (with "??/" as a trigraph for "\\"). */
+enum quoting_style
+ {
+ /* Output names as-is (ls --quoting-style=literal). Can result in
+ embedded null bytes if QA_ELIDE_NULL_BYTES is not in
+ effect.
+
+ quotearg_buffer:
+ "simple", "\0 \t\n'\"\033??/\\", "a:b"
+ quotearg:
+ "simple", " \t\n'\"\033??/\\", "a:b"
+ quotearg_colon:
+ "simple", " \t\n'\"\033??/\\", "a:b"
+ */
+ literal_quoting_style,
+
+ /* Quote names for the shell if they contain shell metacharacters
+ or would cause ambiguous output (ls --quoting-style=shell).
+ Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not
+ in effect.
+
+ quotearg_buffer:
+ "simple", "'\0 \t\n'\\''\"\033??/\\'", "a:b"
+ quotearg:
+ "simple", "' \t\n'\\''\"\033??/\\'", "a:b"
+ quotearg_colon:
+ "simple", "' \t\n'\\''\"\033??/\\'", "'a:b'"
+ */
+ shell_quoting_style,
+
+ /* Quote names for the shell, even if they would normally not
+ require quoting (ls --quoting-style=shell-always). Can result
+ in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect.
+ Behaves like shell_quoting_style if QA_ELIDE_OUTER_QUOTES is in
+ effect.
+
+ quotearg_buffer:
+ "'simple'", "'\0 \t\n'\\''\"\033??/\\'", "'a:b'"
+ quotearg:
+ "'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
+ quotearg_colon:
+ "'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
+ */
+ shell_always_quoting_style,
+
+ /* Quote names as for a C language string (ls --quoting-style=c).
+ Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is
+ in effect. Split into consecutive strings if
+ QA_SPLIT_TRIGRAPHS.
+
+ quotearg_buffer:
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
+ quotearg:
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
+ quotearg_colon:
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
+ */
+ c_quoting_style,
+
+ /* Like c_quoting_style except omit the surrounding double-quote
+ characters if no quoted characters are encountered.
+
+ quotearg_buffer:
+ "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
+ quotearg:
+ "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
+ quotearg_colon:
+ "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
+ */
+ c_maybe_quoting_style,
+
+ /* Like c_quoting_style except always omit the surrounding
+ double-quote characters (ls --quoting-style=escape).
+
+ quotearg_buffer:
+ "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
+ quotearg:
+ "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
+ quotearg_colon:
+ "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a\\:b"
+ */
+ escape_quoting_style,
+
+ /* Like clocale_quoting_style, but quote `like this' instead of
+ "like this" in the default C locale (ls --quoting-style=locale).
+
+ LC_MESSAGES=C
+ quotearg_buffer:
+ "`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
+ quotearg:
+ "`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
+ quotearg_colon:
+ "`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a\\:b'"
+
+ LC_MESSAGES=pt_PT.utf8
+ quotearg_buffer:
+ "\302\253simple\302\273",
+ "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
+ quotearg:
+ "\302\253simple\302\273",
+ "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
+ quotearg_colon:
+ "\302\253simple\302\273",
+ "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
+ */
+ locale_quoting_style,
+
+ /* Like c_quoting_style except use quotation marks appropriate for
+ the locale (ls --quoting-style=clocale).
+
+ LC_MESSAGES=C
+ quotearg_buffer:
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
+ quotearg:
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
+ quotearg_colon:
+ "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
+
+ LC_MESSAGES=pt_PT.utf8
+ quotearg_buffer:
+ "\302\253simple\302\273",
+ "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
+ quotearg:
+ "\302\253simple\302\273",
+ "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
+ quotearg_colon:
+ "\302\253simple\302\273",
+ "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
+ */
+ clocale_quoting_style
+ };
+
+/* Flags for use in set_quoting_flags. */
+enum quoting_flags
+ {
+ /* Always elide null bytes from styles that do not quote them,
+ even when the length of the result is available to the
+ caller. */
+ QA_ELIDE_NULL_BYTES = 0x01,
+
+ /* Omit the surrounding quote characters if no escaped characters
+ are encountered. Note that if no other character needs
+ escaping, then neither does the escape character. */
+ QA_ELIDE_OUTER_QUOTES = 0x02,
+
+ /* In the c_quoting_style and c_maybe_quoting_style, split ANSI
+ trigraph sequences into concatenated strings (for example,
+ "?""?/" rather than "??/", which could be confused with
+ "\\"). */
+ QA_SPLIT_TRIGRAPHS = 0x04
+ };
+
+/* For now, --quoting-style=literal is the default, but this may change. */
+# ifndef DEFAULT_QUOTING_STYLE
+# define DEFAULT_QUOTING_STYLE literal_quoting_style
+# endif
+
+/* Names of quoting styles and their corresponding values. */
+extern char const *const quoting_style_args[];
+extern enum quoting_style const quoting_style_vals[];
+
+struct quoting_options;
+
+/* The functions listed below set and use a hidden variable
+ that contains the default quoting style options. */
+
+/* Allocate a new set of quoting options, with contents initially identical
+ to O if O is not null, or to the default if O is null.
+ It is the caller's responsibility to free the result. */
+struct quoting_options *clone_quoting_options (struct quoting_options *o);
+
+/* Get the value of O's quoting style. If O is null, use the default. */
+enum quoting_style get_quoting_style (struct quoting_options *o);
+
+/* In O (or in the default if O is null),
+ set the value of the quoting style to S. */
+void set_quoting_style (struct quoting_options *o, enum quoting_style s);
+
+/* In O (or in the default if O is null),
+ set the value of the quoting options for character C to I.
+ Return the old value. Currently, the only values defined for I are
+ 0 (the default) and 1 (which means to quote the character even if
+ it would not otherwise be quoted). */
+int set_char_quoting (struct quoting_options *o, char c, int i);
+
+/* In O (or in the default if O is null),
+ set the value of the quoting options flag to I, which can be a
+ bitwise combination of enum quoting_flags, or 0 for default
+ behavior. Return the old value. */
+int set_quoting_flags (struct quoting_options *o, int i);
+
+/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
+ argument ARG (of size ARGSIZE), using O to control quoting.
+ If O is null, use the default.
+ Terminate the output with a null character, and return the written
+ size of the output, not counting the terminating null.
+ If BUFFERSIZE is too small to store the output string, return the
+ value that would have been returned had BUFFERSIZE been large enough.
+ If ARGSIZE is -1, use the string length of the argument for ARGSIZE.
+ On output, BUFFER might contain embedded null bytes if ARGSIZE was
+ not -1, the style of O does not use backslash escapes, and the
+ flags of O do not request elision of null bytes.*/
+size_t quotearg_buffer (char *buffer, size_t buffersize,
+ char const *arg, size_t argsize,
+ struct quoting_options const *o);
+
+/* Like quotearg_buffer, except return the result in a newly allocated
+ buffer. It is the caller's responsibility to free the result. The
+ result will not contain embedded null bytes. */
+char *quotearg_alloc (char const *arg, size_t argsize,
+ struct quoting_options const *o);
+
+/* Like quotearg_alloc, except that the length of the result,
+ excluding the terminating null byte, is stored into SIZE if it is
+ non-NULL. The result might contain embedded null bytes if ARGSIZE
+ was not -1, SIZE was not NULL, the style of O does not use
+ backslash escapes, and the flags of O do not request elision of
+ null bytes.*/
+char *quotearg_alloc_mem (char const *arg, size_t argsize,
+ size_t *size, struct quoting_options const *o);
+
+/* Use storage slot N to return a quoted version of the string ARG.
+ Use the default quoting options.
+ The returned value points to static storage that can be
+ reused by the next call to this function with the same value of N.
+ N must be nonnegative. The output of all functions in the
+ quotearg_n family are guaranteed to not contain embedded null
+ bytes.*/
+char *quotearg_n (int n, char const *arg);
+
+/* Equivalent to quotearg_n (0, ARG). */
+char *quotearg (char const *arg);
+
+/* Use storage slot N to return a quoted version of the argument ARG
+ of size ARGSIZE. This is like quotearg_n (N, ARG), except it can
+ quote null bytes. */
+char *quotearg_n_mem (int n, char const *arg, size_t argsize);
+
+/* Equivalent to quotearg_n_mem (0, ARG, ARGSIZE). */
+char *quotearg_mem (char const *arg, size_t argsize);
+
+/* Use style S and storage slot N to return a quoted version of the string ARG.
+ This is like quotearg_n (N, ARG), except that it uses S with no other
+ options to specify the quoting method. */
+char *quotearg_n_style (int n, enum quoting_style s, char const *arg);
+
+/* Use style S and storage slot N to return a quoted version of the
+ argument ARG of size ARGSIZE. This is like quotearg_n_style
+ (N, S, ARG), except it can quote null bytes. */
+char *quotearg_n_style_mem (int n, enum quoting_style s,
+ char const *arg, size_t argsize);
+
+/* Equivalent to quotearg_n_style (0, S, ARG). */
+char *quotearg_style (enum quoting_style s, char const *arg);
+
+/* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */
+char *quotearg_style_mem (enum quoting_style s,
+ char const *arg, size_t argsize);
+
+/* Like quotearg (ARG), except also quote any instances of CH. */
+char *quotearg_char (char const *arg, char ch);
+
+/* Like quotearg_char (ARG, CH), except it can quote null bytes. */
+char *quotearg_char_mem (char const *arg, size_t argsize, char ch);
+
+/* Equivalent to quotearg_char (ARG, ':'). */
+char *quotearg_colon (char const *arg);
+
+/* Like quotearg_colon (ARG), except it can quote null bytes. */
+char *quotearg_colon_mem (char const *arg, size_t argsize);
+
+/* Free any dynamically allocated memory. */
+void quotearg_free (void);
+
+#endif /* !QUOTEARG_H_ */
--- /dev/null
+/* realloc() function that is glibc compatible.
+
+ Copyright (C) 1997, 2003, 2004, 2006, 2007 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 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/>. */
+
+/* written by Jim Meyering and Bruno Haible */
+
+#include <config.h>
+
+/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */
+#ifdef realloc
+# define NEED_REALLOC_GNU 1
+#endif
+
+/* Infer the properties of the system's malloc function.
+ Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
+#if GNULIB_MALLOC_GNU && !defined malloc
+# define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1
+#endif
+
+/* Below we want to call the system's malloc and realloc.
+ Undefine the symbols here so that including <stdlib.h> provides a
+ declaration of malloc(), not of rpl_malloc(), and likewise for realloc. */
+#undef malloc
+#undef realloc
+
+/* Specification. */
+#include <stdlib.h>
+
+#include <errno.h>
+
+/* Below we want to call the system's malloc and realloc.
+ Undefine the symbols, if they were defined by gnulib's <stdlib.h>
+ replacement. */
+#undef malloc
+#undef realloc
+
+/* Change the size of an allocated block of memory P to N bytes,
+ with error checking. If N is zero, change it to 1. If P is NULL,
+ use malloc. */
+
+void *
+rpl_realloc (void *p, size_t n)
+{
+ void *result;
+
+#if NEED_REALLOC_GNU
+ if (n == 0)
+ {
+ n = 1;
+
+ /* In theory realloc might fail, so don't rely on it to free. */
+ free (p);
+ p = NULL;
+ }
+#endif
+
+ if (p == NULL)
+ {
+#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
+ if (n == 0)
+ n = 1;
+#endif
+ result = malloc (n);
+ }
+ else
+ result = realloc (p, n);
+
+#if !HAVE_REALLOC_POSIX
+ if (result == NULL)
+ errno = ENOMEM;
+#endif
+
+ return result;
+}
--- /dev/null
+/* Work around rename bugs in some systems. On SunOS 4.1.1_U1
+ and mips-dec-ultrix4.4, rename fails when the source file has
+ a trailing slash. On mingw, rename fails when the destination
+ exists.
+
+ Copyright (C) 2001, 2002, 2003, 2005, 2006, 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 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/>. */
+
+/* written by Volker Borchert */
+
+#include <config.h>
+#undef rename
+
+#if RENAME_DEST_EXISTS_BUG
+/* This replacement must come first, otherwise when cross
+ * compiling to Windows we will guess that it has the trailing
+ * slash bug and entirely miss this one. */
+#include <errno.h>
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+/* Rename the file SRC to DST. This replacement is necessary on
+ Windows, on which the system rename function will not replace
+ an existing DST. */
+int
+rpl_rename (char const *src, char const *dst)
+{
+ int error;
+
+ /* MoveFileEx works if SRC is a directory without any flags,
+ but fails with MOVEFILE_REPLACE_EXISTING, so try without
+ flags first. */
+ if (MoveFileEx (src, dst, 0))
+ return 0;
+
+ /* Retry with MOVEFILE_REPLACE_EXISTING if the move failed
+ * due to the destination already existing. */
+ error = GetLastError ();
+ if (error == ERROR_FILE_EXISTS || error == ERROR_ALREADY_EXISTS)
+ {
+ if (MoveFileEx (src, dst, MOVEFILE_REPLACE_EXISTING))
+ return 0;
+
+ error = GetLastError ();
+ }
+
+ switch (error)
+ {
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_BAD_PATHNAME:
+ case ERROR_DIRECTORY:
+ errno = ENOENT;
+ break;
+
+ case ERROR_ACCESS_DENIED:
+ case ERROR_SHARING_VIOLATION:
+ errno = EACCES;
+ break;
+
+ case ERROR_OUTOFMEMORY:
+ errno = ENOMEM;
+ break;
+
+ case ERROR_CURRENT_DIRECTORY:
+ errno = EBUSY;
+ break;
+
+ case ERROR_NOT_SAME_DEVICE:
+ errno = EXDEV;
+ break;
+
+ case ERROR_WRITE_PROTECT:
+ errno = EROFS;
+ break;
+
+ case ERROR_WRITE_FAULT:
+ case ERROR_READ_FAULT:
+ case ERROR_GEN_FAILURE:
+ errno = EIO;
+ break;
+
+ case ERROR_HANDLE_DISK_FULL:
+ case ERROR_DISK_FULL:
+ case ERROR_DISK_TOO_FRAGMENTED:
+ errno = ENOSPC;
+ break;
+
+ case ERROR_FILE_EXISTS:
+ case ERROR_ALREADY_EXISTS:
+ errno = EEXIST;
+ break;
+
+ case ERROR_BUFFER_OVERFLOW:
+ case ERROR_FILENAME_EXCED_RANGE:
+ errno = ENAMETOOLONG;
+ break;
+
+ case ERROR_INVALID_NAME:
+ case ERROR_DELETE_PENDING:
+ errno = EPERM; /* ? */
+ break;
+
+#ifndef ERROR_FILE_TOO_LARGE
+/* This value is documented but not defined in all versions of windows.h. */
+#define ERROR_FILE_TOO_LARGE 223
+#endif
+ case ERROR_FILE_TOO_LARGE:
+ errno = EFBIG;
+ break;
+
+ default:
+ errno = EINVAL;
+ break;
+ }
+
+ return -1;
+}
+#elif RENAME_TRAILING_SLASH_BUG
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "dirname.h"
+#include "xalloc.h"
+
+/* Rename the file SRC to DST, removing any trailing
+ slashes from SRC. Needed for SunOS 4.1.1_U1. */
+
+int
+rpl_rename (char const *src, char const *dst)
+{
+ char *src_temp;
+ int ret_val;
+ size_t s_len = strlen (src);
+
+ if (s_len && src[s_len - 1] == '/')
+ {
+ src_temp = xstrdup (src);
+ strip_trailing_slashes (src_temp);
+ }
+ else
+ src_temp = (char *) src;
+
+ ret_val = rename (src_temp, dst);
+
+ if (src_temp != src)
+ free (src_temp);
+
+ return ret_val;
+}
+#endif /* RENAME_TRAILING_SLASH_BUG */
--- /dev/null
+/* An interface to read and write that retries after interrupts.
+
+ Copyright (C) 1993, 1994, 1998, 2002, 2003, 2004, 2005, 2006 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 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/>. */
+
+#include <config.h>
+
+/* Specification. */
+#ifdef SAFE_WRITE
+# include "safe-write.h"
+#else
+# include "safe-read.h"
+#endif
+
+/* Get ssize_t. */
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <errno.h>
+
+#ifdef EINTR
+# define IS_EINTR(x) ((x) == EINTR)
+#else
+# define IS_EINTR(x) 0
+#endif
+
+#include <limits.h>
+
+#ifdef SAFE_WRITE
+# define safe_rw safe_write
+# define rw write
+#else
+# define safe_rw safe_read
+# define rw read
+# undef const
+# define const /* empty */
+#endif
+
+/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
+ interrupted. Return the actual number of bytes read(written), zero for EOF,
+ or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */
+size_t
+safe_rw (int fd, void const *buf, size_t count)
+{
+ /* Work around a bug in Tru64 5.1. Attempting to read more than
+ INT_MAX bytes fails with errno == EINVAL. See
+ <http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
+ When decreasing COUNT, keep it block-aligned. */
+ enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
+
+ for (;;)
+ {
+ ssize_t result = rw (fd, buf, count);
+
+ if (0 <= result)
+ return result;
+ else if (IS_EINTR (errno))
+ continue;
+ else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
+ count = BUGGY_READ_MAXIMUM;
+ else
+ return result;
+ }
+}
--- /dev/null
+/* An interface to write that retries after interrupts.
+ Copyright (C) 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 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/>. */
+
+#define SAFE_WRITE
+#include "safe-read.c"
--- /dev/null
+/* An interface to write() that retries after interrupts.
+ Copyright (C) 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 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/>. */
+
+#include <stddef.h>
+
+#define SAFE_WRITE_ERROR ((size_t) -1)
+
+/* Write up to COUNT bytes at BUF to descriptor FD, retrying if interrupted.
+ Return the actual number of bytes written, zero for EOF, or SAFE_WRITE_ERROR
+ upon error. */
+extern size_t safe_write (int fd, const void *buf, size_t count);
--- /dev/null
+/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _GL_STDBOOL_H
+#define _GL_STDBOOL_H
+
+/* ISO C 99 <stdbool.h> for platforms that lack it. */
+
+/* Usage suggestions:
+
+ Programs that use <stdbool.h> should be aware of some limitations
+ and standards compliance issues.
+
+ Standards compliance:
+
+ - <stdbool.h> must be #included before 'bool', 'false', 'true'
+ can be used.
+
+ - You cannot assume that sizeof (bool) == 1.
+
+ - Programs should not undefine the macros bool, true, and false,
+ as C99 lists that as an "obsolescent feature".
+
+ Limitations of this substitute, when used in a C89 environment:
+
+ - <stdbool.h> must be #included before the '_Bool' type can be used.
+
+ - You cannot assume that _Bool is a typedef; it might be a macro.
+
+ - Bit-fields of type 'bool' are not supported. Portable code
+ should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
+
+ - In C99, casts and automatic conversions to '_Bool' or 'bool' are
+ performed in such a way that every nonzero value gets converted
+ to 'true', and zero gets converted to 'false'. This doesn't work
+ with this substitute. With this substitute, only the values 0 and 1
+ give the expected result when converted to _Bool' or 'bool'.
+
+ Also, it is suggested that programs use 'bool' rather than '_Bool';
+ this isn't required, but 'bool' is more common. */
+
+
+/* 7.16. Boolean type and values */
+
+/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
+ definitions below, but temporarily we have to #undef them. */
+#if defined __BEOS__ && !defined __HAIKU__
+# include <OS.h> /* defines bool but not _Bool */
+# undef false
+# undef true
+#endif
+
+/* For the sake of symbolic names in gdb, we define true and false as
+ enum constants, not only as macros.
+ It is tempting to write
+ typedef enum { false = 0, true = 1 } _Bool;
+ so that gdb prints values of type 'bool' symbolically. But if we do
+ this, values of type '_Bool' may promote to 'int' or 'unsigned int'
+ (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
+ (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
+ enum; this ensures that '_Bool' promotes to 'int'. */
+#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
+ /* A compiler known to have 'bool'. */
+ /* If the compiler already has both 'bool' and '_Bool', we can assume they
+ are the same types. */
+# if !@HAVE__BOOL@
+typedef bool _Bool;
+# endif
+#else
+# if !defined __GNUC__
+ /* If @HAVE__BOOL@:
+ Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
+ the built-in _Bool type is used. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+ Similar bugs are likely with other compilers as well; this file
+ wouldn't be used if <stdbool.h> was working.
+ So we override the _Bool type.
+ If !@HAVE__BOOL@:
+ Need to define _Bool ourselves. As 'signed char' or as an enum type?
+ Use of a typedef, with SunPRO C, leads to a stupid
+ "warning: _Bool is a keyword in ISO C99".
+ Use of an enum type, with IRIX cc, leads to a stupid
+ "warning(1185): enumerated type mixed with another type".
+ Even the existence of an enum type, without a typedef,
+ "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
+ The only benefit of the enum, debuggability, is not important
+ with these compilers. So use 'signed char' and no enum. */
+# define _Bool signed char
+# else
+ /* With this compiler, trust the _Bool type if the compiler has it. */
+# if !@HAVE__BOOL@
+typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+# endif
+# endif
+#endif
+#define bool _Bool
+
+/* The other macros must be usable in preprocessor directives. */
+#define false 0
+#define true 1
+#define __bool_true_false_are_defined 1
+
+#endif /* _GL_STDBOOL_H */
--- /dev/null
+/* Case-insensitive string comparison function.
+ Copyright (C) 1998-1999, 2005-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+#include <ctype.h>
+#include <limits.h>
+
+#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
+
+/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexicographically less than, equal to or greater
+ than S2.
+ Note: This function does not work with multibyte strings! */
+
+int
+strcasecmp (const char *s1, const char *s2)
+{
+ const unsigned char *p1 = (const unsigned char *) s1;
+ const unsigned char *p2 = (const unsigned char *) s2;
+ unsigned char c1, c2;
+
+ if (p1 == p2)
+ return 0;
+
+ do
+ {
+ c1 = TOLOWER (*p1);
+ c2 = TOLOWER (*p2);
+
+ if (c1 == '\0')
+ break;
+
+ ++p1;
+ ++p2;
+ }
+ while (c1 == c2);
+
+ if (UCHAR_MAX <= INT_MAX)
+ return c1 - c2;
+ else
+ /* On machines where 'char' and 'int' are types of the same size, the
+ difference of two 'unsigned char' values - including the sign bit -
+ doesn't fit in an 'int'. */
+ return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
--- /dev/null
+/* stripslash.c -- remove redundant trailing slashes from a file name
+
+ Copyright (C) 1990, 2001, 2003-2006 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 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/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+/* Remove trailing slashes from FILE. Return true if a trailing slash
+ was removed. This is useful when using file name completion from a
+ shell that adds a "/" after directory names (such as tcsh and
+ bash), because on symlinks to directories, several system calls
+ have different semantics according to whether a trailing slash is
+ present. */
+
+bool
+strip_trailing_slashes (char *file)
+{
+ char *base = last_component (file);
+ char *base_lim;
+ bool had_slash;
+
+ /* last_component returns "" for file system roots, but we need to turn
+ `///' into `/'. */
+ if (! *base)
+ base = file;
+ base_lim = base + base_len (base);
+ had_slash = (*base_lim != '\0');
+ *base_lim = '\0';
+ return had_slash;
+}
--- /dev/null
+/* strncasecmp.c -- case insensitive string comparator
+ Copyright (C) 1998-1999, 2005-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+#include <ctype.h>
+#include <limits.h>
+
+#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
+
+/* Compare no more than N bytes of strings S1 and S2, ignoring case,
+ returning less than, equal to or greater than zero if S1 is
+ lexicographically less than, equal to or greater than S2.
+ Note: This function cannot work correctly in multibyte locales. */
+
+int
+strncasecmp (const char *s1, const char *s2, size_t n)
+{
+ register const unsigned char *p1 = (const unsigned char *) s1;
+ register const unsigned char *p2 = (const unsigned char *) s2;
+ unsigned char c1, c2;
+
+ if (p1 == p2 || n == 0)
+ return 0;
+
+ do
+ {
+ c1 = TOLOWER (*p1);
+ c2 = TOLOWER (*p2);
+
+ if (--n == 0 || c1 == '\0')
+ break;
+
+ ++p1;
+ ++p2;
+ }
+ while (c1 == c2);
+
+ if (UCHAR_MAX <= INT_MAX)
+ return c1 - c2;
+ else
+ /* On machines where 'char' and 'int' are types of the same size, the
+ difference of two 'unsigned char' values - including the sign bit -
+ doesn't fit in an 'int'. */
+ return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
--- /dev/null
+/* A replacement function, for systems that lack strndup.
+
+ Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <stdlib.h>
+
+char *
+strndup (char const *s, size_t n)
+{
+ size_t len = strnlen (s, n);
+ char *new = malloc (len + 1);
+
+ if (new == NULL)
+ return NULL;
+
+ new[len] = '\0';
+ return memcpy (new, s, len);
+}
--- /dev/null
+/* Prefer faster, non-thread-safe stdio functions if available.
+
+ Copyright (C) 2001, 2002, 2003, 2004 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 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/>. */
+
+/* Written by Jim Meyering. */
+
+#ifndef UNLOCKED_IO_H
+# define UNLOCKED_IO_H 1
+
+/* These are wrappers for functions/macros from the GNU C library, and
+ from other C libraries supporting POSIX's optional thread-safe functions.
+
+ The standard I/O functions are thread-safe. These *_unlocked ones are
+ more efficient but not thread-safe. That they're not thread-safe is
+ fine since all of the applications in this package are single threaded.
+
+ Also, some code that is shared with the GNU C library may invoke
+ the *_unlocked functions directly. On hosts that lack those
+ functions, invoke the non-thread-safe versions instead. */
+
+# include <stdio.h>
+
+# if HAVE_DECL_CLEARERR_UNLOCKED
+# undef clearerr
+# define clearerr(x) clearerr_unlocked (x)
+# else
+# define clearerr_unlocked(x) clearerr (x)
+# endif
+
+# if HAVE_DECL_FEOF_UNLOCKED
+# undef feof
+# define feof(x) feof_unlocked (x)
+# else
+# define feof_unlocked(x) feof (x)
+# endif
+
+# if HAVE_DECL_FERROR_UNLOCKED
+# undef ferror
+# define ferror(x) ferror_unlocked (x)
+# else
+# define ferror_unlocked(x) ferror (x)
+# endif
+
+# if HAVE_DECL_FFLUSH_UNLOCKED
+# undef fflush
+# define fflush(x) fflush_unlocked (x)
+# else
+# define fflush_unlocked(x) fflush (x)
+# endif
+
+# if HAVE_DECL_FGETS_UNLOCKED
+# undef fgets
+# define fgets(x,y,z) fgets_unlocked (x,y,z)
+# else
+# define fgets_unlocked(x,y,z) fgets (x,y,z)
+# endif
+
+# if HAVE_DECL_FPUTC_UNLOCKED
+# undef fputc
+# define fputc(x,y) fputc_unlocked (x,y)
+# else
+# define fputc_unlocked(x,y) fputc (x,y)
+# endif
+
+# if HAVE_DECL_FPUTS_UNLOCKED
+# undef fputs
+# define fputs(x,y) fputs_unlocked (x,y)
+# else
+# define fputs_unlocked(x,y) fputs (x,y)
+# endif
+
+# if HAVE_DECL_FREAD_UNLOCKED
+# undef fread
+# define fread(w,x,y,z) fread_unlocked (w,x,y,z)
+# else
+# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
+# endif
+
+# if HAVE_DECL_FWRITE_UNLOCKED
+# undef fwrite
+# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
+# else
+# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
+# endif
+
+# if HAVE_DECL_GETC_UNLOCKED
+# undef getc
+# define getc(x) getc_unlocked (x)
+# else
+# define getc_unlocked(x) getc (x)
+# endif
+
+# if HAVE_DECL_GETCHAR_UNLOCKED
+# undef getchar
+# define getchar() getchar_unlocked ()
+# else
+# define getchar_unlocked() getchar ()
+# endif
+
+# if HAVE_DECL_PUTC_UNLOCKED
+# undef putc
+# define putc(x,y) putc_unlocked (x,y)
+# else
+# define putc_unlocked(x,y) putc (x,y)
+# endif
+
+# if HAVE_DECL_PUTCHAR_UNLOCKED
+# undef putchar
+# define putchar(x) putchar_unlocked (x)
+# else
+# define putchar_unlocked(x) putchar (x)
+# endif
+
+# undef flockfile
+# define flockfile(x) ((void) 0)
+
+# undef ftrylockfile
+# define ftrylockfile(x) 0
+
+# undef funlockfile
+# define funlockfile(x) ((void) 0)
+
+#endif /* UNLOCKED_IO_H */
--- /dev/null
+/* Compile-time assert-like macros.
+
+ Copyright (C) 2005, 2006 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 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/>. */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
+
+#ifndef VERIFY_H
+# define VERIFY_H 1
+
+/* Each of these macros verifies that its argument R is nonzero. To
+ be portable, R should be an integer constant expression. Unlike
+ assert (R), there is no run-time overhead.
+
+ There are two macros, since no single macro can be used in all
+ contexts in C. verify_true (R) is for scalar contexts, including
+ integer constant expression contexts. verify (R) is for declaration
+ contexts, e.g., the top level.
+
+ Symbols ending in "__" are private to this header.
+
+ The code below uses several ideas.
+
+ * The first step is ((R) ? 1 : -1). Given an expression R, of
+ integral or boolean or floating-point type, this yields an
+ expression of integral type, whose value is later verified to be
+ constant and nonnegative.
+
+ * Next this expression W is wrapped in a type
+ struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
+ If W is negative, this yields a compile-time error. No compiler can
+ deal with a bit-field of negative size.
+
+ One might think that an array size check would have the same
+ effect, that is, that the type struct { unsigned int dummy[W]; }
+ would work as well. However, inside a function, some compilers
+ (such as C++ compilers and GNU C) allow local parameters and
+ variables inside array size expressions. With these compilers,
+ an array size check would not properly diagnose this misuse of
+ the verify macro:
+
+ void function (int n) { verify (n < 0); }
+
+ * For the verify macro, the struct verify_type__ will need to
+ somehow be embedded into a declaration. To be portable, this
+ declaration must declare an object, a constant, a function, or a
+ typedef name. If the declared entity uses the type directly,
+ such as in
+
+ struct dummy {...};
+ typedef struct {...} dummy;
+ extern struct {...} *dummy;
+ extern void dummy (struct {...} *);
+ extern struct {...} *dummy (void);
+
+ two uses of the verify macro would yield colliding declarations
+ if the entity names are not disambiguated. A workaround is to
+ attach the current line number to the entity name:
+
+ #define GL_CONCAT0(x, y) x##y
+ #define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
+ extern struct {...} * GL_CONCAT(dummy,__LINE__);
+
+ But this has the problem that two invocations of verify from
+ within the same macro would collide, since the __LINE__ value
+ would be the same for both invocations.
+
+ A solution is to use the sizeof operator. It yields a number,
+ getting rid of the identity of the type. Declarations like
+
+ extern int dummy [sizeof (struct {...})];
+ extern void dummy (int [sizeof (struct {...})]);
+ extern int (*dummy (void)) [sizeof (struct {...})];
+
+ can be repeated.
+
+ * Should the implementation use a named struct or an unnamed struct?
+ Which of the following alternatives can be used?
+
+ extern int dummy [sizeof (struct {...})];
+ extern int dummy [sizeof (struct verify_type__ {...})];
+ extern void dummy (int [sizeof (struct {...})]);
+ extern void dummy (int [sizeof (struct verify_type__ {...})]);
+ extern int (*dummy (void)) [sizeof (struct {...})];
+ extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
+
+ In the second and sixth case, the struct type is exported to the
+ outer scope; two such declarations therefore collide. GCC warns
+ about the first, third, and fourth cases. So the only remaining
+ possibility is the fifth case:
+
+ extern int (*dummy (void)) [sizeof (struct {...})];
+
+ * This implementation exploits the fact that GCC does not warn about
+ the last declaration mentioned above. If a future version of GCC
+ introduces a warning for this, the problem could be worked around
+ by using code specialized to GCC, e.g.,:
+
+ #if 4 <= __GNUC__
+ # define verify(R) \
+ extern int (* verify_function__ (void)) \
+ [__builtin_constant_p (R) && (R) ? 1 : -1]
+ #endif
+
+ * In C++, any struct definition inside sizeof is invalid.
+ Use a template type to work around the problem. */
+
+
+/* Verify requirement R at compile-time, as an integer constant expression.
+ Return 1. */
+
+# ifdef __cplusplus
+template <int w>
+ struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
+# define verify_true(R) \
+ (!!sizeof (verify_type__<(R) ? 1 : -1>))
+# else
+# define verify_true(R) \
+ (!!sizeof \
+ (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
+# endif
+
+/* Verify requirement R at compile-time, as a declaration without a
+ trailing ';'. */
+
+# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)]
+
+#endif
--- /dev/null
+/* xalloc.h -- malloc with out-of-memory checking
+
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2003, 2004, 2006, 2007, 2008 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 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/>. */
+
+#ifndef XALLOC_H_
+# define XALLOC_H_
+
+# include <stddef.h>
+
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+
+# ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
+# define __attribute__(x)
+# endif
+# endif
+
+# ifndef ATTRIBUTE_NORETURN
+# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# endif
+
+# ifndef ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3
+# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+# define ATTRIBUTE_MALLOC
+# endif
+# endif
+
+/* This function is always triggered when memory is exhausted.
+ It must be defined by the application, either explicitly
+ or by using gnulib's xalloc-die module. This is the
+ function to call when one wants the program to die because of a
+ memory allocation failure. */
+extern void xalloc_die (void) ATTRIBUTE_NORETURN;
+
+void *xmalloc (size_t s) ATTRIBUTE_MALLOC;
+void *xzalloc (size_t s) ATTRIBUTE_MALLOC;
+void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
+void *xrealloc (void *p, size_t s);
+void *x2realloc (void *p, size_t *pn);
+void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC;
+char *xstrdup (char const *str) ATTRIBUTE_MALLOC;
+
+/* Return 1 if an array of N objects, each of size S, cannot exist due
+ to size arithmetic overflow. S must be positive and N must be
+ nonnegative. This is a macro, not an inline function, so that it
+ works correctly even when SIZE_MAX < N.
+
+ By gnulib convention, SIZE_MAX represents overflow in size
+ calculations, so the conservative dividend to use here is
+ SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
+ However, malloc (SIZE_MAX) fails on all known hosts where
+ sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
+ exactly-SIZE_MAX allocations on such hosts; this avoids a test and
+ branch when S is known to be 1. */
+# define xalloc_oversized(n, s) \
+ ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
+
+
+/* In the following macros, T must be an elementary or structure/union or
+ typedef'ed type, or a pointer to such a type. To apply one of the
+ following macros to a function pointer or array type, you need to typedef
+ it first and use the typedef name. */
+
+/* Allocate an object of type T dynamically, with error checking. */
+/* extern t *XMALLOC (typename t); */
+# define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
+
+/* Allocate memory for N elements of type T, with error checking. */
+/* extern t *XNMALLOC (size_t n, typename t); */
+# define XNMALLOC(n, t) \
+ ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
+
+/* Allocate an object of type T dynamically, with error checking,
+ and zero it. */
+/* extern t *XZALLOC (typename t); */
+# define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
+
+/* Allocate memory for N elements of type T, with error checking,
+ and zero it. */
+/* extern t *XCALLOC (size_t n, typename t); */
+# define XCALLOC(n, t) \
+ ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
+
+
+# if HAVE_INLINE
+# define static_inline static inline
+# else
+ void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
+ void *xnrealloc (void *p, size_t n, size_t s);
+ void *x2nrealloc (void *p, size_t *pn, size_t s);
+ char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
+# endif
+
+# ifdef static_inline
+
+/* Allocate an array of N objects, each with S bytes of memory,
+ dynamically, with error checking. S must be nonzero. */
+
+static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
+static_inline void *
+xnmalloc (size_t n, size_t s)
+{
+ if (xalloc_oversized (n, s))
+ xalloc_die ();
+ return xmalloc (n * s);
+}
+
+/* Change the size of an allocated block of memory P to an array of N
+ objects each of S bytes, with error checking. S must be nonzero. */
+
+static_inline void *
+xnrealloc (void *p, size_t n, size_t s)
+{
+ if (xalloc_oversized (n, s))
+ xalloc_die ();
+ return xrealloc (p, n * s);
+}
+
+/* If P is null, allocate a block of at least *PN such objects;
+ otherwise, reallocate P so that it contains more than *PN objects
+ each of S bytes. *PN must be nonzero unless P is null, and S must
+ be nonzero. Set *PN to the new number of objects, and return the
+ pointer to the new block. *PN is never set to zero, and the
+ returned pointer is never null.
+
+ Repeated reallocations are guaranteed to make progress, either by
+ allocating an initial block with a nonzero size, or by allocating a
+ larger block.
+
+ In the following implementation, nonzero sizes are increased by a
+ factor of approximately 1.5 so that repeated reallocations have
+ O(N) overall cost rather than O(N**2) cost, but the
+ specification for this function does not guarantee that rate.
+
+ Here is an example of use:
+
+ int *p = NULL;
+ size_t used = 0;
+ size_t allocated = 0;
+
+ void
+ append_int (int value)
+ {
+ if (used == allocated)
+ p = x2nrealloc (p, &allocated, sizeof *p);
+ p[used++] = value;
+ }
+
+ This causes x2nrealloc to allocate a block of some nonzero size the
+ first time it is called.
+
+ To have finer-grained control over the initial size, set *PN to a
+ nonzero value before calling this function with P == NULL. For
+ example:
+
+ int *p = NULL;
+ size_t used = 0;
+ size_t allocated = 0;
+ size_t allocated1 = 1000;
+
+ void
+ append_int (int value)
+ {
+ if (used == allocated)
+ {
+ p = x2nrealloc (p, &allocated1, sizeof *p);
+ allocated = allocated1;
+ }
+ p[used++] = value;
+ }
+
+ */
+
+static_inline void *
+x2nrealloc (void *p, size_t *pn, size_t s)
+{
+ size_t n = *pn;
+
+ if (! p)
+ {
+ if (! n)
+ {
+ /* The approximate size to use for initial small allocation
+ requests, when the invoking code specifies an old size of
+ zero. 64 bytes is the largest "small" request for the
+ GNU C library malloc. */
+ enum { DEFAULT_MXFAST = 64 };
+
+ n = DEFAULT_MXFAST / s;
+ n += !n;
+ }
+ }
+ else
+ {
+ /* Set N = ceil (1.5 * N) so that progress is made if N == 1.
+ Check for overflow, so that N * S stays in size_t range.
+ The check is slightly conservative, but an exact check isn't
+ worth the trouble. */
+ if ((size_t) -1 / 3 * 2 / s <= n)
+ xalloc_die ();
+ n += (n + 1) / 2;
+ }
+
+ *pn = n;
+ return xrealloc (p, n * s);
+}
+
+/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
+ except it returns char *. */
+
+static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
+static_inline char *
+xcharalloc (size_t n)
+{
+ return XNMALLOC (n, char);
+}
+
+# endif
+
+# ifdef __cplusplus
+}
+
+/* C++ does not allow conversions from void * to other pointer types
+ without a cast. Use templates to work around the problem when
+ possible. */
+
+template <typename T> inline T *
+xrealloc (T *p, size_t s)
+{
+ return (T *) xrealloc ((void *) p, s);
+}
+
+template <typename T> inline T *
+xnrealloc (T *p, size_t n, size_t s)
+{
+ return (T *) xnrealloc ((void *) p, n, s);
+}
+
+template <typename T> inline T *
+x2realloc (T *p, size_t *pn)
+{
+ return (T *) x2realloc ((void *) p, pn);
+}
+
+template <typename T> inline T *
+x2nrealloc (T *p, size_t *pn, size_t s)
+{
+ return (T *) x2nrealloc ((void *) p, pn, s);
+}
+
+template <typename T> inline T *
+xmemdup (T const *p, size_t s)
+{
+ return (T *) xmemdup ((void const *) p, s);
+}
+
+# endif
+
+
+#endif /* !XALLOC_H_ */
--- /dev/null
+/* xmalloc.c -- malloc with out of memory checking
+
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008-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 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/>. */
+
+#include <config.h>
+
+#if ! HAVE_INLINE
+# define static_inline
+#endif
+#include "xalloc.h"
+#undef static_inline
+
+#include <stdlib.h>
+#include <string.h>
+
+/* 1 if calloc is known to be compatible with GNU calloc. This
+ matters if we are not also using the calloc module, which defines
+ HAVE_CALLOC and supports the GNU API even on non-GNU platforms. */
+#if defined HAVE_CALLOC || defined __GLIBC__
+enum { HAVE_GNU_CALLOC = 1 };
+#else
+enum { HAVE_GNU_CALLOC = 0 };
+#endif
+
+/* Allocate N bytes of memory dynamically, with error checking. */
+
+void *
+xmalloc (size_t n)
+{
+ void *p = malloc (n);
+ if (!p && n != 0)
+ xalloc_die ();
+ return p;
+}
+
+/* Change the size of an allocated block of memory P to N bytes,
+ with error checking. */
+
+void *
+xrealloc (void *p, size_t n)
+{
+ p = realloc (p, n);
+ if (!p && n != 0)
+ xalloc_die ();
+ return p;
+}
+
+/* If P is null, allocate a block of at least *PN bytes; otherwise,
+ reallocate P so that it contains more than *PN bytes. *PN must be
+ nonzero unless P is null. Set *PN to the new block's size, and
+ return the pointer to the new block. *PN is never set to zero, and
+ the returned pointer is never null. */
+
+void *
+x2realloc (void *p, size_t *pn)
+{
+ return x2nrealloc (p, pn, 1);
+}
+
+/* Allocate S bytes of zeroed memory dynamically, with error checking.
+ There's no need for xnzalloc (N, S), since it would be equivalent
+ to xcalloc (N, S). */
+
+void *
+xzalloc (size_t s)
+{
+ return memset (xmalloc (s), 0, s);
+}
+
+/* Allocate zeroed memory for N elements of S bytes, with error
+ checking. S must be nonzero. */
+
+void *
+xcalloc (size_t n, size_t s)
+{
+ void *p;
+ /* Test for overflow, since some calloc implementations don't have
+ proper overflow checks. But omit overflow and size-zero tests if
+ HAVE_GNU_CALLOC, since GNU calloc catches overflow and never
+ returns NULL if successful. */
+ if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s))
+ || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0)))
+ xalloc_die ();
+ return p;
+}
+
+/* Clone an object P of size S, with error checking. There's no need
+ for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
+ need for an arithmetic overflow check. */
+
+void *
+xmemdup (void const *p, size_t s)
+{
+ return memcpy (xmalloc (s), p, s);
+}
+
+/* Clone STRING. */
+
+char *
+xstrdup (char const *string)
+{
+ return xmemdup (string, strlen (string) + 1);
+}
--- /dev/null
+/* Duplicate a bounded initial segment of a string, with out-of-memory
+ checking.
+ Copyright (C) 2003, 2006, 2007 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 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/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "xstrndup.h"
+
+#include <string.h>
+#include "xalloc.h"
+
+/* Return a newly allocated copy of at most N bytes of STRING.
+ In other words, return a copy of the initial segment of length N of
+ STRING. */
+char *
+xstrndup (const char *string, size_t n)
+{
+ char *s = strndup (string, n);
+ if (! s)
+ xalloc_die ();
+ return s;
+}
--- /dev/null
+/* Duplicate a bounded initial segment of a string, with out-of-memory
+ checking.
+ Copyright (C) 2003 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 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/>. */
+
+#include <stddef.h>
+
+/* Return a newly allocated copy of at most N bytes of STRING.
+ In other words, return a copy of the initial segment of length N of
+ STRING. */
+extern char *xstrndup (const char *string, size_t n);
--- /dev/null
+#serial 3
+dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_ARGMATCH],
+[
+ AC_LIBOBJ([argmatch])
+])
--- /dev/null
+# backupfile.m4 serial 12
+dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_BACKUPFILE],
+[
+ AC_LIBOBJ([backupfile])
+
+ dnl Prerequisites of lib/backupfile.c.
+ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
+ AC_REQUIRE([gl_AC_DOS])
+ AC_REQUIRE([AC_SYS_LONG_FILE_NAMES])
+ AC_CHECK_FUNCS_ONCE([pathconf])
+])
--- /dev/null
+# serial 11
+
+dnl From Jim Meyering.
+dnl
+dnl Check whether struct dirent has a member named d_ino.
+dnl
+
+# Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009 Free Software
+# Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
+ [AC_CACHE_CHECK([for d_ino member in directory struct],
+ gl_cv_struct_dirent_d_ino,
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <dirent.h>
+ ]],
+ [[DIR *dp = opendir (".");
+ struct dirent *e;
+ struct stat st;
+ if (! dp)
+ return 1;
+ e = readdir (dp);
+ return ! (e
+ && stat (e->d_name, &st) == 0
+ && e->d_ino == st.st_ino);]])],
+ [gl_cv_struct_dirent_d_ino=yes],
+ [gl_cv_struct_dirent_d_ino=no],
+ [gl_cv_struct_dirent_d_ino=no])])
+ if test $gl_cv_struct_dirent_d_ino = yes; then
+ AC_DEFINE([D_INO_IN_DIRENT], [1],
+ [Define if struct dirent has a member d_ino that actually works.])
+ fi
+ ]
+)
--- /dev/null
+#serial 7 -*- autoconf -*-
+dnl Copyright (C) 2002-2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_DIRNAME],
+[
+ AC_LIBOBJ([basename])
+ AC_LIBOBJ([dirname])
+ AC_LIBOBJ([stripslash])
+
+ dnl Prerequisites of lib/dirname.h.
+ AC_REQUIRE([gl_AC_DOS])
+ AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
+
+ dnl No prerequisites of lib/basename.c, lib/dirname.c, lib/stripslash.c.
+])
--- /dev/null
+#serial 10 -*- autoconf -*-
+
+# Define some macros required for proper operation of code in lib/*.c
+# on MSDOS/Windows systems.
+
+# Copyright (C) 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# From Jim Meyering.
+
+AC_DEFUN([gl_AC_DOS],
+ [
+ AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
+ [
+ AC_TRY_COMPILE([],
+ [#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
+neither MSDOS nor Windows
+#endif],
+ [ac_cv_win_or_dos=yes],
+ [ac_cv_win_or_dos=no])
+ ])
+
+ if test x"$ac_cv_win_or_dos" = xyes; then
+ ac_fs_accepts_drive_letter_prefix=1
+ ac_fs_backslash_is_file_name_separator=1
+ AC_CACHE_CHECK([whether drive letter can start relative path],
+ [ac_cv_drive_letter_can_be_relative],
+ [
+ AC_TRY_COMPILE([],
+ [#if defined __CYGWIN__
+drive letters are always absolute
+#endif],
+ [ac_cv_drive_letter_can_be_relative=yes],
+ [ac_cv_drive_letter_can_be_relative=no])
+ ])
+ if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
+ ac_fs_drive_letter_can_be_relative=1
+ else
+ ac_fs_drive_letter_can_be_relative=0
+ fi
+ else
+ ac_fs_accepts_drive_letter_prefix=0
+ ac_fs_backslash_is_file_name_separator=0
+ ac_fs_drive_letter_can_be_relative=0
+ fi
+
+ AC_DEFINE_UNQUOTED([FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX],
+ $ac_fs_accepts_drive_letter_prefix,
+ [Define on systems for which file names may have a so-called
+ `drive letter' prefix, define this to compute the length of that
+ prefix, including the colon.])
+
+ AH_VERBATIM(ISSLASH,
+ [#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#else
+# define ISSLASH(C) ((C) == '/')
+#endif])
+
+ AC_DEFINE_UNQUOTED([FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR],
+ $ac_fs_backslash_is_file_name_separator,
+ [Define if the backslash character may also serve as a file name
+ component separator.])
+
+ AC_DEFINE_UNQUOTED([FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE],
+ $ac_fs_drive_letter_can_be_relative,
+ [Define if a drive letter prefix denotes a relative path if it is
+ not followed by a file name component separator.])
+ ])
--- /dev/null
+# double-slash-root.m4 serial 4 -*- Autoconf -*-
+dnl Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root],
+ [ if test x"$cross_compiling" = xyes ; then
+ # When cross-compiling, there is no way to tell whether // is special
+ # short of a list of hosts. However, the only known hosts to date
+ # that have a distinct // are Apollo DomainOS (too old to port to),
+ # Cygwin, and z/OS. If anyone knows of another system for which // has
+ # special semantics and is distinct from /, please report it to
+ # <bug-gnulib@gnu.org>.
+ case $host in
+ *-cygwin | i370-ibm-openedition)
+ gl_cv_double_slash_root=yes ;;
+ *)
+ # Be optimistic and assume that / and // are the same when we
+ # don't know.
+ gl_cv_double_slash_root='unknown, assuming no' ;;
+ esac
+ else
+ set x `ls -di / // 2>/dev/null`
+ if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
+ gl_cv_double_slash_root=no
+ else
+ gl_cv_double_slash_root=yes
+ fi
+ fi])
+ if test "$gl_cv_double_slash_root" = yes; then
+ AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],
+ [Define to 1 if // is a file system root distinct from /.])
+ fi
+])
--- /dev/null
+#serial 11
+
+# Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004 Free Software
+# Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_ERROR],
+[
+ AC_FUNC_ERROR_AT_LINE
+ dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]).
+ gl_PREREQ_ERROR
+])
+
+# Prerequisites of lib/error.c.
+AC_DEFUN([gl_PREREQ_ERROR],
+[
+ AC_REQUIRE([AC_FUNC_STRERROR_R])
+ :
+])
--- /dev/null
+# exitfail.m4 serial 6
+dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_EXITFAIL],
+[
+ AC_LIBOBJ([exitfail])
+
+ dnl No prerequisites of lib/exitfail.c.
+ :
+])
--- /dev/null
+# serial 8 -*- Autoconf -*-
+# Enable extensions on systems that normally disable them.
+
+# Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
+# Autoconf. Perhaps we can remove this once we can assume Autoconf
+# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
+# enough in this area it's likely we'll need to redefine
+# AC_USE_SYSTEM_EXTENSIONS for quite some time.
+
+# AC_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+# Remember that #undef in AH_VERBATIM gets replaced with #define by
+# AC_DEFINE. The goal here is to define all known feature-enabling
+# macros, then, if reports of conflicts are made, disable macros that
+# cause problems on some platforms (such as __EXTENSIONS__).
+AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
+[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
+AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
+
+ AC_REQUIRE([AC_CANONICAL_HOST])
+
+ AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
+ if test "$MINIX" = yes; then
+ AC_DEFINE([_POSIX_SOURCE], [1],
+ [Define to 1 if you need to in order for `stat' and other
+ things to work.])
+ AC_DEFINE([_POSIX_1_SOURCE], [2],
+ [Define to 2 if the system does not provide POSIX.1 features
+ except with this defined.])
+ AC_DEFINE([_MINIX], [1],
+ [Define to 1 if on MINIX.])
+ fi
+
+ dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
+ dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
+ dnl provided.
+ case "$host_os" in
+ hpux*)
+ AC_DEFINE([_XOPEN_SOURCE], [500],
+ [Define to 500 only on HP-UX.])
+ ;;
+ esac
+
+ AH_VERBATIM([__EXTENSIONS__],
+[/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+])
+ AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
+ [ac_cv_safe_to_define___extensions__],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+# define __EXTENSIONS__ 1
+ ]AC_INCLUDES_DEFAULT])],
+ [ac_cv_safe_to_define___extensions__=yes],
+ [ac_cv_safe_to_define___extensions__=no])])
+ test $ac_cv_safe_to_define___extensions__ = yes &&
+ AC_DEFINE([__EXTENSIONS__])
+ AC_DEFINE([_ALL_SOURCE])
+ AC_DEFINE([_GNU_SOURCE])
+ AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
+ AC_DEFINE([_TANDEM_SOURCE])
+])# AC_USE_SYSTEM_EXTENSIONS
+
+# gl_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
+[
+ dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
+ dnl gnulib does not need it. But if it gets required by third-party macros
+ dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
+ dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
+ dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
+ dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
+ AC_REQUIRE([AC_GNU_SOURCE])
+
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+])
--- /dev/null
+# getopt.m4 serial 14
+dnl Copyright (C) 2002-2006, 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# The getopt module assume you want GNU getopt, with getopt_long etc,
+# rather than vanilla POSIX getopt. This means your code should
+# always include <getopt.h> for the getopt prototypes.
+
+AC_DEFUN([gl_GETOPT_SUBSTITUTE],
+[
+ AC_LIBOBJ([getopt])
+ AC_LIBOBJ([getopt1])
+ gl_GETOPT_SUBSTITUTE_HEADER
+ gl_PREREQ_GETOPT
+])
+
+AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
+[
+ GETOPT_H=getopt.h
+ AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
+ [Define to rpl_ if the getopt replacement functions and variables
+ should be used.])
+ AC_SUBST([GETOPT_H])
+])
+
+AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
+[
+ if test -z "$GETOPT_H"; then
+ AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
+ fi
+
+ if test -z "$GETOPT_H"; then
+ AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
+ fi
+
+ dnl BSD getopt_long uses an incompatible method to reset option processing,
+ dnl and (as of 2004-10-15) mishandles optional option-arguments.
+ if test -z "$GETOPT_H"; then
+ AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
+ fi
+
+ dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
+ dnl option string (as of 2005-05-05).
+ if test -z "$GETOPT_H"; then
+ AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[#include <getopt.h>]],
+ [[
+ char *myargv[3];
+ myargv[0] = "conftest";
+ myargv[1] = "-+";
+ myargv[2] = 0;
+ return getopt (2, myargv, "+a") != '?';
+ ]])],
+ [gl_cv_func_gnu_getopt=yes],
+ [gl_cv_func_gnu_getopt=no],
+ [dnl cross compiling - pessimistically guess based on decls
+ dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
+ dnl option string (as of 2005-05-05).
+ AC_CHECK_DECL([getopt_clip],
+ [gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
+ [#include <getopt.h>])])])
+ if test "$gl_cv_func_gnu_getopt" = "no"; then
+ GETOPT_H=getopt.h
+ fi
+ fi
+])
+
+AC_DEFUN([gl_GETOPT_IFELSE],
+[
+ AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
+ AS_IF([test -n "$GETOPT_H"], [$1], [$2])
+])
+
+AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])])
+
+# Prerequisites of lib/getopt*.
+AC_DEFUN([gl_PREREQ_GETOPT],
+[
+ AC_CHECK_DECLS_ONCE([getenv])
+])
--- /dev/null
+# gettext.m4 serial 62 (gettext-0.18)
+dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006.
+
+dnl Macro to add for using GNU gettext.
+
+dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
+dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
+dnl default (if it is not specified or empty) is 'no-libtool'.
+dnl INTLSYMBOL should be 'external' for packages with no intl directory,
+dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
+dnl If INTLSYMBOL is 'use-libtool', then a libtool library
+dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
+dnl depending on --{enable,disable}-{shared,static} and on the presence of
+dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
+dnl $(top_builddir)/intl/libintl.a will be created.
+dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
+dnl implementations (in libc or libintl) without the ngettext() function
+dnl will be ignored. If NEEDSYMBOL is specified and is
+dnl 'need-formatstring-macros', then GNU gettext implementations that don't
+dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
+dnl INTLDIR is used to find the intl libraries. If empty,
+dnl the value `$(top_builddir)/intl/' is used.
+dnl
+dnl The result of the configuration is one of three cases:
+dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
+dnl and used.
+dnl Catalog format: GNU --> install in $(datadir)
+dnl Catalog extension: .mo after installation, .gmo in source tree
+dnl 2) GNU gettext has been found in the system's C library.
+dnl Catalog format: GNU --> install in $(datadir)
+dnl Catalog extension: .mo after installation, .gmo in source tree
+dnl 3) No internationalization, always use English msgid.
+dnl Catalog format: none
+dnl Catalog extension: none
+dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
+dnl The use of .gmo is historical (it was needed to avoid overwriting the
+dnl GNU format catalogs when building on a platform with an X/Open gettext),
+dnl but we keep it in order not to force irrelevant filename changes on the
+dnl maintainers.
+dnl
+AC_DEFUN([AM_GNU_GETTEXT],
+[
+ dnl Argument checking.
+ ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
+ [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
+])])])])])
+ ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
+ [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
+])])])])
+ define([gt_included_intl],
+ ifelse([$1], [external],
+ ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
+ [yes]))
+ define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
+ gt_NEEDS_INIT
+ AM_GNU_GETTEXT_NEED([$2])
+
+ AC_REQUIRE([AM_PO_SUBDIRS])dnl
+ ifelse(gt_included_intl, yes, [
+ AC_REQUIRE([AM_INTL_SUBDIR])dnl
+ ])
+
+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+
+ dnl Sometimes libintl requires libiconv, so first search for libiconv.
+ dnl Ideally we would do this search only after the
+ dnl if test "$USE_NLS" = "yes"; then
+ dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
+ dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
+ dnl the configure script would need to contain the same shell code
+ dnl again, outside any 'if'. There are two solutions:
+ dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
+ dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
+ dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
+ dnl documented, we avoid it.
+ ifelse(gt_included_intl, yes, , [
+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
+ ])
+
+ dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
+ gt_INTL_MACOSX
+
+ dnl Set USE_NLS.
+ AC_REQUIRE([AM_NLS])
+
+ ifelse(gt_included_intl, yes, [
+ BUILD_INCLUDED_LIBINTL=no
+ USE_INCLUDED_LIBINTL=no
+ ])
+ LIBINTL=
+ LTLIBINTL=
+ POSUB=
+
+ dnl Add a version number to the cache macros.
+ case " $gt_needs " in
+ *" need-formatstring-macros "*) gt_api_version=3 ;;
+ *" need-ngettext "*) gt_api_version=2 ;;
+ *) gt_api_version=1 ;;
+ esac
+ gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
+ gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
+
+ dnl If we use NLS figure out what method
+ if test "$USE_NLS" = "yes"; then
+ gt_use_preinstalled_gnugettext=no
+ ifelse(gt_included_intl, yes, [
+ AC_MSG_CHECKING([whether included gettext is requested])
+ AC_ARG_WITH([included-gettext],
+ [ --with-included-gettext use the GNU gettext library included here],
+ nls_cv_force_use_gnu_gettext=$withval,
+ nls_cv_force_use_gnu_gettext=no)
+ AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
+
+ nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
+ if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ ])
+ dnl User does not insist on using GNU NLS library. Figure out what
+ dnl to use. If GNU gettext is available we use this. Else we have
+ dnl to fall back to GNU NLS library.
+
+ if test $gt_api_version -ge 3; then
+ gt_revision_test_code='
+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
+#endif
+changequote(,)dnl
+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
+changequote([,])dnl
+'
+ else
+ gt_revision_test_code=
+ fi
+ if test $gt_api_version -ge 2; then
+ gt_expression_test_code=' + * ngettext ("", "", 0)'
+ else
+ gt_expression_test_code=
+ fi
+
+ AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
+ [AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern int *_nl_domain_bindings;],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
+ [eval "$gt_func_gnugettext_libc=yes"],
+ [eval "$gt_func_gnugettext_libc=no"])])
+
+ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
+ dnl Sometimes libintl requires libiconv, so first search for libiconv.
+ ifelse(gt_included_intl, yes, , [
+ AM_ICONV_LINK
+ ])
+ dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
+ dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
+ dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
+ dnl even if libiconv doesn't exist.
+ AC_LIB_LINKFLAGS_BODY([intl])
+ AC_CACHE_CHECK([for GNU gettext in libintl],
+ [$gt_func_gnugettext_libintl],
+ [gt_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $INCINTL"
+ gt_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBINTL"
+ dnl Now see whether libintl exists and does not depend on libiconv.
+ AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *_nl_expand_alias (const char *);],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+ [eval "$gt_func_gnugettext_libintl=yes"],
+ [eval "$gt_func_gnugettext_libintl=no"])
+ dnl Now see whether libintl exists and depends on libiconv.
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
+ LIBS="$LIBS $LIBICONV"
+ AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *_nl_expand_alias (const char *);],
+ [bindtextdomain ("", "");
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+ [LIBINTL="$LIBINTL $LIBICONV"
+ LTLIBINTL="$LTLIBINTL $LTLIBICONV"
+ eval "$gt_func_gnugettext_libintl=yes"
+ ])
+ fi
+ CPPFLAGS="$gt_save_CPPFLAGS"
+ LIBS="$gt_save_LIBS"])
+ fi
+
+ dnl If an already present or preinstalled GNU gettext() is found,
+ dnl use it. But if this macro is used in GNU gettext, and GNU
+ dnl gettext is already preinstalled in libintl, we update this
+ dnl libintl. (Cf. the install rule in intl/Makefile.in.)
+ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
+ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
+ && test "$PACKAGE" != gettext-runtime \
+ && test "$PACKAGE" != gettext-tools; }; then
+ gt_use_preinstalled_gnugettext=yes
+ else
+ dnl Reset the values set by searching for libintl.
+ LIBINTL=
+ LTLIBINTL=
+ INCINTL=
+ fi
+
+ ifelse(gt_included_intl, yes, [
+ if test "$gt_use_preinstalled_gnugettext" != "yes"; then
+ dnl GNU gettext is not found in the C library.
+ dnl Fall back on included GNU gettext library.
+ nls_cv_use_gnu_gettext=yes
+ fi
+ fi
+
+ if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions used to generate GNU NLS library.
+ BUILD_INCLUDED_LIBINTL=yes
+ USE_INCLUDED_LIBINTL=yes
+ LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
+ LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
+ LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
+ fi
+
+ CATOBJEXT=
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Mark actions to use GNU gettext tools.
+ CATOBJEXT=.gmo
+ fi
+ ])
+
+ if test -n "$INTL_MACOSX_LIBS"; then
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ dnl Some extra flags are needed during linking.
+ LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
+ LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
+ fi
+ fi
+
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ AC_DEFINE([ENABLE_NLS], [1],
+ [Define to 1 if translation of program messages to the user's native language
+ is requested.])
+ else
+ USE_NLS=no
+ fi
+ fi
+
+ AC_MSG_CHECKING([whether to use NLS])
+ AC_MSG_RESULT([$USE_NLS])
+ if test "$USE_NLS" = "yes"; then
+ AC_MSG_CHECKING([where the gettext function comes from])
+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
+ gt_source="external libintl"
+ else
+ gt_source="libc"
+ fi
+ else
+ gt_source="included intl directory"
+ fi
+ AC_MSG_RESULT([$gt_source])
+ fi
+
+ if test "$USE_NLS" = "yes"; then
+
+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then
+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
+ AC_MSG_CHECKING([how to link with libintl])
+ AC_MSG_RESULT([$LIBINTL])
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
+ fi
+
+ dnl For backward compatibility. Some packages may be using this.
+ AC_DEFINE([HAVE_GETTEXT], [1],
+ [Define if the GNU gettext() function is already present or preinstalled.])
+ AC_DEFINE([HAVE_DCGETTEXT], [1],
+ [Define if the GNU dcgettext() function is already present or preinstalled.])
+ fi
+
+ dnl We need to process the po/ directory.
+ POSUB=po
+ fi
+
+ ifelse(gt_included_intl, yes, [
+ dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
+ dnl to 'yes' because some of the testsuite requires it.
+ if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
+ BUILD_INCLUDED_LIBINTL=yes
+ fi
+
+ dnl Make all variables we use known to autoconf.
+ AC_SUBST([BUILD_INCLUDED_LIBINTL])
+ AC_SUBST([USE_INCLUDED_LIBINTL])
+ AC_SUBST([CATOBJEXT])
+
+ dnl For backward compatibility. Some configure.ins may be using this.
+ nls_cv_header_intl=
+ nls_cv_header_libgt=
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ DATADIRNAME=share
+ AC_SUBST([DATADIRNAME])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INSTOBJEXT=.mo
+ AC_SUBST([INSTOBJEXT])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ GENCAT=gencat
+ AC_SUBST([GENCAT])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INTLOBJS=
+ if test "$USE_INCLUDED_LIBINTL" = yes; then
+ INTLOBJS="\$(GETTOBJS)"
+ fi
+ AC_SUBST([INTLOBJS])
+
+ dnl Enable libtool support if the surrounding package wishes it.
+ INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
+ AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
+ ])
+
+ dnl For backward compatibility. Some Makefiles may be using this.
+ INTLLIBS="$LIBINTL"
+ AC_SUBST([INTLLIBS])
+
+ dnl Make all documented variables known to autoconf.
+ AC_SUBST([LIBINTL])
+ AC_SUBST([LTLIBINTL])
+ AC_SUBST([POSUB])
+])
+
+
+dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
+m4_define([gt_NEEDS_INIT],
+[
+ m4_divert_text([DEFAULTS], [gt_needs=])
+ m4_define([gt_NEEDS_INIT], [])
+])
+
+
+dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
+AC_DEFUN([AM_GNU_GETTEXT_NEED],
+[
+ m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
+])
+
+
+dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
+AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
--- /dev/null
+# hash.m4 serial 6
+dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_HASH],
+[
+ AC_LIBOBJ([hash])
+
+ dnl Prerequisites of lib/hash.c.
+ AC_REQUIRE([AM_STDBOOL_H])
+])
--- /dev/null
+# inline.m4 serial 4
+dnl Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Test for the 'inline' keyword or equivalent.
+dnl Define 'inline' to a supported equivalent, or to nothing if not supported,
+dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an
+dnl equivalent is effectively supported, i.e. if the compiler is likely to
+dnl drop unused 'static inline' functions.
+AC_DEFUN([gl_INLINE],
+[
+ AC_REQUIRE([AC_C_INLINE])
+ AC_CACHE_CHECK([whether the compiler generally respects inline],
+ [gl_cv_c_inline_effective],
+ [if test $ac_cv_c_inline = no; then
+ gl_cv_c_inline_effective=no
+ else
+ dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is
+ dnl specified.
+ dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result
+ dnl depends on optimization flags, which can be in CFLAGS.
+ dnl (AC_EGREP_CPP looks only at the CPPFLAGS.)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]],
+ [[#ifdef __NO_INLINE__
+ #error "inline is not effective"
+ #endif]])],
+ [gl_cv_c_inline_effective=yes],
+ [gl_cv_c_inline_effective=no])
+ fi
+ ])
+ if test $gl_cv_c_inline_effective = yes; then
+ AC_DEFINE([HAVE_INLINE], [1],
+ [Define to 1 if the compiler supports one of the keywords
+ 'inline', '__inline__', '__inline' and effectively inlines
+ functions marked as such.])
+ fi
+])
--- /dev/null
+# malloc.m4 serial 9
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_FUNC_MALLOC_POSIX
+# --------------------
+# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
+# fails), and replace malloc if it is not.
+AC_DEFUN([gl_FUNC_MALLOC_POSIX],
+[
+ AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
+ if test $gl_cv_func_malloc_posix = yes; then
+ HAVE_MALLOC_POSIX=1
+ AC_DEFINE([HAVE_MALLOC_POSIX], [1],
+ [Define if the 'malloc' function is POSIX compliant.])
+ else
+ AC_LIBOBJ([malloc])
+ HAVE_MALLOC_POSIX=0
+ fi
+ AC_SUBST([HAVE_MALLOC_POSIX])
+])
+
+# Test whether malloc, realloc, calloc are POSIX compliant,
+# Set gl_cv_func_malloc_posix to yes or no accordingly.
+AC_DEFUN([gl_CHECK_MALLOC_POSIX],
+[
+ AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant],
+ [gl_cv_func_malloc_posix],
+ [
+ dnl It is too dangerous to try to allocate a large amount of memory:
+ dnl some systems go to their knees when you do that. So assume that
+ dnl all Unix implementations of the function are POSIX compliant.
+ AC_TRY_COMPILE([],
+ [#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ choke me
+ #endif
+ ], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no])
+ ])
+])
--- /dev/null
+# mbrtowc.m4 serial 14
+dnl Copyright (C) 2001-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MBRTOWC],
+[
+ AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+ AC_REQUIRE([AC_TYPE_MBSTATE_T])
+ gl_MBSTATE_T_BROKEN
+ if test $REPLACE_MBSTATE_T = 1; then
+ REPLACE_MBRTOWC=1
+ fi
+ AC_CHECK_FUNCS_ONCE([mbrtowc])
+ if test $ac_cv_func_mbrtowc = no; then
+ HAVE_MBRTOWC=0
+ fi
+ if test $HAVE_MBRTOWC != 0 && test $REPLACE_MBRTOWC != 1; then
+ gl_MBRTOWC_NULL_ARG
+ gl_MBRTOWC_RETVAL
+ gl_MBRTOWC_NUL_RETVAL
+ case "$gl_cv_func_mbrtowc_null_arg" in
+ *yes) ;;
+ *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1],
+ [Define if the mbrtowc function has the NULL string argument bug.])
+ REPLACE_MBRTOWC=1
+ ;;
+ esac
+ case "$gl_cv_func_mbrtowc_retval" in
+ *yes) ;;
+ *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
+ [Define if the mbrtowc function returns a wrong return value.])
+ REPLACE_MBRTOWC=1
+ ;;
+ esac
+ case "$gl_cv_func_mbrtowc_nul_retval" in
+ *yes) ;;
+ *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
+ [Define if the mbrtowc function does not return 0 for a NUL character.])
+ REPLACE_MBRTOWC=1
+ ;;
+ esac
+ fi
+ if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
+ gl_REPLACE_WCHAR_H
+ AC_LIBOBJ([mbrtowc])
+ gl_PREREQ_MBRTOWC
+ fi
+])
+
+dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
+dnl redefines the semantics of the given mbstate_t type.
+dnl Result is REPLACE_MBSTATE_T.
+dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
+dnl avoid inconsistencies.
+
+AC_DEFUN([gl_MBSTATE_T_BROKEN],
+[
+ AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+ AC_REQUIRE([AC_TYPE_MBSTATE_T])
+ AC_CHECK_FUNCS_ONCE([mbsinit])
+ AC_CHECK_FUNCS_ONCE([mbrtowc])
+ if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+ gl_MBRTOWC_INCOMPLETE_STATE
+ gl_MBRTOWC_SANITYCHECK
+ REPLACE_MBSTATE_T=0
+ case "$gl_cv_func_mbrtowc_incomplete_state" in
+ *yes) ;;
+ *) REPLACE_MBSTATE_T=1 ;;
+ esac
+ case "$gl_cv_func_mbrtowc_sanitycheck" in
+ *yes) ;;
+ *) REPLACE_MBSTATE_T=1 ;;
+ esac
+ else
+ REPLACE_MBSTATE_T=1
+ fi
+ if test $REPLACE_MBSTATE_T = 1; then
+ gl_REPLACE_WCHAR_H
+ fi
+])
+
+dnl Test whether mbrtowc puts the state into non-initial state when parsing an
+dnl incomplete multibyte character.
+dnl Result is gl_cv_func_mbrtowc_incomplete_state.
+
+AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_JA])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
+ [gl_cv_func_mbrtowc_incomplete_state],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on AIX and OSF/1.
+ osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_JA != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+ {
+ const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+ mbstate_t state;
+ wchar_t wc;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+ if (mbsinit (&state))
+ return 1;
+ }
+ return 0;
+}],
+ [gl_cv_func_mbrtowc_incomplete_state=yes],
+ [gl_cv_func_mbrtowc_incomplete_state=no],
+ [])
+ fi
+ ])
+])
+
+dnl Test whether mbrtowc works not worse than mbtowc.
+dnl Result is gl_cv_func_mbrtowc_sanitycheck.
+
+AC_DEFUN([gl_MBRTOWC_SANITYCHECK],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_ZH_CN])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc],
+ [gl_cv_func_mbrtowc_sanitycheck],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on Solaris 8.
+ solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_ZH_CN != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ /* This fails on Solaris 8:
+ mbrtowc returns 2, and sets wc to 0x00F0.
+ mbtowc returns 4 (correct) and sets wc to 0x5EDC. */
+ if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+ {
+ char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+ mbstate_t state;
+ wchar_t wc;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ if (mbrtowc (&wc, input + 3, 6, &state) != 4
+ && mbtowc (&wc, input + 3, 6) == 4)
+ return 1;
+ }
+ return 0;
+}],
+ [gl_cv_func_mbrtowc_sanitycheck=yes],
+ [gl_cv_func_mbrtowc_sanitycheck=no],
+ [])
+ fi
+ ])
+])
+
+dnl Test whether mbrtowc supports a NULL string argument correctly.
+dnl Result is gl_cv_func_mbrtowc_null_arg.
+
+AC_DEFUN([gl_MBRTOWC_NULL_ARG],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_FR_UTF8])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
+ [gl_cv_func_mbrtowc_null_arg],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on OSF/1.
+ osf*) gl_cv_func_mbrtowc_null_arg="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_mbrtowc_null_arg="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_FR_UTF8 != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+ {
+ mbstate_t state;
+ wchar_t wc;
+ int ret;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ wc = (wchar_t) 0xBADFACE;
+ mbrtowc (&wc, NULL, 5, &state);
+ /* Check that wc was not modified. */
+ if (wc != (wchar_t) 0xBADFACE)
+ return 1;
+ }
+ return 0;
+}], [gl_cv_func_mbrtowc_null_arg=yes], [gl_cv_func_mbrtowc_null_arg=no], [])
+ fi
+ ])
+])
+
+dnl Test whether mbrtowc, when parsing the end of a multibyte character,
+dnl correctly returns the number of bytes that were needed to complete the
+dnl character (not the total number of bytes of the multibyte character).
+dnl Result is gl_cv_func_mbrtowc_retval.
+
+AC_DEFUN([gl_MBRTOWC_RETVAL],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_FR_UTF8])
+ AC_REQUIRE([gt_LOCALE_JA])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether mbrtowc has a correct return value],
+ [gl_cv_func_mbrtowc_retval],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on HP-UX and Solaris.
+ hpux* | solaris*) gl_cv_func_mbrtowc_retval="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_mbrtowc_retval="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ /* This fails on Solaris. */
+ if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+ {
+ char input[] = "B\303\274\303\237er"; /* "Büßer" */
+ mbstate_t state;
+ wchar_t wc;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+ {
+ input[1] = '\0';
+ if (mbrtowc (&wc, input + 2, 5, &state) != 1)
+ return 1;
+ }
+ }
+ /* This fails on HP-UX 11.11. */
+ if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+ {
+ char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+ mbstate_t state;
+ wchar_t wc;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+ {
+ input[1] = '\0';
+ if (mbrtowc (&wc, input + 2, 5, &state) != 2)
+ return 1;
+ }
+ }
+ return 0;
+}],
+ [gl_cv_func_mbrtowc_retval=yes],
+ [gl_cv_func_mbrtowc_retval=no],
+ [])
+ fi
+ ])
+])
+
+dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
+dnl Result is gl_cv_func_mbrtowc_nul_retval.
+
+AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_ZH_CN])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
+ [gl_cv_func_mbrtowc_nul_retval],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on Solaris 8 and 9.
+ solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_ZH_CN != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ /* This fails on Solaris 8 and 9. */
+ if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+ {
+ mbstate_t state;
+ wchar_t wc;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ if (mbrtowc (&wc, "", 1, &state) != 0)
+ return 1;
+ }
+ return 0;
+}],
+ [gl_cv_func_mbrtowc_nul_retval=yes],
+ [gl_cv_func_mbrtowc_nul_retval=no],
+ [])
+ fi
+ ])
+])
+
+# Prerequisites of lib/mbrtowc.c.
+AC_DEFUN([gl_PREREQ_MBRTOWC], [
+ :
+])
+
+
+dnl From Paul Eggert
+
+dnl This override of an autoconf macro can be removed when autoconf 2.60 or
+dnl newer can be assumed everywhere.
+
+m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.60]),[-1],[
+AC_DEFUN([AC_FUNC_MBRTOWC],
+[
+ dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
+ AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
+ gl_cv_func_mbrtowc,
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <wchar.h>]],
+ [[wchar_t wc;
+ char const s[] = "";
+ size_t n = 1;
+ mbstate_t state;
+ return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
+ gl_cv_func_mbrtowc=yes,
+ gl_cv_func_mbrtowc=no)])
+ if test $gl_cv_func_mbrtowc = yes; then
+ AC_DEFINE([HAVE_MBRTOWC], [1],
+ [Define to 1 if mbrtowc and mbstate_t are properly declared.])
+ fi
+])
+])
--- /dev/null
+# mbstate_t.m4 serial 12
+dnl Copyright (C) 2000-2002, 2008, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# From Paul Eggert.
+
+# BeOS 5 has <wchar.h> but does not define mbstate_t,
+# so you can't declare an object of that type.
+# Check for this incompatibility with Standard C.
+
+# AC_TYPE_MBSTATE_T
+# -----------------
+AC_DEFUN([AC_TYPE_MBSTATE_T],
+[
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
+
+ AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT[
+# include <wchar.h>]],
+ [[mbstate_t x; return sizeof x;]])],
+ [ac_cv_type_mbstate_t=yes],
+ [ac_cv_type_mbstate_t=no])])
+ if test $ac_cv_type_mbstate_t = yes; then
+ AC_DEFINE([HAVE_MBSTATE_T], [1],
+ [Define to 1 if <wchar.h> declares mbstate_t.])
+ else
+ AC_DEFINE([mbstate_t], [int],
+ [Define to a type if <wchar.h> does not define.])
+ fi
+])
--- /dev/null
+# memchr.m4 serial 5
+dnl Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MEMCHR],
+[
+ AC_REPLACE_FUNCS([memchr])
+ if test $ac_cv_func_memchr = no; then
+ gl_PREREQ_MEMCHR
+ fi
+])
+
+# Prerequisites of lib/memchr.c.
+AC_DEFUN([gl_PREREQ_MEMCHR], [
+ AC_CHECK_HEADERS([bp-sym.h])
+])
--- /dev/null
+# minmax.m4 serial 3
+dnl Copyright (C) 2005, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_PREREQ([2.52])
+
+AC_DEFUN([gl_MINMAX],
+[
+ AC_REQUIRE([gl_PREREQ_MINMAX])
+])
+
+# Prerequisites of lib/minmax.h.
+AC_DEFUN([gl_PREREQ_MINMAX],
+[
+ gl_MINMAX_IN_HEADER([limits.h])
+ gl_MINMAX_IN_HEADER([sys/param.h])
+])
+
+dnl gl_MINMAX_IN_HEADER(HEADER)
+dnl The parameter has to be a literal header name; it cannot be macro,
+dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
+dnl invocations with a literal macro name.)
+AC_DEFUN([gl_MINMAX_IN_HEADER],
+[
+ m4_pushdef([header], AS_TR_SH([$1]))
+ m4_pushdef([HEADER], AS_TR_CPP([$1]))
+ AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
+ [gl_cv_minmax_in_]header,
+ [AC_TRY_COMPILE([#include <$1>
+int x = MIN (42, 17);], [],
+ [gl_cv_minmax_in_]header[=yes],
+ [gl_cv_minmax_in_]header[=no])])
+ if test $gl_cv_minmax_in_[]header = yes; then
+ AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
+ [Define to 1 if <$1> defines the MIN and MAX macros.])
+ fi
+ m4_popdef([HEADER])
+ m4_popdef([header])
+])
--- /dev/null
+# onceonly.m4 serial 6
+dnl Copyright (C) 2002-2003, 2005-2006, 2008 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl This file defines some "once only" variants of standard autoconf macros.
+dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
+dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
+dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
+dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL
+dnl The advantage is that the check for each of the headers/functions/decls
+dnl will be put only once into the 'configure' file. It keeps the size of
+dnl the 'configure' file down, and avoids redundant output when 'configure'
+dnl is run.
+dnl The drawback is that the checks cannot be conditionalized. If you write
+dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
+dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
+dnl empty, and the check will be inserted before the body of the AC_DEFUNed
+dnl function.
+
+dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
+dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
+dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
+dnl headers at once, thus reducing the size of 'configure'. It is known to work
+dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
+
+dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
+dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
+dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
+dnl argument!
+AC_PREREQ([2.59])
+
+# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
+# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
+AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
+ :
+ m4_foreach_w([gl_HEADER_NAME], [$1], [
+ AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
+ [./-], [___])), [
+ m4_divert_text([INIT_PREPARE],
+ [gl_header_list="$gl_header_list gl_HEADER_NAME"])
+ gl_HEADERS_EXPANSION
+ AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
+ [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
+ ])
+ AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
+ [./-], [___])))
+ ])
+])
+m4_define([gl_HEADERS_EXPANSION], [
+ m4_divert_text([DEFAULTS], [gl_header_list=])
+ AC_CHECK_HEADERS([$gl_header_list])
+ m4_define([gl_HEADERS_EXPANSION], [])
+])
+
+# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
+# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
+AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
+ :
+ m4_foreach_w([gl_FUNC_NAME], [$1], [
+ AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
+ m4_divert_text([INIT_PREPARE],
+ [gl_func_list="$gl_func_list gl_FUNC_NAME"])
+ gl_FUNCS_EXPANSION
+ AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
+ [Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.])
+ ])
+ AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
+ ])
+])
+m4_define([gl_FUNCS_EXPANSION], [
+ m4_divert_text([DEFAULTS], [gl_func_list=])
+ AC_CHECK_FUNCS([$gl_func_list])
+ m4_define([gl_FUNCS_EXPANSION], [])
+])
+
+# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
+# AC_CHECK_DECLS(DECL1, DECL2, ...).
+AC_DEFUN([AC_CHECK_DECLS_ONCE], [
+ :
+ m4_foreach_w([gl_DECL_NAME], [$1], [
+ AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
+ AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
+ ])
+ AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
+ ])
+])
--- /dev/null
+# quote.m4 serial 5
+dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_QUOTE],
+[
+ AC_LIBOBJ([quote])
+
+ dnl Prerequisites of lib/quote.c.
+ dnl (none)
+])
--- /dev/null
+# quotearg.m4 serial 8
+dnl Copyright (C) 2002, 2004-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_QUOTEARG],
+[
+ AC_LIBOBJ([quotearg])
+])
--- /dev/null
+# realloc.m4 serial 9
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_FUNC_REALLOC_POSIX
+# ---------------------
+# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
+# fails), and replace realloc if it is not.
+AC_DEFUN([gl_FUNC_REALLOC_POSIX],
+[
+ AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
+ if test $gl_cv_func_malloc_posix = yes; then
+ HAVE_REALLOC_POSIX=1
+ AC_DEFINE([HAVE_REALLOC_POSIX], [1],
+ [Define if the 'realloc' function is POSIX compliant.])
+ else
+ AC_LIBOBJ([realloc])
+ HAVE_REALLOC_POSIX=0
+ fi
+ AC_SUBST([HAVE_REALLOC_POSIX])
+])
--- /dev/null
+# serial 13
+
+# Copyright (C) 2001, 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+dnl From Volker Borchert.
+dnl Determine whether rename works for source file names with a trailing slash.
+dnl The rename from SunOS 4.1.1_U1 doesn't.
+dnl
+dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
+dnl to compile the wrapper function.
+dnl
+
+AC_DEFUN([gl_FUNC_RENAME],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_CACHE_CHECK([whether rename is broken with a trailing slash],
+ gl_cv_func_rename_trailing_slash_bug,
+ [
+ rm -rf conftest.d1 conftest.d2
+ mkdir conftest.d1 ||
+ AC_MSG_ERROR([cannot create temporary directory])
+ AC_TRY_RUN([
+# include <stdio.h>
+# include <stdlib.h>
+ int
+ main ()
+ {
+ exit (rename ("conftest.d1/", "conftest.d2") ? 1 : 0);
+ }
+ ],
+ gl_cv_func_rename_trailing_slash_bug=no,
+ gl_cv_func_rename_trailing_slash_bug=yes,
+ dnl When crosscompiling, assume rename is broken.
+ gl_cv_func_rename_trailing_slash_bug=yes)
+
+ rm -rf conftest.d1 conftest.d2
+ ])
+ AC_CACHE_CHECK([whether rename is broken when the destination exists],
+ gl_cv_func_rename_dest_exists_bug,
+ [
+ case "$host_os" in
+ mingw*) gl_cv_func_rename_dest_exists_bug=yes ;;
+ *) gl_cv_func_rename_dest_exists_bug=no ;;
+ esac
+ ])
+ if test $gl_cv_func_rename_trailing_slash_bug = yes ||
+ test $gl_cv_func_rename_dest_exists_bug = yes; then
+ AC_LIBOBJ([rename])
+ AC_DEFINE([rename], [rpl_rename],
+ [Define to rpl_rename if the replacement function should be used.])
+ if test $gl_cv_func_rename_trailing_slash_bug = yes; then
+ AC_DEFINE([RENAME_TRAILING_SLASH_BUG], [1],
+ [Define if rename does not work for source file names with a trailing
+ slash, like the one from SunOS 4.1.1_U1.])
+ fi
+ if test $gl_cv_func_rename_dest_exists_bug = yes; then
+ AC_DEFINE([RENAME_DEST_EXISTS_BUG], [1],
+ [Define if rename does not work when the destination file exists,
+ as on Windows.])
+ fi
+ gl_PREREQ_RENAME
+ fi
+])
+
+# Prerequisites of lib/rename.c.
+AC_DEFUN([gl_PREREQ_RENAME], [:])
--- /dev/null
+# safe-write.m4 serial 3
+dnl Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SAFE_WRITE],
+[
+ AC_LIBOBJ([safe-write])
+
+ gl_PREREQ_SAFE_WRITE
+])
+
+# Prerequisites of lib/safe-write.c.
+AC_DEFUN([gl_PREREQ_SAFE_WRITE],
+[
+ gl_PREREQ_SAFE_READ
+])
--- /dev/null
+# ssize_t.m4 serial 4 (gettext-0.15)
+dnl Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+dnl Test whether ssize_t is defined.
+
+AC_DEFUN([gt_TYPE_SSIZE_T],
+[
+ AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
+ [AC_TRY_COMPILE([#include <sys/types.h>],
+ [int x = sizeof (ssize_t *) + sizeof (ssize_t);
+ return !x;],
+ [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
+ if test $gt_cv_ssize_t = no; then
+ AC_DEFINE([ssize_t], [int],
+ [Define as a signed type of the same size as size_t.])
+ fi
+])
--- /dev/null
+# Check for stdbool.h that conforms to C99.
+
+dnl Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Prepare for substituting <stdbool.h> if it is not supported.
+
+AC_DEFUN([AM_STDBOOL_H],
+[
+ AC_REQUIRE([AC_HEADER_STDBOOL])
+
+ # Define two additional variables used in the Makefile substitution.
+
+ if test "$ac_cv_header_stdbool_h" = yes; then
+ STDBOOL_H=''
+ else
+ STDBOOL_H='stdbool.h'
+ fi
+ AC_SUBST([STDBOOL_H])
+
+ if test "$ac_cv_type__Bool" = yes; then
+ HAVE__BOOL=1
+ else
+ HAVE__BOOL=0
+ fi
+ AC_SUBST([HAVE__BOOL])
+])
+
+# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
+AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
+
+# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf
+# have this macro built-in.
+
+AC_DEFUN([AC_HEADER_STDBOOL],
+ [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
+ [ac_cv_header_stdbool_h],
+ [AC_TRY_COMPILE(
+ [
+ #include <stdbool.h>
+ #ifndef bool
+ "error: bool is not defined"
+ #endif
+ #ifndef false
+ "error: false is not defined"
+ #endif
+ #if false
+ "error: false is not 0"
+ #endif
+ #ifndef true
+ "error: true is not defined"
+ #endif
+ #if true != 1
+ "error: true is not 1"
+ #endif
+ #ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+ #endif
+
+ struct s { _Bool s: 1; _Bool t; } s;
+
+ char a[true == 1 ? 1 : -1];
+ char b[false == 0 ? 1 : -1];
+ char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+ char d[(bool) 0.5 == true ? 1 : -1];
+ bool e = &s;
+ char f[(_Bool) 0.0 == false ? 1 : -1];
+ char g[true];
+ char h[sizeof (_Bool)];
+ char i[sizeof s.t];
+ enum { j = false, k = true, l = false * true, m = true * 256 };
+ _Bool n[m];
+ char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+ char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+ #if defined __xlc__ || defined __GNUC__
+ /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+ reported by James Lemley on 2005-10-05; see
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+ This test is not quite right, since xlc is allowed to
+ reject this program, as the initializer for xlcbug is
+ not one of the forms that C requires support for.
+ However, doing the test right would require a run-time
+ test, and that would make cross-compilation harder.
+ Let us hope that IBM fixes the xlc bug, and also adds
+ support for this kind of constant expression. In the
+ meantime, this test will reject xlc, which is OK, since
+ our stdbool.h substitute should suffice. We also test
+ this with GCC, where it should work, to detect more
+ quickly whether someone messes up the test in the
+ future. */
+ char digs[] = "0123456789";
+ int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+ #endif
+ /* Catch a bug in an HP-UX C compiler. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ */
+ _Bool q = true;
+ _Bool *pq = &q;
+ ],
+ [
+ *pq |= q;
+ *pq |= ! q;
+ /* Refer to every declared value, to avoid compiler optimizations. */
+ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ + !m + !n + !o + !p + !q + !pq);
+ ],
+ [ac_cv_header_stdbool_h=yes],
+ [ac_cv_header_stdbool_h=no])])
+ AC_CHECK_TYPES([_Bool])
+ if test $ac_cv_header_stdbool_h = yes; then
+ AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
+ fi])
--- /dev/null
+# strcase.m4 serial 1
+dnl Copyright (C) 2002 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_STRCASE],
+[
+ gl_FUNC_STRCASECMP
+ gl_FUNC_STRNCASECMP
+])
+
+AC_DEFUN([gl_FUNC_STRCASECMP],
+[
+ AC_REPLACE_FUNCS(strcasecmp)
+ if test $ac_cv_func_strcasecmp = no; then
+ gl_PREREQ_STRCASECMP
+ fi
+])
+
+AC_DEFUN([gl_FUNC_STRNCASECMP],
+[
+ AC_REPLACE_FUNCS(strncasecmp)
+ if test $ac_cv_func_strncasecmp = no; then
+ gl_PREREQ_STRNCASECMP
+ fi
+])
+
+# Prerequisites of lib/strcasecmp.c.
+AC_DEFUN([gl_PREREQ_STRCASECMP], [
+ :
+])
+
+# Prerequisites of lib/strncasecmp.c.
+AC_DEFUN([gl_PREREQ_STRNCASECMP], [
+ :
+])
--- /dev/null
+# strndup.m4 serial 16
+dnl Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRNDUP],
+[
+ dnl Persuade glibc <string.h> to declare strndup().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_CHECK_DECLS_ONCE([strndup])
+ if test $ac_cv_have_decl_strndup = no; then
+ HAVE_DECL_STRNDUP=0
+ fi
+
+ # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
+ AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup],
+ [AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([[#include <string.h>
+ #include <stdlib.h>]], [[
+#ifndef HAVE_DECL_STRNDUP
+ extern char *strndup (const char *, size_t);
+#endif
+ char *s;
+ s = strndup ("some longer string", 15);
+ free (s);
+ s = strndup ("shorter string", 13);
+ return s[13] != '\0';]])],
+ [gl_cv_func_strndup=yes],
+ [gl_cv_func_strndup=no],
+ [AC_CHECK_FUNC([strndup],
+ [AC_EGREP_CPP([too risky], [
+#ifdef _AIX
+ too risky
+#endif
+ ],
+ [gl_cv_func_strndup=no],
+ [gl_cv_func_strndup=yes])],
+ [gl_cv_func_strndup=no])])])
+ if test $gl_cv_func_strndup = yes; then
+ AC_DEFINE([HAVE_STRNDUP], [1],
+ [Define if you have the strndup() function and it works.])
+ else
+ HAVE_STRNDUP=0
+ AC_LIBOBJ([strndup])
+ gl_PREREQ_STRNDUP
+ fi
+])
+
+# Prerequisites of lib/strndup.c.
+AC_DEFUN([gl_PREREQ_STRNDUP], [:])
--- /dev/null
+# unlocked-io.m4 serial 15
+
+# Copyright (C) 1998-2006, 2009 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+dnl From Jim Meyering.
+dnl
+dnl See if the glibc *_unlocked I/O macros or functions are available.
+dnl Use only those *_unlocked macros or functions that are declared
+dnl (because some of them were declared in Solaris 2.5.1 but were removed
+dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
+dnl on Solaris 2.6).
+
+AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
+[
+ AC_DEFINE([USE_UNLOCKED_IO], [1],
+ [Define to 1 if you want getc etc. to use unlocked I/O if available.
+ Unlocked I/O can improve performance in unithreaded apps,
+ but it is not safe for multithreaded apps.])
+
+ dnl Persuade glibc and Solaris <stdio.h> to declare
+ dnl fgets_unlocked(), fputs_unlocked() etc.
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_DECLS_ONCE([clearerr_unlocked])
+ AC_CHECK_DECLS_ONCE([feof_unlocked])
+ AC_CHECK_DECLS_ONCE([ferror_unlocked])
+ AC_CHECK_DECLS_ONCE([fflush_unlocked])
+ AC_CHECK_DECLS_ONCE([fgets_unlocked])
+ AC_CHECK_DECLS_ONCE([fputc_unlocked])
+ AC_CHECK_DECLS_ONCE([fputs_unlocked])
+ AC_CHECK_DECLS_ONCE([fread_unlocked])
+ AC_CHECK_DECLS_ONCE([fwrite_unlocked])
+ AC_CHECK_DECLS_ONCE([getc_unlocked])
+ AC_CHECK_DECLS_ONCE([getchar_unlocked])
+ AC_CHECK_DECLS_ONCE([putc_unlocked])
+ AC_CHECK_DECLS_ONCE([putchar_unlocked])
+])
--- /dev/null
+# serial 9
+
+# Copyright (C) 1998-2001, 2003-2004, 2007, 2009 Free Software
+# Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+dnl From Jim Meyering
+
+dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared --
+dnl usually in <utime.h>.
+dnl Some systems have utime.h but don't declare the struct anywhere.
+
+AC_DEFUN([gl_CHECK_TYPE_STRUCT_UTIMBUF],
+[
+ AC_CHECK_HEADERS_ONCE([sys/time.h utime.h])
+ AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#if HAVE_SYS_TIME_H
+ #include <sys/time.h>
+ #endif
+ #include <time.h>
+ #ifdef HAVE_UTIME_H
+ #include <utime.h>
+ #endif
+ ]],
+ [[static struct utimbuf x; x.actime = x.modtime;]])],
+ [gl_cv_sys_struct_utimbuf=yes],
+ [gl_cv_sys_struct_utimbuf=no])])
+
+ if test $gl_cv_sys_struct_utimbuf = yes; then
+ AC_DEFINE([HAVE_STRUCT_UTIMBUF], [1],
+ [Define if struct utimbuf is declared -- usually in <utime.h>.
+ Some systems have utime.h but don't declare the struct anywhere. ])
+ fi
+])
--- /dev/null
+# xalloc.m4 serial 16
+dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_XALLOC],
+[
+ AC_LIBOBJ([xmalloc])
+
+ gl_PREREQ_XALLOC
+ gl_PREREQ_XMALLOC
+])
+
+# Prerequisites of lib/xalloc.h.
+AC_DEFUN([gl_PREREQ_XALLOC], [
+ AC_REQUIRE([gl_INLINE])
+ :
+])
+
+# Prerequisites of lib/xmalloc.c.
+AC_DEFUN([gl_PREREQ_XMALLOC], [
+ :
+])
--- /dev/null
+# xstrndup.m4 serial 2
+dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_XSTRNDUP],
+[
+ gl_PREREQ_XSTRNDUP
+])
+
+# Prerequisites of lib/xstrndup.c.
+AC_DEFUN([gl_PREREQ_XSTRNDUP], [
+ :
+])
--- /dev/null
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2006-12-25.00
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ trap '(exit $?); exit' 1 2 13 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names starting with `-'.
+ case $src in
+ -*) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+
+ dst=$dst_arg
+ # Protect names starting with `-'.
+ case $dst in
+ -*) dst=./$dst;;
+ esac
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writeable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ -*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test -z "$d" && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
--- /dev/null
+#serial 2
+
+dnl From Mumit Khan and Paul Eggert
+dnl Determine whether mkdir accepts only one argument instead of the usual two.
+
+AC_DEFUN([PATCH_FUNC_MKDIR_TAKES_ONE_ARG],
+ [AC_CHECK_FUNCS(mkdir)
+ AC_CACHE_CHECK([whether mkdir takes only one argument],
+ patch_cv_mkdir_takes_one_arg,
+ [patch_cv_mkdir_takes_one_arg=no
+ if test $ac_cv_func_mkdir = yes; then
+ AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+ ],
+ [mkdir (".", 0);],
+ ,
+ [AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+ ],
+ [mkdir (".");],
+ patch_cv_mkdir_takes_one_arg=yes
+ )]
+ )
+ fi
+ ]
+ )
+ if test $patch_cv_mkdir_takes_one_arg = yes; then
+ AC_DEFINE([MKDIR_TAKES_ONE_ARG], 1,
+ [Define if mkdir takes only one argument.])
+ fi
+ ]
+)
--- /dev/null
+# Check for setmode, DOS style.
+
+# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+AC_DEFUN([AC_FUNC_SETMODE_DOS],
+ [AC_CHECK_HEADERS(fcntl.h unistd.h)
+ AC_CACHE_CHECK([for DOS-style setmode],
+ [ac_cv_func_setmode_dos],
+ [AC_TRY_LINK(
+ [#include <io.h>
+ #if HAVE_FCNTL_H
+ # include <fcntl.h>
+ #endif
+ #if HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif],
+ [int ret = setmode && setmode (1, O_BINARY);],
+ [ac_cv_func_setmode_dos=yes],
+ [ac_cv_func_setmode_dos=no])])
+ if test $ac_cv_func_setmode_dos = yes; then
+ AC_DEFINE(HAVE_SETMODE_DOS, 1,
+ [Define to 1 if you have the DOS-style `setmode' function.])
+ fi])
--- /dev/null
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+
+scriptversion=2006-05-11.19
+
+# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+nl='
+'
+IFS=" "" $nl"
+errstatus=0
+dirmode=
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <bug-automake@gnu.org>."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage"
+ exit $?
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --version)
+ echo "$0 $scriptversion"
+ exit $?
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error. This is a problem when calling mkinstalldirs
+# from a parallel make. We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
+case $dirmode in
+ '')
+ if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ else
+ # On NextStep and OpenStep, the `mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because `.' already
+ # exists.
+ test -d ./-p && rmdir ./-p
+ test -d ./--version && rmdir ./--version
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+ test ! -d ./--version; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ else
+ # Clean up after NextStep and OpenStep mkdir.
+ for d in ./-m ./-p ./--version "./$dirmode";
+ do
+ test -d $d && rmdir $d
+ done
+ fi
+ ;;
+esac
+
+for file
+do
+ case $file in
+ /*) pathcomp=/ ;;
+ *) pathcomp= ;;
+ esac
+ oIFS=$IFS
+ IFS=/
+ set fnord $file
+ shift
+ IFS=$oIFS
+
+ for d
+ do
+ test "x$d" = x && continue
+
+ pathcomp=$pathcomp$d
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
+
+ pathcomp=$pathcomp/
+ done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
--- /dev/null
+diff -up patch-2.6/src/inp.c.sigsegv patch-2.6/src/inp.c
+--- patch-2.6/src/inp.c.sigsegv 2009-11-02 19:09:57.000000000 +0000
++++ patch-2.6/src/inp.c 2009-11-16 09:31:52.305022200 +0000
+@@ -77,6 +77,14 @@ re_input (void)
+ }
+ }
+
++void
++reset_scan_input_vars()
++{
++ using_plan_a = 1;
++ i_buffer = NULL;
++ i_ptr = NULL;
++}
++
+ /* Construct the line index, somehow or other. */
+
+ void
+diff -up patch-2.6/src/inp.h.sigsegv patch-2.6/src/inp.h
+--- patch-2.6/src/inp.h.sigsegv 2009-11-02 19:09:57.000000000 +0000
++++ patch-2.6/src/inp.h 2009-11-16 09:32:24.440021838 +0000
+@@ -24,4 +24,5 @@ XTERN LINENUM input_lines; /* how long
+ char const *ifetch (LINENUM, bool, size_t *);
+ void get_input_file (char const *, char const *);
+ void re_input (void);
++void reset_scan_input_vars (void);
+ void scan_input (char *);
+diff -up patch-2.6/src/patch.c.sigsegv patch-2.6/src/patch.c
+--- patch-2.6/src/patch.c.sigsegv 2009-11-02 19:09:57.000000000 +0000
++++ patch-2.6/src/patch.c 2009-11-16 09:31:52.306021801 +0000
+@@ -210,7 +210,10 @@ main (int argc, char **argv)
+
+ /* find out where all the lines are */
+ if (!skip_rest_of_patch)
+- scan_input (inname);
++ scan_input (inname);
++ else
++ reset_scan_input_vars ();
++
+
+ /* from here on, open no standard i/o files, because malloc */
+ /* might misfire and we can't catch it easily */
--- /dev/null
+* Fri Jul 20 2011 Junfeng Dong <junfeng.dong@intel.com> -2.6
+- Import 2.6 for SLP.
--- /dev/null
+#
+# Do NOT Edit the Auto-generated Part!
+# Generated by: spectacle version 0.22
+#
+# >> macros
+# << macros
+
+Name: patch
+Summary: The GNU patch command, for modifying/upgrading files
+Version: 2.6
+Release: 1
+Group: Development/Tools
+License: GPLv3
+URL: http://www.gnu.org/software/patch/patch.html
+Source0: ftp://ftp.gnu.org/gnu/patch/patch-%{version}.tar.xz
+Patch0: patch-2.5.4-sigsegv.patch
+
+%description
+The patch program applies diff files to originals. The diff command
+is used to compare an original to a changed file. Diff lists the
+changes made to the file. A person who has the original file can then
+use the patch command with the diff file to add the changes to their
+original file (patching the file).
+
+Patch should be installed because it is a common way of upgrading
+applications.
+
+
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+# patch-2.5.4-sigsegv.patch
+%patch0 -p1
+# >> setup
+# << setup
+
+%build
+# >> build pre
+CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
+# << build pre
+
+%configure --disable-static
+make %{?jobs:-j%jobs}
+
+# >> build post
+# << build post
+%install
+rm -rf %{buildroot}
+# >> install pre
+# << install pre
+%make_install
+
+
+%files
+%defattr(-,root,root,-)
+# >> files
+%{_bindir}/*
+%doc %{_mandir}/*/*
+# << files
+
--- /dev/null
+.\" patch man page
+.de Id
+.ds Dt \\$4
+..
+.ds = \-\^\-
+.de Sp
+.if t .sp .3
+.if n .sp
+..
+.TH PATCH 1 \*(Dt GNU
+.ta 3n
+.SH NAME
+patch \- apply a diff file to an original
+.SH SYNOPSIS
+.B patch
+.RI [ options ]
+.RI [ originalfile
+.RI [ patchfile ]]
+.Sp
+but usually just
+.Sp
+.BI "patch \-p" "num"
+.BI < patchfile
+.SH DESCRIPTION
+.B patch
+takes a patch file
+.I patchfile
+containing a difference listing produced by the
+.B diff
+program and applies those differences to one or more original files,
+producing patched versions.
+Normally the patched versions are put in place of the originals.
+Backups can be made; see the
+.B \-b
+or
+.B \*=backup
+option.
+The names of the files to be patched are usually taken from the patch file,
+but if there's just one file to be patched it can be specified on the
+command line as
+.IR originalfile .
+.PP
+Upon startup, patch attempts to determine the type of the diff listing,
+unless overruled by a
+\fB\-c\fP (\fB\*=context\fP),
+\fB\-e\fP (\fB\*=ed\fP),
+\fB\-n\fP (\fB\*=normal\fP),
+or
+\fB\-u\fP (\fB\*=unified\fP)
+option.
+Context diffs (old-style, new-style, and unified) and
+normal diffs are applied by the
+.B patch
+program itself, while
+.B ed
+diffs are simply fed to the
+.BR ed (1)
+editor via a pipe.
+.PP
+.B patch
+tries to skip any leading garbage, apply the diff,
+and then skip any trailing garbage.
+Thus you could feed an article or message containing a
+diff listing to
+.BR patch ,
+and it should work.
+If the entire diff is indented by a consistent amount,
+or if a context diff contains lines ending in \s-1CRLF\s0
+or is encapsulated one or more times by prepending
+"\fB\- \fP" to lines starting with "\fB\-\fP" as specified by Internet RFC 934,
+this is taken into account.
+After removing indenting or encapsulation,
+lines beginning with
+.B #
+are ignored, as they are considered to be comments.
+.PP
+With context diffs, and to a lesser extent with normal diffs,
+.B patch
+can detect when the line numbers mentioned in the patch are incorrect,
+and attempts to find the correct place to apply each hunk of the patch.
+As a first guess, it takes the line number mentioned for the hunk, plus or
+minus any offset used in applying the previous hunk.
+If that is not the correct place,
+.B patch
+scans both forwards and backwards for a set of lines matching the context
+given in the hunk.
+First
+.B patch
+looks for a place where all lines of the context match.
+If no such place is found, and it's a context diff, and the maximum fuzz factor
+is set to 1 or more, then another scan takes place ignoring the first and last
+line of context.
+If that fails, and the maximum fuzz factor is set to 2 or more,
+the first two and last two lines of context are ignored,
+and another scan is made.
+(The default maximum fuzz factor is 2.)
+.PP
+Hunks with less prefix context than suffix context (after applying fuzz)
+must apply at the start of the file if their first line number is\ 1. Hunks
+with more prefix context than suffix context (after applying fuzz) must apply
+at the end of the file.
+.PP
+If
+.B patch
+cannot find a place to install that hunk of the patch, it puts the
+hunk out to a reject file, which normally is the name of the output file
+plus a
+.B \&.rej
+suffix, or
+.B #
+if
+.B \&.rej
+would generate a file name that is too long
+(if even appending the single character
+.B #
+makes the file name too long, then
+.B #
+replaces the file name's last character).
+.PP
+The rejected hunk comes out in unified or context diff format.
+If the input was a normal diff, many of the contexts are simply null.
+The line numbers on the hunks in the reject file may be different than
+in the patch file: they reflect the approximate location patch thinks the
+failed hunks belong in the new file rather than the old one.
+.PP
+As each hunk is completed, you are told if the hunk
+failed, and if so which line (in the new file)
+.B patch
+thought the hunk should go on.
+If the hunk is installed at a different line
+from the line number specified in the diff, you
+are told the offset.
+A single large offset
+.I may
+indicate that a hunk was installed in the
+wrong place.
+You are also told if a fuzz factor was used to make the match, in which
+case you should also be slightly suspicious.
+If the
+.B \*=verbose
+option is given, you are also told about hunks that match exactly.
+.PP
+If no original file
+.I origfile
+is specified on the command line,
+.B patch
+tries to figure out from the leading garbage what the name of the file
+to edit is, using the following rules.
+.LP
+First,
+.B patch
+takes an ordered list of candidate file names as follows:
+.TP 3
+.B " \(bu"
+If the header is that of a context diff,
+.B patch
+takes the old and new file names in the header.
+A name is ignored if it does not have enough slashes to satisfy the
+.BI \-p num
+or
+.BI \*=strip= num
+option.
+The name
+.B /dev/null
+is also ignored.
+.TP
+.B " \(bu"
+If there is an
+.B Index:\&
+line in the leading garbage
+and if either the old and new names are both absent or if
+.B patch
+is conforming to \s-1POSIX\s0,
+.B patch
+takes the name in the
+.B Index:\&
+line.
+.TP
+.B " \(bu"
+For the purpose of the following rules,
+the candidate file names are considered to be in the order (old, new, index),
+regardless of the order that they appear in the header.
+.LP
+Then
+.B patch
+selects a file name from the candidate list as follows:
+.TP 3
+.B " \(bu"
+If some of the named files exist,
+.B patch
+selects the first name if conforming to \s-1POSIX\s0,
+and the best name otherwise.
+.TP
+.B " \(bu"
+If
+.B patch
+is not ignoring \s-1RCS\s0, ClearCase, Perforce, and \s-1SCCS\s0 (see the
+.BI "\-g\ " num
+or
+.BI \*=get= num
+option), and no named files exist
+but an \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master is found,
+.B patch
+selects the first named file
+with an \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master.
+.TP
+.B " \(bu"
+If no named files exist,
+no \s-1RCS\s0, ClearCase, Perforce, or \s-1SCCS\s0 master was found,
+some names are given,
+.B patch
+is not conforming to \s-1POSIX\s0,
+and the patch appears to create a file,
+.B patch
+selects the best name requiring the creation of the fewest directories.
+.TP
+.B " \(bu"
+If no file name results from the above heuristics, you are asked
+for the name of the file to patch, and
+.B patch
+selects that name.
+.LP
+To determine the
+.I best
+of a nonempty list of file names,
+.B patch
+first takes all the names with the fewest path name components;
+of those, it then takes all the names with the shortest basename;
+of those, it then takes all the shortest names;
+finally, it takes the first remaining name.
+.PP
+Additionally, if the leading garbage contains a
+.B Prereq:\&
+line,
+.B patch
+takes the first word from the prerequisites line (normally a version
+number) and checks the original file to see if that word can be found.
+If not,
+.B patch
+asks for confirmation before proceeding.
+.PP
+The upshot of all this is that you should be able to say, while in a news
+interface, something like the following:
+.Sp
+ \fB| patch \-d /usr/src/local/blurfl\fP
+.Sp
+and patch a file in the
+.B blurfl
+directory directly from the article containing
+the patch.
+.PP
+If the patch file contains more than one patch,
+.B patch
+tries to apply each of them as if they came from separate patch files.
+This means, among other things, that it is assumed that the name of the file
+to patch must be determined for each diff listing,
+and that the garbage before each diff listing
+contains interesting things such as file names and revision level, as
+mentioned previously.
+.SH OPTIONS
+.TP 3
+\fB\-b\fP or \fB\*=backup\fP
+Make backup files.
+That is, when patching a file,
+rename or copy the original instead of removing it.
+When backing up a file that does not exist,
+an empty, unreadable backup file is created
+as a placeholder to represent the nonexistent file.
+See the
+.B \-V
+or
+.B \*=version\-control
+option for details about how backup file names are determined.
+.TP
+.B \*=backup\-if\-mismatch
+Back up a file if the patch does not match the file exactly
+and if backups are not otherwise requested.
+This is the default unless
+.B patch
+is conforming to \s-1POSIX\s0.
+.TP
+.B \*=no\-backup\-if\-mismatch
+Do not back up a file if the patch does not match the file exactly
+and if backups are not otherwise requested.
+This is the default if
+.B patch
+is conforming to \s-1POSIX\s0.
+.TP
+\fB\-B\fP \fIpref\fP or \fB\*=prefix=\fP\fIpref\fP
+Use the
+.B simple
+method to determine backup file names (see the
+.BI "\-V " method
+or
+.BI "\*=version\-control " method
+option), and append
+.I pref
+to a file name when generating its backup file name.
+For example, with
+.B "\-B\ /junk/"
+the simple backup file name for
+.B src/patch/util.c
+is
+.BR /junk/src/patch/util.c .
+.TP
+\fB\*=binary\fP
+Write all files in binary mode, except for standard output and
+.BR /dev/tty .
+When reading, disable the heuristic for transforming CRLF line endings into LF
+line endings.
+(On \s-1POSIX\s0-conforming systems, reads and writes never transform line
+endings. On Windows, reads and writes do transform line endings by default,
+and patches should be generated by
+.B "diff\ \*=binary"
+when line endings are significant.)
+.TP
+\fB\-c\fP or \fB\*=context\fP
+Interpret the patch file as a ordinary context diff.
+.TP
+\fB\-d\fP \fIdir\fP or \fB\*=directory=\fP\fIdir\fP
+Change to the directory
+.I dir
+immediately, before doing
+anything else.
+.TP
+\fB\-D\fP \fIdefine\fP or \fB\*=ifdef=\fP\fIdefine\fP
+Use the
+.BR #ifdef " .\|.\|. " #endif
+construct to mark changes, with
+.I define
+as the differentiating symbol.
+.TP
+.B "\*=dry\-run"
+Print the results of applying the patches without actually changing any files.
+.TP
+\fB\-e\fP or \fB\*=ed\fP
+Interpret the patch file as an
+.B ed
+script.
+.TP
+\fB\-E\fP or \fB\*=remove\-empty\-files\fP
+Remove output files that are empty after the patches have been applied.
+Normally this option is unnecessary, since
+.B patch
+can examine the time stamps on the header to determine whether a file
+should exist after patching.
+However, if the input is not a context diff or if
+.B patch
+is conforming to \s-1POSIX\s0,
+.B patch
+does not remove empty patched files unless this option is given.
+When
+.B patch
+removes a file, it also attempts to remove any empty ancestor directories.
+.TP
+\fB\-f\fP or \fB\*=force\fP
+Assume that the user knows exactly what he or she is doing, and do not
+ask any questions. Skip patches whose headers
+do not say which file is to be patched; patch files even though they have the
+wrong version for the
+.B Prereq:\&
+line in the patch; and assume that
+patches are not reversed even if they look like they are.
+This option does not suppress commentary; use
+.B \-s
+for that.
+.TP
+\fB\-F\fP \fInum\fP or \fB\*=fuzz=\fP\fInum\fP
+Set the maximum fuzz factor.
+This option only applies to diffs that have context, and causes
+.B patch
+to ignore up to that many lines in looking for places to install a hunk.
+Note that a larger fuzz factor increases the odds of a faulty patch.
+The default fuzz factor is 2, and it may not be set to more than
+the number of lines of context in the context diff, ordinarily 3.
+.TP
+\fB\-g\fP \fInum\fP or \fB\*=get=\fP\fInum\fP
+This option controls
+.BR patch 's
+actions when a file is under \s-1RCS\s0 or \s-1SCCS\s0 control,
+and does not exist or is read-only and matches the default version,
+or when a file is under ClearCase or Perforce control and does not exist.
+If
+.I num
+is positive,
+.B patch
+gets (or checks out) the file from the revision control system; if zero,
+.B patch
+ignores \s-1RCS\s0, ClearCase, Perforce, and \s-1SCCS\s0
+and does not get the file; and if negative,
+.B patch
+asks the user whether to get the file.
+The default value of this option is given by the value of the
+.B PATCH_GET
+environment variable if it is set; if not, the default value is zero.
+.TP
+.B "\*=help"
+Print a summary of options and exit.
+.TP
+\fB\-i\fP \fIpatchfile\fP or \fB\*=input=\fP\fIpatchfile\fP
+Read the patch from
+.IR patchfile .
+If
+.I patchfile
+is
+.BR \- ,
+read from standard input, the default.
+.TP
+\fB\-l\fP or \fB\*=ignore\-whitespace\fP
+Match patterns loosely, in case tabs or spaces
+have been munged in your files.
+Any sequence of one or more blanks in the patch file matches any sequence
+in the original file, and sequences of blanks at the ends of lines are ignored.
+Normal characters must still match exactly.
+Each line of the context must still match a line in the original file.
+.TP
+\fB\*=merge\fP
+Merge a patch file into the original files similar to \fBmerge\fP(1). If a
+conflict is found, \fBpatch\fP outputs a warning and brackets the conflict
+with \fB<<<<<<<\fP and \fB>>>>>>>\fP lines. A typical conflict will look like
+this:
+.LP
+.RS
+.nf
+.B <<<<<<<
+.I lines from the original file
+.B =======
+.I lines from the patch
+.B >>>>>>>
+.RE
+.fi
+.IP "" 3
+If there are conflicts, the user should edit the result and delete one
+of the alternatives. This option implies \fB\*=forward\fP and does not
+take the \fB--fuzz\fR=\fInum\fP option into account.
+.TP
+\fB\-n\fP or \fB\*=normal\fP
+Interpret the patch file as a normal diff.
+.TP
+\fB\-N\fP or \fB\*=forward\fP
+Ignore patches that seem to be reversed or already applied.
+See also
+.BR \-R .
+.TP
+\fB\-o\fP \fIoutfile\fP or \fB\*=output=\fP\fIoutfile\fP
+Send output to
+.I outfile
+instead of patching files in place.
+Do not use this option if
+.I outfile
+is one of the files to be patched.
+When \fIoutfile\fP is \fB\-\fP, send output to standard output, and send any
+messages that would usually go to standard output to standard error.
+.TP
+\fB\-p\fP\fInum\fP or \fB\*=strip\fP\fB=\fP\fInum\fP
+Strip the smallest prefix containing
+.I num
+leading slashes from each file name found in the patch file.
+A sequence of one or more adjacent slashes is counted as a single slash.
+This controls how file names found in the patch file are treated, in case
+you keep your files in a different directory than the person who sent
+out the patch.
+For example, supposing the file name in the patch file was
+.Sp
+ \fB/u/howard/src/blurfl/blurfl.c\fP
+.Sp
+setting
+.B \-p0
+gives the entire file name unmodified,
+.B \-p1
+gives
+.Sp
+ \fBu/howard/src/blurfl/blurfl.c\fP
+.Sp
+without the leading slash,
+.B \-p4
+gives
+.Sp
+ \fBblurfl/blurfl.c\fP
+.Sp
+and not specifying
+.B \-p
+at all just gives you \fBblurfl.c\fP.
+Whatever you end up with is looked for either in the current directory,
+or the directory specified by the
+.B \-d
+option.
+.TP
+.B \*=posix
+Conform more strictly to the \s-1POSIX\s0 standard, as follows.
+.RS
+.TP 3
+.B " \(bu"
+Take the first existing file from the list (old, new, index)
+when intuiting file names from diff headers.
+.TP
+.B " \(bu"
+Do not remove files that are empty after patching.
+.TP
+.B " \(bu"
+Do not ask whether to get files from \s-1RCS\s0, ClearCase, Perforce,
+or \s-1SCCS\s0.
+.TP
+.B " \(bu"
+Require that all options precede the files in the command line.
+.TP
+.B " \(bu"
+Do not backup files when there is a mismatch.
+.RE
+.TP
+.BI \*=quoting\-style= word
+Use style
+.I word
+to quote output names.
+The
+.I word
+should be one of the following:
+.RS
+.TP
+.B literal
+Output names as-is.
+.TP
+.B shell
+Quote names for the shell if they contain shell metacharacters or would
+cause ambiguous output.
+.TP
+.B shell-always
+Quote names for the shell, even if they would normally not require quoting.
+.TP
+.B c
+Quote names as for a C language string.
+.TP
+.B escape
+Quote as with
+.B c
+except omit the surrounding double-quote characters.
+.LP
+You can specify the default value of the
+.B \*=quoting\-style
+option with the environment variable
+.BR QUOTING_STYLE .
+If that environment variable is not set, the default value is
+.BR shell .
+.RE
+.TP
+\fB\-r\fP \fIrejectfile\fP or \fB\*=reject\-file=\fP\fIrejectfile\fP
+Put rejects into
+.I rejectfile
+instead of the default
+.B \&.rej
+file. When \fIrejectfile\fP is \fB\-\fP, discard rejects.
+.TP
+\fB\-R\fP or \fB\*=reverse\fP
+Assume that this patch was created with the old and new files swapped.
+(Yes, I'm afraid that does happen occasionally, human nature being what it
+is.)
+.B patch
+attempts to swap each hunk around before applying it.
+Rejects come out in the swapped format.
+The
+.B \-R
+option does not work with
+.B ed
+diff scripts because there is too little
+information to reconstruct the reverse operation.
+.Sp
+If the first hunk of a patch fails,
+.B patch
+reverses the hunk to see if it can be applied that way.
+If it can, you are asked if you want to have the
+.B \-R
+option set.
+If it can't, the patch continues to be applied normally.
+(Note: this method cannot detect a reversed patch if it is a normal diff
+and if the first command is an append (i.e. it should have been a delete)
+since appends always succeed, due to the fact that a null context matches
+anywhere.
+Luckily, most patches add or change lines rather than delete them, so most
+reversed normal diffs begin with a delete, which fails, triggering
+the heuristic.)
+.TP
+\fB\*=reject\-format=\fP\fIformat\fP
+Produce reject files in the specified \fIformat\fP (either \fBcontext\fP or
+\fBunified\fP). Without this option, rejected hunks come out in unified diff
+format if the input patch was of that format, otherwise in ordinary context
+diff form.
+.TP
+\fB\-s\fP or \fB\*=silent\fP or \fB\*=quiet\fP
+Work silently, unless an error occurs.
+.TP
+\fB\-t\fP or \fB\*=batch\fP
+Suppress questions like
+.BR \-f ,
+but make some different assumptions:
+skip patches whose headers do not contain file names (the same as \fB\-f\fP);
+skip patches for which the file has the wrong version for the
+.B Prereq:\&
+line
+in the patch; and assume that patches are reversed if they look like
+they are.
+.TP
+\fB\-T\fP or \fB\*=set\-time\fP
+Set the modification and access times of patched files from time stamps
+given in context diff headers, assuming that the context diff headers
+use local time. This option is not recommended, because patches using
+local time cannot easily be used by people in other time zones, and
+because local time stamps are ambiguous when local clocks move backwards
+during daylight-saving time adjustments. Instead of using this option,
+generate patches with \s-1UTC\s0 and use the
+.B \-Z
+or
+.B \*=set\-utc
+option instead.
+.TP
+\fB\-u\fP or \fB\*=unified\fP
+Interpret the patch file as a unified context diff.
+.TP
+\fB\-v\fP or \fB\*=version\fP
+Print out
+.BR patch 's
+revision header and patch level, and exit.
+.TP
+\fB\-V\fP \fImethod\fP or \fB\*=version\-control=\fP\fImethod\fP
+Use
+.I method
+to determine
+backup file names. The method can also be given by the
+.B PATCH_VERSION_CONTROL
+(or, if that's not set, the
+.BR VERSION_CONTROL )
+environment variable, which is overridden by this option.
+The method does not affect whether backup files are made;
+it affects only the names of any backup files that are made.
+.Sp
+The value of
+.I method
+is like the \s-1GNU\s0
+Emacs `version-control' variable;
+.B patch
+also recognizes synonyms that
+are more descriptive. The valid values for
+.I method
+are (unique abbreviations are
+accepted):
+.RS
+.TP 3
+\fBexisting\fP or \fBnil\fP
+Make numbered backups of files that already have them,
+otherwise simple backups.
+This is the default.
+.TP
+\fBnumbered\fP or \fBt\fP
+Make numbered backups. The numbered backup file name for
+.I F
+is
+.IB F .~ N ~
+where
+.I N
+is the version number.
+.TP
+\fBsimple\fP or \fBnever\fP
+Make simple backups.
+The
+.B \-B
+or
+.BR \*=prefix ,
+.B \-Y
+or
+.BR \*=basename\-prefix ,
+and
+.B \-z
+or
+.BR \*=suffix
+options specify the simple backup file name.
+If none of these options are given, then a simple backup suffix is used;
+it is the value of the
+.B SIMPLE_BACKUP_SUFFIX
+environment variable if set, and is
+.B \&.orig
+otherwise.
+.PP
+With numbered or simple backups,
+if the backup file name is too long, the backup suffix
+.B ~
+is used instead; if even appending
+.B ~
+would make the name too long, then
+.B ~
+replaces the last character of the file name.
+.RE
+.TP
+\fB\*=verbose\fP
+Output extra information about the work being done.
+.TP
+\fB\-x\fP \fInum\fP or \fB\*=debug=\fP\fInum\fP
+Set internal debugging flags of interest only to
+.B patch
+patchers.
+.TP
+\fB\-Y\fP \fIpref\fP or \fB\*=basename\-prefix=\fP\fIpref\fP
+Use the
+.B simple
+method to determine backup file names (see the
+.BI "\-V " method
+or
+.BI "\*=version\-control " method
+option), and prefix
+.I pref
+to the basename of a file name when generating its backup file name.
+For example, with
+.B "\-Y\ .del/"
+the simple backup file name for
+.B src/patch/util.c
+is
+.BR src/patch/.del/util.c .
+.TP
+\fB\-z\fP \fIsuffix\fP or \fB\*=suffix=\fP\fIsuffix\fP
+Use the
+.B simple
+method to determine backup file names (see the
+.BI "\-V " method
+or
+.BI "\*=version\-control " method
+option), and use
+.I suffix
+as the suffix.
+For example, with
+.B "\-z\ -"
+the backup file name for
+.B src/patch/util.c
+is
+.BR src/patch/util.c- .
+.TP
+\fB\-Z\fP or \fB\*=set\-utc\fP
+Set the modification and access times of patched files from time stamps
+given in context diff headers, assuming that the context diff headers
+use Coordinated Universal Time (\s-1UTC\s0, often known as \s-1GMT\s0).
+Also see the
+.B \-T
+or
+.B \*=set\-time
+option.
+.Sp
+The
+.B \-Z
+or
+.B \*=set\-utc
+and
+.B \-T
+or
+.B \*=set\-time
+options normally refrain from setting a file's time if the file's original time
+does not match the time given in the patch header, or if its
+contents do not match the patch exactly. However, if the
+.B \-f
+or
+.B \*=force
+option is given, the file time is set regardless.
+.Sp
+Due to the limitations of
+.B diff
+output format, these options cannot update the times of files whose
+contents have not changed. Also, if you use these options, you should remove
+(e.g. with
+.BR "make\ clean" )
+all files that depend on the patched files, so that later invocations of
+.B make
+do not get confused by the patched files' times.
+.SH ENVIRONMENT
+.TP 3
+.B PATCH_GET
+This specifies whether
+.B patch
+gets missing or read-only files from \s-1RCS\s0, ClearCase, Perforce,
+or \s-1SCCS\s0
+by default; see the
+.B \-g
+or
+.B \*=get
+option.
+.TP
+.B POSIXLY_CORRECT
+If set,
+.B patch
+conforms more strictly to the \s-1POSIX\s0 standard by default:
+see the
+.B \*=posix
+option.
+.TP
+.B QUOTING_STYLE
+Default value of the
+.B \*=quoting\-style
+option.
+.TP
+.B SIMPLE_BACKUP_SUFFIX
+Extension to use for simple backup file names instead of
+.BR \&.orig .
+.TP
+\fBTMPDIR\fP, \fBTMP\fP, \fBTEMP\fP
+Directory to put temporary files in;
+.B patch
+uses the first environment variable in this list that is set.
+If none are set, the default is system-dependent;
+it is normally
+.B /tmp
+on Unix hosts.
+.TP
+\fBVERSION_CONTROL\fP or \fBPATCH_VERSION_CONTROL\fP
+Selects version control style; see the
+.B \-v
+or
+.B \*=version\-control
+option.
+.SH FILES
+.TP 3
+.IB $TMPDIR "/p*"
+temporary files
+.TP
+.B /dev/tty
+controlling terminal; used to get answers to questions asked of the user
+.SH "SEE ALSO"
+.BR diff (1),
+.BR ed (1),
+.BR merge (1).
+.Sp
+Marshall T. Rose and Einar A. Stefferud,
+Proposed Standard for Message Encapsulation,
+Internet RFC 934 <URL:ftp://ftp.isi.edu/in-notes/rfc934.txt> (1985-01).
+.SH "NOTES FOR PATCH SENDERS"
+There are several things you should bear in mind if you are going to
+be sending out patches.
+.PP
+Create your patch systematically.
+A good method is the command
+.BI "diff\ \-Naur\ " "old\ new"
+where
+.I old
+and
+.I new
+identify the old and new directories.
+The names
+.I old
+and
+.I new
+should not contain any slashes.
+The
+.B diff
+command's headers should have dates
+and times in Universal Time using traditional Unix format,
+so that patch recipients can use the
+.B \-Z
+or
+.B \*=set\-utc
+option.
+Here is an example command, using Bourne shell syntax:
+.Sp
+ \fBLC_ALL=C TZ=UTC0 diff \-Naur gcc\-2.7 gcc\-2.8\fP
+.PP
+Tell your recipients how to apply the patch
+by telling them which directory to
+.B cd
+to, and which
+.B patch
+options to use. The option string
+.B "\-Np1"
+is recommended.
+Test your procedure by pretending to be a recipient and applying
+your patch to a copy of the original files.
+.PP
+You can save people a lot of grief by keeping a
+.B patchlevel.h
+file which is patched to increment the patch level
+as the first diff in the patch file you send out.
+If you put a
+.B Prereq:\&
+line in with the patch, it won't let them apply
+patches out of order without some warning.
+.PP
+You can create a file by sending out a diff that compares
+.B /dev/null
+or an empty file dated the Epoch (1970-01-01 00:00:00 \s-1UTC\s0)
+to the file you want to create.
+This only works if the file you want to create doesn't exist already in
+the target directory.
+Conversely, you can remove a file by sending out a context diff that compares
+the file to be deleted with an empty file dated the Epoch.
+The file will be removed unless
+.B patch
+is conforming to \s-1POSIX\s0 and the
+.B \-E
+or
+.B \*=remove\-empty\-files
+option is not given.
+An easy way to generate patches that create and remove files
+is to use \s-1GNU\s0
+.BR diff 's
+.B \-N
+or
+.B \*=new\-file
+option.
+.PP
+If the recipient is supposed to use the
+.BI \-p N
+option, do not send output that looks like this:
+.Sp
+.ft B
+.ne 3
+ diff \-Naur v2.0.29/prog/README prog/README
+.br
+ \-\^\-\^\- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
+.br
+ +\^+\^+ prog/README Mon Mar 17 14:58:22 1997
+.ft
+.Sp
+because the two file names have different numbers of slashes,
+and different versions of
+.B patch
+interpret the file names differently.
+To avoid confusion, send output that looks like this instead:
+.Sp
+.ft B
+.ne 3
+ diff \-Naur v2.0.29/prog/README v2.0.30/prog/README
+.br
+ \-\^\-\^\- v2.0.29/prog/README Mon Mar 10 15:13:12 1997
+.br
+ +\^+\^+ v2.0.30/prog/README Mon Mar 17 14:58:22 1997
+.ft
+.Sp
+.PP
+Avoid sending patches that compare backup file names like
+.BR README.orig ,
+since this might confuse
+.B patch
+into patching a backup file instead of the real file.
+Instead, send patches that compare the same base file names
+in different directories, e.g.\&
+.B old/README
+and
+.BR new/README .
+.PP
+Take care not to send out reversed patches, since it makes people wonder
+whether they already applied the patch.
+.PP
+Try not to have your patch modify derived files
+(e.g. the file
+.B configure
+where there is a line
+.B "configure: configure.in"
+in your makefile), since the recipient should be
+able to regenerate the derived files anyway.
+If you must send diffs of derived files,
+generate the diffs using \s-1UTC\s0,
+have the recipients apply the patch with the
+.B \-Z
+or
+.B \*=set\-utc
+option, and have them remove any unpatched files that depend on patched files
+(e.g. with
+.BR "make\ clean" ).
+.PP
+While you may be able to get away with putting 582 diff listings into
+one file, it may be wiser to group related patches into separate files in
+case something goes haywire.
+.SH DIAGNOSTICS
+Diagnostics generally indicate that
+.B patch
+couldn't parse your patch file.
+.PP
+If the
+.B \*=verbose
+option is given, the message
+.B Hmm.\|.\|.\&
+indicates that there is unprocessed text in
+the patch file and that
+.B patch
+is attempting to intuit whether there is a patch in that text and, if so,
+what kind of patch it is.
+.PP
+.BR patch 's
+exit status is
+0 if all hunks are applied successfully,
+1 if some hunks cannot be applied or there were merge conflicts,
+and 2 if there is more serious trouble.
+When applying a set of patches in a loop it behooves you to check this
+exit status so you don't apply a later patch to a partially patched file.
+.SH CAVEATS
+Context diffs cannot reliably represent the creation or deletion of
+empty files, empty directories, or special files such as symbolic links.
+Nor can they represent changes to file metadata like ownership, permissions,
+or whether one file is a hard link to another.
+If changes like these are also required, separate instructions
+(e.g. a shell script) to accomplish them should accompany the patch.
+.PP
+.B patch
+cannot tell if the line numbers are off in an
+.B ed
+script, and can detect
+bad line numbers in a normal diff only when it finds a change or deletion.
+A context diff using fuzz factor 3 may have the same problem.
+You should probably do
+a context diff in these cases to see if the changes made sense.
+Of course, compiling without errors is a pretty good indication that the patch
+worked, but not always.
+.PP
+.B patch
+usually produces the correct results, even when it has to do a lot of
+guessing.
+However, the results are guaranteed to be correct only when the patch is
+applied to exactly the same version of the file that the patch was
+generated from.
+.SH "COMPATIBILITY ISSUES"
+The \s-1POSIX\s0 standard specifies behavior that differs from
+.BR patch 's
+traditional behavior.
+You should be aware of these differences if you must interoperate with
+.B patch
+versions 2.1 and earlier, which do not conform to \s-1POSIX\s0.
+.TP 3
+.B " \(bu"
+In traditional
+.BR patch ,
+the
+.B \-p
+option's operand was optional, and a bare
+.B \-p
+was equivalent to
+.BR \-p0.
+The
+.B \-p
+option now requires an operand, and
+.B "\-p\ 0"
+is now equivalent to
+.BR \-p0 .
+For maximum compatibility, use options like
+.B \-p0
+and
+.BR \-p1 .
+.Sp
+Also,
+traditional
+.B patch
+simply counted slashes when stripping path prefixes;
+.B patch
+now counts pathname components.
+That is, a sequence of one or more adjacent slashes
+now counts as a single slash.
+For maximum portability, avoid sending patches containing
+.B //
+in file names.
+.TP
+.B " \(bu"
+In traditional
+.BR patch ,
+backups were enabled by default.
+This behavior is now enabled with the
+.B \-b
+or
+.B \*=backup
+option.
+.Sp
+Conversely, in \s-1POSIX\s0
+.BR patch ,
+backups are never made, even when there is a mismatch.
+In \s-1GNU\s0
+.BR patch ,
+this behavior is enabled with the
+.B \*=no\-backup\-if\-mismatch
+option, or by conforming to \s-1POSIX\s0 with the
+.B \*=posix
+option or by setting the
+.B POSIXLY_CORRECT
+environment variable.
+.Sp
+The
+.BI \-b "\ suffix"
+option
+of traditional
+.B patch
+is equivalent to the
+.BI "\-b\ \-z" "\ suffix"
+options of \s-1GNU\s0
+.BR patch .
+.TP
+.B " \(bu"
+Traditional
+.B patch
+used a complicated (and incompletely documented) method
+to intuit the name of the file to be patched from the patch header.
+This method did not conform to \s-1POSIX\s0, and had a few gotchas.
+Now
+.B patch
+uses a different, equally complicated (but better documented) method
+that is optionally \s-1POSIX\s0-conforming; we hope it has
+fewer gotchas. The two methods are compatible if the
+file names in the context diff header and the
+.B Index:\&
+line are all identical after prefix-stripping.
+Your patch is normally compatible if each header's file names
+all contain the same number of slashes.
+.TP
+.B " \(bu"
+When traditional
+.B patch
+asked the user a question, it sent the question to standard error
+and looked for an answer from
+the first file in the following list that was a terminal:
+standard error, standard output,
+.BR /dev/tty ,
+and standard input.
+Now
+.B patch
+sends questions to standard output and gets answers from
+.BR /dev/tty .
+Defaults for some answers have been changed so that
+.B patch
+never goes into an infinite loop when using default answers.
+.TP
+.B " \(bu"
+Traditional
+.B patch
+exited with a status value that counted the number of bad hunks,
+or with status 1 if there was real trouble.
+Now
+.B patch
+exits with status 1 if some hunks failed,
+or with 2 if there was real trouble.
+.TP
+.B " \(bu"
+Limit yourself to the following options when sending instructions
+meant to be executed by anyone running \s-1GNU\s0
+.BR patch ,
+traditional
+.BR patch ,
+or a
+.B patch
+that conforms to \s-1POSIX\s0.
+Spaces are significant in the following list, and operands are required.
+.Sp
+.nf
+.in +3
+.ne 11
+.B \-c
+.BI \-d " dir"
+.BI \-D " define"
+.B \-e
+.B \-l
+.B \-n
+.B \-N
+.BI \-o " outfile"
+.BI \-p num
+.B \-R
+.BI \-r " rejectfile"
+.in
+.fi
+.SH BUGS
+Please report bugs via email to
+.BR <bug-patch@gnu.org> .
+.PP
+If code has been duplicated (for instance with
+\fB#ifdef OLDCODE\fP .\|.\|. \fB#else .\|.\|. #endif\fP),
+.B patch
+is incapable of patching both versions, and, if it works at all, will likely
+patch the wrong one, and tell you that it succeeded to boot.
+.PP
+If you apply a patch you've already applied,
+.B patch
+thinks it is a reversed patch, and offers to un-apply the patch.
+This could be construed as a feature.
+.PP
+Computing how to merge a hunk is significantly harder than using the standard
+fuzzy algorithm. Bigger hunks, more context, a bigger offset from the
+original location, and a worse match all slow the algorithm down.
+.SH COPYING
+Copyright
+.ie t \(co
+.el (C)
+1984, 1985, 1986, 1988 Larry Wall.
+.br
+Copyright
+.ie t \(co
+.el (C)
+1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+2000, 2001, 2002, 2009 Free Software Foundation, Inc.
+.PP
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+.PP
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+.PP
+Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for modified
+versions, except that this permission notice may be included in
+translations approved by the copyright holders instead of in
+the original English.
+.SH AUTHORS
+Larry Wall wrote the original version of
+.BR patch .
+Paul Eggert removed
+.BR patch 's
+arbitrary limits; added support for binary files,
+setting file times, and deleting files;
+and made it conform better to \s-1POSIX\s0.
+Other contributors include Wayne Davison, who added unidiff support,
+and David MacKenzie, who added configuration and backup support.
+Andreas Gr\[:u]nbacher added support for merging.
--- /dev/null
+/* A safer version of chdir, which returns back to the
+ initial working directory when the program exits. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static char *initial_wd;
+
+static void
+restore_wd (void)
+{
+ chdir (initial_wd);
+}
+
+int
+chdir_safer (char const *dir)
+{
+ if (! initial_wd)
+ {
+ size_t s;
+ for (s = 256; ! (initial_wd = getcwd (0, s)); s *= 2)
+ if (errno != ERANGE)
+ return -1;
+ if (atexit (restore_wd) != 0)
+ {
+ free (initial_wd);
+ initial_wd = 0;
+ return -1;
+ }
+ }
+
+ return chdir (dir);
+}
--- /dev/null
+To configure `patch' for DJGPP, issue these commands from the
+`patch' source directory:
+
+ pc\djgpp\configure
+ make
+
+To build `patch' in a directory other than where the sources are,
+add a parameter that specifies the source directory, e.g.:
+
+ e:\src\patch\pc\djgpp\configure e:/src/patch
+
+You MUST use forward slashes to specify the source directory.
+
+Running configure.bat requires a port of `sed'.
+You can find one on the usual DJGPP archive sites.
+
+
+Thanks to Eli Zaretskii <eliz@is.elta.co.il> for
+suggestions and ideas for this DJGPP port.
--- /dev/null
+1c\
+/* config.h for compiling `patch' with DJGPP for MS-DOS and MS-Windows.\
+ Please keep this file as similar as possible to ../../config.h\
+ to simplify maintenance later. */\
+\
+/* This does most of the work; the rest of this file defines only those\
+ symbols that <sys/config.h> doesn't define correctly. */\
+#include <sys/config.h>
+
+s/#undef HAVE_DONE_WORKING_MALLOC_CHECK/#define HAVE_DONE_WORKING_MALLOC_CHECK 1/
+s/#undef HAVE_DONE_WORKING_REALLOC_CHECK/#define HAVE_DONE_WORKING_REALLOC_CHECK 1/
+s/#undef HAVE_LONG_FILE_NAMES/#define HAVE_LONG_FILE_NAMES 1/
+s/#undef HAVE_MEMCMP/#define HAVE_MEMCMP 1/
+s/#undef HAVE_MKTEMP/#define HAVE_MKTEMP 1/
+s/#undef HAVE_PATHCONF/#define HAVE_PATHCONF 1/
+s/#undef HAVE_RAISE/#define HAVE_RAISE 1/
+s/#undef HAVE_SIGPROCMASK/#define HAVE_SIGPROCMASK 1/
+s/#undef HAVE_STRUCT_UTIMBUF/#define HAVE_STRUCT_UTIMBUF 1/
+s/#undef HAVE_UTIME_H/#define HAVE_UTIME_H 1/
+s/#undef HAVE_VPRINTF/#define HAVE_VPRINTF 1/
+s/#undef PROTOTYPES/#define PROTOTYPES 1/
+
+s,#undef.*,/* & */,
+
+$a\
+/* DGJPP-specific definitions */\
+\
+#define chdir chdir_safer\
+int chdir_safer (char const *);\
+\
+#define FILESYSTEM_PREFIX_LEN(f) ((f)[0] && (f)[1] == ':' ? 2 : 0)\
+#define ISSLASH(c) ((c) == '/' || (c) == '\\\\')\
+\
+#define HAVE_DOS_FILE_NAMES 1\
+\
+#define HAVE_SETMODE 1\
+#ifdef WIN32\
+# define setmode _setmode\
+#endif\
+\
+#define TMPDIR "c:"
--- /dev/null
+@echo off\r
+Rem Configure patch for DJGPP v2.\r
+Rem $Id: configure.bat,v 1.4 1997/06/17 06:52:12 eggert Exp $\r
+\r
+Rem The DOS shell has fixed-size environment storage.\r
+Rem When the environment is full, the shell prints\r
+Rem "Out of environment space" and truncates the string at will.\r
+Rem Since people often ignore these messages,\r
+Rem test whether the environment variable got the correct value.\r
+\r
+Rem Where is our source directory?\r
+set srcdir=.\r
+if not "%srcdir%" == "." goto SmallEnv\r
+if not "%1" == "" set srcdir=%1\r
+if not "%1" == "" if not "%srcdir%" == "%1" goto SmallEnv\r
+\r
+Rem Create Makefile\r
+sed -f %srcdir%/pc/djgpp/configure.sed -e "s,@srcdir@,%srcdir%,g" %srcdir%/Makefile.in >Makefile\r
+sed -n -e "/^VERSION/p" %srcdir%/configure.in >>Makefile\r
+\r
+goto Exit\r
+\r
+:SmallEnv\r
+echo Your environment size is too small. Please enlarge it and run me again.\r
+\r
+:Exit\r
+set srcdir=\r
--- /dev/null
+# Edit Makefile.in to produce Makefile for DJGPP v2
+# $Id: configure.sed,v 1.9 1998/03/22 20:16:29 eggert Exp $
+
+1i\
+# Makefile generated by "configure.bat" for DJGPP v2\
+
+/@SET_MAKE@/d
+
+s|@CC@|gcc|g
+s|@ed_PROGRAM@|ed|g
+s|@INSTALL@|${DJDIR}/bin/ginstall -c|g
+s|@INSTALL_PROGRAM@|${INSTALL}|g
+s|@INSTALL_DATA@|${INSTALL} -m 644|g
+s|@program_transform_name@||g
+
+s|@CFLAGS@|-g -O2|g
+s|@CPPFLAGS@|-I$(srcdir)/pc/djgpp|g
+s|@DEFS@|-DHAVE_CONFIG_H|g
+s|@LDFLAGS@||g
+s|@LIBOBJS@|getopt1.o getopt.o chdirsaf.o|g
+s|@LIBS@||g
+s|@PACKAGE@|patch|g
+s|@U@||g
+/@VERSION@/d
+
+s|@prefix@|${DJDIR}|g
+s|@exec_prefix@|${prefix}|g
+
+/^CONFIG_STATUS *=/s|=.*|= $(srcdir)/pc/djgpp/configure.bat|
+/^ \$(SHELL) \$(CONFIG_STATUS) *$/s// $(CONFIG_STATUS) $(srcdir)/
+
+$a\
+config.h: config.hin pc/djgpp/config.sed; sed -f $(srcdir)/pc/djgpp/config.sed $(srcdir)/config.hin >$@\
+chdirsaf.o: chdirsaf.c\
+# Use sed instead of cp, since cp might not be installed.\
+chdirsaf.c: pc/chdirsaf.c; sed -e '' $? > $@\
+distclean::; rm -f chdirsaf.c
--- /dev/null
+/* Find a best match between two vectors.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Written by Andreas Gruenbacher <agruen@gnu.org>, 2009.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
+
+
+/* Before including this file, you need to define:
+ EQUAL_IDX(x, y) A two-argument macro that tests elements
+ at index x and y for equality.
+ OFFSET A signed integer type sufficient to hold the
+ difference between two indices. Usually
+ something like ssize_t. */
+
+/*
+ * Shortest Edit Sequence
+ *
+ * Based on the Greedy LCS/SES Algorithm (Figure 2) in:
+ *
+ * Eugene W. Myers, "An O(ND) Difference Algorithm and Its Variations",
+ * Algorithmica, Vol. 1, No. 1, pp. 251-266, March 1986.
+ * Available: http://dx.doi.org/10.1007/BF01840446
+ * http://xmailserver.org/diff2.pdf
+ *
+ * Returns the number of changes (insertions and deletions) required to get
+ * from a[] to b[]. Returns MAX + 1 if a[] cannot be turned into b[] with
+ * MAX or fewer changes.
+ *
+ * MIN specifies the minimum number of elements in which a[] and b[] must
+ * match. This allows to prevent trivial matches in which a sequence is
+ * completely discarded, or completely made up.
+ *
+ * If PY is not NULL, matches a[] against a prefix of b[], and returns the
+ * number of elements in b[] that were matched in *PY. Otherwise, matches
+ * all elements of b[].
+ *
+ * Note that the divide-and-conquer strategy discussed in section 4b of the
+ * paper is more efficient, but does not allow an open-ended prefix string
+ * search.
+ */
+
+OFFSET
+bestmatch(OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim,
+ OFFSET min, OFFSET max, OFFSET *py)
+{
+ const OFFSET dmin = xoff - ylim; /* Minimum valid diagonal. */
+ const OFFSET dmax = xlim - yoff; /* Maximum valid diagonal. */
+ const OFFSET fmid = xoff - yoff; /* Center diagonal. */
+ OFFSET fmin = fmid;
+ OFFSET fmax = fmid;
+ OFFSET V[2 * max + 3], *fd = V + max + 2 - fmid;
+ OFFSET fmid_plus_2_min, ymax = -1;
+ OFFSET c;
+
+ /*
+ The number of elements that were matched in x and in y can be
+ computed as either (x - x_skipped) or (y - y_skipped), with:
+
+ delta = (x - xoff) - (y - yoff)
+ x_skipped = (c + delta) / 2
+ y_skipped = (c - delta) / 2
+
+ For searching for a minimum number of matching elements, we end up
+ with this check:
+
+ (x - x_skipped) >= min
+ ...
+ x + y - c >= (xoff - yoff) + 2 * min
+ x + y - c >= fmid + 2 * min
+ */
+
+ if (min)
+ {
+ fmid_plus_2_min = fmid + 2 * min;
+ min += yoff;
+ if (min > ylim)
+ return max + 1;
+ }
+ else
+ fmid_plus_2_min = 0; /* disable this check */
+ if (!py)
+ min = ylim;
+
+ /* Handle the exact-match case. */
+ while (xoff < xlim && yoff < ylim && EQUAL_IDX (xoff, yoff))
+ {
+ xoff++;
+ yoff++;
+ }
+ if (xoff == xlim && yoff >= min
+ && xoff + yoff >= fmid_plus_2_min)
+ {
+ ymax = yoff;
+ c = 0;
+ }
+ else
+ {
+ fd[fmid] = xoff;
+ for (c = 1; c <= max; c++)
+ {
+ OFFSET d;
+
+ if (fmin > dmin)
+ fd[--fmin - 1] = -1;
+ else
+ ++fmin;
+ if (fmax < dmax)
+ fd[++fmax + 1] = -1;
+ else
+ --fmax;
+ for (d = fmax; d >= fmin; d -= 2)
+ {
+ OFFSET x, y;
+
+ if (fd[d - 1] < fd[d + 1])
+ x = fd[d + 1];
+ else
+ x = fd[d - 1] + 1;
+ for (y = x - d;
+ x < xlim && y < ylim && EQUAL_IDX (x, y);
+ x++, y++)
+ continue;
+ fd[d] = x;
+ if (x == xlim && y >= min
+ && x + y - c >= fmid_plus_2_min)
+ {
+ if (ymax < y)
+ ymax = y;
+ if (y == ylim)
+ goto done;
+ }
+ }
+ if (ymax != -1)
+ goto done;
+ }
+ }
+
+ done:
+ if (py)
+ *py = ymax;
+ return c;
+}
+
+#undef OFFSET
+#undef EQUAL_IDX
--- /dev/null
+/* common definitions for `patch' */
+
+/* Copyright (C) 1986, 1988 Larry Wall
+
+ Copyright (C) 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2002, 2003,
+ 2006, 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef DEBUGGING
+#define DEBUGGING 1
+#endif
+
+#include <config.h>
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <time.h>
+
+#include <sys/stat.h>
+#if ! defined S_ISDIR && defined S_IFDIR
+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+#if ! defined S_ISREG && defined S_IFREG
+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH 1
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH 2
+#endif
+#ifndef S_IROTH
+#define S_IROTH 4
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP (S_IXOTH << 3)
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP (S_IWOTH << 3)
+#endif
+#ifndef S_IRGRP
+#define S_IRGRP (S_IROTH << 3)
+#endif
+#ifndef S_IXUSR
+#define S_IXUSR (S_IXOTH << 6)
+#endif
+#ifndef S_IWUSR
+#define S_IWUSR (S_IWOTH << 6)
+#endif
+#ifndef S_IRUSR
+#define S_IRUSR (S_IROTH << 6)
+#endif
+
+#include <limits.h>
+
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#elif HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t) -1)
+#endif
+
+#include <ctype.h>
+/* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
+ as an argument to <ctype.h> macros like `isspace'. */
+#if STDC_HEADERS
+#define CTYPE_DOMAIN(c) 1
+#else
+#define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
+#endif
+#ifndef ISSPACE
+#define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
+#endif
+
+#ifndef ISDIGIT
+#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
+#endif
+
+
+/* handy definitions */
+
+#define strEQ(s1,s2) (!strcmp(s1, s2))
+#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
+
+/* typedefs */
+
+typedef off_t LINENUM; /* must be signed */
+
+/* globals */
+
+XTERN char *program_name; /* The name this program was run with. */
+
+XTERN char *buf; /* general purpose buffer */
+XTERN size_t bufsize; /* allocated size of buf */
+
+XTERN bool using_plan_a; /* try to keep everything in memory */
+
+XTERN char *inname;
+XTERN char *outfile;
+XTERN int inerrno;
+XTERN int invc;
+XTERN struct stat instat;
+XTERN bool dry_run;
+XTERN bool posixly_correct;
+
+XTERN char const *origprae;
+XTERN char const *origbase;
+XTERN char const *origsuff;
+
+XTERN char const * volatile TMPINNAME;
+XTERN char const * volatile TMPOUTNAME;
+XTERN char const * volatile TMPPATNAME;
+
+XTERN int volatile TMPINNAME_needs_removal;
+XTERN int volatile TMPOUTNAME_needs_removal;
+XTERN int volatile TMPPATNAME_needs_removal;
+
+#ifdef DEBUGGING
+XTERN int debug;
+#else
+# define debug 0
+#endif
+XTERN bool force;
+XTERN bool batch;
+XTERN bool noreverse;
+XTERN bool reverse;
+XTERN enum { DEFAULT_VERBOSITY, SILENT, VERBOSE } verbosity;
+XTERN bool skip_rest_of_patch;
+XTERN int strippath;
+XTERN bool canonicalize;
+XTERN int patch_get;
+XTERN bool set_time;
+XTERN bool set_utc;
+
+enum diff
+ {
+ NO_DIFF,
+ CONTEXT_DIFF,
+ NORMAL_DIFF,
+ ED_DIFF,
+ NEW_CONTEXT_DIFF,
+ UNI_DIFF
+ };
+
+XTERN enum diff diff_type;
+
+XTERN char *revision; /* prerequisite revision, if any */
+
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__
+# define __attribute__(x)
+#endif
+
+void fatal_exit (int) __attribute__ ((noreturn));
+
+#include <errno.h>
+#if !STDC_HEADERS && !defined errno
+extern int errno;
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#else
+# ifndef lseek
+ off_t lseek ();
+# endif
+#endif
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+#if HAVE_FSEEKO
+ typedef off_t file_offset;
+# define file_seek fseeko
+# define file_tell ftello
+#else
+ typedef long file_offset;
+# define file_seek fseek
+# define file_tell ftell
+#endif
+#if ! (HAVE_GETEUID || defined geteuid)
+# if ! (HAVE_GETUID || defined getuid)
+# define geteuid() (-1)
+# else
+# define geteuid() getuid ()
+# endif
+#endif
+
+#if HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#endif
+#ifndef O_WRONLY
+#define O_WRONLY 1
+#endif
+#ifndef O_RDWR
+#define O_RDWR 2
+#endif
+#ifndef _O_BINARY
+#define _O_BINARY 0
+#endif
+#ifndef O_BINARY
+#define O_BINARY _O_BINARY
+#endif
+#ifndef O_CREAT
+#define O_CREAT 0
+#endif
+#ifndef O_EXCL
+#define O_EXCL 0
+#endif
+#ifndef O_TRUNC
+#define O_TRUNC 0
+#endif
+
+#ifdef MKDIR_TAKES_ONE_ARG
+# undef mkdir
+# define mkdir(name, mode) ((mkdir) (name))
+#endif
+
+#ifdef HAVE_SETMODE_DOS
+ XTERN int binary_transput; /* O_BINARY if binary i/o is desired */
+#else
+# define binary_transput 0
+#endif
+
+/* Disable the CR stripping heuristic? */
+XTERN bool no_strip_trailing_cr;
+
+#ifndef NULL_DEVICE
+#define NULL_DEVICE "/dev/null"
+#endif
+
+#ifndef TTY_DEVICE
+#define TTY_DEVICE "/dev/tty"
+#endif
+
+/* Output stream state. */
+struct outstate
+{
+ FILE *ofp;
+ bool after_newline;
+ bool zero_output;
+};
+
+/* offset in the input and output at which the previous hunk matched */
+XTERN LINENUM in_offset;
+XTERN LINENUM out_offset;
+
+/* how many input lines have been irretractably output */
+XTERN LINENUM last_frozen_line;
+
+bool copy_till (struct outstate *, LINENUM);
+bool similar (char const *, size_t, char const *, size_t);
+
+#ifdef ENABLE_MERGE
+bool merge_hunk (int hunk, struct outstate *, LINENUM where, bool *);
+#else
+# define merge_hunk(hunk, outstate, where, somefailed) false
+#endif
--- /dev/null
+/* Analyze differences between two vectors.
+
+ Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2008, 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 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/>. */
+
+
+/* The basic idea is to consider two vectors as similar if, when
+ transforming the first vector into the second vector through a
+ sequence of edits (inserts and deletes of one element each),
+ this sequence is short - or equivalently, if the ordered list
+ of elements that are untouched by these edits is long. For a
+ good introduction to the subject, read about the "Levenshtein
+ distance" in Wikipedia.
+
+ The basic algorithm is described in:
+ "An O(ND) Difference Algorithm and its Variations", Eugene Myers,
+ Algorithmica Vol. 1 No. 2, 1986, pp. 251-266;
+ see especially section 4.2, which describes the variation used below.
+
+ The basic algorithm was independently discovered as described in:
+ "Algorithms for Approximate String Matching", E. Ukkonen,
+ Information and Control Vol. 64, 1985, pp. 100-118.
+
+ Unless the 'find_minimal' flag is set, this code uses the TOO_EXPENSIVE
+ heuristic, by Paul Eggert, to limit the cost to O(N**1.5 log N)
+ at the price of producing suboptimal output for large inputs with
+ many differences. */
+
+/* Before including this file, you need to define:
+ ELEMENT The element type of the vectors being compared.
+ EQUAL(elex, eley) A two-argument macro that tests two elements for
+ equality, or
+ EQUAL_IDX(ctxt, x, y) A three-argument macro that tests the elements at
+ offset x and y for equality.
+ OFFSET A signed integer type sufficient to hold the
+ difference between two indices. Usually
+ something like ssize_t.
+ EXTRA_CONTEXT_FIELDS Declarations of fields for 'struct context'.
+ NOTE_DELETE(ctxt, xoff) Record the removal of the object xvec[xoff].
+ NOTE_INSERT(ctxt, yoff) Record the insertion of the object yvec[yoff].
+ EARLY_ABORT(ctxt) (Optional) A boolean expression that triggers an
+ early abort of the computation.
+ USE_HEURISTIC (Optional) Define if you want to support the
+ heuristic for large vectors.
+ Before including this file, you also need to include:
+ #include <limits.h>
+ #include <stdbool.h>
+ #include "minmax.h"
+ */
+
+/* Maximum value of type OFFSET. */
+#define OFFSET_MAX \
+ ((((OFFSET)1 << (sizeof (OFFSET) * CHAR_BIT - 2)) - 1) * 2 + 1)
+
+/* Default to no early abort. */
+#ifndef EARLY_ABORT
+# define EARLY_ABORT(ctxt) false
+#endif
+
+/* Use this to suppress gcc's `...may be used before initialized' warnings. */
+#ifndef IF_LINT
+# ifdef lint
+# define IF_LINT(Code) Code
+# else
+# define IF_LINT(Code) /* empty */
+# endif
+#endif
+
+#ifdef EQUAL
+# define EQUAL_IDX(ctxt, x, y) EQUAL(xv[x], yv[y])
+#endif
+
+/*
+ * Context of comparison operation.
+ */
+struct context
+{
+#ifdef EQUAL
+ /* Vectors being compared. */
+ ELEMENT const *xvec;
+ ELEMENT const *yvec;
+#endif
+
+ /* Extra fields. */
+ EXTRA_CONTEXT_FIELDS
+
+ /* Vector, indexed by diagonal, containing 1 + the X coordinate of the point
+ furthest along the given diagonal in the forward search of the edit
+ matrix. */
+ OFFSET *fdiag;
+
+ /* Vector, indexed by diagonal, containing the X coordinate of the point
+ furthest along the given diagonal in the backward search of the edit
+ matrix. */
+ OFFSET *bdiag;
+
+ #ifdef USE_HEURISTIC
+ /* This corresponds to the diff -H flag. With this heuristic, for
+ vectors with a constant small density of changes, the algorithm is
+ linear in the vectors size. */
+ bool heuristic;
+ #endif
+
+ /* Edit scripts longer than this are too expensive to compute. */
+ OFFSET too_expensive;
+
+ /* Snakes bigger than this are considered `big'. */
+ #define SNAKE_LIMIT 20
+};
+
+struct partition
+{
+ /* Midpoints of this partition. */
+ OFFSET xmid;
+ OFFSET ymid;
+
+ /* True if low half will be analyzed minimally. */
+ bool lo_minimal;
+
+ /* Likewise for high half. */
+ bool hi_minimal;
+};
+
+
+/* Find the midpoint of the shortest edit script for a specified portion
+ of the two vectors.
+
+ Scan from the beginnings of the vectors, and simultaneously from the ends,
+ doing a breadth-first search through the space of edit-sequence.
+ When the two searches meet, we have found the midpoint of the shortest
+ edit sequence.
+
+ If FIND_MINIMAL is true, find the minimal edit script regardless of
+ expense. Otherwise, if the search is too expensive, use heuristics to
+ stop the search and report a suboptimal answer.
+
+ Set PART->(xmid,ymid) to the midpoint (XMID,YMID). The diagonal number
+ XMID - YMID equals the number of inserted elements minus the number
+ of deleted elements (counting only elements before the midpoint).
+
+ Set PART->lo_minimal to true iff the minimal edit script for the
+ left half of the partition is known; similarly for PART->hi_minimal.
+
+ This function assumes that the first elements of the specified portions
+ of the two vectors do not match, and likewise that the last elements do not
+ match. The caller must trim matching elements from the beginning and end
+ of the portions it is going to specify.
+
+ If we return the "wrong" partitions, the worst this can do is cause
+ suboptimal diff output. It cannot cause incorrect diff output. */
+
+static void
+diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, bool find_minimal,
+ struct partition *part, struct context *ctxt)
+{
+ OFFSET *const fd = ctxt->fdiag; /* Give the compiler a chance. */
+ OFFSET *const bd = ctxt->bdiag; /* Additional help for the compiler. */
+#ifdef EQUAL
+ ELEMENT const *const xv = ctxt->xvec; /* Still more help for the compiler. */
+ ELEMENT const *const yv = ctxt->yvec; /* And more and more . . . */
+#endif
+ const OFFSET dmin = xoff - ylim; /* Minimum valid diagonal. */
+ const OFFSET dmax = xlim - yoff; /* Maximum valid diagonal. */
+ const OFFSET fmid = xoff - yoff; /* Center diagonal of top-down search. */
+ const OFFSET bmid = xlim - ylim; /* Center diagonal of bottom-up search. */
+ OFFSET fmin = fmid;
+ OFFSET fmax = fmid; /* Limits of top-down search. */
+ OFFSET bmin = bmid;
+ OFFSET bmax = bmid; /* Limits of bottom-up search. */
+ OFFSET c; /* Cost. */
+ bool odd = (fmid - bmid) & 1; /* True if southeast corner is on an odd
+ diagonal with respect to the northwest. */
+
+ fd[fmid] = xoff;
+ bd[bmid] = xlim;
+
+ for (c = 1;; ++c)
+ {
+ OFFSET d; /* Active diagonal. */
+ bool big_snake = false;
+
+ /* Extend the top-down search by an edit step in each diagonal. */
+ if (fmin > dmin)
+ fd[--fmin - 1] = -1;
+ else
+ ++fmin;
+ if (fmax < dmax)
+ fd[++fmax + 1] = -1;
+ else
+ --fmax;
+ for (d = fmax; d >= fmin; d -= 2)
+ {
+ OFFSET x;
+ OFFSET y;
+ OFFSET tlo = fd[d - 1];
+ OFFSET thi = fd[d + 1];
+ OFFSET x0 = tlo < thi ? thi : tlo + 1;
+
+ for (x = x0, y = x0 - d;
+ x < xlim && y < ylim && EQUAL_IDX (ctxt, x, y);
+ x++, y++)
+ continue;
+ if (x - x0 > SNAKE_LIMIT)
+ big_snake = true;
+ fd[d] = x;
+ if (odd && bmin <= d && d <= bmax && bd[d] <= x)
+ {
+ part->xmid = x;
+ part->ymid = y;
+ part->lo_minimal = part->hi_minimal = true;
+ return;
+ }
+ }
+
+ /* Similarly extend the bottom-up search. */
+ if (bmin > dmin)
+ bd[--bmin - 1] = OFFSET_MAX;
+ else
+ ++bmin;
+ if (bmax < dmax)
+ bd[++bmax + 1] = OFFSET_MAX;
+ else
+ --bmax;
+ for (d = bmax; d >= bmin; d -= 2)
+ {
+ OFFSET x;
+ OFFSET y;
+ OFFSET tlo = bd[d - 1];
+ OFFSET thi = bd[d + 1];
+ OFFSET x0 = tlo < thi ? tlo : thi - 1;
+
+ for (x = x0, y = x0 - d;
+ xoff < x && yoff < y && EQUAL_IDX (ctxt, x - 1, y - 1);
+ x--, y--)
+ continue;
+ if (x0 - x > SNAKE_LIMIT)
+ big_snake = true;
+ bd[d] = x;
+ if (!odd && fmin <= d && d <= fmax && x <= fd[d])
+ {
+ part->xmid = x;
+ part->ymid = y;
+ part->lo_minimal = part->hi_minimal = true;
+ return;
+ }
+ }
+
+ if (find_minimal)
+ continue;
+
+#ifdef USE_HEURISTIC
+ /* Heuristic: check occasionally for a diagonal that has made lots
+ of progress compared with the edit distance. If we have any
+ such, find the one that has made the most progress and return it
+ as if it had succeeded.
+
+ With this heuristic, for vectors with a constant small density
+ of changes, the algorithm is linear in the vector size. */
+
+ if (200 < c && big_snake && ctxt->heuristic)
+ {
+ OFFSET best = 0;
+
+ for (d = fmax; d >= fmin; d -= 2)
+ {
+ OFFSET dd = d - fmid;
+ OFFSET x = fd[d];
+ OFFSET y = x - d;
+ OFFSET v = (x - xoff) * 2 - dd;
+
+ if (v > 12 * (c + (dd < 0 ? -dd : dd)))
+ {
+ if (v > best
+ && xoff + SNAKE_LIMIT <= x && x < xlim
+ && yoff + SNAKE_LIMIT <= y && y < ylim)
+ {
+ /* We have a good enough best diagonal; now insist
+ that it end with a significant snake. */
+ int k;
+
+ for (k = 1; EQUAL_IDX (ctxt, x - k, y - k); k++)
+ if (k == SNAKE_LIMIT)
+ {
+ best = v;
+ part->xmid = x;
+ part->ymid = y;
+ break;
+ }
+ }
+ }
+ }
+ if (best > 0)
+ {
+ part->lo_minimal = true;
+ part->hi_minimal = false;
+ return;
+ }
+
+ best = 0;
+ for (d = bmax; d >= bmin; d -= 2)
+ {
+ OFFSET dd = d - bmid;
+ OFFSET x = bd[d];
+ OFFSET y = x - d;
+ OFFSET v = (xlim - x) * 2 + dd;
+
+ if (v > 12 * (c + (dd < 0 ? -dd : dd)))
+ {
+ if (v > best
+ && xoff < x && x <= xlim - SNAKE_LIMIT
+ && yoff < y && y <= ylim - SNAKE_LIMIT)
+ {
+ /* We have a good enough best diagonal; now insist
+ that it end with a significant snake. */
+ int k;
+
+ for (k = 0; EQUAL_IDX (ctxt, x + k, y + k); k++)
+ if (k == SNAKE_LIMIT - 1)
+ {
+ best = v;
+ part->xmid = x;
+ part->ymid = y;
+ break;
+ }
+ }
+ }
+ }
+ if (best > 0)
+ {
+ part->lo_minimal = false;
+ part->hi_minimal = true;
+ return;
+ }
+ }
+#endif /* USE_HEURISTIC */
+
+ /* Heuristic: if we've gone well beyond the call of duty, give up
+ and report halfway between our best results so far. */
+ if (c >= ctxt->too_expensive)
+ {
+ OFFSET fxybest;
+ OFFSET fxbest IF_LINT (= 0);
+ OFFSET bxybest;
+ OFFSET bxbest IF_LINT (= 0);
+
+ /* Find forward diagonal that maximizes X + Y. */
+ fxybest = -1;
+ for (d = fmax; d >= fmin; d -= 2)
+ {
+ OFFSET x = MIN (fd[d], xlim);
+ OFFSET y = x - d;
+ if (ylim < y)
+ {
+ x = ylim + d;
+ y = ylim;
+ }
+ if (fxybest < x + y)
+ {
+ fxybest = x + y;
+ fxbest = x;
+ }
+ }
+
+ /* Find backward diagonal that minimizes X + Y. */
+ bxybest = OFFSET_MAX;
+ for (d = bmax; d >= bmin; d -= 2)
+ {
+ OFFSET x = MAX (xoff, bd[d]);
+ OFFSET y = x - d;
+ if (y < yoff)
+ {
+ x = yoff + d;
+ y = yoff;
+ }
+ if (x + y < bxybest)
+ {
+ bxybest = x + y;
+ bxbest = x;
+ }
+ }
+
+ /* Use the better of the two diagonals. */
+ if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff))
+ {
+ part->xmid = fxbest;
+ part->ymid = fxybest - fxbest;
+ part->lo_minimal = true;
+ part->hi_minimal = false;
+ }
+ else
+ {
+ part->xmid = bxbest;
+ part->ymid = bxybest - bxbest;
+ part->lo_minimal = false;
+ part->hi_minimal = true;
+ }
+ return;
+ }
+ }
+}
+
+
+/* Compare in detail contiguous subsequences of the two vectors
+ which are known, as a whole, to match each other.
+
+ The subsequence of vector 0 is [XOFF, XLIM) and likewise for vector 1.
+
+ Note that XLIM, YLIM are exclusive bounds. All indices into the vectors
+ are origin-0.
+
+ If FIND_MINIMAL, find a minimal difference no matter how
+ expensive it is.
+
+ The results are recorded by invoking NOTE_DELETE and NOTE_INSERT.
+
+ Return false if terminated normally, or true if terminated through early
+ abort. */
+
+static bool
+compareseq (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim,
+ bool find_minimal, struct context *ctxt)
+{
+#ifdef EQUAL
+ ELEMENT const *xv = ctxt->xvec; /* Help the compiler. */
+ ELEMENT const *yv = ctxt->yvec;
+#endif
+
+ /* Slide down the bottom initial diagonal. */
+ while (xoff < xlim && yoff < ylim && EQUAL_IDX (ctxt, xoff, yoff))
+ {
+ xoff++;
+ yoff++;
+ }
+
+ /* Slide up the top initial diagonal. */
+ while (xoff < xlim && yoff < ylim && EQUAL_IDX (ctxt, xlim - 1, ylim - 1))
+ {
+ xlim--;
+ ylim--;
+ }
+
+ /* Handle simple cases. */
+ if (xoff == xlim)
+ while (yoff < ylim)
+ {
+ NOTE_INSERT (ctxt, yoff);
+ if (EARLY_ABORT (ctxt))
+ return true;
+ yoff++;
+ }
+ else if (yoff == ylim)
+ while (xoff < xlim)
+ {
+ NOTE_DELETE (ctxt, xoff);
+ if (EARLY_ABORT (ctxt))
+ return true;
+ xoff++;
+ }
+ else
+ {
+ struct partition part;
+
+ /* Find a point of correspondence in the middle of the vectors. */
+ diag (xoff, xlim, yoff, ylim, find_minimal, &part, ctxt);
+
+ /* Use the partitions to split this problem into subproblems. */
+ if (compareseq (xoff, part.xmid, yoff, part.ymid, part.lo_minimal, ctxt))
+ return true;
+ if (compareseq (part.xmid, xlim, part.ymid, ylim, part.hi_minimal, ctxt))
+ return true;
+ }
+
+ return false;
+}
+
+#undef ELEMENT
+#undef EQUAL
+#undef EQUAL_IDX
+#undef OFFSET
+#undef EXTRA_CONTEXT_FIELDS
+#undef NOTE_DELETE
+#undef NOTE_INSERT
+#undef EARLY_ABORT
+#undef USE_HEURISTIC
+#undef OFFSET_MAX
--- /dev/null
+/* inputting files to be patched */
+
+/* Copyright (C) 1986, 1988 Larry Wall
+ Copyright (C) 1991, 1992, 1993, 1997, 1998, 1999, 2002, 2003, 2006,
+ 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#define XTERN extern
+#include <common.h>
+#include <backupfile.h>
+#include <pch.h>
+#include <quotearg.h>
+#include <util.h>
+#include <xalloc.h>
+#undef XTERN
+#define XTERN
+#include <inp.h>
+
+/* Input-file-with-indexable-lines abstract type */
+
+static char *i_buffer; /* plan A buffer */
+static char const **i_ptr; /* pointers to lines in plan A buffer */
+
+static size_t tibufsize; /* size of plan b buffers */
+#ifndef TIBUFSIZE_MINIMUM
+#define TIBUFSIZE_MINIMUM (8 * 1024) /* minimum value for tibufsize */
+#endif
+static int tifd = -1; /* plan b virtual string array */
+static char *tibuf[2]; /* plan b buffers */
+static LINENUM tiline[2] = {-1, -1}; /* 1st line in each buffer */
+static LINENUM lines_per_buf; /* how many lines per buffer */
+static size_t tireclen; /* length of records in tmp file */
+static size_t last_line_size; /* size of last input line */
+
+static bool plan_a (char const *); /* yield false if memory runs out */
+static void plan_b (char const *);
+static void report_revision (bool);
+static void too_many_lines (char const *) __attribute__((noreturn));
+
+/* New patch--prepare to edit another file. */
+
+void
+re_input (void)
+{
+ if (using_plan_a) {
+ if (i_buffer)
+ {
+ free (i_buffer);
+ i_buffer = 0;
+ free (i_ptr);
+ }
+ }
+ else {
+ close (tifd);
+ tifd = -1;
+ if (tibuf[0])
+ {
+ free (tibuf[0]);
+ tibuf[0] = 0;
+ }
+ tiline[0] = tiline[1] = -1;
+ tireclen = 0;
+ }
+}
+
+/* Construct the line index, somehow or other. */
+
+void
+scan_input (char *filename)
+{
+ using_plan_a = ! (debug & 16) && plan_a (filename);
+ if (!using_plan_a)
+ plan_b(filename);
+
+ if (verbosity != SILENT)
+ {
+ filename = quotearg (filename);
+
+ if (verbosity == VERBOSE)
+ say ("Patching file %s using Plan %s...\n",
+ filename, using_plan_a ? "A" : "B");
+ else
+ say ("patching file %s\n", filename);
+ }
+}
+
+/* Report whether a desired revision was found. */
+
+static void
+report_revision (bool found_revision)
+{
+ char const *rev = quotearg (revision);
+
+ if (found_revision)
+ {
+ if (verbosity == VERBOSE)
+ say ("Good. This file appears to be the %s version.\n", rev);
+ }
+ else if (force)
+ {
+ if (verbosity != SILENT)
+ say ("Warning: this file doesn't appear to be the %s version -- patching anyway.\n",
+ rev);
+ }
+ else if (batch)
+ fatal ("This file doesn't appear to be the %s version -- aborting.",
+ rev);
+ else
+ {
+ ask ("This file doesn't appear to be the %s version -- patch anyway? [n] ",
+ rev);
+ if (*buf != 'y')
+ fatal ("aborted");
+ }
+}
+
+
+static void
+too_many_lines (char const *filename)
+{
+ fatal ("File %s has too many lines", quotearg (filename));
+}
+
+
+void
+get_input_file (char const *filename, char const *outname)
+{
+ bool elsewhere = strcmp (filename, outname) != 0;
+ char const *cs;
+ char *diffbuf;
+ char *getbuf;
+
+ if (inerrno == -1)
+ inerrno = stat (filename, &instat) == 0 ? 0 : errno;
+
+ /* Perhaps look for RCS or SCCS versions. */
+ if (patch_get
+ && invc != 0
+ && (inerrno
+ || (! elsewhere
+ && (/* No one can write to it. */
+ (instat.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) == 0
+ /* Only the owner (who's not me) can write to it. */
+ || ((instat.st_mode & (S_IWGRP|S_IWOTH)) == 0
+ && instat.st_uid != geteuid ()))))
+ && (invc = !! (cs = (version_controller
+ (filename, elsewhere,
+ inerrno ? (struct stat *) 0 : &instat,
+ &getbuf, &diffbuf))))) {
+
+ if (!inerrno) {
+ if (!elsewhere
+ && (instat.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) != 0)
+ /* Somebody can write to it. */
+ fatal ("File %s seems to be locked by somebody else under %s",
+ quotearg (filename), cs);
+ if (diffbuf)
+ {
+ /* It might be checked out unlocked. See if it's safe to
+ check out the default version locked. */
+
+ if (verbosity == VERBOSE)
+ say ("Comparing file %s to default %s version...\n",
+ quotearg (filename), cs);
+
+ if (systemic (diffbuf) != 0)
+ {
+ say ("warning: Patching file %s, which does not match default %s version\n",
+ quotearg (filename), cs);
+ cs = 0;
+ }
+ }
+ if (dry_run)
+ cs = 0;
+ }
+
+ if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf,
+ &instat))
+ inerrno = 0;
+
+ free (getbuf);
+ if (diffbuf)
+ free (diffbuf);
+ }
+
+ if (inerrno)
+ {
+ instat.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
+ instat.st_size = 0;
+ }
+ else if (! S_ISREG (instat.st_mode))
+ fatal ("File %s is not a regular file -- can't patch",
+ quotearg (filename));
+}
+
+
+/* Try keeping everything in memory. */
+
+static bool
+plan_a (char const *filename)
+{
+ register char const *s;
+ register char const *lim;
+ register char const **ptr;
+ register char *buffer;
+ register LINENUM iline;
+ size_t size = instat.st_size;
+
+ /* Fail if the file size doesn't fit in a size_t,
+ or if storage isn't available. */
+ if (! (size == instat.st_size
+ && (buffer = malloc (size ? size : (size_t) 1))))
+ return false;
+
+ /* Read the input file, but don't bother reading it if it's empty.
+ When creating files, the files do not actually exist. */
+ if (size)
+ {
+ int ifd = open (filename, O_RDONLY|binary_transput);
+ size_t buffered = 0, n;
+ if (ifd < 0)
+ pfatal ("can't open file %s", quotearg (filename));
+
+ while (size - buffered != 0)
+ {
+ n = read (ifd, buffer + buffered, size - buffered);
+ if (n == 0)
+ {
+ /* Some non-POSIX hosts exaggerate st_size in text mode;
+ or the file may have shrunk! */
+ size = buffered;
+ break;
+ }
+ if (n == (size_t) -1)
+ {
+ /* Perhaps size is too large for this host. */
+ close (ifd);
+ free (buffer);
+ return false;
+ }
+ buffered += n;
+ }
+
+ if (close (ifd) != 0)
+ read_fatal ();
+ }
+
+ /* Scan the buffer and build array of pointers to lines. */
+ lim = buffer + size;
+ iline = 3; /* 1 unused, 1 for SOF, 1 for EOF if last line is incomplete */
+ for (s = buffer; (s = (char *) memchr (s, '\n', lim - s)); s++)
+ if (++iline < 0)
+ too_many_lines (filename);
+ if (! (iline == (size_t) iline
+ && (size_t) iline * sizeof *ptr / sizeof *ptr == (size_t) iline
+ && (ptr = (char const **) malloc ((size_t) iline * sizeof *ptr))))
+ {
+ free (buffer);
+ return false;
+ }
+ iline = 0;
+ for (s = buffer; ; s++)
+ {
+ ptr[++iline] = s;
+ if (! (s = (char *) memchr (s, '\n', lim - s)))
+ break;
+ }
+ if (size && lim[-1] != '\n')
+ ptr[++iline] = lim;
+ input_lines = iline - 1;
+
+ if (revision)
+ {
+ char const *rev = revision;
+ int rev0 = rev[0];
+ bool found_revision = false;
+ size_t revlen = strlen (rev);
+
+ if (revlen <= size)
+ {
+ char const *limrev = lim - revlen;
+
+ for (s = buffer; (s = (char *) memchr (s, rev0, limrev - s)); s++)
+ if (memcmp (s, rev, revlen) == 0
+ && (s == buffer || ISSPACE ((unsigned char) s[-1]))
+ && (s + 1 == limrev || ISSPACE ((unsigned char) s[revlen])))
+ {
+ found_revision = true;
+ break;
+ }
+ }
+
+ report_revision (found_revision);
+ }
+
+ /* Plan A will work. */
+ i_buffer = buffer;
+ i_ptr = ptr;
+ return true;
+}
+
+/* Keep (virtually) nothing in memory. */
+
+static void
+plan_b (char const *filename)
+{
+ register FILE *ifp;
+ register int c;
+ register size_t len;
+ register size_t maxlen;
+ register bool found_revision;
+ register size_t i;
+ register char const *rev;
+ register size_t revlen;
+ register LINENUM line = 1;
+ int exclusive;
+
+ if (instat.st_size == 0)
+ filename = NULL_DEVICE;
+ if (! (ifp = fopen (filename, binary_transput ? "rb" : "r")))
+ pfatal ("Can't open file %s", quotearg (filename));
+ exclusive = TMPINNAME_needs_removal ? 0 : O_EXCL;
+ TMPINNAME_needs_removal = 1;
+ tifd = create_file (TMPINNAME, O_RDWR | O_BINARY | exclusive, (mode_t) 0,
+ true);
+ i = 0;
+ len = 0;
+ maxlen = 1;
+ rev = revision;
+ found_revision = !rev;
+ revlen = rev ? strlen (rev) : 0;
+
+ while ((c = getc (ifp)) != EOF)
+ {
+ len++;
+
+ if (c == '\n')
+ {
+ if (++line < 0)
+ too_many_lines (filename);
+ if (maxlen < len)
+ maxlen = len;
+ len = 0;
+ }
+
+ if (!found_revision)
+ {
+ if (i == revlen)
+ {
+ found_revision = ISSPACE ((unsigned char) c);
+ i = (size_t) -1;
+ }
+ else if (i != (size_t) -1)
+ i = rev[i]==c ? i + 1 : (size_t) -1;
+
+ if (i == (size_t) -1 && ISSPACE ((unsigned char) c))
+ i = 0;
+ }
+ }
+
+ if (revision)
+ report_revision (found_revision);
+ Fseek (ifp, 0, SEEK_SET); /* rewind file */
+ for (tibufsize = TIBUFSIZE_MINIMUM; tibufsize < maxlen; tibufsize <<= 1)
+ continue;
+ lines_per_buf = tibufsize / maxlen;
+ tireclen = maxlen;
+ tibuf[0] = xmalloc (2 * tibufsize);
+ tibuf[1] = tibuf[0] + tibufsize;
+
+ for (line = 1; ; line++)
+ {
+ char *p = tibuf[0] + maxlen * (line % lines_per_buf);
+ char const *p0 = p;
+ if (! (line % lines_per_buf)) /* new block */
+ if (write (tifd, tibuf[0], tibufsize) != tibufsize)
+ write_fatal ();
+ if ((c = getc (ifp)) == EOF)
+ break;
+
+ for (;;)
+ {
+ *p++ = c;
+ if (c == '\n')
+ {
+ last_line_size = p - p0;
+ break;
+ }
+
+ if ((c = getc (ifp)) == EOF)
+ {
+ last_line_size = p - p0;
+ line++;
+ goto EOF_reached;
+ }
+ }
+ }
+ EOF_reached:
+ if (ferror (ifp) || fclose (ifp) != 0)
+ read_fatal ();
+
+ if (line % lines_per_buf != 0)
+ if (write (tifd, tibuf[0], tibufsize) != tibufsize)
+ write_fatal ();
+ input_lines = line - 1;
+}
+
+/* Fetch a line from the input file.
+ WHICHBUF is ignored when the file is in memory. */
+
+char const *
+ifetch (LINENUM line, bool whichbuf, size_t *psize)
+{
+ register char const *q;
+ register char const *p;
+
+ if (line < 1 || line > input_lines) {
+ *psize = 0;
+ return "";
+ }
+ if (using_plan_a) {
+ p = i_ptr[line];
+ *psize = i_ptr[line + 1] - p;
+ return p;
+ } else {
+ LINENUM offline = line % lines_per_buf;
+ LINENUM baseline = line - offline;
+
+ if (tiline[0] == baseline)
+ whichbuf = false;
+ else if (tiline[1] == baseline)
+ whichbuf = true;
+ else {
+ tiline[whichbuf] = baseline;
+ if ((lseek (tifd, baseline/lines_per_buf * tibufsize, SEEK_SET)
+ == -1)
+ || read (tifd, tibuf[whichbuf], tibufsize) < 0)
+ read_fatal ();
+ }
+ p = tibuf[whichbuf] + (tireclen*offline);
+ if (line == input_lines)
+ *psize = last_line_size;
+ else {
+ for (q = p; *q++ != '\n'; )
+ continue;
+ *psize = q - p;
+ }
+ return p;
+ }
+}
--- /dev/null
+/* inputting files to be patched */
+
+/* Copyright (C) 1986, 1988 Larry Wall
+ Copyright (C) 1991, 1992, 1993, 1997, 1998, 1999, 2002, 2003, 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+XTERN LINENUM input_lines; /* how long is input file in lines */
+
+char const *ifetch (LINENUM, bool, size_t *);
+void get_input_file (char const *, char const *);
+void re_input (void);
+void scan_input (char *);
--- /dev/null
+/* Convert struct partime into time_t. */
+
+/* Copyright (C) 1992, 1993, 1994, 1995, 1997, 2003, 2006 Paul Eggert
+ Distributed under license by the Free Software Foundation, Inc.
+
+ This file is part of RCS.
+
+ RCS 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.
+
+ RCS 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 RCS; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Report problems and direct all questions to:
+
+ rcs-bugs@cs.purdue.edu
+
+ */
+
+/* For maximum portability, use only localtime and gmtime.
+ Make no assumptions about the time_t epoch or the range of time_t values.
+ Avoid mktime because it's not universal and because there's no easy,
+ portable way for mktime to yield the inverse of gmtime. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <maketime.h>
+
+#include <limits.h>
+#include <partime.h>
+#include <stdlib.h>
+#include <time.h>
+
+/* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
+ Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
+ Then this yields nonzero if overflow occurred during the addition.
+ Overflow occurs if A and B have the same sign, but A and SUM differ in sign.
+ Use `^' to test whether signs differ, and `< 0' to isolate the sign. */
+#define overflow_sum_sign(a, b, sum) ((~((a) ^ (b)) & ((a) ^ (sum))) < 0)
+
+/* Quotient and remainder when dividing A by B,
+ truncating towards minus infinity, where B is positive. */
+#define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
+#define MOD(a, b) ((a) % (b) + (b) * ((a) % (b) < 0))
+
+/* Number of days in 400 consecutive Gregorian years. */
+#define Y400_DAYS (365 * 400L + 100 - 4 + 1)
+
+/* Number of years to add to tm_year to get Gregorian year. */
+#define TM_YEAR_ORIGIN 1900
+
+static int
+isleap (int y)
+{
+ return (y & 3) == 0 && (y % 100 != 0 || y % 400 == 0);
+}
+
+/* days in year before start of months 0-12 */
+static int const month_yday[] =
+{
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
+};
+
+/* Yield the number of days in TM's month. */
+static int
+month_days (struct tm const *tm)
+{
+ int m = tm->tm_mon;
+ return (month_yday[m + 1] - month_yday[m]
+ + (m == 1 && isleap (tm->tm_year + TM_YEAR_ORIGIN)));
+}
+
+/* Convert UNIXTIME to struct tm form.
+ Use gmtime if available and if !LOCALZONE, localtime otherwise. */
+struct tm *
+time2tm (time_t unixtime, int localzone)
+{
+ struct tm *tm;
+#ifdef TZ_is_unset
+ static char const *TZ;
+ if (!TZ && !(TZ = getenv ("TZ")))
+ TZ_is_unset ("The TZ environment variable is not set; please set it to your timezone");
+#endif
+ if (localzone || !(tm = gmtime (&unixtime)))
+ tm = localtime (&unixtime);
+ return tm;
+}
+
+/* Yield A - B, measured in seconds. */
+time_t
+difftm (struct tm const *a, struct tm const *b)
+{
+ int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
+ int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
+ int ac = DIV (ay, 100);
+ int bc = DIV (by, 100);
+ int difference_in_day_of_year = a->tm_yday - b->tm_yday;
+ int intervening_leap_days = (((ay >> 2) - (by >> 2))
+ - (ac - bc)
+ + ((ac >> 2) - (bc >> 2)));
+ time_t difference_in_years = ay - by;
+ time_t difference_in_days
+ = (difference_in_years * 365
+ + (intervening_leap_days + difference_in_day_of_year));
+ return (((((difference_in_days * 24
+ + (a->tm_hour - b->tm_hour))
+ * 60)
+ + (a->tm_min - b->tm_min))
+ * 60)
+ + (a->tm_sec - b->tm_sec));
+}
+
+/* Adjust time T by adding SECONDS.
+ The absolute value of SECONDS cannot exceed 59 * INT_MAX,
+ and also cannot exceed one month's worth of seconds;
+ this is enough to handle any POSIX or real-life daylight-saving offset.
+ Adjust only T's year, mon, mday, hour, min and sec members;
+ plus adjust wday if it is defined. */
+void
+adjzone (register struct tm *t, long seconds)
+{
+ int days = 0;
+
+ /* This code can be off by a second if SECONDS is not a multiple of 60,
+ if T is local time, and if a leap second happens during this minute.
+ But this bug has never occurred, and most likely will not ever occur.
+ Liberia, the last country for which SECONDS % 60 was nonzero,
+ switched to UTC in May 1972; the first leap second was in June 1972. */
+ int leap_second = t->tm_sec == 60;
+ long sec = seconds + (t->tm_sec - leap_second);
+ if (sec < 0)
+ {
+ if ((t->tm_min -= (59 - sec) / 60) < 0
+ && (t->tm_hour -= (59 - t->tm_min) / 60) < 0)
+ {
+ days = - ((23 - t->tm_hour) / 24);
+ if ((t->tm_mday += days) <= 0)
+ {
+ if (--t->tm_mon < 0)
+ {
+ --t->tm_year;
+ t->tm_mon = 11;
+ }
+ t->tm_mday += month_days (t);
+ }
+ }
+ }
+ else
+ {
+ if (60 <= (t->tm_min += sec / 60)
+ && (24 <= (t->tm_hour += t->tm_min / 60)))
+ {
+ days = t->tm_hour / 24;
+ if (month_days (t) < (t->tm_mday += days))
+ {
+ if (11 < ++t->tm_mon)
+ {
+ ++t->tm_year;
+ t->tm_mon = 0;
+ }
+ t->tm_mday = 1;
+ }
+ }
+ }
+ if (TM_DEFINED (t->tm_wday))
+ t->tm_wday = MOD (t->tm_wday + days, 7);
+ t->tm_hour = MOD (t->tm_hour, 24);
+ t->tm_min = MOD (t->tm_min, 60);
+ t->tm_sec = (int) MOD (sec, 60) + leap_second;
+}
+
+/* Convert TM to time_t, using localtime if LOCALZONE and gmtime otherwise.
+ Use only TM's year, mon, mday, hour, min, and sec members.
+ Ignore TM's old tm_yday and tm_wday, but fill in their correct values.
+ Yield -1 on failure (e.g. a member out of range).
+ POSIX 1003.1 doesn't allow leap seconds, but some implementations
+ have them anyway, so allow them if localtime/gmtime does. */
+time_t
+tm2time (struct tm *tm, int localzone)
+{
+ /* Cache the most recent t,tm pairs; 1 for gmtime, 1 for localtime. */
+ static time_t t_cache[2];
+ static struct tm tm_cache[2];
+
+ time_t d, gt;
+ struct tm const *gtm;
+ /* The maximum number of iterations should be enough to handle any
+ combinations of leap seconds, time zone rule changes, and solar time.
+ 4 is probably enough; we use a bigger number just to be safe. */
+ int remaining_tries = 8;
+
+ /* Avoid subscript errors. */
+ if (12 <= (unsigned) tm->tm_mon)
+ return -1;
+
+ tm->tm_yday = month_yday[tm->tm_mon] + tm->tm_mday
+ - (tm->tm_mon < 2 || !isleap (tm->tm_year + TM_YEAR_ORIGIN));
+
+ /* Make a first guess. */
+ gt = t_cache[localzone];
+ gtm = gt ? &tm_cache[localzone] : time2tm (gt, localzone);
+
+ /* Repeatedly use the error from the guess to improve the guess. */
+ while ((d = difftm (tm, gtm)) != 0)
+ {
+ if (--remaining_tries == 0)
+ return -1;
+ gt += d;
+ gtm = time2tm (gt, localzone);
+ }
+
+ /* Check that the guess actually matches;
+ overflow can cause difftm to yield 0 even on differing times,
+ or tm may have members out of range (e.g. bad leap seconds). */
+#define TM_DIFFER(a,b) \
+ ( \
+ ((a)->tm_year ^ (b)->tm_year) | \
+ ((a)->tm_mon ^ (b)->tm_mon) | \
+ ((a)->tm_mday ^ (b)->tm_mday) | \
+ ((a)->tm_hour ^ (b)->tm_hour) | \
+ ((a)->tm_min ^ (b)->tm_min) | \
+ ((a)->tm_sec ^ (b)->tm_sec) \
+ )
+ if (TM_DIFFER (tm, gtm))
+ {
+ /* If gt is a leap second, try gt+1; if it is one greater than
+ a leap second, try gt-1; otherwise, it doesn't matter.
+ Leap seconds always fall at month end. */
+ int yd = tm->tm_year - gtm->tm_year;
+ gt += yd + (yd ? 0 : tm->tm_mon - gtm->tm_mon);
+ gtm = time2tm (gt, localzone);
+ if (TM_DIFFER (tm, gtm))
+ return -1;
+ }
+ t_cache[localzone] = gt;
+ tm_cache[localzone] = *gtm;
+
+ tm->tm_wday = gtm->tm_wday;
+ return gt;
+}
+
+/* Check *PT and convert it to time_t.
+ If it is incompletely specified, use DEFAULT_TIME to fill it out.
+ Use localtime if PT->zone is the special value TM_LOCAL_ZONE.
+ Yield -1 on failure.
+ ISO 8601 day-of-year and week numbers are not yet supported. */
+static time_t
+maketime (struct partime const *pt, time_t default_time)
+{
+ int localzone, wday, year;
+ struct tm tm;
+ struct tm *tm0 = 0;
+ time_t r;
+ int use_ordinal_day;
+
+ tm0 = 0; /* Keep gcc -Wall happy. */
+ localzone = pt->zone == TM_LOCAL_ZONE;
+
+ tm = pt->tm;
+ year = tm.tm_year;
+ wday = tm.tm_wday;
+ use_ordinal_day = (!TM_DEFINED (tm.tm_mday)
+ && TM_DEFINED (wday) && TM_DEFINED (pt->wday_ordinal));
+
+ if (use_ordinal_day || TM_DEFINED (pt->ymodulus) || !TM_DEFINED (year))
+ {
+ /* Get tm corresponding to default time. */
+ tm0 = time2tm (default_time, localzone);
+ if (!localzone)
+ adjzone (tm0, pt->zone);
+ }
+
+ if (use_ordinal_day)
+ tm.tm_mday = (tm0->tm_mday
+ + ((wday - tm0->tm_wday + 7) % 7
+ + 7 * (pt->wday_ordinal - (pt->wday_ordinal != 0))));
+
+ if (TM_DEFINED (pt->ymodulus))
+ {
+ /* Yield a year closest to the default that has the given modulus. */
+ int year0 = tm0->tm_year + TM_YEAR_ORIGIN;
+ int y0 = MOD (year0, pt->ymodulus);
+ int d = 2 * (year - y0);
+ year += (((year0 - y0) / pt->ymodulus
+ + (pt->ymodulus < d ? -1 : d < -pt->ymodulus))
+ * pt->ymodulus);
+ }
+ else if (!TM_DEFINED (year))
+ {
+ /* Set default year, month, day from current time. */
+ year = tm0->tm_year + TM_YEAR_ORIGIN;
+ if (!TM_DEFINED (tm.tm_mon))
+ {
+ tm.tm_mon = tm0->tm_mon;
+ if (!TM_DEFINED (tm.tm_mday))
+ tm.tm_mday = tm0->tm_mday;
+ }
+ }
+
+ /* Set remaining default fields to be their minimum values. */
+ if (!TM_DEFINED (tm.tm_mon))
+ tm.tm_mon = 0;
+ if (!TM_DEFINED (tm.tm_mday))
+ tm.tm_mday = 1;
+ if (!TM_DEFINED (tm.tm_hour))
+ tm.tm_hour = 0;
+ if (!TM_DEFINED (tm.tm_min))
+ tm.tm_min = 0;
+ if (!TM_DEFINED (tm.tm_sec))
+ tm.tm_sec = 0;
+
+ tm.tm_year = year - TM_YEAR_ORIGIN;
+ if ((year < tm.tm_year) != (TM_YEAR_ORIGIN < 0))
+ return -1;
+
+ if (!localzone)
+ {
+ adjzone (&tm, -pt->zone);
+ wday = tm.tm_wday;
+ }
+
+ /* Convert and fill in the rest of the tm. */
+ r = tm2time (&tm, localzone);
+ if (r == -1)
+ return r;
+
+ /* Check weekday. */
+ if (TM_DEFINED (wday) && wday != tm.tm_wday)
+ return -1;
+
+ /* Add relative time, except for seconds.
+ We handle seconds separately, at the end,
+ so that leap seconds are handled properly. */
+ if (pt->tmr.tm_year | pt->tmr.tm_mon | pt->tmr.tm_mday
+ | pt->tmr.tm_hour | pt->tmr.tm_min)
+ {
+ int years = tm.tm_year + pt->tmr.tm_year;
+ int mons = tm.tm_mon + pt->tmr.tm_mon;
+ int mdays = tm.tm_mday + pt->tmr.tm_mday;
+ int hours = tm.tm_hour + pt->tmr.tm_hour;
+ int mins = tm.tm_min + pt->tmr.tm_min;
+
+ int carried_hours = DIV (mins, 60);
+ int hours1 = hours + carried_hours;
+ int carried_days = DIV (hours1, 24);
+ int mdays1 = mdays + carried_days;
+
+ int mon0 = MOD (mons, 12);
+ int carried_years0 = DIV (mons, 12);
+ int year0 = years + carried_years0;
+ int yday0 = (month_yday[mon0]
+ - (mon0 < 2 || !isleap (year0 + TM_YEAR_ORIGIN)));
+
+ int yday1 = yday0 + mdays1;
+ int carried_years1 = DIV (yday1, Y400_DAYS) * 400;
+ int year1 = year0 + carried_years1;
+ int yday2 = MOD (yday1, Y400_DAYS);
+ int leap;
+
+ if (overflow_sum_sign (tm.tm_year, pt->tmr.tm_year, years)
+ | overflow_sum_sign (tm.tm_mon, pt->tmr.tm_mon, mons)
+ | overflow_sum_sign (tm.tm_mday, pt->tmr.tm_mday, mdays)
+ | overflow_sum_sign (tm.tm_hour, pt->tmr.tm_hour, hours)
+ | overflow_sum_sign (tm.tm_min, pt->tmr.tm_min, mins)
+ | overflow_sum_sign (hours, carried_hours, hours1)
+ | overflow_sum_sign (mdays, carried_days, mdays1)
+ | overflow_sum_sign (years, carried_years0, year0)
+ | overflow_sum_sign (yday0, mdays1, yday1)
+ | overflow_sum_sign (year0, carried_years1, year1))
+ return -1;
+
+ for (;;)
+ {
+ int days_per_year = 365 + (leap = isleap (year1 + TM_YEAR_ORIGIN));
+ if (yday2 < days_per_year)
+ break;
+ yday2 -= days_per_year;
+ year1++;
+ }
+
+ tm.tm_year = year1;
+
+ {
+ int mon;
+ for (mon = 11;
+ (tm.tm_mday = (yday2 - month_yday[mon] + (mon < 2 || !leap))) <= 0;
+ mon--)
+ continue;
+ tm.tm_mon = mon;
+ }
+
+ tm.tm_hour = MOD (hours1, 24);
+ tm.tm_min = MOD (mins, 60);
+
+ r = tm2time (&tm, localzone);
+ if (r == -1)
+ return r;
+ }
+
+ /* Add the seconds' part of relative time. */
+ {
+ time_t rs = r + pt->tmr.tm_sec;
+ if ((pt->tmr.tm_sec < 0) != (rs < r))
+ return -1;
+ return rs;
+ }
+}
+
+/* Parse a free-format date in *SOURCE, yielding a Unix format time.
+ Update *SOURCE to point to the first character after the date.
+ If *SOURCE is missing some information, take defaults from
+ DEFAULT_TIME and DEFAULT_ZONE. *SOURCE may even be the empty
+ string or an immediately invalid string, in which case the default
+ time and zone is used.
+ Return (time_t) -1 if the time is invalid or cannot be represented. */
+time_t
+str2time (char const **source, time_t default_time, long default_zone)
+{
+ struct partime pt;
+
+ *source = partime (*source, &pt);
+ if (pt.zone == TM_UNDEFINED_ZONE)
+ pt.zone = default_zone;
+ return maketime (&pt, default_time);
+}
+
+#ifdef TEST
+#include <stdio.h>
+int
+main (int argc, char **argv)
+{
+ time_t default_time = time (0);
+ long default_zone = argv[1] ? atol (argv[1]) : TM_LOCAL_ZONE;
+ char buf[1000];
+ while (fgets (buf, sizeof (buf), stdin))
+ {
+ char const *p = buf;
+ time_t t = str2time (&p, default_time, default_zone);
+ printf ("`%.*s' -> %s",
+ (int) (p - buf - (p[0] == '\0' && p[-1] == '\n')), buf,
+ asctime ((argv[1] ? gmtime : localtime) (&t)));
+ }
+ return 0;
+}
+#endif
--- /dev/null
+/* Yield time_t from struct partime yielded by partime. */
+
+/* Copyright (C) 1993, 1994, 1995, 2003, 2006 Paul Eggert
+ Distributed under license by the Free Software Foundation, Inc.
+
+ This file is part of RCS.
+
+ RCS 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.
+
+ RCS 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 RCS; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Report problems and direct all questions to:
+
+ rcs-bugs@cs.purdue.edu
+
+ */
+
+#include <time.h>
+
+struct tm *time2tm (time_t, int);
+time_t difftm (struct tm const *, struct tm const *);
+time_t str2time (char const **, time_t, long);
+time_t tm2time (struct tm *, int);
+void adjzone (struct tm *, long);
--- /dev/null
+/* Merge a patch
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Written by Andreas Gruenbacher <agruen@gnu.org>, 2009.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
+
+#define XTERN extern
+#include <common.h>
+#include <minmax.h>
+#include <xalloc.h>
+#include <inp.h>
+#include <pch.h>
+#include <util.h>
+
+static LINENUM count_context_lines (void);
+static bool context_matches_file (LINENUM, LINENUM);
+static void compute_changes (LINENUM, LINENUM, LINENUM, LINENUM, char *,
+ char *);
+
+#define OFFSET LINENUM
+#define EQUAL_IDX(x, y) (context_matches_file (x, y))
+#include "bestmatch.h"
+
+#define EQUAL_IDX(ctxt, x, y) (context_matches_file (x, y))
+#define OFFSET LINENUM
+#define EXTRA_CONTEXT_FIELDS \
+ char *xchar; \
+ char *ychar;
+#define NOTE_DELETE(ctxt, xoff) ctxt->xchar[xoff] = '-';
+#define NOTE_INSERT(ctxt, yoff) ctxt->ychar[yoff] = '+';
+#define USE_HEURISTIC 1
+#include "diffseq.h"
+
+static LINENUM
+locate_merge (LINENUM *matched)
+{
+ LINENUM first_guess = pch_first () + in_offset;
+ LINENUM pat_lines = pch_ptrn_lines ();
+ LINENUM context_lines = count_context_lines ();
+ LINENUM max_where = input_lines - pat_lines + context_lines + 1;
+ LINENUM min_where = last_frozen_line + 1;
+ LINENUM max_pos_offset = max_where - first_guess;
+ LINENUM max_neg_offset = first_guess - min_where;
+ LINENUM max_offset = (max_pos_offset < max_neg_offset
+ ? max_neg_offset : max_pos_offset);
+ LINENUM where = first_guess, max_matched = 0;
+ LINENUM min, max;
+ LINENUM offset;
+
+ /* Note: we need to preserve patch's property that it applies hunks at the
+ best match closest to their original position in the file. It is
+ common for hunks to apply equally well in several places in a file.
+ Applying at the first best match would be a lot easier.
+ */
+
+ if (context_lines == 0)
+ goto out; /* locate_hunk() already tried that */
+
+ /* Allow at most CONTEXT_LINES lines to be replaced (replacing counts
+ as insert + delete), and require the remaining MIN lines to match. */
+ max = 2 * context_lines;
+ min = pat_lines - context_lines;
+
+ if (debug & 1)
+ {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ say ("locating merge: min=%s max=%s ",
+ format_linenum (numbuf0, min),
+ format_linenum (numbuf1, max));
+ }
+
+ /* Hunks from the start or end of the file have less context. Anchor them
+ to the start or end, trying to make up for this disadvantage. */
+ if (pch_prefix_context () < pch_suffix_context () && pch_first () <= 1)
+ max_pos_offset = 0;
+ else if (pch_suffix_context () > pch_prefix_context ())
+ max_neg_offset = 0;
+
+ /* Do not try lines <= 0. */
+ if (first_guess <= max_neg_offset)
+ max_neg_offset = first_guess - 1;
+
+ for (offset = 0; offset <= max_offset; offset++)
+ {
+ if (offset <= max_pos_offset)
+ {
+ LINENUM guess = first_guess + offset;
+ LINENUM last;
+ LINENUM changes;
+
+ changes = bestmatch (1, pat_lines + 1, guess, input_lines + 1,
+ min, max, &last);
+ if (changes <= max && max_matched < last - guess)
+ {
+ max_matched = last - guess;
+ where = guess;
+ if (changes == 0)
+ break;
+ min = last - guess;
+ max = changes - 1;
+ }
+ }
+ if (0 < offset && offset <= max_neg_offset)
+ {
+ LINENUM guess = first_guess - offset;
+ LINENUM last;
+ LINENUM changes;
+
+ changes = bestmatch (1, pat_lines + 1, guess, input_lines + 1,
+ min, max, &last);
+ if (changes <= max && max_matched < last - guess)
+ {
+ max_matched = last - guess;
+ where = guess;
+ if (changes == 0)
+ break;
+ min = last - guess;
+ max = changes - 1;
+ }
+ }
+ }
+ if (debug & 1)
+ {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ char numbuf2[LINENUM_LENGTH_BOUND + 1];
+ say ("where=%s matched=%s changes=%s\n",
+ format_linenum (numbuf0, where),
+ format_linenum (numbuf1, max_matched),
+ format_linenum (numbuf2, max + 1));
+ }
+
+ out:
+ *matched = max_matched;
+ if (where < min_where)
+ where = min_where;
+ return where;
+}
+
+static void
+print_linerange (LINENUM from, LINENUM to)
+{
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+
+ if (to <= from)
+ printf ("%s",
+ format_linenum (numbuf0, from));
+ else
+ printf ("%s-%s",
+ format_linenum (numbuf0, from),
+ format_linenum (numbuf1, to));
+}
+
+static void
+merge_result (bool *first_result, int hunk, char const *what, LINENUM from,
+ LINENUM to)
+{
+ static char const *last_what;
+
+ if (*first_result && what)
+ {
+ printf ("Hunk #%d %s at ", hunk, what);
+ last_what = what;
+ }
+ else if (! what)
+ {
+ if (! *first_result)
+ {
+ fputs (".\n", stdout);
+ fflush (stdout);
+ last_what = 0;
+ }
+ return;
+ }
+ else if (last_what == what)
+ fputs (",", stdout);
+ else
+ printf (", %s at ", what);
+ print_linerange (from + out_offset, to + out_offset);
+ *first_result = false;
+}
+
+bool
+merge_hunk (int hunk, struct outstate *outstate, LINENUM where,
+ bool *somefailed)
+{
+ bool applies_cleanly;
+ bool first_result = true;
+ FILE *fp = outstate->ofp;
+ LINENUM old = 1;
+ LINENUM firstold = pch_ptrn_lines ();
+ LINENUM new = firstold + 1;
+ LINENUM firstnew = pch_end ();
+ LINENUM in;
+ LINENUM firstin;
+ char *oldin;
+ LINENUM matched;
+ LINENUM lastwhere;
+
+ /* Convert '!' markers into '-' and '+' to simplify things here. */
+ pch_normalize (UNI_DIFF);
+
+ assert (pch_char (firstnew + 1) == '^');
+ while (pch_char (new) == '=' || pch_char (new) == '\n')
+ new++;
+
+ if (where)
+ {
+ applies_cleanly = true;
+ matched = pch_ptrn_lines ();
+ }
+ else
+ {
+ where = locate_merge (&matched);
+ applies_cleanly = false;
+ }
+
+ in = firstold + 2;
+ oldin = xmalloc (in + matched + 1);
+ memset (oldin, ' ', in + matched);
+ oldin[0] = '*';
+ oldin[in - 1] = '=';
+ oldin[in + matched] = '^';
+ compute_changes (old, in - 1, where, where + matched,
+ oldin + old, oldin + in);
+
+ if (debug & 2)
+ {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ LINENUM n;
+
+ fputc ('\n', stderr);
+ for (n = 0; n <= in + matched; n++)
+ {
+ fprintf (stderr, "%s %c",
+ format_linenum (numbuf0, n),
+ oldin[n]);
+ if (n == 0)
+ fprintf(stderr, " %s,%s\n",
+ format_linenum (numbuf0, pch_first()),
+ format_linenum (numbuf1, pch_ptrn_lines()));
+ else if (n <= firstold)
+ fprintf (stderr, " |%.*s",
+ (int) pch_line_len (n), pfetch (n));
+ else if (n == in - 1)
+ fprintf(stderr, " %s,%s\n",
+ format_linenum (numbuf0, where),
+ format_linenum (numbuf1, matched));
+ else if (n >= in && n < in + matched)
+ {
+ size_t size;
+ const char *line;
+
+ line = ifetch (where + n - in, false, &size);
+ fprintf (stderr, " |%.*s",
+ (int) size, line);
+ }
+ else
+ fputc('\n', stderr);
+ }
+ fflush (stderr);
+ }
+
+ if (last_frozen_line < where - 1)
+ if (! copy_till (outstate, where - 1))
+ return false;
+
+ for (;;)
+ {
+ firstold = old;
+ firstnew = new;
+ firstin = in;
+
+ if (pch_char (old) == '-' || pch_char (new) == '+')
+ {
+ LINENUM lines;
+
+ while (pch_char (old) == '-')
+ {
+ if (oldin[old] == '-' || oldin[in] == '+')
+ goto conflict;
+ else if (oldin[old] == ' ')
+ {
+ assert (oldin[in] == ' ');
+ in++;
+ }
+ old++;
+ }
+ if (oldin[old] == '-' || oldin[in] == '+')
+ goto conflict;
+ while (pch_char (new) == '+')
+ new++;
+
+ lines = new - firstnew;
+ if (verbosity == VERBOSE
+ || ((verbosity != SILENT) && ! applies_cleanly))
+ merge_result (&first_result, hunk, "merged",
+ where, where + lines - 1);
+ last_frozen_line += (old - firstold);
+ where += (old - firstold);
+ out_offset += new - firstnew;
+
+ if (firstnew < new)
+ {
+ while (firstnew < new)
+ {
+ outstate->after_newline = pch_write_line (firstnew, fp);
+ firstnew++;
+ }
+ outstate->zero_output = false;
+ }
+ }
+ else if (pch_char (old) == ' ')
+ {
+ if (oldin[old] == '-')
+ {
+ while (pch_char (old) == ' ')
+ {
+ if (oldin[old] != '-')
+ break;
+ if (pch_char (new) == '+')
+ goto conflict;
+ else
+ assert (pch_char (new) == ' ');
+ old++;
+ new++;
+ }
+ if (pch_char (old) == '-' || pch_char (new) == '+')
+ goto conflict;
+ }
+ else if (oldin[in] == '+')
+ {
+ while (oldin[in] == '+')
+ in++;
+
+ /* Take these lines from the input file. */
+ where += in - firstin;
+ if (! copy_till (outstate, where - 1))
+ return false;
+ }
+ else if (oldin[old] == ' ')
+ {
+ while (pch_char (old) == ' '
+ && oldin[old] == ' '
+ && pch_char (new) == ' '
+ && oldin[in] == ' ')
+ {
+ old++;
+ new++;
+ in++;
+ }
+
+ /* Take these lines from the input file. */
+ where += (in - firstin);
+ if (! copy_till (outstate, where - 1))
+ return false;
+ }
+ }
+ else
+ {
+ assert (pch_char (old) == '=' && pch_char (new) == '^');
+ /* Nothing more left to merge. */
+ break;
+ }
+ continue;
+
+ conflict:
+ /* Find the end of the conflict. */
+ for (;;)
+ {
+ if (pch_char (old) == '-')
+ {
+ while (oldin[in] == '+')
+ in++;
+ if (oldin[old] == ' ')
+ {
+ assert (oldin[in] == ' ');
+ in++;
+ }
+ old++;
+ }
+ else if (oldin[old] == '-')
+ {
+ while (pch_char (new) == '+')
+ new++;
+ if (pch_char (old) == ' ')
+ {
+ assert (pch_char (new) == ' ');
+ new++;
+ }
+ old++;
+ }
+ else if (pch_char (new) == '+')
+ while (pch_char (new) == '+')
+ new++;
+ else if (oldin[in] == '+')
+ while (oldin[in] == '+')
+ in++;
+ else
+ break;
+ }
+ assert (((pch_char (old) == ' ' && pch_char (new) == ' ')
+ || (pch_char (old) == '=' && pch_char (new) == '^'))
+ && ((oldin[old] == ' ' && oldin[in] == ' ')
+ || (oldin[old] == '=' && oldin[in] == '^')));
+
+ /* Output common prefix lines. */
+ for (lastwhere = where;
+ firstin < in && firstnew < new
+ && context_matches_file (firstnew, lastwhere);
+ firstin++, firstnew++, lastwhere++)
+ continue;
+ if (firstin == in && firstnew == new)
+ merge_result (&first_result, hunk, "already applied",
+ where, lastwhere - 1);
+ if (where != lastwhere)
+ {
+ where = lastwhere;
+ if (! copy_till (outstate, where - 1))
+ return false;
+ }
+
+ if (firstin < in || firstnew < new)
+ {
+ LINENUM common_suffix;
+ LINENUM lines;
+
+ /* Remember common suffix lines. */
+ for (common_suffix = 0,
+ lastwhere = where + (in - firstin);
+ firstin < in && firstnew < new
+ && context_matches_file (new - 1, lastwhere - 1);
+ in--, new--, lastwhere--, common_suffix++)
+ continue;
+
+ lines = 3 + (in - firstin) + (new - firstnew);
+ merge_result (&first_result, hunk, "NOT MERGED",
+ where, where + lines - 1);
+ out_offset += 3 + (new - firstnew);
+
+ fputs (outstate->after_newline + "\n<<<<<<<\n", fp);
+ outstate->after_newline = true;
+ if (firstin < in)
+ {
+ where += (in - firstin);
+ if (! copy_till (outstate, where - 1))
+ return false;
+ }
+ fputs (outstate->after_newline + "\n=======\n", fp);
+ outstate->after_newline = true;
+ while (firstnew < new)
+ {
+ outstate->after_newline = pch_write_line (firstnew, fp);
+ firstnew++;
+ }
+ fputs (outstate->after_newline + "\n>>>>>>>\n", fp);
+ outstate->after_newline = true;
+ outstate->zero_output = false;
+ if (ferror (fp))
+ write_fatal ();
+
+ /* Output common suffix lines. */
+ if (common_suffix)
+ {
+ where += common_suffix;
+ if (! copy_till (outstate, where - 1))
+ return false;
+ in += common_suffix;
+ new += common_suffix;
+ }
+ *somefailed = true;
+ }
+ }
+ merge_result (&first_result, 0, 0, 0, 0);
+
+ assert (last_frozen_line == where - 1);
+ free (oldin);
+ return true;
+}
+
+static LINENUM
+count_context_lines (void)
+{
+ LINENUM old;
+ LINENUM lastold = pch_ptrn_lines ();
+ LINENUM context;
+
+ for (context = 0, old = 1; old <= lastold; old++)
+ if (pch_char (old) == ' ')
+ context++;
+ return context;
+}
+
+static bool
+context_matches_file (LINENUM old, LINENUM where)
+{
+ size_t size;
+ const char *line;
+
+ line = ifetch (where, false, &size);
+ return size &&
+ (canonicalize ?
+ similar (pfetch (old), pch_line_len (old), line, size) :
+ (size == pch_line_len (old) &&
+ memcmp (line, pfetch (old), size) == 0));
+}
+
+static void
+compute_changes (LINENUM xmin, LINENUM xmax, LINENUM ymin, LINENUM ymax,
+ char *xchar, char *ychar)
+{
+ struct context ctxt;
+ LINENUM diags;
+
+ ctxt.xchar = xchar - xmin;
+ ctxt.ychar = ychar - ymin;
+
+ diags = xmax + ymax + 3;
+ ctxt.fdiag = xmalloc (2 * diags * sizeof (*ctxt.fdiag));
+ ctxt.bdiag = ctxt.fdiag + diags;
+ ctxt.fdiag += ymax + 1;
+ ctxt.bdiag += ymax + 1;
+
+ ctxt.heuristic = true;
+ ctxt.too_expensive = xmax + ymax;
+
+ compareseq (xmin, xmax, ymin, ymax, true, &ctxt);
+
+ ctxt.fdiag -= ymax + 1;
+ free (ctxt.fdiag);
+}
--- /dev/null
+/* Parse a string, yielding a struct partime that describes it. */
+
+/* Copyright (C) 1993, 1994, 1995, 1997, 2002, 2003, 2006 Paul Eggert
+ Distributed under license by the Free Software Foundation, Inc.
+
+ This file is part of RCS.
+
+ RCS 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.
+
+ RCS 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 RCS; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Report problems and direct all questions to:
+
+ rcs-bugs@cs.purdue.edu
+
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <partime.h>
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <ctype.h>
+#if STDC_HEADERS
+# define CTYPE_DOMAIN(c) 1
+#else
+# define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
+#endif
+#define ISALNUM(c) (CTYPE_DOMAIN (c) && isalnum (c))
+#define ISALPHA(c) (CTYPE_DOMAIN (c) && isalpha (c))
+#define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
+#define ISUPPER(c) (CTYPE_DOMAIN (c) && isupper (c))
+#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
+
+
+/* Lookup tables for names of months, weekdays, time zones. */
+
+#define NAME_LENGTH_MAXIMUM 4
+
+struct name_val
+ {
+ char name[NAME_LENGTH_MAXIMUM];
+ int val;
+ };
+
+
+static char const *parse_pattern_letter (char const *, int, struct partime *);
+
+
+static struct name_val const month_names[] =
+{
+ {"jan", 0},
+ {"feb", 1},
+ {"mar", 2},
+ {"apr", 3},
+ {"may", 4},
+ {"jun", 5},
+ {"jul", 6},
+ {"aug", 7},
+ {"sep", 8},
+ {"oct", 9},
+ {"nov", 10},
+ {"dec", 11},
+ {"", TM_UNDEFINED}
+};
+
+static struct name_val const weekday_names[] =
+{
+ {"sun", 0},
+ {"mon", 1},
+ {"tue", 2},
+ {"wed", 3},
+ {"thu", 4},
+ {"fri", 5},
+ {"sat", 6},
+ {"", TM_UNDEFINED}
+};
+
+#define RELATIVE_CONS(member, multiplier) \
+ (offsetof (struct tm, member) + (multiplier) * sizeof (struct tm))
+#define RELATIVE_OFFSET(c) ((c) % sizeof (struct tm))
+#define RELATIVE_MULTIPLIER(c) ((c) / sizeof (struct tm))
+static struct name_val const relative_units[] =
+{
+ {"year", RELATIVE_CONS (tm_year, 1) },
+ {"mont", RELATIVE_CONS (tm_mon , 1) },
+ {"fort", RELATIVE_CONS (tm_mday, 14) },
+ {"week", RELATIVE_CONS (tm_mday, 7) },
+ {"day" , RELATIVE_CONS (tm_mday, 1) },
+ {"hour", RELATIVE_CONS (tm_hour, 1) },
+ {"min" , RELATIVE_CONS (tm_min , 1) },
+ {"sec" , RELATIVE_CONS (tm_sec , 1) },
+ {"", TM_UNDEFINED}
+};
+
+static struct name_val const ago[] =
+{
+ {"ago", 0},
+ {"", TM_UNDEFINED}
+};
+
+static struct name_val const dst_names[] =
+{
+ {"dst", 1},
+ {"", 0}
+};
+
+#define hr60nonnegative(t) ((t)/100 * 60 + (t)%100)
+#define hr60(t) ((t) < 0 ? - hr60nonnegative (-(t)) : hr60nonnegative (t))
+#define zs(t, s) {s, hr60 (t)}
+#define zd(t, s, d) zs (t, s), zs ((t) + 100, d)
+
+static struct name_val const zone_names[] =
+{
+ zs (-1000, "hst"), /* Hawaii */
+ zd (-1000, "hast", "hadt"), /* Hawaii-Aleutian */
+ zd (- 900, "akst", "akdt"), /* Alaska */
+ zd (- 800, "pst" , "pdt" ), /* Pacific */
+ zd (- 700, "mst" , "mdt" ), /* Mountain */
+ zd (- 600, "cst" , "cdt" ), /* Central */
+ zd (- 500, "est" , "edt" ), /* Eastern */
+ zd (- 400, "ast" , "adt" ), /* Atlantic */
+ zd (- 330, "nst" , "ndt" ), /* Newfoundland */
+ zs ( 000, "utc" ), /* Coordinated Universal */
+ zs ( 000, "uct" ), /* " */
+ zs ( 000, "cut" ), /* " */
+ zs ( 000, "ut"), /* Universal */
+ zs ( 000, "z"), /* Zulu (required by ISO 8601) */
+ zd ( 000, "gmt" , "bst" ), /* Greenwich Mean, British Summer */
+ zd ( 000, "wet" , "west"), /* Western European */
+ zd ( 100, "cet" , "cest"), /* Central European */
+ zd ( 100, "met" , "mest"), /* Middle European (bug in old tz versions) */
+ zd ( 100, "mez" , "mesz"), /* Mittel-Europaeische Zeit */
+ zd ( 200, "eet" , "eest"), /* Eastern European */
+ zs ( 530, "ist" ), /* India */
+ zd ( 900, "jst" , "jdt" ), /* Japan */
+ zd ( 900, "kst" , "kdt" ), /* Korea */
+ zd ( 1200, "nzst", "nzdt"), /* New Zealand */
+ {"lt", 1},
+#if 0
+ /* The following names are duplicates or are not well attested.
+ It's not worth keeping a complete list, since alphabetic time zone names
+ are deprecated and there are lots more where these came from. */
+ zs (-1100, "sst" ), /* Samoan */
+ zd (- 900, "yst" , "ydt" ), /* Yukon - name is no longer used */
+ zd (- 500, "ast" , "adt" ), /* Acre */
+ zd (- 400, "wst" , "wdt" ), /* Western Brazil */
+ zd (- 400, "cst" , "cdt" ), /* Chile */
+ zd (- 200, "fst" , "fdt" ), /* Fernando de Noronha */
+ zs ( 000, "wat" ), /* West African */
+ zs ( 100, "cat" ), /* Central African */
+ zs ( 200, "sat" ), /* South African */
+ zd ( 200, "ist" , "idt" ), /* Israel */
+ zs ( 300, "eat" ), /* East African */
+ zd ( 300, "msk" , "msd" ), /* Moscow */
+ zd ( 330, "ist" , "idt" ), /* Iran */
+ zs ( 800, "hkt" ), /* Hong Kong */
+ zs ( 800, "sgt" ), /* Singapore */
+ zd ( 800, "cst" , "cdt" ), /* China */
+ zd ( 800, "wst" , "wst" ), /* Western Australia */
+ zd ( 930, "cst" , "cst" ), /* Central Australia */
+ zs ( 1000, "gst" ), /* Guam */
+ zd ( 1000, "est" , "est" ), /* Eastern Australia */
+#endif
+ {"", -1}
+};
+
+/* Look for a prefix of S in TABLE, returning val for first matching entry. */
+static int
+lookup (char const *s, struct name_val const table[])
+{
+ int j;
+ char buf[NAME_LENGTH_MAXIMUM];
+
+ for (j = 0; j < NAME_LENGTH_MAXIMUM; j++)
+ {
+ unsigned char c = *s;
+ if (! ISALPHA (c))
+ {
+ buf[j] = '\0';
+ break;
+ }
+ buf[j] = ISUPPER (c) ? tolower (c) : c;
+ s++;
+ s += *s == '.';
+ }
+
+ for (;; table++)
+ for (j = 0; ; j++)
+ if (j == NAME_LENGTH_MAXIMUM || ! table[0].name[j])
+ return table[0].val;
+ else if (buf[j] != table[0].name[j])
+ break;
+}
+
+
+/* Set *T to ``undefined'' values. */
+static void
+undefine (struct partime *t)
+{
+ t->tm.tm_sec = t->tm.tm_min = t->tm.tm_hour = t->tm.tm_mday = t->tm.tm_mon
+ = t->tm.tm_year = t->tm.tm_wday = t->tm.tm_yday
+ = t->wday_ordinal = t->ymodulus = t->yweek
+ = TM_UNDEFINED;
+ t->tmr.tm_sec = t->tmr.tm_min = t->tmr.tm_hour =
+ t->tmr.tm_mday = t->tmr.tm_mon = t->tmr.tm_year = 0;
+ t->zone = TM_UNDEFINED_ZONE;
+}
+
+/* Patterns to look for in a time string.
+ Order is important: we look for the first matching pattern
+ whose values do not contradict values that we already know about.
+ See `parse_pattern_letter' below for the meaning of the pattern codes. */
+static char const time_patterns[] =
+{
+ /* Traditional patterns come first,
+ to prevent an ISO 8601 format from misinterpreting their prefixes. */
+
+ /* RFC 822, extended */
+ 'E', '_', 'N', '_', 'y', '$', 0,
+ 'x', 0,
+
+ /* traditional */
+ '4', '_', 'M', '_', 'D', '_', 'h', '_', 'm', '_', 's', '$', 0,
+ 'R', '_', 'M', '_', 'D', '_', 'h', '_', 'm', '_', 's', '$', 0,
+ 'E', '_', 'N', 0,
+ 'N', '_', 'E', '_', 'y', ';', 0,
+ 'N', '_', 'E', ';', 0,
+ 'N', 0,
+ 't', ':', 'm', ':', 's', '_', 'A', 0,
+ 't', ':', 'm', '_', 'A', 0,
+ 't', '_', 'A', 0,
+
+ /* traditional get_date */
+ 'i', '_', 'x', 0,
+ 'Y', '/', 'n', '/', 'E', ';', 0,
+ 'n', '/', 'E', '/', 'y', ';', 0,
+ 'n', '/', 'E', ';', 0,
+ 'u', 0,
+
+ /* ISO 8601:1988 formats, generalized a bit. */
+ 'y', '-', 'M', '-', 'D', '$', 0,
+ '4', 'M', 'D', '$', 0,
+ 'Y', '-', 'M', '$', 0,
+ 'R', 'M', 'D', '$', 0,
+ '-', 'R', '=', 'M', '$', 0,
+ '-', 'R', '$', 0,
+ '-', '-', 'M', '=', 'D', '$', 0,
+ 'M', '=', 'D', 'T', 0,
+ '-', '-', 'M', '$', 0,
+ '-', '-', '-', 'D', '$', 0,
+ 'D', 'T', 0,
+ 'Y', '-', 'd', '$', 0,
+ '4', 'd', '$', 0,
+ 'R', '=', 'd', '$', 0,
+ '-', 'd', '$', 0,
+ 'd', 'T', 0,
+ 'y', '-', 'W', '-', 'X', 0,
+ 'y', 'W', 'X', 0,
+ 'y', '=', 'W', 0,
+ '-', 'r', '-', 'W', '-', 'X', 0,
+ 'r', '-', 'W', '-', 'X', 'T', 0,
+ '-', 'r', 'W', 'X', 0,
+ 'r', 'W', 'X', 'T', 0,
+ '-', 'W', '=', 'X', 0,
+ 'W', '=', 'X', 'T', 0,
+ '-', 'W', 0,
+ '-', 'w', '-', 'X', 0,
+ 'w', '-', 'X', 'T', 0,
+ '-', '-', '-', 'X', '$', 0,
+ 'X', 'T', 0,
+ '4', '$', 0,
+ 'T', 0,
+ 'h', ':', 'm', ':', 's', '$', 0,
+ 'h', 'm', 's', '$', 0,
+ 'h', ':', 'L', '$', 0,
+ 'h', 'L', '$', 0,
+ 'H', '$', 0,
+ '-', 'm', ':', 's', '$', 0,
+ '-', 'm', 's', '$', 0,
+ '-', 'L', '$', 0,
+ '-', '-', 's', '$', 0,
+ 'Y', 0,
+ 'Z', 0,
+
+ 0
+};
+
+/* Parse an initial prefix of STR according to *PATTERNS, setting *T.
+ Return the first character after the prefix, or 0 if it couldn't be parsed.
+ *PATTERNS is a character array containing one pattern string after another;
+ it is terminated by an empty string.
+ If success, set *PATTERNS to the next pattern to try.
+ Set *PATTERNS to 0 if we know there are no more patterns to try;
+ if *PATTERNS is initially 0, give up immediately. */
+static char const *
+parse_prefix (char const *str, char const **patterns, struct partime *t)
+{
+ char const *pat = *patterns;
+ unsigned char c;
+
+ if (! pat)
+ return 0;
+
+ /* Remove initial noise. */
+ while (! ISALNUM (c = *str) && c != '-' && c != '+')
+ {
+ if (! c)
+ {
+ undefine (t);
+ *patterns = 0;
+ return str;
+ }
+
+ str++;
+ }
+
+ /* Try a pattern until one succeeds. */
+ while (*pat)
+ {
+ char const *s = str;
+ undefine (t);
+
+ do
+ {
+ if (! (c = *pat++))
+ {
+ *patterns = pat;
+ return s;
+ }
+ }
+ while ((s = parse_pattern_letter (s, c, t)) != 0);
+
+ while (*pat++)
+ continue;
+ }
+
+ return 0;
+}
+
+/* Parse an initial prefix of S of length DIGITS; it must be a number.
+ Store the parsed number into *RES.
+ Return the first character after the prefix, or 0 if it wasn't parsed. */
+static char const *
+parse_fixed (char const *s, int digits, int *res)
+{
+ int n = 0;
+ char const *lim = s + digits;
+ while (s < lim)
+ {
+ unsigned d = *s++ - '0';
+ if (9 < d)
+ return 0;
+ n = 10 * n + d;
+ }
+ *res = n;
+ return s;
+}
+
+/* Parse a possibly empty initial prefix of S.
+ Store the parsed number into *RES.
+ Return the first character after the prefix. */
+static char const *
+parse_varying (char const *s, int *res)
+{
+ int n = 0;
+ for (;;)
+ {
+ unsigned d = *s - '0';
+ if (9 < d)
+ break;
+ s++;
+ n = 10 * n + d;
+ }
+ *res = n;
+ return s;
+}
+
+/* Parse an initial prefix of S of length DIGITS;
+ it must be a number in the range LO through HI.
+ Store the parsed number into *RES.
+ Return the first character after the prefix, or 0 if it wasn't parsed. */
+static char const *
+parse_ranged (char const *s, int digits, int lo, int hi, int *res)
+{
+ s = parse_fixed (s, digits, res);
+ return s && lo <= *res && *res <= hi ? s : 0;
+}
+
+/* Parse an initial prefix of S of length DIGITS;
+ it must be a number in the range LO through HI
+ and it may be followed by a fraction to be computed using RESOLUTION.
+ Store the parsed number into *RES; store the fraction times RESOLUTION,
+ rounded to the nearest integer, into *FRES.
+ Return the first character after the prefix, or 0 if it wasn't parsed. */
+static char const *
+parse_decimal (char const *s, int digits, int lo, int hi, int resolution,
+ int *res, int *fres)
+{
+ s = parse_fixed (s, digits, res);
+ if (s && lo <= *res && *res <= hi)
+ {
+ int f = 0;
+ if ((s[0] == ',' || s[0] == '.') && ISDIGIT (s[1]))
+ {
+ char const *s1 = ++s;
+ int num10 = 0, denom10 = 10, product;
+ while (ISDIGIT (*++s))
+ {
+ int d = denom10 * 10;
+ if (d / 10 != denom10)
+ return 0; /* overflow */
+ denom10 = d;
+ }
+ s = parse_fixed (s1, (int) (s - s1), &num10);
+ product = num10 * resolution;
+ f = (product + (denom10 >> 1)) / denom10;
+ f -= f & (product % denom10 == denom10 >> 1); /* round to even */
+ if (f < 0 || product/resolution != num10)
+ return 0; /* overflow */
+ }
+ *fres = f;
+ return s;
+ }
+ return 0;
+}
+
+/* Parse an initial prefix of S; it must denote a time zone.
+ Set *ZONE to the number of seconds east of GMT,
+ or to TM_LOCAL_ZONE if it is the local time zone.
+ Return the first character after the prefix, or 0 if it wasn't parsed. */
+char *
+parzone (s, zone)
+ char const *s;
+ long *zone;
+{
+ char const *s1;
+ char sign;
+ int hh, mm, ss;
+ int minutes_east_of_UTC;
+ int trailing_DST;
+ long offset, z;
+
+ /* The formats are LT, n, n DST, nDST, no, o
+ where n is a time zone name
+ and o is a time zone offset of the form [-+]hh[:mm[:ss]]. */
+ switch (*s)
+ {
+ case '-':
+ case '+':
+ z = 0;
+ break;
+
+ default:
+ minutes_east_of_UTC = lookup (s, zone_names);
+ if (minutes_east_of_UTC == -1)
+ return 0;
+
+ /* Don't bother to check rest of spelling,
+ but look for an embedded "DST". */
+ trailing_DST = 0;
+ while (ISALPHA ((unsigned char) *s))
+ {
+ if ((*s == 'D' || *s == 'd') && lookup (s, dst_names))
+ trailing_DST = 1;
+ s++;
+ s += *s == '.';
+ }
+
+ /* Don't modify LT. */
+ if (minutes_east_of_UTC == 1)
+ {
+ *zone = TM_LOCAL_ZONE;
+ return (char *) s;
+ }
+
+ z = minutes_east_of_UTC * 60L;
+ s1 = s;
+
+ /* Look for trailing "DST" or " DST". */
+ while (ISSPACE ((unsigned char) *s))
+ s++;
+ if (lookup (s, dst_names))
+ {
+ while (ISALPHA ((unsigned char) *s))
+ {
+ s++;
+ s += *s == '.';
+ }
+ trailing_DST = 1;
+ }
+
+ if (trailing_DST)
+ {
+ *zone = z + 60*60;
+ return (char *) s;
+ }
+
+ s = s1;
+
+ switch (*s)
+ {
+ case '-':
+ case '+':
+ break;
+
+ default:
+ *zone = z;
+ return (char *) s;
+ }
+
+ break;
+ }
+
+ sign = *s++;
+
+ if (! (s = parse_ranged (s, 2, 0, 23, &hh)))
+ return 0;
+ mm = ss = 0;
+ if (*s == ':')
+ s++;
+ if (ISDIGIT (*s))
+ {
+ if (! (s = parse_ranged (s, 2, 0, 59, &mm)))
+ return 0;
+ if (*s == ':' && s[-3] == ':' && ISDIGIT (s[1])
+ && ! (s = parse_ranged (s + 1, 2, 0, 59, &ss)))
+ return 0;
+ }
+ if (ISDIGIT (*s))
+ return 0;
+ offset = (hh * 60 + mm) * 60L + ss;
+ *zone = z + (sign == '-' ? -offset : offset);
+ /* ?? Are fractions allowed here? If so, they're not implemented. */
+ return (char *) s;
+}
+
+/* Parse an initial prefix of S, matching the pattern whose code is C.
+ Set *T accordingly.
+ Return the first character after the prefix, or 0 if it wasn't parsed. */
+static char const *
+parse_pattern_letter (char const *s, int c, struct partime *t)
+{
+ char const *s0 = s;
+
+ switch (c)
+ {
+ case '$': /* The next character must be a non-digit. */
+ if (ISDIGIT (*s))
+ return 0;
+ break;
+
+ case '-':
+ case '/':
+ case ':':
+ /* These characters stand for themselves. */
+ if (*s++ != c)
+ return 0;
+ break;
+
+ case '4': /* 4-digit year */
+ s = parse_fixed (s, 4, &t->tm.tm_year);
+ break;
+
+ case ';': /* The next character must be a non-digit, and cannot be ':'. */
+ if (ISDIGIT (*s) || *s == ':')
+ return 0;
+ break;
+
+ case '=': /* optional '-' */
+ s += *s == '-';
+ break;
+
+ case 'A': /* AM or PM */
+ /* This matches the regular expression [AaPp]\.?([Mm]\.?)?.
+ It must not be followed by a letter or digit;
+ otherwise it would match prefixes of strings like "PST". */
+ switch (*s)
+ {
+ case 'A':
+ case 'a':
+ if (t->tm.tm_hour == 12)
+ t->tm.tm_hour = 0;
+ break;
+
+ case 'P':
+ case 'p':
+ if (t->tm.tm_hour != 12)
+ t->tm.tm_hour += 12;
+ break;
+
+ default:
+ return 0;
+ }
+ s++;
+ s += *s == '.';
+ switch (*s)
+ {
+ case 'M':
+ case 'm':
+ s++;
+ s += *s == '.';
+ break;
+ }
+ if (ISALNUM ((unsigned char) *s))
+ return 0;
+ break;
+
+ case 'D': /* day of month [01-31] */
+ s = parse_ranged (s, 2, 1, 31, &t->tm.tm_mday);
+ break;
+
+ case 'd': /* day of year [001-366] */
+ s = parse_ranged (s, 3, 1, 366, &t->tm.tm_yday);
+ t->tm.tm_yday--;
+ break;
+
+ case 'E': /* traditional day of month [1-9, 01-31] */
+ s = parse_ranged (s, (ISDIGIT (s[0]) && ISDIGIT (s[1])) + 1, 1, 31,
+ &t->tm.tm_mday);
+ break;
+
+ case 'h': /* hour [00-23] */
+ s = parse_ranged (s, 2, 0, 23, &t->tm.tm_hour);
+ break;
+
+ case 'H': /* hour [00-23 followed by optional fraction] */
+ {
+ int frac;
+ s = parse_decimal (s, 2, 0, 23, 60 * 60, &t->tm.tm_hour, &frac);
+ t->tm.tm_min = frac / 60;
+ t->tm.tm_sec = frac % 60;
+ }
+ break;
+
+ case 'i': /* ordinal day number, e.g. "3rd" */
+ s = parse_varying (s, &t->wday_ordinal);
+ if (s == s0)
+ return 0;
+ while (ISALPHA ((unsigned char) *s))
+ s++;
+ break;
+
+ case 'L': /* minute [00-59 followed by optional fraction] */
+ s = parse_decimal (s, 2, 0, 59, 60, &t->tm.tm_min, &t->tm.tm_sec);
+ break;
+
+ case 'm': /* minute [00-59] */
+ s = parse_ranged (s, 2, 0, 59, &t->tm.tm_min);
+ break;
+
+ case 'M': /* month [01-12] */
+ s = parse_ranged (s, 2, 1, 12, &t->tm.tm_mon);
+ t->tm.tm_mon--;
+ break;
+
+ case 'n': /* traditional month [1-9, 01-12] */
+ s = parse_ranged (s, (ISDIGIT (s[0]) && ISDIGIT (s[1])) + 1, 1, 12,
+ &t->tm.tm_mon);
+ t->tm.tm_mon--;
+ break;
+
+ case 'N': /* month name [e.g. "Jan"] */
+ if (! TM_DEFINED (t->tm.tm_mon = lookup (s, month_names)))
+ return 0;
+ /* Don't bother to check rest of spelling. */
+ while (ISALPHA ((unsigned char) *s))
+ s++;
+ break;
+
+ case 'r': /* year % 10 (remainder in origin-0 decade) [0-9] */
+ s = parse_fixed (s, 1, &t->tm.tm_year);
+ t->ymodulus = 10;
+ break;
+
+ case_R:
+ case 'R': /* year % 100 (remainder in origin-0 century) [00-99] */
+ s = parse_fixed (s, 2, &t->tm.tm_year);
+ t->ymodulus = 100;
+ break;
+
+ case 's': /* second [00-60 followed by optional fraction] */
+ {
+ int frac;
+ s = parse_decimal (s, 2, 0, 60, 1, &t->tm.tm_sec, &frac);
+ }
+ break;
+
+ case 'T': /* 'T' or 't' */
+ switch (*s++)
+ {
+ case 'T':
+ case 't':
+ break;
+ default:
+ return 0;
+ }
+ break;
+
+ case 't': /* traditional hour [1-9 or 01-12] */
+ s = parse_ranged (s, (ISDIGIT (s[0]) && ISDIGIT (s[1])) + 1, 1, 12,
+ &t->tm.tm_hour);
+ break;
+
+ case 'u': /* relative unit */
+ {
+ int i;
+ int n;
+ int negative = 0;
+ switch (*s)
+ {
+ case '-': negative = 1;
+ /* Fall through. */
+ case '+': s++;
+ }
+ if (ISDIGIT (*s))
+ s = parse_varying (s, &n);
+ else if (s == s0)
+ n = 1;
+ else
+ return 0;
+ if (negative)
+ n = -n;
+ while (! ISALNUM ((unsigned char) *s) && *s)
+ s++;
+ i = lookup (s, relative_units);
+ if (!TM_DEFINED (i))
+ return 0;
+ * (int *) ((char *) &t->tmr + RELATIVE_OFFSET (i))
+ += n * RELATIVE_MULTIPLIER (i);
+ while (ISALPHA ((unsigned char) *s))
+ s++;
+ while (! ISALNUM ((unsigned char) *s) && *s)
+ s++;
+ if (TM_DEFINED (lookup (s, ago)))
+ {
+ t->tmr.tm_sec = - t->tmr.tm_sec;
+ t->tmr.tm_min = - t->tmr.tm_min;
+ t->tmr.tm_hour = - t->tmr.tm_hour;
+ t->tmr.tm_mday = - t->tmr.tm_mday;
+ t->tmr.tm_mon = - t->tmr.tm_mon;
+ t->tmr.tm_year = - t->tmr.tm_year;
+ while (ISALPHA ((unsigned char) *s))
+ s++;
+ }
+ break;
+ }
+
+ case 'w': /* 'W' or 'w' only (stands for current week) */
+ switch (*s++)
+ {
+ case 'W':
+ case 'w':
+ break;
+ default:
+ return 0;
+ }
+ break;
+
+ case 'W': /* 'W' or 'w', followed by a week of year [00-53] */
+ switch (*s++)
+ {
+ case 'W':
+ case 'w':
+ break;
+ default:
+ return 0;
+ }
+ s = parse_ranged (s, 2, 0, 53, &t->yweek);
+ break;
+
+ case 'X': /* weekday (1=Mon ... 7=Sun) [1-7] */
+ s = parse_ranged (s, 1, 1, 7, &t->tm.tm_wday);
+ t->tm.tm_wday--;
+ break;
+
+ case 'x': /* weekday name [e.g. "Sun"] */
+ if (! TM_DEFINED (t->tm.tm_wday = lookup (s, weekday_names)))
+ return 0;
+ /* Don't bother to check rest of spelling. */
+ while (ISALPHA ((unsigned char) *s))
+ s++;
+ break;
+
+ case 'y': /* either R or Y */
+ if (ISDIGIT (s[0]) && ISDIGIT (s[1]) && ! ISDIGIT (s[2]))
+ goto case_R;
+ /* fall into */
+ case 'Y': /* year in full [4 or more digits] */
+ s = parse_varying (s, &t->tm.tm_year);
+ if (s - s0 < 4)
+ return 0;
+ break;
+
+ case 'Z': /* time zone */
+ s = parzone (s, &t->zone);
+ break;
+
+ case '_': /* possibly empty sequence of non-alphanumerics */
+ while (! ISALNUM ((unsigned char) *s) && *s)
+ s++;
+ break;
+
+ default: /* bad pattern */
+ return 0;
+ }
+
+ return s;
+}
+
+/* If there is no conflict, merge into *T the additional information in *U
+ and return 0. Otherwise do nothing and return -1. */
+static int
+merge_partime (struct partime *t, struct partime const *u)
+{
+# define conflict(a,b) ((a) != (b) && TM_DEFINED (a) && TM_DEFINED (b))
+ if (conflict (t->tm.tm_sec, u->tm.tm_sec)
+ || conflict (t->tm.tm_min, u->tm.tm_min)
+ || conflict (t->tm.tm_hour, u->tm.tm_hour)
+ || conflict (t->tm.tm_mday, u->tm.tm_mday)
+ || conflict (t->tm.tm_mon, u->tm.tm_mon)
+ || conflict (t->tm.tm_year, u->tm.tm_year)
+ || conflict (t->tm.tm_wday, u->tm.tm_wday)
+ || conflict (t->tm.tm_yday, u->tm.tm_yday)
+ || conflict (t->ymodulus, u->ymodulus)
+ || conflict (t->yweek, u->yweek)
+ || (t->zone != u->zone
+ && t->zone != TM_UNDEFINED_ZONE
+ && u->zone != TM_UNDEFINED_ZONE))
+ return -1;
+# undef conflict
+# define merge_(a,b) if (TM_DEFINED (b)) (a) = (b);
+ merge_ (t->tm.tm_sec, u->tm.tm_sec)
+ merge_ (t->tm.tm_min, u->tm.tm_min)
+ merge_ (t->tm.tm_hour, u->tm.tm_hour)
+ merge_ (t->tm.tm_mday, u->tm.tm_mday)
+ merge_ (t->tm.tm_mon, u->tm.tm_mon)
+ merge_ (t->tm.tm_year, u->tm.tm_year)
+ merge_ (t->tm.tm_wday, u->tm.tm_wday)
+ merge_ (t->tm.tm_yday, u->tm.tm_yday)
+ merge_ (t->ymodulus, u->ymodulus)
+ merge_ (t->yweek, u->yweek)
+# undef merge_
+ t->tmr.tm_sec += u->tmr.tm_sec;
+ t->tmr.tm_min += u->tmr.tm_min;
+ t->tmr.tm_hour += u->tmr.tm_hour;
+ t->tmr.tm_mday += u->tmr.tm_mday;
+ t->tmr.tm_mon += u->tmr.tm_mon;
+ t->tmr.tm_year += u->tmr.tm_year;
+ if (u->zone != TM_UNDEFINED_ZONE)
+ t->zone = u->zone;
+ return 0;
+}
+
+/* Parse a date/time prefix of S, putting the parsed result into *T.
+ Return the first character after the prefix.
+ The prefix may contain no useful information;
+ in that case, *T will contain only undefined values. */
+char *
+partime (s, t)
+ char const *s;
+ struct partime *t;
+{
+ struct partime p;
+
+ undefine (t);
+
+ while (*s)
+ {
+ char const *patterns = time_patterns;
+ char const *s1;
+
+ do
+ {
+ if (! (s1 = parse_prefix (s, &patterns, &p)))
+ return (char *) s;
+ }
+ while (merge_partime (t, &p) != 0);
+
+ s = s1;
+ }
+
+ return (char *) s;
+}
--- /dev/null
+/* Parse a string, yielding a struct partime that describes it. */
+
+/* Copyright (C) 1993, 1994, 1995, 1997, 2003, 2006 Paul Eggert
+ Distributed under license by the Free Software Foundation, Inc.
+
+ This file is part of RCS.
+
+ RCS 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.
+
+ RCS 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 RCS; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Report problems and direct all questions to:
+
+ rcs-bugs@cs.purdue.edu
+
+ */
+
+#include <limits.h>
+#include <time.h>
+
+#define TM_UNDEFINED (-1)
+#define TM_DEFINED(x) (0 <= (x))
+
+#define TM_LOCAL_ZONE LONG_MIN
+#define TM_UNDEFINED_ZONE (LONG_MIN + 1)
+
+struct partime
+ {
+ /* This structure describes the parsed time.
+ Only the following tm_* members are used:
+ sec, min, hour, mday, mon, year, wday, yday.
+ If ! TM_DEFINED (value), the parser never found the value.
+ The tm_year field is the actual year, not the year - 1900;
+ but see ymodulus below. */
+ struct tm tm;
+
+ /* Like tm, but values are relative to the value in tm,
+ and values are initialized to 0 rather than to TM_UNDEFINED.
+ Only the following tm_* members are used:
+ sec, min, hour, mday, mon, year. */
+ struct tm tmr;
+
+ /* If TM_DEFINED (wday_ordinal),
+ then day number (e.g. 3 in "3rd Sunday"). */
+ int wday_ordinal;
+
+ /* If TM_DEFINED (ymodulus),
+ then tm.tm_year is actually modulo ymodulus. */
+ int ymodulus;
+
+ /* Week of year, ISO 8601 style.
+ If ! TM_DEFINED (yweek), the parser never found yweek.
+ Weeks start on Mondays.
+ Week 1 includes Jan 4. */
+ int yweek;
+
+ /* Seconds east of UTC; or TM_LOCAL_ZONE or TM_UNDEFINED_ZONE. */
+ long zone;
+ };
+
+char *partime (char const *, struct partime *);
+char *parzone (char const *, long *);
--- /dev/null
+/* patch - a program to apply diffs to original files */
+
+/* Copyright (C) 1984, 1985, 1986, 1987, 1988 Larry Wall
+
+ Copyright (C) 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2002,
+ 2003, 2006, 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#define XTERN
+#include <common.h>
+#undef XTERN
+#define XTERN extern
+#include <argmatch.h>
+#include <backupfile.h>
+#include <exitfail.h>
+#include <getopt.h>
+#include <inp.h>
+#include <pch.h>
+#include <quotearg.h>
+#include <util.h>
+#include <version.h>
+#include <xalloc.h>
+
+/* procedures */
+
+static FILE *create_output_file (char const *, int);
+static LINENUM locate_hunk (LINENUM);
+static bool apply_hunk (struct outstate *, LINENUM);
+static bool patch_match (LINENUM, LINENUM, LINENUM, LINENUM);
+static bool spew_output (struct outstate *, struct stat *);
+static char const *make_temp (char);
+static int numeric_string (char const *, bool, char const *);
+static void cleanup (void);
+static void get_some_switches (void);
+static void init_output (char const *, int, struct outstate *);
+static void init_reject (void);
+static void reinitialize_almost_everything (void);
+static void remove_if_needed (char const *, int volatile *);
+static void usage (FILE *, int) __attribute__((noreturn));
+
+static void abort_hunk (bool, bool);
+static void abort_hunk_context (bool, bool);
+static void abort_hunk_unified (bool, bool);
+
+#ifdef ENABLE_MERGE
+static bool merge;
+#else
+# define merge false
+#endif
+
+static enum diff reject_format = NO_DIFF; /* automatic */
+static bool make_backups;
+static bool backup_if_mismatch;
+static char const *version_control;
+static char const *version_control_context;
+static bool remove_empty_files;
+static bool explicit_inname;
+
+/* true if -R was specified on command line. */
+static bool reverse_flag_specified;
+
+static char const *do_defines; /* symbol to patch using ifdef, ifndef, etc. */
+static char const if_defined[] = "\n#ifdef %s\n";
+static char const not_defined[] = "\n#ifndef %s\n";
+static char const else_defined[] = "\n#else\n";
+static char const end_defined[] = "\n#endif\n";
+
+static int Argc;
+static char * const *Argv;
+
+static FILE *rejfp; /* reject file pointer */
+
+static char const *patchname;
+static char *rejname;
+static char const * volatile TMPREJNAME;
+static int volatile TMPREJNAME_needs_removal;
+
+static LINENUM maxfuzz = 2;
+
+static char serrbuf[BUFSIZ];
+
+/* Apply a set of diffs as appropriate. */
+
+int
+main (int argc, char **argv)
+{
+ char const *val;
+ bool somefailed = false;
+ struct outstate outstate;
+ struct stat outst;
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ bool written_to_rejname = false;
+ bool apply_empty_patch = false;
+
+ exit_failure = 2;
+ program_name = argv[0];
+ init_time ();
+
+ setbuf(stderr, serrbuf);
+
+ bufsize = 8 * 1024;
+ buf = xmalloc (bufsize);
+
+ strippath = -1;
+
+ val = getenv ("QUOTING_STYLE");
+ {
+ int i = val ? argmatch (val, quoting_style_args, 0, 0) : -1;
+ set_quoting_style ((struct quoting_options *) 0,
+ i < 0 ? shell_quoting_style : (enum quoting_style) i);
+ }
+
+ posixly_correct = getenv ("POSIXLY_CORRECT") != 0;
+ backup_if_mismatch = ! posixly_correct;
+ patch_get = ((val = getenv ("PATCH_GET"))
+ ? numeric_string (val, true, "PATCH_GET value")
+ : 0);
+
+ val = getenv ("SIMPLE_BACKUP_SUFFIX");
+ simple_backup_suffix = val && *val ? val : ".orig";
+
+ if ((version_control = getenv ("PATCH_VERSION_CONTROL")))
+ version_control_context = "$PATCH_VERSION_CONTROL";
+ else if ((version_control = getenv ("VERSION_CONTROL")))
+ version_control_context = "$VERSION_CONTROL";
+
+ /* Cons up the names of the global temporary files.
+ Do this before `cleanup' can possibly be called (e.g. by `pfatal'). */
+ TMPOUTNAME = make_temp ('o');
+ TMPINNAME = make_temp ('i');
+ TMPREJNAME = make_temp ('r');
+ TMPPATNAME = make_temp ('p');
+
+ /* parse switches */
+ Argc = argc;
+ Argv = argv;
+ get_some_switches();
+
+ if (make_backups | backup_if_mismatch)
+ backup_type = get_version (version_control_context, version_control);
+
+ init_backup_hash_table ();
+ init_output (outfile, 0, &outstate);
+
+ /* Make sure we clean up in case of disaster. */
+ set_signals (false);
+
+ if (inname && outfile)
+ {
+ apply_empty_patch = true;
+ inerrno = -1;
+ }
+ for (
+ open_patch_file (patchname);
+ there_is_another_patch (! (inname || posixly_correct))
+ || apply_empty_patch;
+ reinitialize_almost_everything(),
+ apply_empty_patch = false
+ ) { /* for each patch in patch file */
+ int hunk = 0;
+ int failed = 0;
+ bool mismatch = false;
+ char *outname = NULL;
+
+ if (! skip_rest_of_patch)
+ {
+ outname = outfile ? outfile : inname;
+ get_input_file (inname, outname);
+ }
+
+ if (diff_type == ED_DIFF) {
+ outstate.zero_output = false;
+ somefailed |= skip_rest_of_patch;
+ do_ed_script (outstate.ofp);
+ if (! dry_run && ! outfile && ! skip_rest_of_patch)
+ {
+ struct stat statbuf;
+ if (stat (TMPOUTNAME, &statbuf) != 0)
+ pfatal ("%s", TMPOUTNAME);
+ outstate.zero_output = statbuf.st_size == 0;
+ }
+ } else {
+ int got_hunk;
+ bool apply_anyway = merge; /* don't try to reverse when merging */
+
+ /* initialize the patched file */
+ if (! skip_rest_of_patch && ! outfile)
+ {
+ int exclusive = TMPOUTNAME_needs_removal ? 0 : O_EXCL;
+ TMPOUTNAME_needs_removal = 1;
+ init_output (TMPOUTNAME, exclusive, &outstate);
+ }
+
+ /* initialize reject file */
+ init_reject ();
+
+ /* find out where all the lines are */
+ if (!skip_rest_of_patch)
+ scan_input (inname);
+
+ /* from here on, open no standard i/o files, because malloc */
+ /* might misfire and we can't catch it easily */
+
+ /* apply each hunk of patch */
+ while (0 < (got_hunk = another_hunk (diff_type, reverse)))
+ {
+ LINENUM where = 0; /* Pacify `gcc -Wall'. */
+ LINENUM newwhere;
+ LINENUM fuzz = 0;
+ LINENUM mymaxfuzz;
+
+ if (merge)
+ {
+ /* When in merge mode, don't apply with fuzz. */
+ mymaxfuzz = 0;
+ }
+ else
+ {
+ LINENUM prefix_context = pch_prefix_context ();
+ LINENUM suffix_context = pch_suffix_context ();
+ LINENUM context = (prefix_context < suffix_context
+ ? suffix_context : prefix_context);
+ mymaxfuzz = (maxfuzz < context ? maxfuzz : context);
+ }
+
+ hunk++;
+ if (!skip_rest_of_patch) {
+ do {
+ where = locate_hunk(fuzz);
+ if (! where || fuzz || in_offset)
+ mismatch = true;
+ if (hunk == 1 && ! where && ! (force | apply_anyway)
+ && reverse == reverse_flag_specified) {
+ /* dwim for reversed patch? */
+ if (!pch_swap()) {
+ say (
+"Not enough memory to try swapped hunk! Assuming unswapped.\n");
+ continue;
+ }
+ /* Try again. */
+ where = locate_hunk (fuzz);
+ if (where
+ && (ok_to_reverse
+ ("%s patch detected!",
+ (reverse
+ ? "Unreversed"
+ : "Reversed (or previously applied)"))))
+ reverse = ! reverse;
+ else
+ {
+ /* Put it back to normal. */
+ if (! pch_swap ())
+ fatal ("lost hunk on alloc error!");
+ if (where)
+ {
+ apply_anyway = true;
+ fuzz--; /* Undo `++fuzz' below. */
+ where = 0;
+ }
+ }
+ }
+ } while (!skip_rest_of_patch && !where
+ && ++fuzz <= mymaxfuzz);
+
+ if (skip_rest_of_patch) { /* just got decided */
+ if (outstate.ofp && ! outfile)
+ {
+ fclose (outstate.ofp);
+ outstate.ofp = 0;
+ }
+ }
+ }
+
+ newwhere = (where ? where : pch_first()) + out_offset;
+ if (skip_rest_of_patch
+ || (merge && ! merge_hunk (hunk, &outstate, where,
+ &somefailed))
+ || (! merge
+ && ((where == 1 && pch_says_nonexistent (reverse) == 2
+ && instat.st_size)
+ || ! where
+ || ! apply_hunk (&outstate, where))))
+ {
+ abort_hunk (! failed, reverse);
+ failed++;
+ if (verbosity == VERBOSE ||
+ (! skip_rest_of_patch && verbosity != SILENT))
+ say ("Hunk #%d %s at %s.\n", hunk,
+ skip_rest_of_patch ? "ignored" : "FAILED",
+ format_linenum (numbuf, newwhere));
+ }
+ else if (! merge &&
+ (verbosity == VERBOSE
+ || (verbosity != SILENT && (fuzz || in_offset))))
+ {
+ say ("Hunk #%d succeeded at %s", hunk,
+ format_linenum (numbuf, newwhere));
+ if (fuzz)
+ say (" with fuzz %s", format_linenum (numbuf, fuzz));
+ if (in_offset)
+ say (" (offset %s line%s)",
+ format_linenum (numbuf, in_offset),
+ "s" + (in_offset == 1));
+ say (".\n");
+ }
+ }
+
+ if (!skip_rest_of_patch)
+ {
+ if (got_hunk < 0 && using_plan_a)
+ {
+ if (outfile)
+ fatal ("out of memory using Plan A");
+ say ("\n\nRan out of memory using Plan A -- trying again...\n\n");
+ if (outstate.ofp)
+ {
+ fclose (outstate.ofp);
+ outstate.ofp = 0;
+ }
+ fclose (rejfp);
+ continue;
+ }
+
+ /* Finish spewing out the new file. */
+ if (! spew_output (&outstate, &outst))
+ {
+ say ("Skipping patch.\n");
+ skip_rest_of_patch = true;
+ }
+ }
+ }
+
+ /* and put the output where desired */
+ ignore_signals ();
+ if (! skip_rest_of_patch && ! outfile) {
+ bool backup = make_backups
+ || (backup_if_mismatch && (mismatch | failed));
+
+ if (outstate.zero_output
+ && (remove_empty_files
+ || (pch_says_nonexistent (! reverse) == 2
+ && ! posixly_correct)))
+ {
+ if (verbosity == VERBOSE)
+ say ("Removing file %s%s\n", quotearg (outname),
+ dry_run ? " and any empty ancestor directories" : "");
+ if (! dry_run)
+ {
+ move_file (0, 0, 0, outname, 0, backup);
+ removedirs (outname);
+ }
+ }
+ else
+ {
+ if (! outstate.zero_output
+ && pch_says_nonexistent (! reverse)
+ && ! (merge && somefailed))
+ {
+ mismatch = true;
+ if (verbosity != SILENT)
+ say ("File %s is not empty after patch, as expected\n",
+ quotearg (outname));
+ }
+
+ if (! dry_run)
+ {
+ /* Avoid replacing files when nothing has changed. */
+ if (failed < hunk || diff_type == ED_DIFF)
+ {
+ time_t t;
+
+ move_file (TMPOUTNAME, &TMPOUTNAME_needs_removal, &outst,
+ outname, instat.st_mode, backup);
+
+ if ((set_time | set_utc)
+ && (t = pch_timestamp (! reverse)) != (time_t) -1)
+ {
+ struct utimbuf utimbuf;
+ utimbuf.actime = utimbuf.modtime = t;
+
+ if (! force && ! inerrno
+ && pch_says_nonexistent (reverse) != 2
+ && (t = pch_timestamp (reverse)) != (time_t) -1
+ && t != instat.st_mtime)
+ say ("Not setting time of file %s "
+ "(time mismatch)\n",
+ quotearg (outname));
+ else if (! force && (mismatch | failed))
+ say ("Not setting time of file %s "
+ "(contents mismatch)\n",
+ quotearg (outname));
+ else if (utime (outname, &utimbuf) != 0)
+ pfatal ("Can't set timestamp on file %s",
+ quotearg (outname));
+ }
+
+ if (! inerrno)
+ {
+ if (chmod (outname, instat.st_mode) != 0)
+ pfatal ("Can't set permissions on file %s",
+ quotearg (outname));
+ if (geteuid () != instat.st_gid)
+ {
+ /* Fails if we are not in group instat.st_gid. */
+ chown (outname, -1, instat.st_gid);
+ }
+ /* FIXME: There may be other attributes to preserve. */
+ }
+ }
+ else
+ create_backup (outname, 0, 0, true);
+ }
+ }
+ }
+ if (diff_type != ED_DIFF) {
+ struct stat rejst;
+
+ if ((failed && fstat (fileno (rejfp), &rejst) != 0)
+ || fclose (rejfp) != 0)
+ write_fatal ();
+ if (failed) {
+ somefailed = true;
+ say ("%d out of %d hunk%s %s", failed, hunk, "s" + (hunk == 1),
+ skip_rest_of_patch ? "ignored" : "FAILED");
+ if (outname && (! rejname || strcmp (rejname, "-") != 0)) {
+ char *rej = rejname;
+ if (!rejname) {
+ /* FIXME: This should really be done differnely! */
+ const char *s = simple_backup_suffix;
+ size_t len;
+ simple_backup_suffix = ".rej";
+ rej = find_backup_file_name (outname, simple_backups);
+ len = strlen (rej);
+ if (rej[len - 1] == '~')
+ rej[len - 1] = '#';
+ simple_backup_suffix = s;
+ }
+ say (" -- saving rejects to file %s\n", quotearg (rej));
+ if (! dry_run)
+ {
+ if (rejname)
+ {
+ if (! written_to_rejname)
+ {
+ copy_file (TMPREJNAME, rejname, 0, 0, 0666, true);
+ written_to_rejname = true;
+ }
+ else
+ append_to_file (TMPREJNAME, rejname);
+ }
+ else
+ {
+ struct stat oldst;
+ int olderrno;
+
+ olderrno = stat (rej, &oldst) ? errno : 0;
+ if (olderrno && olderrno != ENOENT)
+ write_fatal ();
+ if (! olderrno && file_already_seen (&oldst))
+ append_to_file (TMPREJNAME, rej);
+ else
+ move_file (TMPREJNAME, &TMPREJNAME_needs_removal,
+ &rejst, rej, 0666, false);
+ }
+ }
+ if (!rejname)
+ free (rej);
+ } else
+ say ("\n");
+ }
+ }
+ set_signals (true);
+ }
+ if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0))
+ write_fatal ();
+ cleanup ();
+ if (somefailed)
+ exit (1);
+ return 0;
+}
+
+/* Prepare to find the next patch to do in the patch file. */
+
+static void
+reinitialize_almost_everything (void)
+{
+ re_patch();
+ re_input();
+
+ input_lines = 0;
+ last_frozen_line = 0;
+
+ if (inname && ! explicit_inname) {
+ free (inname);
+ inname = 0;
+ }
+
+ in_offset = 0;
+ out_offset = 0;
+
+ diff_type = NO_DIFF;
+
+ if (revision) {
+ free(revision);
+ revision = 0;
+ }
+
+ reverse = reverse_flag_specified;
+ skip_rest_of_patch = false;
+}
+
+static char const shortopts[] = "bB:cd:D:eEfF:g:i:l"
+#if 0 && defined(ENABLE_MERGE)
+ "m"
+#endif
+ "nNo:p:r:RstTuvV:x:Y:z:Z";
+
+static struct option const longopts[] =
+{
+ {"backup", no_argument, NULL, 'b'},
+ {"prefix", required_argument, NULL, 'B'},
+ {"context", no_argument, NULL, 'c'},
+ {"directory", required_argument, NULL, 'd'},
+ {"ifdef", required_argument, NULL, 'D'},
+ {"ed", no_argument, NULL, 'e'},
+ {"remove-empty-files", no_argument, NULL, 'E'},
+ {"force", no_argument, NULL, 'f'},
+ {"fuzz", required_argument, NULL, 'F'},
+ {"get", no_argument, NULL, 'g'},
+ {"input", required_argument, NULL, 'i'},
+ {"ignore-whitespace", no_argument, NULL, 'l'},
+#ifdef ENABLE_MERGE
+ {"merge", no_argument, NULL, 'm'},
+#endif
+ {"normal", no_argument, NULL, 'n'},
+ {"forward", no_argument, NULL, 'N'},
+ {"output", required_argument, NULL, 'o'},
+ {"strip", required_argument, NULL, 'p'},
+ {"reject-file", required_argument, NULL, 'r'},
+ {"reverse", no_argument, NULL, 'R'},
+ {"quiet", no_argument, NULL, 's'},
+ {"silent", no_argument, NULL, 's'},
+ {"batch", no_argument, NULL, 't'},
+ {"set-time", no_argument, NULL, 'T'},
+ {"unified", no_argument, NULL, 'u'},
+ {"version", no_argument, NULL, 'v'},
+ {"version-control", required_argument, NULL, 'V'},
+ {"debug", required_argument, NULL, 'x'},
+ {"basename-prefix", required_argument, NULL, 'Y'},
+ {"suffix", required_argument, NULL, 'z'},
+ {"set-utc", no_argument, NULL, 'Z'},
+ {"dry-run", no_argument, NULL, CHAR_MAX + 1},
+ {"verbose", no_argument, NULL, CHAR_MAX + 2},
+ {"binary", no_argument, NULL, CHAR_MAX + 3},
+ {"help", no_argument, NULL, CHAR_MAX + 4},
+ {"backup-if-mismatch", no_argument, NULL, CHAR_MAX + 5},
+ {"no-backup-if-mismatch", no_argument, NULL, CHAR_MAX + 6},
+ {"posix", no_argument, NULL, CHAR_MAX + 7},
+ {"quoting-style", required_argument, NULL, CHAR_MAX + 8},
+ {"reject-format", required_argument, NULL, CHAR_MAX + 9},
+ {NULL, no_argument, NULL, 0}
+};
+
+static char const *const option_help[] =
+{
+"Input options:",
+"",
+" -p NUM --strip=NUM Strip NUM leading components from file names.",
+" -F LINES --fuzz LINES Set the fuzz factor to LINES for inexact matching.",
+" -l --ignore-whitespace Ignore white space changes between patch and input.",
+"",
+" -c --context Interpret the patch as a context difference.",
+" -e --ed Interpret the patch as an ed script.",
+" -n --normal Interpret the patch as a normal difference.",
+" -u --unified Interpret the patch as a unified difference.",
+"",
+" -N --forward Ignore patches that appear to be reversed or already applied.",
+" -R --reverse Assume patches were created with old and new files swapped.",
+"",
+" -i PATCHFILE --input=PATCHFILE Read patch from PATCHFILE instead of stdin.",
+"",
+"Output options:",
+"",
+" -o FILE --output=FILE Output patched files to FILE.",
+" -r FILE --reject-file=FILE Output rejects to FILE.",
+"",
+" -D NAME --ifdef=NAME Make merged if-then-else output using NAME.",
+#ifdef ENABLE_MERGE
+" -m --merge Merge using conflict markers instead of creating reject files.",
+#endif
+" -E --remove-empty-files Remove output files that are empty after patching.",
+"",
+" -Z --set-utc Set times of patched files, assuming diff uses UTC (GMT).",
+" -T --set-time Likewise, assuming local time.",
+"",
+" --quoting-style=WORD output file names using quoting style WORD.",
+" Valid WORDs are: literal, shell, shell-always, c, escape.",
+" Default is taken from QUOTING_STYLE env variable, or 'shell' if unset.",
+"",
+"Backup and version control options:",
+"",
+" -b --backup Back up the original contents of each file.",
+" --backup-if-mismatch Back up if the patch does not match exactly.",
+" --no-backup-if-mismatch Back up mismatches only if otherwise requested.",
+"",
+" -V STYLE --version-control=STYLE Use STYLE version control.",
+" STYLE is either 'simple', 'numbered', or 'existing'.",
+" -B PREFIX --prefix=PREFIX Prepend PREFIX to backup file names.",
+" -Y PREFIX --basename-prefix=PREFIX Prepend PREFIX to backup file basenames.",
+" -z SUFFIX --suffix=SUFFIX Append SUFFIX to backup file names.",
+"",
+" -g NUM --get=NUM Get files from RCS etc. if positive; ask if negative.",
+"",
+"Miscellaneous options:",
+"",
+" -t --batch Ask no questions; skip bad-Prereq patches; assume reversed.",
+" -f --force Like -t, but ignore bad-Prereq patches, and assume unreversed.",
+" -s --quiet --silent Work silently unless an error occurs.",
+" --verbose Output extra information about the work being done.",
+" --dry-run Do not actually change any files; just print what would happen.",
+" --posix Conform to the POSIX standard.",
+"",
+" -d DIR --directory=DIR Change the working directory to DIR first.",
+" --reject-format=FORMAT Create 'context' or 'unified' rejects.",
+" --binary Read and write data in binary mode.",
+"",
+" -v --version Output version info.",
+" --help Output this help.",
+"",
+"Report bugs to <" PACKAGE_BUGREPORT ">.",
+0
+};
+
+static void
+usage (FILE *stream, int status)
+{
+ char const * const *p;
+
+ if (status != 0)
+ {
+ fprintf (stream, "%s: Try `%s --help' for more information.\n",
+ program_name, Argv[0]);
+ }
+ else
+ {
+ fprintf (stream, "Usage: %s [OPTION]... [ORIGFILE [PATCHFILE]]\n\n",
+ Argv[0]);
+ for (p = option_help; *p; p++)
+ fprintf (stream, "%s\n", *p);
+ }
+
+ exit (status);
+}
+
+/* Process switches and filenames. */
+
+static void
+get_some_switches (void)
+{
+ register int optc;
+
+ if (rejname)
+ free (rejname);
+ rejname = 0;
+ if (optind == Argc)
+ return;
+ while ((optc = getopt_long (Argc, Argv, shortopts, longopts, (int *) 0))
+ != -1) {
+ switch (optc) {
+ case 'b':
+ make_backups = true;
+ /* Special hack for backward compatibility with CVS 1.9.
+ If the last 4 args are `-b SUFFIX ORIGFILE PATCHFILE',
+ treat `-b' as if it were `-b -z'. */
+ if (Argc - optind == 3
+ && strcmp (Argv[optind - 1], "-b") == 0
+ && ! (Argv[optind + 0][0] == '-' && Argv[optind + 0][1])
+ && ! (Argv[optind + 1][0] == '-' && Argv[optind + 1][1])
+ && ! (Argv[optind + 2][0] == '-' && Argv[optind + 2][1]))
+ {
+ optarg = Argv[optind++];
+ if (verbosity != SILENT)
+ say ("warning: the `-b %s' option is obsolete; use `-b -z %s' instead\n",
+ optarg, optarg);
+ goto case_z;
+ }
+ break;
+ case 'B':
+ if (!*optarg)
+ fatal ("backup prefix is empty");
+ origprae = savestr (optarg);
+ break;
+ case 'c':
+ diff_type = CONTEXT_DIFF;
+ break;
+ case 'd':
+ if (chdir(optarg) < 0)
+ pfatal ("Can't change to directory %s", quotearg (optarg));
+ break;
+ case 'D':
+ do_defines = savestr (optarg);
+ break;
+ case 'e':
+ diff_type = ED_DIFF;
+ break;
+ case 'E':
+ remove_empty_files = true;
+ break;
+ case 'f':
+ force = true;
+ break;
+ case 'F':
+ maxfuzz = numeric_string (optarg, false, "fuzz factor");
+ break;
+ case 'g':
+ patch_get = numeric_string (optarg, true, "get option value");
+ break;
+ case 'i':
+ patchname = savestr (optarg);
+ break;
+ case 'l':
+ canonicalize = true;
+ break;
+#ifdef ENABLE_MERGE
+ case 'm':
+ merge = true;
+ break;
+#endif
+ case 'n':
+ diff_type = NORMAL_DIFF;
+ break;
+ case 'N':
+ noreverse = true;
+ break;
+ case 'o':
+ outfile = savestr (optarg);
+ break;
+ case 'p':
+ strippath = numeric_string (optarg, false, "strip count");
+ break;
+ case 'r':
+ rejname = savestr (optarg);
+ break;
+ case 'R':
+ reverse = true;
+ reverse_flag_specified = true;
+ break;
+ case 's':
+ verbosity = SILENT;
+ break;
+ case 't':
+ batch = true;
+ break;
+ case 'T':
+ set_time = true;
+ break;
+ case 'u':
+ diff_type = UNI_DIFF;
+ break;
+ case 'v':
+ version();
+ exit (0);
+ break;
+ case 'V':
+ version_control = optarg;
+ version_control_context = "--version-control or -V option";
+ break;
+#if DEBUGGING
+ case 'x':
+ debug = numeric_string (optarg, true, "debugging option");
+ break;
+#endif
+ case 'Y':
+ if (!*optarg)
+ fatal ("backup basename prefix is empty");
+ origbase = savestr (optarg);
+ break;
+ case 'z':
+ case_z:
+ if (!*optarg)
+ fatal ("backup suffix is empty");
+ origsuff = savestr (optarg);
+ break;
+ case 'Z':
+ set_utc = true;
+ break;
+ case CHAR_MAX + 1:
+ dry_run = true;
+ break;
+ case CHAR_MAX + 2:
+ verbosity = VERBOSE;
+ break;
+ case CHAR_MAX + 3:
+ no_strip_trailing_cr = true;
+#if HAVE_SETMODE_DOS
+ binary_transput = O_BINARY;
+#endif
+ break;
+ case CHAR_MAX + 4:
+ usage (stdout, 0);
+ case CHAR_MAX + 5:
+ backup_if_mismatch = true;
+ break;
+ case CHAR_MAX + 6:
+ backup_if_mismatch = false;
+ break;
+ case CHAR_MAX + 7:
+ posixly_correct = true;
+ break;
+ case CHAR_MAX + 8:
+ {
+ int i = argmatch (optarg, quoting_style_args, 0, 0);
+ if (i < 0)
+ {
+ invalid_arg ("quoting style", optarg, i);
+ usage (stderr, 2);
+ }
+ set_quoting_style ((struct quoting_options *) 0,
+ (enum quoting_style) i);
+ }
+ break;
+ case CHAR_MAX + 9:
+ if (strcmp (optarg, "context") == 0)
+ reject_format = NEW_CONTEXT_DIFF;
+ else if (strcmp (optarg, "unified") == 0)
+ reject_format = UNI_DIFF;
+ else
+ usage (stderr, 2);
+ break;
+ default:
+ usage (stderr, 2);
+ }
+ }
+
+ /* Process any filename args. */
+ if (optind < Argc)
+ {
+ inname = savestr (Argv[optind++]);
+ explicit_inname = true;
+ invc = -1;
+ if (optind < Argc)
+ {
+ patchname = savestr (Argv[optind++]);
+ if (optind < Argc)
+ {
+ fprintf (stderr, "%s: %s: extra operand\n",
+ program_name, quotearg (Argv[optind]));
+ usage (stderr, 2);
+ }
+ }
+ }
+}
+
+/* Handle STRING (possibly negative if NEGATIVE_ALLOWED is nonzero)
+ of type ARGTYPE_MSGID by converting it to an integer,
+ returning the result. */
+static int
+numeric_string (char const *string,
+ bool negative_allowed,
+ char const *argtype_msgid)
+{
+ int value = 0;
+ char const *p = string;
+ int sign = *p == '-' ? -1 : 1;
+
+ p += *p == '-' || *p == '+';
+
+ do
+ {
+ int v10 = value * 10;
+ int digit = *p - '0';
+ int signed_digit = sign * digit;
+ int next_value = v10 + signed_digit;
+
+ if (9 < (unsigned) digit)
+ fatal ("%s %s is not a number", argtype_msgid, quotearg (string));
+
+ if (v10 / 10 != value || (next_value < v10) != (signed_digit < 0))
+ fatal ("%s %s is too large", argtype_msgid, quotearg (string));
+
+ value = next_value;
+ }
+ while (*++p);
+
+ if (value < 0 && ! negative_allowed)
+ fatal ("%s %s is negative", argtype_msgid, quotearg (string));
+
+ return value;
+}
+
+/* Attempt to find the right place to apply this hunk of patch. */
+
+static LINENUM
+locate_hunk (LINENUM fuzz)
+{
+ register LINENUM first_guess = pch_first () + in_offset;
+ register LINENUM offset;
+ LINENUM pat_lines = pch_ptrn_lines();
+ LINENUM prefix_context = pch_prefix_context ();
+ LINENUM suffix_context = pch_suffix_context ();
+ LINENUM context = (prefix_context < suffix_context
+ ? suffix_context : prefix_context);
+ LINENUM prefix_fuzz = fuzz + prefix_context - context;
+ LINENUM suffix_fuzz = fuzz + suffix_context - context;
+ LINENUM max_where = input_lines - (pat_lines - suffix_fuzz) + 1;
+ LINENUM min_where = last_frozen_line + 1 - (prefix_context - prefix_fuzz);
+ LINENUM max_pos_offset = max_where - first_guess;
+ LINENUM max_neg_offset = first_guess - min_where;
+ LINENUM max_offset = (max_pos_offset < max_neg_offset
+ ? max_neg_offset : max_pos_offset);
+
+ if (!pat_lines) /* null range matches always */
+ return first_guess;
+
+ /* Do not try lines <= 0. */
+ if (first_guess <= max_neg_offset)
+ max_neg_offset = first_guess - 1;
+
+ if (prefix_fuzz < 0 && pch_first () <= 1)
+ {
+ /* Can only match start of file. */
+
+ if (suffix_fuzz < 0)
+ /* Can only match entire file. */
+ if (pat_lines != input_lines || prefix_context < last_frozen_line)
+ return 0;
+
+ offset = 1 - first_guess;
+ if (last_frozen_line <= prefix_context
+ && offset <= max_pos_offset
+ && patch_match (first_guess, offset, (LINENUM) 0, suffix_fuzz))
+ {
+ in_offset += offset;
+ return first_guess + offset;
+ }
+ else
+ return 0;
+ }
+ else if (prefix_fuzz < 0)
+ prefix_fuzz = 0;
+
+ if (suffix_fuzz < 0)
+ {
+ /* Can only match end of file. */
+ offset = first_guess - (input_lines - pat_lines + 1);
+ if (offset <= max_neg_offset
+ && patch_match (first_guess, -offset, prefix_fuzz, (LINENUM) 0))
+ {
+ in_offset -= offset;
+ return first_guess - offset;
+ }
+ else
+ return 0;
+ }
+
+ for (offset = 0; offset <= max_offset; offset++) {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ if (offset <= max_pos_offset
+ && patch_match (first_guess, offset, prefix_fuzz, suffix_fuzz)) {
+ if (debug & 1)
+ say ("Offset changing from %s to %s\n",
+ format_linenum (numbuf0, in_offset),
+ format_linenum (numbuf1, in_offset + offset));
+ in_offset += offset;
+ return first_guess+offset;
+ }
+ if (0 < offset && offset <= max_neg_offset
+ && patch_match (first_guess, -offset, prefix_fuzz, suffix_fuzz)) {
+ if (debug & 1)
+ say ("Offset changing from %s to %s\n",
+ format_linenum (numbuf0, in_offset),
+ format_linenum (numbuf1, in_offset - offset));
+ in_offset -= offset;
+ return first_guess-offset;
+ }
+ }
+ return 0;
+}
+
+static void
+mangled_patch (LINENUM old, LINENUM new)
+{
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ if (debug & 1)
+ say ("oldchar = '%c', newchar = '%c'\n",
+ pch_char (old), pch_char (new));
+ fatal ("Out-of-sync patch, lines %s,%s -- mangled text or line numbers, "
+ "maybe?",
+ format_linenum (numbuf0, pch_hunk_beg () + old),
+ format_linenum (numbuf1, pch_hunk_beg () + new));
+}
+
+/* Output a line number range in unified format. */
+
+static void
+print_unidiff_range (FILE *fp, LINENUM start, LINENUM count)
+{
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+
+ switch (count)
+ {
+ case 0:
+ fprintf (fp, "%s,0", format_linenum (numbuf0, start - 1));
+ break;
+
+ case 1:
+ fprintf (fp, "%s", format_linenum (numbuf0, start));
+ break;
+
+ default:
+ fprintf (fp, "%s,%s",
+ format_linenum (numbuf0, start),
+ format_linenum (numbuf1, count));
+ break;
+ }
+}
+
+static void
+print_header_line (FILE *fp, const char *tag, bool reverse)
+{
+ const char *name = pch_name (reverse);
+ const char *timestr = pch_timestr (reverse);
+
+ /* FIXME: include timestamp as well. */
+ fprintf (fp, "%s %s%s\n", tag, name ? name : "/dev/null",
+ timestr ? timestr : "");
+}
+
+/* Produce unified reject files */
+
+static void
+abort_hunk_unified (bool header, bool reverse)
+{
+ FILE *fp = rejfp;
+ register LINENUM old = 1;
+ register LINENUM lastline = pch_ptrn_lines ();
+ register LINENUM new = lastline + 1;
+
+ if (header)
+ {
+ if (pch_name (INDEX))
+ fprintf(fp, "Index: %s\n", pch_name (INDEX));
+ print_header_line (rejfp, "---", reverse);
+ print_header_line (rejfp, "+++", ! reverse);
+ }
+
+ /* Add out_offset to guess the same as the previous successful hunk. */
+ fprintf (fp, "@@ -");
+ print_unidiff_range (fp, pch_first () + out_offset, lastline);
+ fprintf (fp, " +");
+ print_unidiff_range (fp, pch_newfirst () + out_offset, pch_repl_lines ());
+ fprintf (fp, " @@\n");
+
+ while (pch_char (new) == '=' || pch_char (new) == '\n')
+ new++;
+
+ if (diff_type != UNI_DIFF)
+ pch_normalize (UNI_DIFF);
+
+ for (; ; old++, new++)
+ {
+ for (; pch_char (old) == '-'; old++)
+ {
+ fputc ('-', fp);
+ pch_write_line (old, fp);
+ }
+ for (; pch_char (new) == '+'; new++)
+ {
+ fputc ('+', fp);
+ pch_write_line (new, fp);
+ }
+
+ if (old > lastline)
+ break;
+
+ if (pch_char (new) != pch_char (old))
+ mangled_patch (old, new);
+
+ fputc (' ', fp);
+ pch_write_line (old, fp);
+ }
+ if (pch_char (new) != '^')
+ mangled_patch (old, new);
+}
+
+/* Output the rejected patch in context format. */
+
+static void
+abort_hunk_context (bool header, bool reverse)
+{
+ register LINENUM i;
+ register LINENUM pat_end = pch_end ();
+ /* add in out_offset to guess the same as the previous successful hunk */
+ LINENUM oldfirst = pch_first() + out_offset;
+ LINENUM newfirst = pch_newfirst() + out_offset;
+ LINENUM oldlast = oldfirst + pch_ptrn_lines() - 1;
+ LINENUM newlast = newfirst + pch_repl_lines() - 1;
+ char const *stars =
+ (int) NEW_CONTEXT_DIFF <= (int) diff_type ? " ****" : "";
+ char const *minuses =
+ (int) NEW_CONTEXT_DIFF <= (int) diff_type ? " ----" : " -----";
+ char const *c_function = pch_c_function();
+
+ if (diff_type == UNI_DIFF)
+ pch_normalize (NEW_CONTEXT_DIFF);
+
+ if (header)
+ {
+ if (pch_name (INDEX))
+ fprintf(rejfp, "Index: %s\n", pch_name (INDEX));
+ print_header_line (rejfp, "***", reverse);
+ print_header_line (rejfp, "---", ! reverse);
+ }
+ fprintf(rejfp, "***************%s\n", c_function ? c_function : "");
+ for (i=0; i<=pat_end; i++) {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ switch (pch_char(i)) {
+ case '*':
+ if (oldlast < oldfirst)
+ fprintf(rejfp, "*** 0%s\n", stars);
+ else if (oldlast == oldfirst)
+ fprintf (rejfp, "*** %s%s\n",
+ format_linenum (numbuf0, oldfirst), stars);
+ else
+ fprintf (rejfp, "*** %s,%s%s\n",
+ format_linenum (numbuf0, oldfirst),
+ format_linenum (numbuf1, oldlast), stars);
+ break;
+ case '=':
+ if (newlast < newfirst)
+ fprintf(rejfp, "--- 0%s\n", minuses);
+ else if (newlast == newfirst)
+ fprintf (rejfp, "--- %s%s\n",
+ format_linenum (numbuf0, newfirst), minuses);
+ else
+ fprintf (rejfp, "--- %s,%s%s\n",
+ format_linenum (numbuf0, newfirst),
+ format_linenum (numbuf1, newlast), minuses);
+ break;
+ case ' ': case '-': case '+': case '!':
+ fprintf (rejfp, "%c ", pch_char (i));
+ /* fall into */
+ case '\n':
+ pch_write_line (i, rejfp);
+ break;
+ default:
+ fatal ("fatal internal error in abort_hunk_context");
+ }
+ if (ferror (rejfp))
+ write_fatal ();
+ }
+}
+
+/* Output the rejected hunk. */
+
+static void
+abort_hunk (bool header, bool reverse)
+{
+ if (reject_format == UNI_DIFF
+ || (reject_format == NO_DIFF && diff_type == UNI_DIFF))
+ abort_hunk_unified (header, reverse);
+ else
+ abort_hunk_context (header, reverse);
+}
+
+/* We found where to apply it (we hope), so do it. */
+
+static bool
+apply_hunk (struct outstate *outstate, LINENUM where)
+{
+ register LINENUM old = 1;
+ register LINENUM lastline = pch_ptrn_lines ();
+ register LINENUM new = lastline+1;
+ register enum {OUTSIDE, IN_IFNDEF, IN_IFDEF, IN_ELSE} def_state = OUTSIDE;
+ register char const *R_do_defines = do_defines;
+ register LINENUM pat_end = pch_end ();
+ register FILE *fp = outstate->ofp;
+
+ where--;
+ while (pch_char(new) == '=' || pch_char(new) == '\n')
+ new++;
+
+ while (old <= lastline) {
+ if (pch_char(old) == '-') {
+ assert (outstate->after_newline);
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ if (R_do_defines) {
+ if (def_state == OUTSIDE) {
+ fprintf (fp, outstate->after_newline + not_defined,
+ R_do_defines);
+ def_state = IN_IFNDEF;
+ }
+ else if (def_state == IN_IFDEF) {
+ fputs (outstate->after_newline + else_defined, fp);
+ def_state = IN_ELSE;
+ }
+ if (ferror (fp))
+ write_fatal ();
+ outstate->after_newline = pch_write_line (old, fp);
+ outstate->zero_output = false;
+ }
+ last_frozen_line++;
+ old++;
+ }
+ else if (new > pat_end) {
+ break;
+ }
+ else if (pch_char(new) == '+') {
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ if (R_do_defines) {
+ if (def_state == IN_IFNDEF) {
+ fputs (outstate->after_newline + else_defined, fp);
+ def_state = IN_ELSE;
+ }
+ else if (def_state == OUTSIDE) {
+ fprintf (fp, outstate->after_newline + if_defined,
+ R_do_defines);
+ def_state = IN_IFDEF;
+ }
+ if (ferror (fp))
+ write_fatal ();
+ }
+ outstate->after_newline = pch_write_line (new, fp);
+ outstate->zero_output = false;
+ new++;
+ }
+ else if (pch_char(new) != pch_char(old))
+ mangled_patch (old, new);
+ else if (pch_char(new) == '!') {
+ assert (outstate->after_newline);
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ assert (outstate->after_newline);
+ if (R_do_defines) {
+ fprintf (fp, 1 + not_defined, R_do_defines);
+ if (ferror (fp))
+ write_fatal ();
+ def_state = IN_IFNDEF;
+ }
+
+ do
+ {
+ if (R_do_defines) {
+ outstate->after_newline = pch_write_line (old, fp);
+ }
+ last_frozen_line++;
+ old++;
+ }
+ while (pch_char (old) == '!');
+
+ if (R_do_defines) {
+ fputs (outstate->after_newline + else_defined, fp);
+ if (ferror (fp))
+ write_fatal ();
+ def_state = IN_ELSE;
+ }
+
+ do
+ {
+ outstate->after_newline = pch_write_line (new, fp);
+ new++;
+ }
+ while (pch_char (new) == '!');
+ outstate->zero_output = false;
+ }
+ else {
+ assert(pch_char(new) == ' ');
+ old++;
+ new++;
+ if (R_do_defines && def_state != OUTSIDE) {
+ fputs (outstate->after_newline + end_defined, fp);
+ if (ferror (fp))
+ write_fatal ();
+ outstate->after_newline = true;
+ def_state = OUTSIDE;
+ }
+ }
+ }
+ if (new <= pat_end && pch_char(new) == '+') {
+ if (! copy_till (outstate, where + old - 1))
+ return false;
+ if (R_do_defines) {
+ if (def_state == OUTSIDE) {
+ fprintf (fp, outstate->after_newline + if_defined,
+ R_do_defines);
+ def_state = IN_IFDEF;
+ }
+ else if (def_state == IN_IFNDEF) {
+ fputs (outstate->after_newline + else_defined, fp);
+ def_state = IN_ELSE;
+ }
+ if (ferror (fp))
+ write_fatal ();
+ outstate->zero_output = false;
+ }
+
+ do
+ {
+ if (! outstate->after_newline && putc ('\n', fp) == EOF)
+ write_fatal ();
+ outstate->after_newline = pch_write_line (new, fp);
+ outstate->zero_output = false;
+ new++;
+ }
+ while (new <= pat_end && pch_char (new) == '+');
+ }
+ if (R_do_defines && def_state != OUTSIDE) {
+ fputs (outstate->after_newline + end_defined, fp);
+ if (ferror (fp))
+ write_fatal ();
+ outstate->after_newline = true;
+ }
+ out_offset += pch_repl_lines() - pch_ptrn_lines ();
+ return true;
+}
+
+/* Create an output file. */
+
+static FILE *
+create_output_file (char const *name, int open_flags)
+{
+ int fd = create_file (name, O_WRONLY | binary_transput | open_flags,
+ instat.st_mode, true);
+ FILE *f = fdopen (fd, binary_transput ? "wb" : "w");
+ if (! f)
+ pfatal ("Can't create file %s", quotearg (name));
+ return f;
+}
+
+/* Open the new file. */
+
+static void
+init_output (char const *name, int open_flags, struct outstate *outstate)
+{
+ if (! name)
+ outstate->ofp = (FILE *) 0;
+ else if (strcmp (name, "-") != 0)
+ outstate->ofp = create_output_file (name, open_flags);
+ else
+ {
+ int stdout_dup = dup (fileno (stdout));
+ outstate->ofp = fdopen (stdout_dup, "a");
+ if (stdout_dup == -1 || ! outstate->ofp)
+ pfatal ("Failed to duplicate standard output");
+ if (dup2 (fileno (stderr), fileno (stdout)) == -1)
+ pfatal ("Failed to redirect messages to standard error");
+ }
+
+ outstate->after_newline = true;
+ outstate->zero_output = true;
+}
+
+/* Open a file to put hunks we can't locate. */
+
+static void
+init_reject (void)
+{
+ int exclusive = TMPREJNAME_needs_removal ? 0 : O_EXCL;
+ TMPREJNAME_needs_removal = 1;
+ rejfp = create_output_file (TMPREJNAME, exclusive);
+}
+
+/* Copy input file to output, up to wherever hunk is to be applied. */
+
+bool
+copy_till (register struct outstate *outstate, register LINENUM lastline)
+{
+ register LINENUM R_last_frozen_line = last_frozen_line;
+ register FILE *fp = outstate->ofp;
+ register char const *s;
+ size_t size;
+
+ if (R_last_frozen_line > lastline)
+ {
+ say ("misordered hunks! output would be garbled\n");
+ return false;
+ }
+ while (R_last_frozen_line < lastline)
+ {
+ s = ifetch (++R_last_frozen_line, false, &size);
+ if (size)
+ {
+ if ((! outstate->after_newline && putc ('\n', fp) == EOF)
+ || ! fwrite (s, sizeof *s, size, fp))
+ write_fatal ();
+ outstate->after_newline = s[size - 1] == '\n';
+ outstate->zero_output = false;
+ }
+ }
+ last_frozen_line = R_last_frozen_line;
+ return true;
+}
+
+/* Finish copying the input file to the output file. */
+
+static bool
+spew_output (struct outstate *outstate, struct stat *st)
+{
+ if (debug & 256)
+ {
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ say ("il=%s lfl=%s\n",
+ format_linenum (numbuf0, input_lines),
+ format_linenum (numbuf1, last_frozen_line));
+ }
+
+ if (last_frozen_line < input_lines)
+ if (! copy_till (outstate, input_lines))
+ return false;
+
+ if (outstate->ofp && ! outfile)
+ {
+ if (fflush (outstate->ofp) != 0
+ || fstat (fileno (outstate->ofp), st) != 0
+ || fclose (outstate->ofp) != 0)
+ write_fatal ();
+ outstate->ofp = 0;
+ }
+
+ return true;
+}
+
+/* Does the patch pattern match at line base+offset? */
+
+static bool
+patch_match (LINENUM base, LINENUM offset,
+ LINENUM prefix_fuzz, LINENUM suffix_fuzz)
+{
+ register LINENUM pline = 1 + prefix_fuzz;
+ register LINENUM iline;
+ register LINENUM pat_lines = pch_ptrn_lines () - suffix_fuzz;
+ size_t size;
+ register char const *p;
+
+ for (iline=base+offset+prefix_fuzz; pline <= pat_lines; pline++,iline++) {
+ p = ifetch (iline, offset >= 0, &size);
+ if (canonicalize) {
+ if (!similar(p, size,
+ pfetch(pline),
+ pch_line_len(pline) ))
+ return false;
+ }
+ else if (size != pch_line_len (pline)
+ || memcmp (p, pfetch (pline), size) != 0)
+ return false;
+ }
+ return true;
+}
+
+/* Do two lines match with canonicalized white space? */
+
+bool
+similar (register char const *a, register size_t alen,
+ register char const *b, register size_t blen)
+{
+ /* Ignore presence or absence of trailing newlines. */
+ alen -= alen && a[alen - 1] == '\n';
+ blen -= blen && b[blen - 1] == '\n';
+
+ for (;;)
+ {
+ if (!blen || (*b == ' ' || *b == '\t'))
+ {
+ while (blen && (*b == ' ' || *b == '\t'))
+ b++, blen--;
+ if (alen)
+ {
+ if (!(*a == ' ' || *a == '\t'))
+ return false;
+ do a++, alen--;
+ while (alen && (*a == ' ' || *a == '\t'));
+ }
+ if (!alen || !blen)
+ return alen == blen;
+ }
+ else if (!alen || *a++ != *b++)
+ return false;
+ else
+ alen--, blen--;
+ }
+}
+
+/* Make a temporary file. */
+
+#if HAVE_MKTEMP && ! HAVE_DECL_MKTEMP && ! defined mktemp
+char *mktemp (char *);
+#endif
+
+#ifndef TMPDIR
+#define TMPDIR "/tmp"
+#endif
+
+static char const *
+make_temp (char letter)
+{
+ char *r;
+#if HAVE_MKTEMP
+ char const *tmpdir = getenv ("TMPDIR"); /* Unix tradition */
+ if (!tmpdir) tmpdir = getenv ("TMP"); /* DOS tradition */
+ if (!tmpdir) tmpdir = getenv ("TEMP"); /* another DOS tradition */
+ if (!tmpdir) tmpdir = TMPDIR;
+ r = xmalloc (strlen (tmpdir) + 10);
+ sprintf (r, "%s/p%cXXXXXX", tmpdir, letter);
+
+ /* It is OK to use mktemp here, since the rest of the code always
+ opens temp files with O_EXCL. It might be better to use mkstemp
+ to avoid some DoS problems, but simply substituting mkstemp for
+ mktemp here will not fix the DoS problems; a more extensive
+ change would be needed. */
+ mktemp (r);
+
+ if (!*r)
+ pfatal ("mktemp");
+#else
+ r = xmalloc (L_tmpnam);
+ if (! (tmpnam (r) == r && *r))
+ pfatal ("tmpnam");
+#endif
+ return r;
+}
+
+/* Fatal exit with cleanup. */
+
+void
+fatal_exit (int sig)
+{
+ cleanup ();
+
+ if (sig)
+ exit_with_signal (sig);
+
+ exit (2);
+}
+
+static void
+remove_if_needed (char const *name, int volatile *needs_removal)
+{
+ if (*needs_removal)
+ {
+ unlink (name);
+ *needs_removal = 0;
+ }
+}
+
+static void
+cleanup (void)
+{
+ remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal);
+ remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal);
+ remove_if_needed (TMPPATNAME, &TMPPATNAME_needs_removal);
+ remove_if_needed (TMPREJNAME, &TMPREJNAME_needs_removal);
+}
--- /dev/null
+/* reading patches */
+
+/* Copyright (C) 1986, 1987, 1988 Larry Wall
+
+ Copyright (C) 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 2001,
+ 2002, 2003, 2006, 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#define XTERN extern
+#include <common.h>
+#include <backupfile.h>
+#include <dirname.h>
+#include <inp.h>
+#include <quotearg.h>
+#include <util.h>
+#undef XTERN
+#define XTERN
+#include <pch.h>
+
+#define INITHUNKMAX 125 /* initial dynamic allocation size */
+
+/* Patch (diff listing) abstract type. */
+
+static FILE *pfp; /* patch file pointer */
+static int p_says_nonexistent[2]; /* [0] for old file, [1] for new:
+ 0 for existent and nonempty,
+ 1 for existent and probably (but not necessarily) empty,
+ 2 for nonexistent */
+static int p_rfc934_nesting; /* RFC 934 nesting level */
+static char *p_name[3]; /* filenames in patch headers */
+static time_t p_timestamp[2]; /* timestamps in patch headers */
+static char *p_timestr[2]; /* timestamps as strings */
+static off_t p_filesize; /* size of the patch file */
+static LINENUM p_first; /* 1st line number */
+static LINENUM p_newfirst; /* 1st line number of replacement */
+static LINENUM p_ptrn_lines; /* # lines in pattern */
+static LINENUM p_repl_lines; /* # lines in replacement text */
+static LINENUM p_end = -1; /* last line in hunk */
+static LINENUM p_max; /* max allowed value of p_end */
+static LINENUM p_prefix_context; /* # of prefix context lines */
+static LINENUM p_suffix_context; /* # of suffix context lines */
+static LINENUM p_input_line; /* current line # from patch file */
+static char **p_line; /* the text of the hunk */
+static size_t *p_len; /* line length including \n if any */
+static char *p_Char; /* +, -, and ! */
+static LINENUM hunkmax = INITHUNKMAX; /* size of above arrays */
+static size_t p_indent; /* indent to patch */
+static bool p_strip_trailing_cr; /* true if stripping trailing \r */
+static bool p_pass_comments_through; /* true if not ignoring # lines */
+static file_offset p_base; /* where to intuit this time */
+static LINENUM p_bline; /* line # of p_base */
+static file_offset p_start; /* where intuit found a patch */
+static LINENUM p_sline; /* and the line number for it */
+static LINENUM p_hunk_beg; /* line number of current hunk */
+static LINENUM p_efake = -1; /* end of faked up lines--don't free */
+static LINENUM p_bfake = -1; /* beg of faked up lines */
+static char *p_c_function; /* the C function a hunk is in */
+
+static char *scan_linenum (char *, LINENUM *);
+static enum diff intuit_diff_type (bool);
+static enum nametype best_name (char * const *, int const *);
+static int prefix_components (char *, bool);
+static size_t pget_line (size_t, int, bool, bool);
+static size_t get_line (void);
+static bool incomplete_line (void);
+static bool grow_hunkmax (void);
+static void malformed (void) __attribute__ ((noreturn));
+static void next_intuit_at (file_offset, LINENUM);
+static void skip_to (file_offset, LINENUM);
+static char get_ed_command_letter (char const *);
+
+/* Prepare to look for the next patch in the patch file. */
+
+void
+re_patch (void)
+{
+ p_first = 0;
+ p_newfirst = 0;
+ p_ptrn_lines = 0;
+ p_repl_lines = 0;
+ p_end = -1;
+ p_max = 0;
+ p_indent = 0;
+ p_strip_trailing_cr = false;
+}
+
+/* Open the patch file at the beginning of time. */
+
+void
+open_patch_file (char const *filename)
+{
+ file_offset file_pos = 0;
+ struct stat st;
+ if (!filename || !*filename || strEQ (filename, "-"))
+ {
+ file_offset stdin_pos;
+#if HAVE_SETMODE_DOS
+ if (binary_transput)
+ {
+ if (isatty (STDIN_FILENO))
+ fatal ("cannot read binary data from tty on this platform");
+ setmode (STDIN_FILENO, O_BINARY);
+ }
+#endif
+ if (fstat (STDIN_FILENO, &st) != 0)
+ pfatal ("fstat");
+ if (S_ISREG (st.st_mode) && (stdin_pos = file_tell (stdin)) != -1)
+ {
+ pfp = stdin;
+ file_pos = stdin_pos;
+ }
+ else
+ {
+ size_t charsread;
+ int exclusive = TMPPATNAME_needs_removal ? 0 : O_EXCL;
+ TMPPATNAME_needs_removal = 1;
+ pfp = fdopen (create_file (TMPPATNAME,
+ O_RDWR | O_BINARY | exclusive,
+ (mode_t) 0, true),
+ "w+b");
+ if (!pfp)
+ pfatal ("Can't open stream for file %s", quotearg (TMPPATNAME));
+ for (st.st_size = 0;
+ (charsread = fread (buf, 1, bufsize, stdin)) != 0;
+ st.st_size += charsread)
+ if (fwrite (buf, 1, charsread, pfp) != charsread)
+ write_fatal ();
+ if (ferror (stdin) || fclose (stdin) != 0)
+ read_fatal ();
+ if (fflush (pfp) != 0
+ || file_seek (pfp, (file_offset) 0, SEEK_SET) != 0)
+ write_fatal ();
+ }
+ }
+ else
+ {
+ pfp = fopen (filename, binary_transput ? "rb" : "r");
+ if (!pfp)
+ pfatal ("Can't open patch file %s", quotearg (filename));
+ if (fstat (fileno (pfp), &st) != 0)
+ pfatal ("fstat");
+ }
+ p_filesize = st.st_size;
+ if (p_filesize != (file_offset) p_filesize)
+ fatal ("patch file is too long");
+ next_intuit_at (file_pos, (LINENUM) 1);
+ set_hunkmax();
+}
+
+/* Make sure our dynamically realloced tables are malloced to begin with. */
+
+void
+set_hunkmax (void)
+{
+ if (!p_line)
+ p_line = (char **) malloc (hunkmax * sizeof *p_line);
+ if (!p_len)
+ p_len = (size_t *) malloc (hunkmax * sizeof *p_len);
+ if (!p_Char)
+ p_Char = malloc (hunkmax * sizeof *p_Char);
+}
+
+/* Enlarge the arrays containing the current hunk of patch. */
+
+static bool
+grow_hunkmax (void)
+{
+ hunkmax *= 2;
+ assert (p_line && p_len && p_Char);
+ if ((p_line = (char **) realloc (p_line, hunkmax * sizeof (*p_line)))
+ && (p_len = (size_t *) realloc (p_len, hunkmax * sizeof (*p_len)))
+ && (p_Char = realloc (p_Char, hunkmax * sizeof (*p_Char))))
+ return true;
+ if (!using_plan_a)
+ xalloc_die ();
+ /* Don't free previous values of p_line etc.,
+ since some broken implementations free them for us.
+ Whatever is null will be allocated again from within plan_a (),
+ of all places. */
+ return false;
+}
+
+static bool
+maybe_reverse (char const *name, bool nonexistent, bool empty)
+{
+ bool is_empty = nonexistent || empty;
+ bool r;
+
+ r = (! is_empty) < p_says_nonexistent[reverse ^ is_empty]
+ && ok_to_reverse ("The next patch%s would %s the file %s,\nwhich %s!",
+ reverse ? ", when reversed," : "",
+ (nonexistent ? "delete"
+ : empty ? "empty out"
+ : "create"),
+ quotearg (name),
+ (nonexistent ? "does not exist"
+ : empty ? "is already empty"
+ : "already exists"));
+ reverse ^= r;
+ return r;
+}
+
+/* True if the remainder of the patch file contains a diff of some sort. */
+
+bool
+there_is_another_patch (bool need_header)
+{
+ if (p_base != 0 && p_base >= p_filesize) {
+ if (verbosity == VERBOSE)
+ say ("done\n");
+ return false;
+ }
+ if (verbosity == VERBOSE)
+ say ("Hmm...");
+ diff_type = intuit_diff_type (need_header);
+ if (diff_type == NO_DIFF) {
+ if (verbosity == VERBOSE)
+ say (p_base
+ ? " Ignoring the trailing garbage.\ndone\n"
+ : " I can't seem to find a patch in there anywhere.\n");
+ if (! p_base && p_filesize)
+ fatal ("Only garbage was found in the patch input.");
+ return false;
+ }
+ if (skip_rest_of_patch)
+ {
+ Fseek (pfp, p_start, SEEK_SET);
+ p_input_line = p_sline - 1;
+ return true;
+ }
+ if (verbosity == VERBOSE)
+ say (" %sooks like %s to me...\n",
+ (p_base == 0 ? "L" : "The next patch l"),
+ diff_type == UNI_DIFF ? "a unified diff" :
+ diff_type == CONTEXT_DIFF ? "a context diff" :
+ diff_type == NEW_CONTEXT_DIFF ? "a new-style context diff" :
+ diff_type == NORMAL_DIFF ? "a normal diff" :
+ "an ed script" );
+
+ if (verbosity != SILENT)
+ {
+ if (p_indent)
+ say ("(Patch is indented %lu space%s.)\n",
+ (unsigned long int) p_indent, p_indent==1?"":"s");
+ if (no_strip_trailing_cr)
+ p_strip_trailing_cr = false;
+ else if (p_strip_trailing_cr)
+ say ("(Stripping trailing CRs from patch.)\n");
+ if (! inname)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("can't find file to patch at input line %s\n",
+ format_linenum (numbuf, p_sline));
+ if (diff_type != ED_DIFF && diff_type != NORMAL_DIFF)
+ say (strippath == -1
+ ? "Perhaps you should have used the -p or --strip option?\n"
+ : "Perhaps you used the wrong -p or --strip option?\n");
+ }
+ }
+
+ skip_to(p_start,p_sline);
+ while (!inname) {
+ char *t;
+ if (force | batch) {
+ say ("No file to patch. Skipping patch.\n");
+ skip_rest_of_patch = true;
+ return true;
+ }
+ ask ("File to patch: ");
+ t = buf + strlen (buf);
+ if (t > buf + 1 && *(t - 1) == '\n')
+ {
+ inname = savebuf (buf, t - buf);
+ inname[t - buf - 1] = 0;
+ if (stat (inname, &instat) == 0)
+ {
+ inerrno = 0;
+ invc = -1;
+ }
+ else
+ {
+ perror (inname);
+ fflush (stderr);
+ free (inname);
+ inname = 0;
+ }
+ }
+ if (!inname) {
+ ask ("Skip this patch? [y] ");
+ if (*buf != 'n') {
+ if (verbosity != SILENT)
+ say ("Skipping patch.\n");
+ skip_rest_of_patch = true;
+ return true;
+ }
+ }
+ }
+ return true;
+}
+
+/* Determine what kind of diff is in the remaining part of the patch file. */
+
+static enum diff
+intuit_diff_type (bool need_header)
+{
+ register file_offset this_line = 0;
+ register file_offset first_command_line = -1;
+ char first_ed_command_letter = 0;
+ LINENUM fcl_line = 0; /* Pacify `gcc -W'. */
+ register bool this_is_a_command = false;
+ register bool stars_this_line = false;
+ enum nametype i;
+ struct stat st[3];
+ int stat_errno[3];
+ int version_controlled[3];
+ register enum diff retval;
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i]) {
+ free (p_name[i]);
+ p_name[i] = 0;
+ }
+ for (i = OLD; i <= NEW; i++)
+ if (p_timestr[i])
+ {
+ free(p_timestr[i]);
+ p_timestr[i] = 0;
+ }
+
+ /* Ed and normal format patches don't have filename headers. */
+ if (diff_type == ED_DIFF || diff_type == NORMAL_DIFF)
+ need_header = false;
+
+ version_controlled[OLD] = -1;
+ version_controlled[NEW] = -1;
+ version_controlled[INDEX] = -1;
+ p_rfc934_nesting = 0;
+ p_timestamp[OLD] = p_timestamp[NEW] = (time_t) -1;
+ p_says_nonexistent[OLD] = p_says_nonexistent[NEW] = 0;
+ Fseek (pfp, p_base, SEEK_SET);
+ p_input_line = p_bline - 1;
+ for (;;) {
+ register char *s;
+ register char *t;
+ register file_offset previous_line = this_line;
+ register bool last_line_was_command = this_is_a_command;
+ register bool stars_last_line = stars_this_line;
+ register size_t indent = 0;
+ char ed_command_letter;
+ bool strip_trailing_cr;
+ size_t chars_read;
+
+ this_line = file_tell (pfp);
+ chars_read = pget_line (0, 0, false, false);
+ if (chars_read == (size_t) -1)
+ xalloc_die ();
+ if (! chars_read) {
+ if (first_ed_command_letter) {
+ /* nothing but deletes!? */
+ p_start = first_command_line;
+ p_sline = fcl_line;
+ retval = ED_DIFF;
+ goto scan_exit;
+ }
+ else {
+ p_start = this_line;
+ p_sline = p_input_line;
+ return NO_DIFF;
+ }
+ }
+ strip_trailing_cr = 2 <= chars_read && buf[chars_read - 2] == '\r';
+ for (s = buf; *s == ' ' || *s == '\t' || *s == 'X'; s++) {
+ if (*s == '\t')
+ indent = (indent + 8) & ~7;
+ else
+ indent++;
+ }
+ if (ISDIGIT (*s))
+ {
+ for (t = s + 1; ISDIGIT (*t) || *t == ','; t++)
+ continue;
+ if (*t == 'd' || *t == 'c' || *t == 'a')
+ {
+ for (t++; ISDIGIT (*t) || *t == ','; t++)
+ continue;
+ for (; *t == ' ' || *t == '\t'; t++)
+ continue;
+ if (*t == '\r')
+ t++;
+ this_is_a_command = (*t == '\n');
+ }
+ }
+ if (! need_header
+ && first_command_line < 0
+ && ((ed_command_letter = get_ed_command_letter (s))
+ || this_is_a_command)) {
+ first_command_line = this_line;
+ first_ed_command_letter = ed_command_letter;
+ fcl_line = p_input_line;
+ p_indent = indent; /* assume this for now */
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ if (!stars_last_line && strnEQ(s, "*** ", 4))
+ {
+ p_name[OLD] = fetchname (s+4, strippath, &p_timestr[OLD],
+ &p_timestamp[OLD]);
+ need_header = false;
+ }
+ else if (strnEQ(s, "+++ ", 4))
+ {
+ /* Swap with NEW below. */
+ p_name[OLD] = fetchname (s+4, strippath, &p_timestr[OLD],
+ &p_timestamp[OLD]);
+ need_header = false;
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ else if (strnEQ(s, "Index:", 6))
+ {
+ p_name[INDEX] = fetchname (s+6, strippath, (char **) 0,
+ (time_t *) 0);
+ need_header = false;
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ else if (strnEQ(s, "Prereq:", 7)) {
+ for (t = s + 7; ISSPACE ((unsigned char) *t); t++)
+ continue;
+ revision = t;
+ for (t = revision; *t; t++)
+ if (ISSPACE ((unsigned char) *t))
+ {
+ char const *u;
+ for (u = t + 1; ISSPACE ((unsigned char) *u); u++)
+ continue;
+ if (*u)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("Prereq: with multiple words at line %s of patch\n",
+ format_linenum (numbuf, this_line));
+ }
+ break;
+ }
+ if (t == revision)
+ revision = 0;
+ else {
+ char oldc = *t;
+ *t = '\0';
+ revision = savestr (revision);
+ *t = oldc;
+ }
+ } else
+ {
+ for (t = s; t[0] == '-' && t[1] == ' '; t += 2)
+ continue;
+ if (strnEQ(t, "--- ", 4))
+ {
+ time_t timestamp = (time_t) -1;
+ p_name[NEW] = fetchname (t+4, strippath, &p_timestr[NEW],
+ ×tamp);
+ need_header = false;
+ if (timestamp != (time_t) -1)
+ {
+ p_timestamp[NEW] = timestamp;
+ p_rfc934_nesting = (t - s) >> 1;
+ }
+ p_strip_trailing_cr = strip_trailing_cr;
+ }
+ }
+ if (need_header)
+ continue;
+ if ((diff_type == NO_DIFF || diff_type == ED_DIFF) &&
+ first_command_line >= 0 &&
+ strEQ(s, ".\n") ) {
+ p_start = first_command_line;
+ p_sline = fcl_line;
+ retval = ED_DIFF;
+ goto scan_exit;
+ }
+ if ((diff_type == NO_DIFF || diff_type == UNI_DIFF)
+ && strnEQ(s, "@@ -", 4)) {
+
+ /* `p_name', `p_timestr', and `p_timestamp' are backwards;
+ swap them. */
+ time_t ti = p_timestamp[OLD];
+ p_timestamp[OLD] = p_timestamp[NEW];
+ p_timestamp[NEW] = ti;
+ t = p_name[OLD];
+ p_name[OLD] = p_name[NEW];
+ p_name[NEW] = t;
+ t = p_timestr[OLD];
+ p_timestr[OLD] = p_timestr[NEW];
+ p_timestr[NEW] = t;
+
+ s += 4;
+ if (s[0] == '0' && !ISDIGIT (s[1]))
+ p_says_nonexistent[OLD] = 1 + ! p_timestamp[OLD];
+ while (*s != ' ' && *s != '\n')
+ s++;
+ while (*s == ' ')
+ s++;
+ if (s[0] == '+' && s[1] == '0' && !ISDIGIT (s[2]))
+ p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW];
+ p_indent = indent;
+ p_start = this_line;
+ p_sline = p_input_line;
+ retval = UNI_DIFF;
+ if (! ((p_name[OLD] || ! p_timestamp[OLD])
+ && (p_name[NEW] || ! p_timestamp[NEW]))
+ && ! p_name[INDEX] && need_header)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("missing header for unified diff at line %s of patch\n",
+ format_linenum (numbuf, p_sline));
+ }
+ goto scan_exit;
+ }
+ stars_this_line = strnEQ(s, "********", 8);
+ if ((diff_type == NO_DIFF
+ || diff_type == CONTEXT_DIFF
+ || diff_type == NEW_CONTEXT_DIFF)
+ && stars_last_line && strnEQ (s, "*** ", 4)) {
+ s += 4;
+ if (s[0] == '0' && !ISDIGIT (s[1]))
+ p_says_nonexistent[OLD] = 1 + ! p_timestamp[OLD];
+ /* if this is a new context diff the character just before */
+ /* the newline is a '*'. */
+ while (*s != '\n')
+ s++;
+ p_indent = indent;
+ p_strip_trailing_cr = strip_trailing_cr;
+ p_start = previous_line;
+ p_sline = p_input_line - 1;
+ retval = (*(s-1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF);
+
+ {
+ /* Scan the first hunk to see whether the file contents
+ appear to have been deleted. */
+ file_offset saved_p_base = p_base;
+ LINENUM saved_p_bline = p_bline;
+ Fseek (pfp, previous_line, SEEK_SET);
+ p_input_line -= 2;
+ if (another_hunk (retval, false)
+ && ! p_repl_lines && p_newfirst == 1)
+ p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW];
+ next_intuit_at (saved_p_base, saved_p_bline);
+ }
+
+ if (! ((p_name[OLD] || ! p_timestamp[OLD])
+ && (p_name[NEW] || ! p_timestamp[NEW]))
+ && ! p_name[INDEX] && need_header)
+ {
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ say ("missing header for context diff at line %s of patch\n",
+ format_linenum (numbuf, p_sline));
+ }
+ goto scan_exit;
+ }
+ if ((diff_type == NO_DIFF || diff_type == NORMAL_DIFF) &&
+ last_line_was_command &&
+ (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2)) ) {
+ p_start = previous_line;
+ p_sline = p_input_line - 1;
+ p_indent = indent;
+ p_strip_trailing_cr = strip_trailing_cr;
+ retval = NORMAL_DIFF;
+ goto scan_exit;
+ }
+ }
+
+ scan_exit:
+
+ /* To intuit `inname', the name of the file to patch,
+ use the algorithm specified by POSIX 1003.1-2001 XCU lines 25680-26599
+ (with some modifications if posixly_correct is zero):
+
+ - Take the old and new names from the context header if present,
+ and take the index name from the `Index:' line if present and
+ if either the old and new names are both absent
+ or posixly_correct is nonzero.
+ Consider the file names to be in the order (old, new, index).
+ - If some named files exist, use the first one if posixly_correct
+ is nonzero, the best one otherwise.
+ - If patch_get is nonzero, and no named files exist,
+ but an RCS or SCCS master file exists,
+ use the first named file with an RCS or SCCS master.
+ - If no named files exist, no RCS or SCCS master was found,
+ some names are given, posixly_correct is zero,
+ and the patch appears to create a file, then use the best name
+ requiring the creation of the fewest directories.
+ - Otherwise, report failure by setting `inname' to 0;
+ this causes our invoker to ask the user for a file name. */
+
+ i = NONE;
+
+ if (!inname)
+ {
+ enum nametype i0 = NONE;
+
+ if (! posixly_correct && (p_name[OLD] || p_name[NEW]) && p_name[INDEX])
+ {
+ free (p_name[INDEX]);
+ p_name[INDEX] = 0;
+ }
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ {
+ if (i0 != NONE && strcmp (p_name[i0], p_name[i]) == 0)
+ {
+ /* It's the same name as before; reuse stat results. */
+ stat_errno[i] = stat_errno[i0];
+ if (! stat_errno[i])
+ st[i] = st[i0];
+ }
+ else if (stat (p_name[i], &st[i]) != 0)
+ stat_errno[i] = errno;
+ else
+ {
+ stat_errno[i] = 0;
+ if (posixly_correct)
+ break;
+ }
+ i0 = i;
+ }
+
+ if (! posixly_correct)
+ {
+ i = best_name (p_name, stat_errno);
+
+ if (i == NONE && patch_get)
+ {
+ enum nametype nope = NONE;
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ {
+ char const *cs;
+ char *getbuf;
+ char *diffbuf;
+ bool readonly = (outfile
+ && strcmp (outfile, p_name[i]) != 0);
+
+ if (nope == NONE || strcmp (p_name[nope], p_name[i]) != 0)
+ {
+ cs = (version_controller
+ (p_name[i], readonly, (struct stat *) 0,
+ &getbuf, &diffbuf));
+ version_controlled[i] = !! cs;
+ if (cs)
+ {
+ if (version_get (p_name[i], cs, false, readonly,
+ getbuf, &st[i]))
+ stat_errno[i] = 0;
+ else
+ version_controlled[i] = 0;
+
+ free (getbuf);
+ if (diffbuf)
+ free (diffbuf);
+
+ if (! stat_errno[i])
+ break;
+ }
+ }
+
+ nope = i;
+ }
+ }
+
+ if (i != NONE && st[i].st_size > 0)
+ i0 = i;
+ if (i0 != NONE
+ && ! maybe_reverse (p_name[i0], i == NONE,
+ i == NONE || st[i].st_size == 0))
+ i = i0;
+
+ if (i == NONE && p_says_nonexistent[reverse])
+ {
+ int newdirs[3];
+ int newdirs_min = INT_MAX;
+ int distance_from_minimum[3];
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ {
+ newdirs[i] = (prefix_components (p_name[i], false)
+ - prefix_components (p_name[i], true));
+ if (newdirs[i] < newdirs_min)
+ newdirs_min = newdirs[i];
+ }
+
+ for (i = OLD; i <= INDEX; i++)
+ if (p_name[i])
+ distance_from_minimum[i] = newdirs[i] - newdirs_min;
+
+ i = best_name (p_name, distance_from_minimum);
+ }
+ }
+ }
+
+ if (i == NONE)
+ {
+ if (inname)
+ {
+ inerrno = stat (inname, &instat) == 0 ? 0 : errno;
+ maybe_reverse (inname, inerrno, inerrno || instat.st_size == 0);
+ }
+ else
+ inerrno = -1;
+ }
+ else
+ {
+ inname = savestr(p_name[i]);
+ inerrno = stat_errno[i];
+ invc = version_controlled[i];
+ instat = st[i];
+ }
+
+ return retval;
+}
+
+/* Count the path name components in FILENAME's prefix.
+ If CHECKDIRS is true, count only existing directories. */
+static int
+prefix_components (char *filename, bool checkdirs)
+{
+ int count = 0;
+ struct stat stat_buf;
+ int stat_result;
+ char *f = filename + FILE_SYSTEM_PREFIX_LEN (filename);
+
+ if (*f)
+ while (*++f)
+ if (ISSLASH (f[0]) && ! ISSLASH (f[-1]))
+ {
+ if (checkdirs)
+ {
+ *f = '\0';
+ stat_result = stat (filename, &stat_buf);
+ *f = '/';
+ if (! (stat_result == 0 && S_ISDIR (stat_buf.st_mode)))
+ break;
+ }
+
+ count++;
+ }
+
+ return count;
+}
+
+/* Return the index of the best of NAME[OLD], NAME[NEW], and NAME[INDEX].
+ Ignore null names, and ignore NAME[i] if IGNORE[i] is nonzero.
+ Return NONE if all names are ignored. */
+static enum nametype
+best_name (char *const *name, int const *ignore)
+{
+ enum nametype i;
+ int components[3];
+ int components_min = INT_MAX;
+ size_t basename_len[3];
+ size_t basename_len_min = SIZE_MAX;
+ size_t len[3];
+ size_t len_min = SIZE_MAX;
+
+ for (i = OLD; i <= INDEX; i++)
+ if (name[i] && !ignore[i])
+ {
+ /* Take the names with the fewest prefix components. */
+ components[i] = prefix_components (name[i], false);
+ if (components_min < components[i])
+ continue;
+ components_min = components[i];
+
+ /* Of those, take the names with the shortest basename. */
+ basename_len[i] = base_len (name[i]);
+ if (basename_len_min < basename_len[i])
+ continue;
+ basename_len_min = basename_len[i];
+
+ /* Of those, take the shortest names. */
+ len[i] = strlen (name[i]);
+ if (len_min < len[i])
+ continue;
+ len_min = len[i];
+ }
+
+ /* Of those, take the first name. */
+ for (i = OLD; i <= INDEX; i++)
+ if (name[i] && !ignore[i]
+ && components[i] == components_min
+ && basename_len[i] == basename_len_min
+ && len[i] == len_min)
+ break;
+
+ return i;
+}
+
+/* Remember where this patch ends so we know where to start up again. */
+
+static void
+next_intuit_at (file_offset file_pos, LINENUM file_line)
+{
+ p_base = file_pos;
+ p_bline = file_line;
+}
+
+/* Basically a verbose fseek() to the actual diff listing. */
+
+static void
+skip_to (file_offset file_pos, LINENUM file_line)
+{
+ register FILE *i = pfp;
+ register FILE *o = stdout;
+ register int c;
+
+ assert(p_base <= file_pos);
+ if ((verbosity == VERBOSE || !inname) && p_base < file_pos) {
+ Fseek (i, p_base, SEEK_SET);
+ say ("The text leading up to this was:\n--------------------------\n");
+
+ while (file_tell (i) < file_pos)
+ {
+ putc ('|', o);
+ do
+ {
+ if ((c = getc (i)) == EOF)
+ read_fatal ();
+ putc (c, o);
+ }
+ while (c != '\n');
+ }
+
+ say ("--------------------------\n");
+ }
+ else
+ Fseek (i, file_pos, SEEK_SET);
+ p_input_line = file_line - 1;
+}
+
+/* Make this a function for better debugging. */
+static void
+malformed (void)
+{
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+ fatal ("malformed patch at line %s: %s",
+ format_linenum (numbuf, p_input_line), buf);
+ /* about as informative as "Syntax error" in C */
+}
+
+/* Parse a line number from a string.
+ Return the address of the first char after the number. */
+static char *
+scan_linenum (char *s0, LINENUM *linenum)
+{
+ char *s;
+ LINENUM n = 0;
+ bool overflow = false;
+ char numbuf[LINENUM_LENGTH_BOUND + 1];
+
+ for (s = s0; ISDIGIT (*s); s++)
+ {
+ LINENUM new_n = 10 * n + (*s - '0');
+ overflow |= new_n / 10 != n;
+ n = new_n;
+ }
+
+ if (s == s0)
+ fatal ("missing line number at line %s: %s",
+ format_linenum (numbuf, p_input_line), buf);
+
+ if (overflow)
+ fatal ("line number %.*s is too large at line %s: %s",
+ (int) (s - s0), s0, format_linenum (numbuf, p_input_line), buf);
+
+ *linenum = n;
+ return s;
+}
+
+/* 1 if there is more of the current diff listing to process;
+ 0 if not; -1 if ran out of memory. */
+
+int
+another_hunk (enum diff difftype, bool rev)
+{
+ register char *s;
+ register LINENUM context = 0;
+ register size_t chars_read;
+ char numbuf0[LINENUM_LENGTH_BOUND + 1];
+ char numbuf1[LINENUM_LENGTH_BOUND + 1];
+ char numbuf2[LINENUM_LENGTH_BOUND + 1];
+ char numbuf3[LINENUM_LENGTH_BOUND + 1];
+
+ while (p_end >= 0) {
+ if (p_end == p_efake)
+ p_end = p_bfake; /* don't free twice */
+ else
+ free(p_line[p_end]);
+ p_end--;
+ }
+ assert(p_end == -1);
+ p_efake = -1;
+
+ if (p_c_function)
+ {
+ free (p_c_function);
+ p_c_function = NULL;
+ }
+
+ p_max = hunkmax; /* gets reduced when --- found */
+ if (difftype == CONTEXT_DIFF || difftype == NEW_CONTEXT_DIFF) {
+ file_offset line_beginning = file_tell (pfp);
+ /* file pos of the current line */
+ LINENUM repl_beginning = 0; /* index of --- line */
+ register LINENUM fillcnt = 0; /* #lines of missing ptrn or repl */
+ register LINENUM fillsrc; /* index of first line to copy */
+ register LINENUM filldst; /* index of first missing line */
+ bool ptrn_spaces_eaten = false; /* ptrn was slightly misformed */
+ bool some_context = false; /* (perhaps internal) context seen */
+ register bool repl_could_be_missing = true;
+ bool ptrn_missing = false; /* The pattern was missing. */
+ bool repl_missing = false; /* Likewise for replacement. */
+ file_offset repl_backtrack_position = 0;
+ /* file pos of first repl line */
+ LINENUM repl_patch_line; /* input line number for same */
+ LINENUM repl_context; /* context for same */
+ LINENUM ptrn_prefix_context = -1; /* lines in pattern prefix context */
+ LINENUM ptrn_suffix_context = -1; /* lines in pattern suffix context */
+ LINENUM repl_prefix_context = -1; /* lines in replac. prefix context */
+ LINENUM ptrn_copiable = 0; /* # of copiable lines in ptrn */
+ LINENUM repl_copiable = 0; /* Likewise for replacement. */
+
+ /* Pacify `gcc -Wall'. */
+ fillsrc = filldst = repl_patch_line = repl_context = 0;
+
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1
+ || chars_read <= 8
+ || strncmp (buf, "********", 8) != 0) {
+ next_intuit_at(line_beginning,p_input_line);
+ return chars_read == (size_t) -1 ? -1 : 0;
+ }
+ s = buf;
+ while (*s == '*')
+ s++;
+ if (*s == ' ')
+ {
+ p_c_function = s;
+ while (*s != '\n')
+ s++;
+ *s = '\0';
+ p_c_function = savestr (p_c_function);
+ }
+ p_hunk_beg = p_input_line + 1;
+ while (p_end < p_max) {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ return -1;
+ if (!chars_read) {
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ if (p_max - p_end < 4) {
+ strcpy (buf, " \n"); /* assume blank lines got chopped */
+ chars_read = 3;
+ } else {
+ fatal ("unexpected end of file in patch");
+ }
+ }
+ p_end++;
+ if (p_end == hunkmax)
+ fatal ("unterminated hunk starting at line %s; giving up at line %s: %s",
+ format_linenum (numbuf0, pch_hunk_beg ()),
+ format_linenum (numbuf1, p_input_line), buf);
+ assert(p_end < hunkmax);
+ p_Char[p_end] = *buf;
+ p_len[p_end] = 0;
+ p_line[p_end] = 0;
+ switch (*buf) {
+ case '*':
+ if (strnEQ(buf, "********", 8)) {
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ else
+ fatal ("unexpected end of hunk at line %s",
+ format_linenum (numbuf0, p_input_line));
+ }
+ if (p_end != 0) {
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ fatal ("unexpected `***' at line %s: %s",
+ format_linenum (numbuf0, p_input_line), buf);
+ }
+ context = 0;
+ p_len[p_end] = strlen (buf);
+ if (! (p_line[p_end] = savestr (buf))) {
+ p_end--;
+ return -1;
+ }
+ for (s = buf; *s && !ISDIGIT (*s); s++)
+ continue;
+ if (strnEQ(s,"0,0",3))
+ remove_prefix (s, 2);
+ s = scan_linenum (s, &p_first);
+ if (*s == ',') {
+ while (*s && !ISDIGIT (*s))
+ s++;
+ scan_linenum (s, &p_ptrn_lines);
+ p_ptrn_lines += 1 - p_first;
+ }
+ else if (p_first)
+ p_ptrn_lines = 1;
+ else {
+ p_ptrn_lines = 0;
+ p_first = 1;
+ }
+ p_max = p_ptrn_lines + 6; /* we need this much at least */
+ while (p_max + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ return -1;
+ p_max = hunkmax;
+ break;
+ case '-':
+ if (buf[1] != '-')
+ goto change_line;
+ if (ptrn_prefix_context == -1)
+ ptrn_prefix_context = context;
+ ptrn_suffix_context = context;
+ if (repl_beginning
+ || (p_end
+ != p_ptrn_lines + 1 + (p_Char[p_end - 1] == '\n')))
+ {
+ if (p_end == 1)
+ {
+ /* `Old' lines were omitted. Set up to fill
+ them in from `new' context lines. */
+ ptrn_missing = true;
+ p_end = p_ptrn_lines + 1;
+ ptrn_prefix_context = ptrn_suffix_context = -1;
+ fillsrc = p_end + 1;
+ filldst = 1;
+ fillcnt = p_ptrn_lines;
+ }
+ else if (! repl_beginning)
+ fatal ("%s `---' at line %s; check line numbers at line %s",
+ (p_end <= p_ptrn_lines
+ ? "Premature"
+ : "Overdue"),
+ format_linenum (numbuf0, p_input_line),
+ format_linenum (numbuf1, p_hunk_beg));
+ else if (! repl_could_be_missing)
+ fatal ("duplicate `---' at line %s; check line numbers at line %s",
+ format_linenum (numbuf0, p_input_line),
+ format_linenum (numbuf1,
+ p_hunk_beg + repl_beginning));
+ else
+ {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ }
+ repl_beginning = p_end;
+ repl_backtrack_position = file_tell (pfp);
+ repl_patch_line = p_input_line;
+ repl_context = context;
+ p_len[p_end] = strlen (buf);
+ if (! (p_line[p_end] = savestr (buf)))
+ {
+ p_end--;
+ return -1;
+ }
+ p_Char[p_end] = '=';
+ for (s = buf; *s && ! ISDIGIT (*s); s++)
+ continue;
+ s = scan_linenum (s, &p_newfirst);
+ if (*s == ',')
+ {
+ do
+ {
+ if (!*++s)
+ malformed ();
+ }
+ while (! ISDIGIT (*s));
+ scan_linenum (s, &p_repl_lines);
+ p_repl_lines += 1 - p_newfirst;
+ }
+ else if (p_newfirst)
+ p_repl_lines = 1;
+ else
+ {
+ p_repl_lines = 0;
+ p_newfirst = 1;
+ }
+ p_max = p_repl_lines + p_end;
+ while (p_max + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ return -1;
+ if (p_repl_lines != ptrn_copiable
+ && (p_prefix_context != 0
+ || context != 0
+ || p_repl_lines != 1))
+ repl_could_be_missing = false;
+ context = 0;
+ break;
+ case '+': case '!':
+ repl_could_be_missing = false;
+ change_line:
+ s = buf + 1;
+ chars_read--;
+ if (*s == '\n' && canonicalize) {
+ strcpy (s, " \n");
+ chars_read = 2;
+ }
+ if (*s == ' ' || *s == '\t') {
+ s++;
+ chars_read--;
+ } else if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ if (! repl_beginning)
+ {
+ if (ptrn_prefix_context == -1)
+ ptrn_prefix_context = context;
+ }
+ else
+ {
+ if (repl_prefix_context == -1)
+ repl_prefix_context = context;
+ }
+ chars_read -=
+ (1 < chars_read
+ && p_end == (repl_beginning ? p_max : p_ptrn_lines)
+ && incomplete_line ());
+ p_len[p_end] = chars_read;
+ p_line[p_end] = savebuf (s, chars_read);
+ if (chars_read && ! p_line[p_end]) {
+ p_end--;
+ return -1;
+ }
+ context = 0;
+ break;
+ case '\t': case '\n': /* assume spaces got eaten */
+ s = buf;
+ if (*buf == '\t') {
+ s++;
+ chars_read--;
+ }
+ if (repl_beginning && repl_could_be_missing &&
+ (!ptrn_spaces_eaten || difftype == NEW_CONTEXT_DIFF) ) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ chars_read -=
+ (1 < chars_read
+ && p_end == (repl_beginning ? p_max : p_ptrn_lines)
+ && incomplete_line ());
+ p_len[p_end] = chars_read;
+ p_line[p_end] = savebuf (buf, chars_read);
+ if (chars_read && ! p_line[p_end]) {
+ p_end--;
+ return -1;
+ }
+ if (p_end != p_ptrn_lines + 1) {
+ ptrn_spaces_eaten |= (repl_beginning != 0);
+ some_context = true;
+ context++;
+ if (repl_beginning)
+ repl_copiable++;
+ else
+ ptrn_copiable++;
+ p_Char[p_end] = ' ';
+ }
+ break;
+ case ' ':
+ s = buf + 1;
+ chars_read--;
+ if (*s == '\n' && canonicalize) {
+ strcpy (s, "\n");
+ chars_read = 2;
+ }
+ if (*s == ' ' || *s == '\t') {
+ s++;
+ chars_read--;
+ } else if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ some_context = true;
+ context++;
+ if (repl_beginning)
+ repl_copiable++;
+ else
+ ptrn_copiable++;
+ chars_read -=
+ (1 < chars_read
+ && p_end == (repl_beginning ? p_max : p_ptrn_lines)
+ && incomplete_line ());
+ p_len[p_end] = chars_read;
+ p_line[p_end] = savebuf (s, chars_read);
+ if (chars_read && ! p_line[p_end]) {
+ p_end--;
+ return -1;
+ }
+ break;
+ default:
+ if (repl_beginning && repl_could_be_missing) {
+ repl_missing = true;
+ goto hunk_done;
+ }
+ malformed ();
+ }
+ }
+
+ hunk_done:
+ if (p_end >=0 && !repl_beginning)
+ fatal ("no `---' found in patch at line %s",
+ format_linenum (numbuf0, pch_hunk_beg ()));
+
+ if (repl_missing) {
+
+ /* reset state back to just after --- */
+ p_input_line = repl_patch_line;
+ context = repl_context;
+ for (p_end--; p_end > repl_beginning; p_end--)
+ free(p_line[p_end]);
+ Fseek (pfp, repl_backtrack_position, SEEK_SET);
+
+ /* redundant 'new' context lines were omitted - set */
+ /* up to fill them in from the old file context */
+ fillsrc = 1;
+ filldst = repl_beginning+1;
+ fillcnt = p_repl_lines;
+ p_end = p_max;
+ }
+ else if (! ptrn_missing && ptrn_copiable != repl_copiable)
+ fatal ("context mangled in hunk at line %s",
+ format_linenum (numbuf0, p_hunk_beg));
+ else if (!some_context && fillcnt == 1) {
+ /* the first hunk was a null hunk with no context */
+ /* and we were expecting one line -- fix it up. */
+ while (filldst < p_end) {
+ p_line[filldst] = p_line[filldst+1];
+ p_Char[filldst] = p_Char[filldst+1];
+ p_len[filldst] = p_len[filldst+1];
+ filldst++;
+ }
+#if 0
+ repl_beginning--; /* this doesn't need to be fixed */
+#endif
+ p_end--;
+ p_first++; /* do append rather than insert */
+ fillcnt = 0;
+ p_ptrn_lines = 0;
+ }
+
+ p_prefix_context = ((repl_prefix_context == -1
+ || (ptrn_prefix_context != -1
+ && ptrn_prefix_context < repl_prefix_context))
+ ? ptrn_prefix_context : repl_prefix_context);
+ p_suffix_context = ((ptrn_suffix_context != -1
+ && ptrn_suffix_context < context)
+ ? ptrn_suffix_context : context);
+ assert (p_prefix_context != -1 && p_suffix_context != -1);
+
+ if (difftype == CONTEXT_DIFF
+ && (fillcnt
+ || (p_first > 1
+ && p_prefix_context + p_suffix_context < ptrn_copiable))) {
+ if (verbosity == VERBOSE)
+ say ("%s\n%s\n%s\n",
+"(Fascinating -- this is really a new-style context diff but without",
+"the telltale extra asterisks on the *** line that usually indicate",
+"the new style...)");
+ diff_type = difftype = NEW_CONTEXT_DIFF;
+ }
+
+ /* if there were omitted context lines, fill them in now */
+ if (fillcnt) {
+ p_bfake = filldst; /* remember where not to free() */
+ p_efake = filldst + fillcnt - 1;
+ while (fillcnt-- > 0) {
+ while (fillsrc <= p_end && fillsrc != repl_beginning
+ && p_Char[fillsrc] != ' ')
+ fillsrc++;
+ if (p_end < fillsrc || fillsrc == repl_beginning)
+ {
+ fatal ("replacement text or line numbers mangled in hunk at line %s",
+ format_linenum (numbuf0, p_hunk_beg));
+ }
+ p_line[filldst] = p_line[fillsrc];
+ p_Char[filldst] = p_Char[fillsrc];
+ p_len[filldst] = p_len[fillsrc];
+ fillsrc++; filldst++;
+ }
+ while (fillsrc <= p_end && fillsrc != repl_beginning)
+ {
+ if (p_Char[fillsrc] == ' ')
+ fatal ("replacement text or line numbers mangled in hunk at line %s",
+ format_linenum (numbuf0, p_hunk_beg));
+ fillsrc++;
+ }
+ if (debug & 64)
+ printf ("fillsrc %s, filldst %s, rb %s, e+1 %s\n",
+ format_linenum (numbuf0, fillsrc),
+ format_linenum (numbuf1, filldst),
+ format_linenum (numbuf2, repl_beginning),
+ format_linenum (numbuf3, p_end + 1));
+ assert(fillsrc==p_end+1 || fillsrc==repl_beginning);
+ assert(filldst==p_end+1 || filldst==repl_beginning);
+ }
+ }
+ else if (difftype == UNI_DIFF) {
+ file_offset line_beginning = file_tell (pfp);
+ /* file pos of the current line */
+ register LINENUM fillsrc; /* index of old lines */
+ register LINENUM filldst; /* index of new lines */
+ char ch = '\0';
+
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1
+ || chars_read <= 4
+ || strncmp (buf, "@@ -", 4) != 0) {
+ next_intuit_at(line_beginning,p_input_line);
+ return chars_read == (size_t) -1 ? -1 : 0;
+ }
+ s = scan_linenum (buf + 4, &p_first);
+ if (*s == ',')
+ s = scan_linenum (s + 1, &p_ptrn_lines);
+ else
+ p_ptrn_lines = 1;
+ if (*s == ' ') s++;
+ if (*s != '+')
+ malformed ();
+ s = scan_linenum (s + 1, &p_newfirst);
+ if (*s == ',')
+ s = scan_linenum (s + 1, &p_repl_lines);
+ else
+ p_repl_lines = 1;
+ if (*s == ' ') s++;
+ if (*s++ != '@')
+ malformed ();
+ if (*s++ == '@' && *s == ' ' && *s != '\0')
+ {
+ p_c_function = s;
+ while (*s != '\n')
+ s++;
+ *s = '\0';
+ p_c_function = savestr (p_c_function);
+ }
+ if (!p_ptrn_lines)
+ p_first++; /* do append rather than insert */
+ if (!p_repl_lines)
+ p_newfirst++;
+ p_max = p_ptrn_lines + p_repl_lines + 1;
+ while (p_max + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ return -1;
+ fillsrc = 1;
+ filldst = fillsrc + p_ptrn_lines;
+ p_end = filldst + p_repl_lines;
+ sprintf (buf, "*** %s,%s ****\n",
+ format_linenum (numbuf0, p_first),
+ format_linenum (numbuf1, p_first + p_ptrn_lines - 1));
+ p_len[0] = strlen (buf);
+ if (! (p_line[0] = savestr (buf))) {
+ p_end = -1;
+ return -1;
+ }
+ p_Char[0] = '*';
+ sprintf (buf, "--- %s,%s ----\n",
+ format_linenum (numbuf0, p_newfirst),
+ format_linenum (numbuf1, p_newfirst + p_repl_lines - 1));
+ p_len[filldst] = strlen (buf);
+ if (! (p_line[filldst] = savestr (buf))) {
+ p_end = 0;
+ return -1;
+ }
+ p_Char[filldst++] = '=';
+ p_prefix_context = -1;
+ p_hunk_beg = p_input_line + 1;
+ while (fillsrc <= p_ptrn_lines || filldst <= p_end) {
+ chars_read = get_line ();
+ if (!chars_read) {
+ if (p_max - filldst < 3) {
+ strcpy (buf, " \n"); /* assume blank lines got chopped */
+ chars_read = 2;
+ } else {
+ fatal ("unexpected end of file in patch");
+ }
+ }
+ if (chars_read == (size_t) -1)
+ s = 0;
+ else if (*buf == '\t' || *buf == '\n') {
+ ch = ' '; /* assume the space got eaten */
+ s = savebuf (buf, chars_read);
+ }
+ else {
+ ch = *buf;
+ s = savebuf (buf+1, --chars_read);
+ }
+ if (chars_read && ! s)
+ {
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ return -1;
+ }
+ switch (ch) {
+ case '-':
+ if (fillsrc > p_ptrn_lines) {
+ free(s);
+ p_end = filldst-1;
+ malformed ();
+ }
+ chars_read -= fillsrc == p_ptrn_lines && incomplete_line ();
+ p_Char[fillsrc] = ch;
+ p_line[fillsrc] = s;
+ p_len[fillsrc++] = chars_read;
+ break;
+ case '=':
+ ch = ' ';
+ /* FALL THROUGH */
+ case ' ':
+ if (fillsrc > p_ptrn_lines) {
+ free(s);
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ malformed ();
+ }
+ context++;
+ chars_read -= fillsrc == p_ptrn_lines && incomplete_line ();
+ p_Char[fillsrc] = ch;
+ p_line[fillsrc] = s;
+ p_len[fillsrc++] = chars_read;
+ s = savebuf (s, chars_read);
+ if (chars_read && ! s) {
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ return -1;
+ }
+ /* FALL THROUGH */
+ case '+':
+ if (filldst > p_end) {
+ free(s);
+ while (--filldst > p_ptrn_lines)
+ free(p_line[filldst]);
+ p_end = fillsrc-1;
+ malformed ();
+ }
+ chars_read -= filldst == p_end && incomplete_line ();
+ p_Char[filldst] = ch;
+ p_line[filldst] = s;
+ p_len[filldst++] = chars_read;
+ break;
+ default:
+ p_end = filldst;
+ malformed ();
+ }
+ if (ch != ' ') {
+ if (p_prefix_context == -1)
+ p_prefix_context = context;
+ context = 0;
+ }
+ }/* while */
+ if (p_prefix_context == -1)
+ malformed ();
+ p_suffix_context = context;
+ }
+ else { /* normal diff--fake it up */
+ char hunk_type;
+ register int i;
+ LINENUM min, max;
+ file_offset line_beginning = file_tell (pfp);
+
+ p_prefix_context = p_suffix_context = 0;
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1 || !chars_read || !ISDIGIT (*buf)) {
+ next_intuit_at(line_beginning,p_input_line);
+ return chars_read == (size_t) -1 ? -1 : 0;
+ }
+ s = scan_linenum (buf, &p_first);
+ if (*s == ',') {
+ s = scan_linenum (s + 1, &p_ptrn_lines);
+ p_ptrn_lines += 1 - p_first;
+ }
+ else
+ p_ptrn_lines = (*s != 'a');
+ hunk_type = *s;
+ if (hunk_type == 'a')
+ p_first++; /* do append rather than insert */
+ s = scan_linenum (s + 1, &min);
+ if (*s == ',')
+ scan_linenum (s + 1, &max);
+ else
+ max = min;
+ if (hunk_type == 'd')
+ min++;
+ p_end = p_ptrn_lines + 1 + max - min + 1;
+ while (p_end + 1 >= hunkmax)
+ if (! grow_hunkmax ())
+ {
+ p_end = -1;
+ return -1;
+ }
+ p_newfirst = min;
+ p_repl_lines = max - min + 1;
+ sprintf (buf, "*** %s,%s\n",
+ format_linenum (numbuf0, p_first),
+ format_linenum (numbuf1, p_first + p_ptrn_lines - 1));
+ p_len[0] = strlen (buf);
+ if (! (p_line[0] = savestr (buf))) {
+ p_end = -1;
+ return -1;
+ }
+ p_Char[0] = '*';
+ for (i=1; i<=p_ptrn_lines; i++) {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ {
+ p_end = i - 1;
+ return -1;
+ }
+ if (!chars_read)
+ fatal ("unexpected end of file in patch at line %s",
+ format_linenum (numbuf0, p_input_line));
+ if (buf[0] != '<' || (buf[1] != ' ' && buf[1] != '\t'))
+ fatal ("`<' expected at line %s of patch",
+ format_linenum (numbuf0, p_input_line));
+ chars_read -= 2 + (i == p_ptrn_lines && incomplete_line ());
+ p_len[i] = chars_read;
+ p_line[i] = savebuf (buf + 2, chars_read);
+ if (chars_read && ! p_line[i]) {
+ p_end = i-1;
+ return -1;
+ }
+ p_Char[i] = '-';
+ }
+ if (hunk_type == 'c') {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ {
+ p_end = i - 1;
+ return -1;
+ }
+ if (! chars_read)
+ fatal ("unexpected end of file in patch at line %s",
+ format_linenum (numbuf0, p_input_line));
+ if (*buf != '-')
+ fatal ("`---' expected at line %s of patch",
+ format_linenum (numbuf0, p_input_line));
+ }
+ sprintf (buf, "--- %s,%s\n",
+ format_linenum (numbuf0, min),
+ format_linenum (numbuf1, max));
+ p_len[i] = strlen (buf);
+ if (! (p_line[i] = savestr (buf))) {
+ p_end = i-1;
+ return -1;
+ }
+ p_Char[i] = '=';
+ for (i++; i<=p_end; i++) {
+ chars_read = get_line ();
+ if (chars_read == (size_t) -1)
+ {
+ p_end = i - 1;
+ return -1;
+ }
+ if (!chars_read)
+ fatal ("unexpected end of file in patch at line %s",
+ format_linenum (numbuf0, p_input_line));
+ if (buf[0] != '>' || (buf[1] != ' ' && buf[1] != '\t'))
+ fatal ("`>' expected at line %s of patch",
+ format_linenum (numbuf0, p_input_line));
+ chars_read -= 2 + (i == p_end && incomplete_line ());
+ p_len[i] = chars_read;
+ p_line[i] = savebuf (buf + 2, chars_read);
+ if (chars_read && ! p_line[i]) {
+ p_end = i-1;
+ return -1;
+ }
+ p_Char[i] = '+';
+ }
+ }
+ if (rev) /* backwards patch? */
+ if (!pch_swap())
+ say ("Not enough memory to swap next hunk!\n");
+ assert (p_end + 1 < hunkmax);
+ p_Char[p_end + 1] = '^'; /* add a stopper for apply_hunk */
+ if (debug & 2) {
+ LINENUM i;
+
+ for (i = 0; i <= p_end + 1; i++) {
+ fprintf (stderr, "%s %c",
+ format_linenum (numbuf0, i),
+ p_Char[i]);
+ if (p_Char[i] == '*')
+ fprintf (stderr, " %s,%s\n",
+ format_linenum (numbuf0, p_first),
+ format_linenum (numbuf1, p_ptrn_lines));
+ else if (p_Char[i] == '=')
+ fprintf (stderr, " %s,%s\n",
+ format_linenum (numbuf0, p_newfirst),
+ format_linenum (numbuf1, p_repl_lines));
+ else if (p_Char[i] != '^')
+ {
+ fputs(" |", stderr);
+ pch_write_line (i, stderr);
+ }
+ else
+ fputc('\n', stderr);
+ }
+ fflush (stderr);
+ }
+ return 1;
+}
+
+static size_t
+get_line (void)
+{
+ return pget_line (p_indent, p_rfc934_nesting, p_strip_trailing_cr,
+ p_pass_comments_through);
+}
+
+/* Input a line from the patch file, worrying about indentation.
+ Strip up to INDENT characters' worth of leading indentation.
+ Then remove up to RFC934_NESTING instances of leading "- ".
+ If STRIP_TRAILING_CR is true, remove any trailing carriage-return.
+ Unless PASS_COMMENTS_THROUGH is true, ignore any resulting lines
+ that begin with '#'; they're comments.
+ Ignore any partial lines at end of input, but warn about them.
+ Succeed if a line was read; it is terminated by "\n\0" for convenience.
+ Return the number of characters read, including '\n' but not '\0'.
+ Return -1 if we ran out of memory. */
+
+static size_t
+pget_line (size_t indent, int rfc934_nesting, bool strip_trailing_cr,
+ bool pass_comments_through)
+{
+ register FILE *fp = pfp;
+ register int c;
+ register size_t i;
+ register char *b;
+ register size_t s;
+
+ do
+ {
+ i = 0;
+ for (;;)
+ {
+ c = getc (fp);
+ if (c == EOF)
+ {
+ if (ferror (fp))
+ read_fatal ();
+ return 0;
+ }
+ if (indent <= i)
+ break;
+ if (c == ' ' || c == 'X')
+ i++;
+ else if (c == '\t')
+ i = (i + 8) & ~7;
+ else
+ break;
+ }
+
+ i = 0;
+ b = buf;
+
+ while (c == '-' && 0 <= --rfc934_nesting)
+ {
+ c = getc (fp);
+ if (c == EOF)
+ goto patch_ends_in_middle_of_line;
+ if (c != ' ')
+ {
+ i = 1;
+ b[0] = '-';
+ break;
+ }
+ c = getc (fp);
+ if (c == EOF)
+ goto patch_ends_in_middle_of_line;
+ }
+
+ s = bufsize;
+
+ for (;;)
+ {
+ if (i == s - 1)
+ {
+ s *= 2;
+ b = realloc (b, s);
+ if (!b)
+ {
+ if (!using_plan_a)
+ xalloc_die ();
+ return (size_t) -1;
+ }
+ buf = b;
+ bufsize = s;
+ }
+ b[i++] = c;
+ if (c == '\n')
+ break;
+ c = getc (fp);
+ if (c == EOF)
+ goto patch_ends_in_middle_of_line;
+ }
+
+ p_input_line++;
+ }
+ while (*b == '#' && !pass_comments_through);
+
+ if (strip_trailing_cr && 2 <= i && b[i - 2] == '\r')
+ b[i-- - 2] = '\n';
+ b[i] = '\0';
+ return i;
+
+ patch_ends_in_middle_of_line:
+ if (ferror (fp))
+ read_fatal ();
+ say ("patch unexpectedly ends in middle of line\n");
+ return 0;
+}
+
+static bool
+incomplete_line (void)
+{
+ register FILE *fp = pfp;
+ register int c;
+ register file_offset line_beginning = file_tell (fp);
+
+ if (getc (fp) == '\\')
+ {
+ while ((c = getc (fp)) != '\n' && c != EOF)
+ continue;
+ return true;
+ }
+ else
+ {
+ /* We don't trust ungetc. */
+ Fseek (pfp, line_beginning, SEEK_SET);
+ return false;
+ }
+}
+
+/* Reverse the old and new portions of the current hunk. */
+
+bool
+pch_swap (void)
+{
+ char **tp_line; /* the text of the hunk */
+ size_t *tp_len; /* length of each line */
+ char *tp_char; /* +, -, and ! */
+ register LINENUM i;
+ register LINENUM n;
+ bool blankline = false;
+ register char *s;
+
+ i = p_first;
+ p_first = p_newfirst;
+ p_newfirst = i;
+
+ /* make a scratch copy */
+
+ tp_line = p_line;
+ tp_len = p_len;
+ tp_char = p_Char;
+ p_line = 0; /* force set_hunkmax to allocate again */
+ p_len = 0;
+ p_Char = 0;
+ set_hunkmax();
+ if (!p_line || !p_len || !p_Char) {
+ if (p_line)
+ free (p_line);
+ p_line = tp_line;
+ if (p_len)
+ free (p_len);
+ p_len = tp_len;
+ if (p_Char)
+ free (p_Char);
+ p_Char = tp_char;
+ return false; /* not enough memory to swap hunk! */
+ }
+
+ /* now turn the new into the old */
+
+ i = p_ptrn_lines + 1;
+ if (tp_char[i] == '\n') { /* account for possible blank line */
+ blankline = true;
+ i++;
+ }
+ if (p_efake >= 0) { /* fix non-freeable ptr range */
+ if (p_efake <= i)
+ n = p_end - i + 1;
+ else
+ n = -i;
+ p_efake += n;
+ p_bfake += n;
+ }
+ for (n=0; i <= p_end; i++,n++) {
+ p_line[n] = tp_line[i];
+ p_Char[n] = tp_char[i];
+ if (p_Char[n] == '+')
+ p_Char[n] = '-';
+ p_len[n] = tp_len[i];
+ }
+ if (blankline) {
+ i = p_ptrn_lines + 1;
+ p_line[n] = tp_line[i];
+ p_Char[n] = tp_char[i];
+ p_len[n] = tp_len[i];
+ n++;
+ }
+ assert(p_Char[0] == '=');
+ p_Char[0] = '*';
+ for (s=p_line[0]; *s; s++)
+ if (*s == '-')
+ *s = '*';
+
+ /* now turn the old into the new */
+
+ assert(tp_char[0] == '*');
+ tp_char[0] = '=';
+ for (s=tp_line[0]; *s; s++)
+ if (*s == '*')
+ *s = '-';
+ for (i=0; n <= p_end; i++,n++) {
+ p_line[n] = tp_line[i];
+ p_Char[n] = tp_char[i];
+ if (p_Char[n] == '-')
+ p_Char[n] = '+';
+ p_len[n] = tp_len[i];
+ }
+ assert(i == p_ptrn_lines + 1);
+ i = p_ptrn_lines;
+ p_ptrn_lines = p_repl_lines;
+ p_repl_lines = i;
+ p_Char[p_end + 1] = '^';
+ if (tp_line)
+ free (tp_line);
+ if (tp_len)
+ free (tp_len);
+ if (tp_char)
+ free (tp_char);
+ return true;
+}
+
+/* Return whether file WHICH (false = old, true = new) appears to nonexistent.
+ Return 1 for empty, 2 for nonexistent. */
+
+int
+pch_says_nonexistent (bool which)
+{
+ return p_says_nonexistent[which];
+}
+
+const char *
+pch_name (enum nametype type)
+{
+ return type == NONE ? NULL : p_name[type];
+}
+
+/* Return timestamp of patch header for file WHICH (false = old, true = new),
+ or -1 if there was no timestamp or an error in the timestamp. */
+
+time_t
+pch_timestamp (bool which)
+{
+ return p_timestamp[which];
+}
+
+/* Return the specified line position in the old file of the old context. */
+
+LINENUM
+pch_first (void)
+{
+ return p_first;
+}
+
+/* Return the number of lines of old context. */
+
+LINENUM
+pch_ptrn_lines (void)
+{
+ return p_ptrn_lines;
+}
+
+/* Return the probable line position in the new file of the first line. */
+
+LINENUM
+pch_newfirst (void)
+{
+ return p_newfirst;
+}
+
+/* Return the number of lines in the replacement text including context. */
+
+LINENUM
+pch_repl_lines (void)
+{
+ return p_repl_lines;
+}
+
+/* Return the number of lines in the whole hunk. */
+
+LINENUM
+pch_end (void)
+{
+ return p_end;
+}
+
+/* Return the number of context lines before the first changed line. */
+
+LINENUM
+pch_prefix_context (void)
+{
+ return p_prefix_context;
+}
+
+/* Return the number of context lines after the last changed line. */
+
+LINENUM
+pch_suffix_context (void)
+{
+ return p_suffix_context;
+}
+
+/* Return the length of a particular patch line. */
+
+size_t
+pch_line_len (LINENUM line)
+{
+ return p_len[line];
+}
+
+/* Return the control character (+, -, *, !, etc) for a patch line. A '\n'
+ indicates an empty line in a hunk. (The empty line is not part of the
+ old or new context. For some reson, the context format allows that.) */
+
+char
+pch_char (LINENUM line)
+{
+ return p_Char[line];
+}
+
+/* Return a pointer to a particular patch line. */
+
+char *
+pfetch (LINENUM line)
+{
+ return p_line[line];
+}
+
+/* Output a patch line. */
+
+bool
+pch_write_line (LINENUM line, FILE *file)
+{
+ bool after_newline = p_line[line][p_len[line] - 1] == '\n';
+ if (! fwrite (p_line[line], sizeof (*p_line[line]), p_len[line], file))
+ write_fatal ();
+ return after_newline;
+}
+
+/* Return where in the patch file this hunk began, for error messages. */
+
+LINENUM
+pch_hunk_beg (void)
+{
+ return p_hunk_beg;
+}
+
+char const *
+pch_c_function (void)
+{
+ return p_c_function;
+}
+
+char const *
+pch_timestr (bool which)
+{
+ return p_timestr[which];
+}
+
+/* Is the newline-terminated line a valid `ed' command for patch
+ input? If so, return the command character; if not, return 0.
+ This accepts just a subset of the valid commands, but it's
+ good enough in practice. */
+
+static char
+get_ed_command_letter (char const *line)
+{
+ char const *p = line;
+ char letter;
+ bool pair = false;
+
+ if (ISDIGIT (*p))
+ {
+ while (ISDIGIT (*++p))
+ continue;
+ if (*p == ',')
+ {
+ if (! ISDIGIT (*++p))
+ return 0;
+ while (ISDIGIT (*++p))
+ continue;
+ pair = true;
+ }
+ }
+
+ letter = *p++;
+
+ switch (letter)
+ {
+ case 'a':
+ case 'i':
+ if (pair)
+ return 0;
+ break;
+
+ case 'c':
+ case 'd':
+ break;
+
+ case 's':
+ if (strncmp (p, "/.//", 4) != 0)
+ return 0;
+ p += 4;
+ break;
+
+ default:
+ return 0;
+ }
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+ if (*p == '\n')
+ return letter;
+ return 0;
+}
+
+/* Apply an ed script by feeding ed itself. */
+
+void
+do_ed_script (FILE *ofp)
+{
+ static char const ed_program[] = ed_PROGRAM;
+
+ register file_offset beginning_of_this_line;
+ register FILE *pipefp = 0;
+ register size_t chars_read;
+
+ if (! dry_run && ! skip_rest_of_patch) {
+ int exclusive = TMPOUTNAME_needs_removal ? 0 : O_EXCL;
+ assert (! inerrno);
+ TMPOUTNAME_needs_removal = 1;
+ copy_file (inname, TMPOUTNAME, 0, exclusive, instat.st_mode, true);
+ sprintf (buf, "%s %s%s", ed_program, verbosity == VERBOSE ? "" : "- ",
+ TMPOUTNAME);
+ fflush (stdout);
+ pipefp = popen(buf, binary_transput ? "wb" : "w");
+ if (!pipefp)
+ pfatal ("Can't open pipe to %s", quotearg (buf));
+ }
+ for (;;) {
+ char ed_command_letter;
+ beginning_of_this_line = file_tell (pfp);
+ chars_read = get_line ();
+ if (! chars_read) {
+ next_intuit_at(beginning_of_this_line,p_input_line);
+ break;
+ }
+ ed_command_letter = get_ed_command_letter (buf);
+ if (ed_command_letter) {
+ if (pipefp)
+ if (! fwrite (buf, sizeof *buf, chars_read, pipefp))
+ write_fatal ();
+ if (ed_command_letter != 'd' && ed_command_letter != 's') {
+ p_pass_comments_through = true;
+ while ((chars_read = get_line ()) != 0) {
+ if (pipefp)
+ if (! fwrite (buf, sizeof *buf, chars_read, pipefp))
+ write_fatal ();
+ if (chars_read == 2 && strEQ (buf, ".\n"))
+ break;
+ }
+ p_pass_comments_through = false;
+ }
+ }
+ else {
+ next_intuit_at(beginning_of_this_line,p_input_line);
+ break;
+ }
+ }
+ if (!pipefp)
+ return;
+ if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, pipefp) == 0
+ || fflush (pipefp) != 0)
+ write_fatal ();
+ if (pclose (pipefp) != 0)
+ fatal ("%s FAILED", ed_program);
+
+ if (ofp)
+ {
+ FILE *ifp = fopen (TMPOUTNAME, binary_transput ? "rb" : "r");
+ int c;
+ if (!ifp)
+ pfatal ("can't open `%s'", TMPOUTNAME);
+ while ((c = getc (ifp)) != EOF)
+ if (putc (c, ofp) == EOF)
+ write_fatal ();
+ if (ferror (ifp) || fclose (ifp) != 0)
+ read_fatal ();
+ }
+}
+
+void
+pch_normalize (enum diff format)
+{
+ LINENUM old = 1;
+ LINENUM new = p_ptrn_lines + 1;
+
+ while (p_Char[new] == '=' || p_Char[new] == '\n')
+ new++;
+
+ if (format == UNI_DIFF)
+ {
+ /* Convert '!' markers into '-' and '+' as defined by the Unified
+ Format. */
+
+ for (; old <= p_ptrn_lines; old++)
+ if (p_Char[old] == '!')
+ p_Char[old] = '-';
+ for (; new <= p_end; new++)
+ if (p_Char[new] == '!')
+ p_Char[new] = '+';
+ }
+ else
+ {
+ /* Convert '-' and '+' markers which are part of a group into '!' as
+ defined by the Context Format. */
+
+ while (old <= p_ptrn_lines)
+ {
+ if (p_Char[old] == '-')
+ {
+ if (new <= p_end && p_Char[new] == '+')
+ {
+ do
+ {
+ p_Char[old] = '!';
+ old++;
+ }
+ while (old <= p_ptrn_lines && p_Char[old] == '-');
+ do
+ {
+ p_Char[new] = '!';
+ new++;
+ }
+ while (new <= p_end && p_Char[new] == '+');
+ }
+ else
+ {
+ do
+ old++;
+ while (old <= p_ptrn_lines && p_Char[old] == '-');
+ }
+ }
+ else if (new <= p_end && p_Char[new] == '+')
+ {
+ do
+ new++;
+ while (new <= p_end && p_Char[new] == '+');
+ }
+ else
+ {
+ old++;
+ new++;
+ }
+ }
+ }
+}
--- /dev/null
+/* reading patches */
+
+/* Copyright (C) 1986, 1987, 1988 Larry Wall
+
+ Copyright (C) 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 2001,
+ 2002, 2003, 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+enum nametype { OLD, NEW, INDEX, NONE };
+
+LINENUM pch_end (void);
+LINENUM pch_first (void);
+LINENUM pch_hunk_beg (void);
+char const *pch_c_function (void);
+char const * pch_timestr (bool which);
+LINENUM pch_newfirst (void);
+LINENUM pch_prefix_context (void);
+LINENUM pch_ptrn_lines (void);
+LINENUM pch_repl_lines (void);
+LINENUM pch_suffix_context (void);
+bool pch_swap (void);
+bool pch_write_line (LINENUM, FILE *);
+bool there_is_another_patch (bool);
+char *pfetch (LINENUM);
+char pch_char (LINENUM);
+int another_hunk (enum diff, bool);
+int pch_says_nonexistent (bool);
+size_t pch_line_len (LINENUM);
+const char *pch_name(enum nametype);
+time_t pch_timestamp (bool);
+void do_ed_script (FILE *);
+void open_patch_file (char const *);
+void re_patch (void);
+void set_hunkmax (void);
+void pch_normalize (enum diff);
--- /dev/null
+/* Shell command argument quoting.
+ Copyright (C) 1994, 1995, 1997 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Paul Eggert <eggert@twinsun.com> */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <quotesys.h>
+
+/* Place into QUOTED a quoted version of ARG suitable for `system'.
+ Return the length of the resulting string (which is not null-terminated).
+ If QUOTED is null, return the length without any side effects. */
+
+size_t
+quote_system_arg (quoted, arg)
+ char *quoted;
+ char const *arg;
+{
+ char const *a;
+ size_t len = 0;
+
+ /* Scan ARG, copying it to QUOTED if QUOTED is not null,
+ looking for shell metacharacters. */
+
+ for (a = arg; ; a++)
+ {
+ char c = *a;
+ switch (c)
+ {
+ case 0:
+ /* ARG has no shell metacharacters. */
+ return len;
+
+ case '=':
+ if (*arg == '-')
+ break;
+ /* Fall through. */
+ case '\t': case '\n': case ' ':
+ case '!': case '"': case '#': case '$': case '%': case '&': case '\'':
+ case '(': case ')': case '*': case ';':
+ case '<': case '>': case '?': case '[': case '\\':
+ case '^': case '`': case '|': case '~':
+ {
+ /* ARG has a shell metacharacter.
+ Start over, quoting it this time. */
+
+ len = 0;
+ c = *arg++;
+
+ /* If ARG is an option, quote just its argument.
+ This is not necessary, but it looks nicer. */
+ if (c == '-' && arg < a)
+ {
+ c = *arg++;
+
+ if (quoted)
+ {
+ quoted[len] = '-';
+ quoted[len + 1] = c;
+ }
+ len += 2;
+
+ if (c == '-')
+ while (arg < a)
+ {
+ c = *arg++;
+ if (quoted)
+ quoted[len] = c;
+ len++;
+ if (c == '=')
+ break;
+ }
+ c = *arg++;
+ }
+
+ if (quoted)
+ quoted[len] = '\'';
+ len++;
+
+ for (; c; c = *arg++)
+ {
+ if (c == '\'')
+ {
+ if (quoted)
+ {
+ quoted[len] = '\'';
+ quoted[len + 1] = '\\';
+ quoted[len + 2] = '\'';
+ }
+ len += 3;
+ }
+ if (quoted)
+ quoted[len] = c;
+ len++;
+ }
+
+ if (quoted)
+ quoted[len] = '\'';
+ return len + 1;
+ }
+ }
+
+ if (quoted)
+ quoted[len] = c;
+ len++;
+ }
+}
--- /dev/null
+/* quotesys.h -- declarations for quoting system arguments */
+
+#if defined __STDC__ || __GNUC__
+# define __QUOTESYS_P(args) args
+#else
+# define __QUOTESYS_P(args) ()
+#endif
+
+size_t quote_system_arg __QUOTESYS_P ((char *, char const *));
--- /dev/null
+/* utility functions for `patch' */
+
+/* Copyright (C) 1986 Larry Wall
+
+ Copyright (C) 1992, 1993, 1997, 1998, 1999, 2001, 2002, 2003, 2006,
+ 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#define XTERN extern
+#include <common.h>
+#include <backupfile.h>
+#include <dirname.h>
+#include <hash.h>
+#include <quotearg.h>
+#include <quotesys.h>
+#undef XTERN
+#define XTERN
+#include <util.h>
+#include <xalloc.h>
+
+#include <maketime.h>
+#include <partime.h>
+
+#include <signal.h>
+#if !defined SIGCHLD && defined SIGCLD
+#define SIGCHLD SIGCLD
+#endif
+#if ! HAVE_RAISE && ! defined raise
+# define raise(sig) kill (getpid (), sig)
+#endif
+
+#include <stdarg.h>
+#include <full-write.h>
+
+static void makedirs (char *);
+
+typedef struct
+{
+ dev_t dev;
+ ino_t ino;
+} file_id;
+
+/* Return an index for ENTRY into a hash table of size TABLE_SIZE. */
+
+static size_t
+file_id_hasher (void const *entry, size_t table_size)
+{
+ file_id const *e = entry;
+ size_t i = e->ino + e->dev;
+ return i % table_size;
+}
+
+/* Do ENTRY1 and ENTRY2 refer to the same files? */
+
+static bool
+file_id_comparator (void const *entry1, void const *entry2)
+{
+ file_id const *e1 = entry1;
+ file_id const *e2 = entry2;
+ return (e1->ino == e2->ino && e1->dev == e2->dev);
+}
+
+static Hash_table *file_id_table;
+
+/* Initialize the hash table. */
+
+void
+init_backup_hash_table (void)
+{
+ file_id_table = hash_initialize (0, NULL, file_id_hasher,
+ file_id_comparator, free);
+ if (!file_id_table)
+ xalloc_die ();
+}
+
+/* Insert a file with status ST into the hash table. */
+
+static void
+insert_file (struct stat const *st)
+{
+ file_id *p;
+ static file_id *next_slot;
+
+ if (!next_slot)
+ next_slot = xmalloc (sizeof *next_slot);
+ next_slot->dev = st->st_dev;
+ next_slot->ino = st->st_ino;
+ p = hash_insert (file_id_table, next_slot);
+ if (!p)
+ xalloc_die ();
+ if (p == next_slot)
+ next_slot = NULL;
+}
+
+/* Has the file identified by ST already been inserted into the hash
+ table? */
+
+bool
+file_already_seen (struct stat const *st)
+{
+ file_id f;
+ f.dev = st->st_dev;
+ f.ino = st->st_ino;
+ return hash_lookup (file_id_table, &f) != 0;
+}
+
+static bool
+contains_slash (const char *s)
+{
+ for (; *s; s++)
+ if (ISSLASH(*s))
+ return true;
+ return false;
+}
+
+static void
+create_backup_copy (char const *from, char const *to, struct stat *st,
+ bool to_dir_known_to_exist)
+{
+ struct utimbuf utimbuf;
+
+ copy_file (from, to, 0, 0, st->st_mode, to_dir_known_to_exist);
+ utimbuf.actime = st->st_atime;
+ utimbuf.modtime = st->st_mtime;
+ if (utime (to, &utimbuf) != 0)
+ pfatal ("Can't set timestamp on file %s",
+ quotearg (to));
+ if (chmod (to, st->st_mode) != 0)
+ pfatal ("Can't set timestamp on file %s",
+ quotearg (to));
+}
+
+void
+create_backup (char *to, struct stat *to_st, int *to_errno,
+ bool leave_original)
+{
+ struct stat tmp_st;
+ int tmp_errno;
+
+ if (! to_st || ! to_errno)
+ {
+ to_st = &tmp_st;
+ to_errno = &tmp_errno;
+ }
+ *to_errno = stat (to, to_st) == 0 ? 0 : errno;
+
+ if (! *to_errno && file_already_seen (to_st))
+ {
+ if (debug & 4)
+ say ("File %s already seen\n", quotearg (to));
+ }
+ else
+ {
+ int try_makedirs_errno = 0;
+ char *bakname;
+
+ if (origprae || origbase || origsuff)
+ {
+ char const *p = origprae ? origprae : "";
+ char const *b = origbase ? origbase : "";
+ char const *s = origsuff ? origsuff : "";
+ char const *t = to;
+ size_t plen = strlen (p);
+ size_t blen = strlen (b);
+ size_t slen = strlen (s);
+ size_t tlen = strlen (t);
+ char const *o;
+ size_t olen;
+
+ for (o = t + tlen, olen = 0;
+ o > t && ! ISSLASH (*(o - 1));
+ o--)
+ continue;
+ olen = t + tlen - o;
+ tlen -= olen;
+ bakname = xmalloc (plen + tlen + blen + olen + slen + 1);
+ memcpy (bakname, p, plen);
+ memcpy (bakname + plen, t, tlen);
+ memcpy (bakname + plen + tlen, b, blen);
+ memcpy (bakname + plen + tlen + blen, o, olen);
+ memcpy (bakname + plen + tlen + blen + olen, s, slen + 1);
+
+ if ((origprae
+ && (contains_slash (origprae + FILE_SYSTEM_PREFIX_LEN (origprae))
+ || contains_slash (to)))
+ || (origbase && contains_slash (origbase)))
+ try_makedirs_errno = ENOENT;
+ }
+ else
+ {
+ bakname = find_backup_file_name (to, backup_type);
+ if (!bakname)
+ xalloc_die ();
+ }
+
+ if (*to_errno)
+ {
+ int fd;
+
+ if (debug & 4)
+ say ("Creating empty file %s\n", quotearg (bakname));
+
+ try_makedirs_errno = ENOENT;
+ unlink (bakname);
+ while ((fd = creat (bakname, 0666)) < 0)
+ {
+ if (errno != try_makedirs_errno)
+ pfatal ("Can't create file %s", quotearg (bakname));
+ makedirs (bakname);
+ try_makedirs_errno = 0;
+ }
+ if (close (fd) != 0)
+ pfatal ("Can't close file %s", quotearg (bakname));
+ }
+ else if (leave_original)
+ create_backup_copy (to, bakname, to_st, try_makedirs_errno == 0);
+ else
+ {
+ if (debug & 4)
+ say ("Renaming file %s to %s\n",
+ quotearg_n (0, to), quotearg_n (1, bakname));
+ while (rename (to, bakname) != 0)
+ {
+ if (errno == try_makedirs_errno)
+ {
+ makedirs (bakname);
+ try_makedirs_errno = 0;
+ }
+ else if (errno == EXDEV)
+ {
+ create_backup_copy (to, bakname, to_st,
+ try_makedirs_errno == 0);
+ unlink (to);
+ break;
+ }
+ else
+ pfatal ("Can't rename file %s to %s",
+ quotearg_n (0, to), quotearg_n (1, bakname));
+ }
+ }
+ free (bakname);
+ }
+}
+
+/* Move a file FROM (where *FROM_NEEDS_REMOVAL is nonzero if FROM
+ needs removal when cleaning up at the end of execution, and where
+ *FROMST is FROM's status if known),
+ to TO, renaming it if possible and copying it if necessary.
+ If we must create TO, use MODE to create it.
+ If FROM is null, remove TO.
+ FROM_NEEDS_REMOVAL must be nonnull if FROM is nonnull.
+ and FROMST must be nonnull if both FROM and BACKUP are nonnull.
+ Back up TO if BACKUP is true. */
+
+void
+move_file (char const *from, int volatile *from_needs_removal,
+ struct stat const *fromst,
+ char *to, mode_t mode, bool backup)
+{
+ struct stat to_st;
+ int to_errno = -1;
+
+ if (backup)
+ create_backup (to, &to_st, &to_errno, false);
+
+ if (from)
+ {
+ if (debug & 4)
+ say ("Renaming file %s to %s\n",
+ quotearg_n (0, from), quotearg_n (1, to));
+
+ if (rename (from, to) != 0)
+ {
+ bool to_dir_known_to_exist = false;
+
+ if (errno == ENOENT
+ && (to_errno == -1 || to_errno == ENOENT))
+ {
+ makedirs (to);
+ to_dir_known_to_exist = true;
+ if (rename (from, to) == 0)
+ goto rename_succeeded;
+ }
+
+ if (errno == EXDEV)
+ {
+ struct stat tost;
+ if (! backup)
+ {
+ if (unlink (to) == 0)
+ to_dir_known_to_exist = true;
+ else if (errno != ENOENT)
+ pfatal ("Can't remove file %s", quotearg (to));
+ }
+ copy_file (from, to, &tost, 0, mode, to_dir_known_to_exist);
+ insert_file (&tost);
+ return;
+ }
+
+ pfatal ("Can't rename file %s to %s",
+ quotearg_n (0, from), quotearg_n (1, to));
+ }
+
+ rename_succeeded:
+ if (fromst)
+ insert_file (fromst);
+ /* Do not clear *FROM_NEEDS_REMOVAL if it's possible that the
+ rename returned zero because FROM and TO are hard links to
+ the same file. */
+ if (0 < to_errno
+ || (to_errno == 0 && to_st.st_nlink <= 1))
+ *from_needs_removal = 0;
+ }
+ else if (! backup)
+ {
+ if (debug & 4)
+ say ("Removing file %s\n", quotearg (to));
+ if (unlink (to) != 0 && errno != ENOENT)
+ pfatal ("Can't remove file %s", quotearg (to));
+ }
+}
+
+/* Create FILE with OPEN_FLAGS, and with MODE adjusted so that
+ we can read and write the file and that the file is not executable.
+ Return the file descriptor. */
+int
+create_file (char const *file, int open_flags, mode_t mode,
+ bool to_dir_known_to_exist)
+{
+ int try_makedirs_errno = to_dir_known_to_exist ? 0 : ENOENT;
+ int fd;
+ mode |= S_IRUSR | S_IWUSR;
+ mode &= ~ (S_IXUSR | S_IXGRP | S_IXOTH);
+ do
+ {
+ if (! (O_CREAT && O_TRUNC))
+ close (creat (file, mode));
+ fd = open (file, O_CREAT | O_TRUNC | open_flags, mode);
+ if (fd < 0)
+ {
+ char *f;
+ if (errno != try_makedirs_errno)
+ pfatal ("Can't create file %s", quotearg (file));
+ f = xstrdup (file);
+ makedirs (f);
+ free (f);
+ try_makedirs_errno = 0;
+ }
+ } while (fd < 0);
+ return fd;
+}
+
+static void
+copy_to_fd (const char *from, int tofd)
+{
+ int fromfd;
+ ssize_t i;
+
+ if ((fromfd = open (from, O_RDONLY | O_BINARY)) < 0)
+ pfatal ("Can't reopen file %s", quotearg (from));
+ while ((i = read (fromfd, buf, bufsize)) != 0)
+ {
+ if (i == (ssize_t) -1)
+ read_fatal ();
+ if (full_write (tofd, buf, i) != i)
+ write_fatal ();
+ }
+ if (close (fromfd) != 0)
+ read_fatal ();
+}
+
+/* Copy a file. */
+
+void
+copy_file (char const *from, char const *to, struct stat *tost,
+ int to_flags, mode_t mode, bool to_dir_known_to_exist)
+{
+ int tofd;
+
+ if (debug & 4)
+ say ("Copying file %s to %s\n",
+ quotearg_n (0, from), quotearg_n (1, to));
+ tofd = create_file (to, O_WRONLY | O_BINARY | to_flags, mode,
+ to_dir_known_to_exist);
+ copy_to_fd (from, tofd);
+ if ((tost && fstat (tofd, tost) != 0)
+ || close (tofd) != 0)
+ write_fatal ();
+}
+
+/* Append to file. */
+
+void
+append_to_file (char const *from, char const *to)
+{
+ int tofd;
+
+ if ((tofd = open (to, O_WRONLY | O_BINARY | O_APPEND)) < 0)
+ pfatal ("Can't reopen file %s", quotearg (to));
+ copy_to_fd (from, tofd);
+ if (close (tofd) != 0)
+ write_fatal ();
+}
+
+static char const DEV_NULL[] = NULL_DEVICE;
+
+static char const RCSSUFFIX[] = ",v";
+static char const CHECKOUT[] = "co %s";
+static char const CHECKOUT_LOCKED[] = "co -l %s";
+static char const RCSDIFF1[] = "rcsdiff %s";
+
+static char const SCCSPREFIX[] = "s.";
+static char const GET[] = "get ";
+static char const GET_LOCKED[] = "get -e ";
+static char const SCCSDIFF1[] = "get -p ";
+static char const SCCSDIFF2[] = "|diff - %s";
+
+static char const CLEARTOOL_CO[] = "cleartool co -unr -nc ";
+
+static char const PERFORCE_CO[] = "p4 edit ";
+
+/* Return "RCS" if FILENAME is controlled by RCS,
+ "SCCS" if it is controlled by SCCS,
+ "ClearCase" if it is controlled by Clearcase,
+ "Perforce" if it is controlled by Perforce,
+ and 0 otherwise.
+ READONLY is true if we desire only readonly access to FILENAME.
+ FILESTAT describes FILENAME's status or is 0 if FILENAME does not exist.
+ If successful and if GETBUF is nonzero, set *GETBUF to a command
+ that gets the file; similarly for DIFFBUF and a command to diff the file
+ (but set *DIFFBUF to 0 if the diff operation is meaningless).
+ *GETBUF and *DIFFBUF must be freed by the caller. */
+char const *
+version_controller (char const *filename, bool readonly,
+ struct stat const *filestat, char **getbuf, char **diffbuf)
+{
+ struct stat cstat;
+ char *dir = dir_name (filename);
+ char *filebase = base_name (filename);
+ char const *dotslash = *filename == '-' ? "./" : "";
+ size_t dirlen = strlen (dir) + 1;
+ size_t maxfixlen = sizeof "SCCS/" - 1 + sizeof SCCSPREFIX - 1;
+ size_t maxtrysize = dirlen + strlen (filebase) + maxfixlen + 1;
+ size_t quotelen = quote_system_arg (0, dir) + quote_system_arg (0, filebase);
+ size_t maxgetsize = sizeof CLEARTOOL_CO + quotelen + maxfixlen;
+ size_t maxdiffsize =
+ (sizeof SCCSDIFF1 + sizeof SCCSDIFF2 + sizeof DEV_NULL - 1
+ + 2 * quotelen + maxfixlen);
+ char *trybuf = xmalloc (maxtrysize);
+ char const *r = 0;
+
+ sprintf (trybuf, "%s/", dir);
+
+#define try1(f,a1) (sprintf (trybuf + dirlen, f, a1), stat (trybuf, &cstat) == 0)
+#define try2(f,a1,a2) (sprintf (trybuf + dirlen, f, a1,a2), stat (trybuf, &cstat) == 0)
+
+ /* Check that RCS file is not working file.
+ Some hosts don't report file name length errors. */
+
+ if ((try2 ("RCS/%s%s", filebase, RCSSUFFIX)
+ || try1 ("RCS/%s", filebase)
+ || try2 ("%s%s", filebase, RCSSUFFIX))
+ && ! (filestat
+ && filestat->st_dev == cstat.st_dev
+ && filestat->st_ino == cstat.st_ino))
+ {
+ if (getbuf)
+ {
+ char *p = *getbuf = xmalloc (maxgetsize);
+ sprintf (p, readonly ? CHECKOUT : CHECKOUT_LOCKED, dotslash);
+ p += strlen (p);
+ p += quote_system_arg (p, filename);
+ *p = '\0';
+ }
+
+ if (diffbuf)
+ {
+ char *p = *diffbuf = xmalloc (maxdiffsize);
+ sprintf (p, RCSDIFF1, dotslash);
+ p += strlen (p);
+ p += quote_system_arg (p, filename);
+ *p++ = '>';
+ strcpy (p, DEV_NULL);
+ }
+
+ r = "RCS";
+ }
+ else if (try2 ("SCCS/%s%s", SCCSPREFIX, filebase)
+ || try2 ("%s%s", SCCSPREFIX, filebase))
+ {
+ if (getbuf)
+ {
+ char *p = *getbuf = xmalloc (maxgetsize);
+ sprintf (p, readonly ? GET : GET_LOCKED);
+ p += strlen (p);
+ p += quote_system_arg (p, trybuf);
+ *p = '\0';
+ }
+
+ if (diffbuf)
+ {
+ char *p = *diffbuf = xmalloc (maxdiffsize);
+ strcpy (p, SCCSDIFF1);
+ p += sizeof SCCSDIFF1 - 1;
+ p += quote_system_arg (p, trybuf);
+ sprintf (p, SCCSDIFF2, dotslash);
+ p += strlen (p);
+ p += quote_system_arg (p, filename);
+ *p++ = '>';
+ strcpy (p, DEV_NULL);
+ }
+
+ r = "SCCS";
+ }
+ else if (!readonly && filestat
+ && try1 ("%s@@", filebase) && S_ISDIR (cstat.st_mode))
+ {
+ if (getbuf)
+ {
+ char *p = *getbuf = xmalloc (maxgetsize);
+ strcpy (p, CLEARTOOL_CO);
+ p += sizeof CLEARTOOL_CO - 1;
+ p += quote_system_arg (p, filename);
+ *p = '\0';
+ }
+
+ if (diffbuf)
+ *diffbuf = 0;
+
+ r = "ClearCase";
+ }
+ else if (!readonly && filestat &&
+ (getenv("P4PORT") || getenv("P4USER") || getenv("P4CONFIG")))
+ {
+ if (getbuf)
+ {
+ char *p = *getbuf = xmalloc (maxgetsize);
+ strcpy (p, PERFORCE_CO);
+ p += sizeof PERFORCE_CO - 1;
+ p += quote_system_arg (p, filename);
+ *p = '\0';
+ }
+
+ if (diffbuf)
+ *diffbuf = 0;
+
+ r = "Perforce";
+ }
+
+ free (trybuf);
+ free (filebase);
+ free (dir);
+ return r;
+}
+
+/* Get FILENAME from version control system CS. The file already exists if
+ EXISTS. Only readonly access is needed if READONLY.
+ Use the command GETBUF to actually get the named file.
+ Store the resulting file status into *FILESTAT.
+ Return true if successful. */
+bool
+version_get (char const *filename, char const *cs, bool exists, bool readonly,
+ char const *getbuf, struct stat *filestat)
+{
+ if (patch_get < 0)
+ {
+ ask ("Get file %s from %s%s? [y] ",
+ quotearg (filename), cs, readonly ? "" : " with lock");
+ if (*buf == 'n')
+ return 0;
+ }
+
+ if (dry_run)
+ {
+ if (! exists)
+ fatal ("can't do dry run on nonexistent version-controlled file %s; invoke `%s' and try again",
+ quotearg (filename), getbuf);
+ }
+ else
+ {
+ if (verbosity == VERBOSE)
+ say ("Getting file %s from %s%s...\n", quotearg (filename),
+ cs, readonly ? "" : " with lock");
+ if (systemic (getbuf) != 0)
+ fatal ("Can't get file %s from %s", quotearg (filename), cs);
+ if (stat (filename, filestat) != 0)
+ pfatal ("%s", quotearg (filename));
+ }
+
+ return 1;
+}
+
+/* Allocate a unique area for a string. */
+
+char *
+savebuf (register char const *s, register size_t size)
+{
+ register char *rv;
+
+ if (! size)
+ return NULL;
+
+ rv = malloc (size);
+
+ if (! rv)
+ {
+ if (! using_plan_a)
+ xalloc_die ();
+ }
+ else
+ memcpy (rv, s, size);
+
+ return rv;
+}
+
+char *
+savestr (char const *s)
+{
+ return savebuf (s, strlen (s) + 1);
+}
+
+void
+remove_prefix (char *p, size_t prefixlen)
+{
+ char const *s = p + prefixlen;
+ while ((*p++ = *s++))
+ continue;
+}
+
+char *
+format_linenum (char numbuf[LINENUM_LENGTH_BOUND + 1], LINENUM n)
+{
+ char *p = numbuf + LINENUM_LENGTH_BOUND;
+ *p = '\0';
+
+ if (n < 0)
+ {
+ do
+ *--p = '0' - (int) (n % 10);
+ while ((n /= 10) != 0);
+
+ *--p = '-';
+ }
+ else
+ {
+ do
+ *--p = '0' + (int) (n % 10);
+ while ((n /= 10) != 0);
+ }
+
+ return p;
+}
+
+/* Terminal output, pun intended. */
+
+void
+fatal (char const *format, ...)
+{
+ va_list args;
+ fprintf (stderr, "%s: **** ", program_name);
+ va_start (args, format);
+ vfprintf (stderr, format, args);
+ va_end (args);
+ putc ('\n', stderr);
+ fflush (stderr);
+ fatal_exit (0);
+}
+
+void
+xalloc_die (void)
+{
+ fatal ("out of memory");
+}
+
+void
+read_fatal (void)
+{
+ pfatal ("read error");
+}
+
+void
+write_fatal (void)
+{
+ pfatal ("write error");
+}
+
+/* Say something from patch, something from the system, then silence . . . */
+
+void
+pfatal (char const *format, ...)
+{
+ int errnum = errno;
+ va_list args;
+ fprintf (stderr, "%s: **** ", program_name);
+ va_start (args, format);
+ vfprintf (stderr, format, args);
+ va_end (args);
+ fflush (stderr); /* perror bypasses stdio on some hosts. */
+ errno = errnum;
+ perror (" ");
+ fflush (stderr);
+ fatal_exit (0);
+}
+
+/* Tell the user something. */
+
+static void
+vsay (char const *format, va_list args)
+{
+ vfprintf (stdout, format, args);
+ fflush (stdout);
+}
+
+void
+say (char const *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ vsay (format, args);
+ va_end (args);
+}
+
+/* Get a response from the user, somehow or other. */
+
+void
+ask (char const *format, ...)
+{
+ static int ttyfd = -2;
+ ssize_t r;
+ va_list args;
+
+ va_start (args, format);
+ vfprintf (stdout, format, args);
+ va_end (args);
+ fflush (stdout);
+
+ if (ttyfd == -2)
+ {
+ /* If standard output is not a tty, don't bother opening /dev/tty,
+ since it's unlikely that stdout will be seen by the tty user.
+ The isatty test also works around a bug in GNU Emacs 19.34 under Linux
+ which makes a call-process `patch' hang when it reads from /dev/tty.
+ POSIX.1-2001 XCU line 26599 requires that we read /dev/tty,
+ though. */
+ ttyfd = (posixly_correct || isatty (STDOUT_FILENO)
+ ? open (TTY_DEVICE, O_RDONLY)
+ : -1);
+ }
+
+ if (ttyfd < 0)
+ {
+ /* No terminal at all -- default it. */
+ printf ("\n");
+ buf[0] = '\n';
+ buf[1] = '\0';
+ }
+ else
+ {
+ size_t s = 0;
+ while ((r = read (ttyfd, buf + s, bufsize - 1 - s)) == bufsize - 1 - s
+ && buf[bufsize - 2] != '\n')
+ {
+ s = bufsize - 1;
+ bufsize *= 2;
+ buf = realloc (buf, bufsize);
+ if (!buf)
+ xalloc_die ();
+ }
+ if (r == 0)
+ printf ("EOF\n");
+ else if (r < 0)
+ {
+ perror ("tty read");
+ fflush (stderr);
+ close (ttyfd);
+ ttyfd = -1;
+ r = 0;
+ }
+ buf[s + r] = '\0';
+ }
+}
+
+/* Return nonzero if it OK to reverse a patch. */
+
+bool
+ok_to_reverse (char const *format, ...)
+{
+ bool r = false;
+
+ if (noreverse || ! (force && verbosity == SILENT))
+ {
+ va_list args;
+ va_start (args, format);
+ vsay (format, args);
+ va_end (args);
+ }
+
+ if (noreverse)
+ {
+ say (" Skipping patch.\n");
+ skip_rest_of_patch = true;
+ }
+ else if (force)
+ {
+ if (verbosity != SILENT)
+ say (" Applying it anyway.\n");
+ }
+ else if (batch)
+ {
+ say (reverse ? " Ignoring -R.\n" : " Assuming -R.\n");
+ r = true;
+ }
+ else
+ {
+ ask (reverse ? " Ignore -R? [n] " : " Assume -R? [n] ");
+ r = *buf == 'y';
+ if (! r)
+ {
+ ask ("Apply anyway? [n] ");
+ if (*buf != 'y')
+ {
+ if (verbosity != SILENT)
+ say ("Skipping patch.\n");
+ skip_rest_of_patch = true;
+ }
+ }
+ }
+
+ return r;
+}
+
+/* How to handle certain events when not in a critical region. */
+
+#define NUM_SIGS ((int) (sizeof (sigs) / sizeof (*sigs)))
+static int const sigs[] = {
+#ifdef SIGHUP
+ SIGHUP,
+#endif
+#ifdef SIGPIPE
+ SIGPIPE,
+#endif
+#ifdef SIGTERM
+ SIGTERM,
+#endif
+#ifdef SIGXCPU
+ SIGXCPU,
+#endif
+#ifdef SIGXFSZ
+ SIGXFSZ,
+#endif
+ SIGINT
+};
+
+#if !HAVE_SIGPROCMASK
+#define sigset_t int
+#define sigemptyset(s) (*(s) = 0)
+#ifndef sigmask
+#define sigmask(sig) (1 << ((sig) - 1))
+#endif
+#define sigaddset(s, sig) (*(s) |= sigmask (sig))
+#define sigismember(s, sig) ((*(s) & sigmask (sig)) != 0)
+#ifndef SIG_BLOCK
+#define SIG_BLOCK 0
+#endif
+#ifndef SIG_UNBLOCK
+#define SIG_UNBLOCK (SIG_BLOCK + 1)
+#endif
+#ifndef SIG_SETMASK
+#define SIG_SETMASK (SIG_BLOCK + 2)
+#endif
+#define sigprocmask(how, n, o) \
+ ((how) == SIG_BLOCK \
+ ? ((o) ? *(o) = sigblock (*(n)) : sigblock (*(n))) \
+ : (how) == SIG_UNBLOCK \
+ ? sigsetmask (((o) ? *(o) = sigblock (0) : sigblock (0)) & ~*(n)) \
+ : (o ? *(o) = sigsetmask (*(n)) : sigsetmask (*(n))))
+#if !HAVE_SIGSETMASK
+#define sigblock(mask) 0
+#define sigsetmask(mask) 0
+#endif
+#endif
+
+static sigset_t initial_signal_mask;
+static sigset_t signals_to_block;
+
+#if ! HAVE_SIGACTION
+static void fatal_exit_handler (int) __attribute__ ((noreturn));
+static void
+fatal_exit_handler (int sig)
+{
+ signal (sig, SIG_IGN);
+ fatal_exit (sig);
+}
+#endif
+
+void
+set_signals (bool reset)
+{
+ int i;
+#if HAVE_SIGACTION
+ struct sigaction initial_act, fatal_act;
+ fatal_act.sa_handler = fatal_exit;
+ sigemptyset (&fatal_act.sa_mask);
+ fatal_act.sa_flags = 0;
+#define setup_handler(sig) sigaction (sig, &fatal_act, (struct sigaction *) 0)
+#else
+#define setup_handler(sig) signal (sig, fatal_exit_handler)
+#endif
+
+ if (!reset)
+ {
+#ifdef SIGCHLD
+ /* System V fork+wait does not work if SIGCHLD is ignored. */
+ signal (SIGCHLD, SIG_DFL);
+#endif
+ sigemptyset (&signals_to_block);
+ for (i = 0; i < NUM_SIGS; i++)
+ {
+ bool ignoring_signal;
+#if HAVE_SIGACTION
+ if (sigaction (sigs[i], (struct sigaction *) 0, &initial_act) != 0)
+ continue;
+ ignoring_signal = initial_act.sa_handler == SIG_IGN;
+#else
+ ignoring_signal = signal (sigs[i], SIG_IGN) == SIG_IGN;
+#endif
+ if (! ignoring_signal)
+ {
+ sigaddset (&signals_to_block, sigs[i]);
+ setup_handler (sigs[i]);
+ }
+ }
+ }
+ else
+ {
+ /* Undo the effect of ignore_signals. */
+#if HAVE_SIGPROCMASK || HAVE_SIGSETMASK
+ sigprocmask (SIG_SETMASK, &initial_signal_mask, (sigset_t *) 0);
+#else
+ for (i = 0; i < NUM_SIGS; i++)
+ if (sigismember (&signals_to_block, sigs[i]))
+ setup_handler (sigs[i]);
+#endif
+ }
+}
+
+/* How to handle certain events when in a critical region. */
+
+void
+ignore_signals (void)
+{
+#if HAVE_SIGPROCMASK || HAVE_SIGSETMASK
+ sigprocmask (SIG_BLOCK, &signals_to_block, &initial_signal_mask);
+#else
+ int i;
+ for (i = 0; i < NUM_SIGS; i++)
+ if (sigismember (&signals_to_block, sigs[i]))
+ signal (sigs[i], SIG_IGN);
+#endif
+}
+
+void
+exit_with_signal (int sig)
+{
+ sigset_t s;
+ signal (sig, SIG_DFL);
+ sigemptyset (&s);
+ sigaddset (&s, sig);
+ sigprocmask (SIG_UNBLOCK, &s, (sigset_t *) 0);
+ raise (sig);
+ exit (2);
+}
+
+int
+systemic (char const *command)
+{
+ if (debug & 8)
+ say ("+ %s\n", command);
+ fflush (stdout);
+ return system (command);
+}
+
+/* Replace '/' with '\0' in FILENAME if it marks a place that
+ needs testing for the existence of directory. Return the address
+ of the last location replaced, or 0 if none were replaced. */
+static char *
+replace_slashes (char *filename)
+{
+ char *f;
+ char *last_location_replaced = 0;
+ char const *component_start;
+
+ for (f = filename + FILE_SYSTEM_PREFIX_LEN (filename); ISSLASH (*f); f++)
+ continue;
+
+ component_start = f;
+
+ for (; *f; f++)
+ if (ISSLASH (*f))
+ {
+ char *slash = f;
+
+ /* Treat multiple slashes as if they were one slash. */
+ while (ISSLASH (f[1]))
+ f++;
+
+ /* Ignore slashes at the end of the path. */
+ if (! f[1])
+ break;
+
+ /* "." and ".." need not be tested. */
+ if (! (slash - component_start <= 2
+ && component_start[0] == '.' && slash[-1] == '.'))
+ {
+ *slash = '\0';
+ last_location_replaced = slash;
+ }
+
+ component_start = f + 1;
+ }
+
+ return last_location_replaced;
+}
+
+/* Make sure we'll have the directories to create a file.
+ Ignore the last element of `filename'. */
+
+static void
+makedirs (register char *filename)
+{
+ register char *f;
+ register char *flim = replace_slashes (filename);
+
+ if (flim)
+ {
+ /* Create any missing directories, replacing NULs by '/'s.
+ Ignore errors. We may have to keep going even after an EEXIST,
+ since the path may contain ".."s; and when there is an EEXIST
+ failure the system may return some other error number.
+ Any problems will eventually be reported when we create the file. */
+ for (f = filename; f <= flim; f++)
+ if (!*f)
+ {
+ mkdir (filename,
+ S_IRUSR|S_IWUSR|S_IXUSR
+ |S_IRGRP|S_IWGRP|S_IXGRP
+ |S_IROTH|S_IWOTH|S_IXOTH);
+ *f = '/';
+ }
+ }
+}
+
+/* Remove empty ancestor directories of FILENAME.
+ Ignore errors, since the path may contain ".."s, and when there
+ is an EEXIST failure the system may return some other error number. */
+void
+removedirs (char *filename)
+{
+ size_t i;
+
+ for (i = strlen (filename); i != 0; i--)
+ if (ISSLASH (filename[i])
+ && ! (ISSLASH (filename[i - 1])
+ || (filename[i - 1] == '.'
+ && (i == 1
+ || ISSLASH (filename[i - 2])
+ || (filename[i - 2] == '.'
+ && (i == 2
+ || ISSLASH (filename[i - 3])))))))
+ {
+ filename[i] = '\0';
+ if (rmdir (filename) == 0 && verbosity == VERBOSE)
+ say ("Removed empty directory %s\n", quotearg (filename));
+ filename[i] = '/';
+ }
+}
+
+static time_t initial_time;
+
+void
+init_time (void)
+{
+ time (&initial_time);
+}
+
+/* Make filenames more reasonable. */
+
+char *
+fetchname (char *at, int strip_leading, char **ptimestr, time_t *pstamp)
+{
+ char *name;
+ char *timestr = NULL;
+ register char *t;
+ int sleading = strip_leading;
+ time_t stamp = (time_t) -1;
+
+ while (ISSPACE ((unsigned char) *at))
+ at++;
+ if (debug & 128)
+ say ("fetchname %s %d\n", at, strip_leading);
+
+ name = at;
+ /* Strip up to `strip_leading' leading slashes and null terminate.
+ If `strip_leading' is negative, strip all leading slashes. */
+ for (t = at; *t; t++)
+ {
+ if (ISSLASH (*t))
+ {
+ while (ISSLASH (t[1]))
+ t++;
+ if (strip_leading < 0 || --sleading >= 0)
+ name = t+1;
+ }
+ else if (ISSPACE ((unsigned char) *t))
+ {
+ /* Allow file names with internal spaces,
+ but only if a tab separates the file name from the date. */
+ char const *u = t;
+ while (*u != '\t' && ISSPACE ((unsigned char) u[1]))
+ u++;
+ if (*u != '\t' && strchr (u + 1, '\t'))
+ continue;
+
+ if (*u == '\n')
+ stamp = (time_t) -1;
+ else
+ {
+ if (ptimestr)
+ {
+ char const *t = u + strlen (u);
+ if (t != u && *(t-1) == '\n')
+ t--;
+ if (t != u && *(t-1) == '\r')
+ t--;
+ timestr = savebuf (u, t - u + 1);
+ timestr[t - u] = 0;
+ }
+
+ if (set_time | set_utc)
+ stamp = str2time (&u, initial_time,
+ set_utc ? 0L : TM_LOCAL_ZONE);
+ else
+ {
+ /* The head says the file is nonexistent if the
+ timestamp is the epoch; but the listed time is
+ local time, not UTC, and POSIX.1 allows local
+ time offset anywhere in the range -25:00 <
+ offset < +26:00. Match any time in that range
+ by assuming local time is -25:00 and then
+ matching any ``local'' time T in the range 0 <
+ T < 25+26 hours. */
+ stamp = str2time (&u, initial_time, -25L * 60 * 60);
+ if (0 < stamp && stamp < (25 + 26) * 60L * 60)
+ stamp = 0;
+ }
+
+ if (*u && ! ISSPACE ((unsigned char) *u))
+ stamp = (time_t) -1;
+ }
+
+ *t = '\0';
+ break;
+ }
+ }
+
+ if (!*name)
+ {
+ if (timestr)
+ free (timestr);
+ return 0;
+ }
+
+ /* If the name is "/dev/null", ignore the name and mark the file
+ as being nonexistent. The name "/dev/null" appears in patches
+ regardless of how NULL_DEVICE is spelled. */
+ if (strcmp (at, "/dev/null") == 0)
+ {
+ if (pstamp)
+ *pstamp = 0;
+ if (timestr)
+ free (timestr);
+ return 0;
+ }
+
+ /* Ignore the name if it doesn't have enough slashes to strip off. */
+ if (0 < sleading)
+ {
+ if (timestr)
+ free (timestr);
+ return 0;
+ }
+
+ if (pstamp)
+ *pstamp = stamp;
+ if (timestr)
+ *ptimestr = timestr;
+ return savestr (name);
+}
+
+void
+Fseek (FILE *stream, file_offset offset, int ptrname)
+{
+ if (file_seek (stream, offset, ptrname) != 0)
+ pfatal ("fseek");
+}
--- /dev/null
+/* utility functions for `patch' */
+
+/* Copyright (C) 1986 Larry Wall
+
+ Copyright (C) 1992, 1993, 1997, 1998, 1999, 2001, 2002, 2003, 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 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; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#if HAVE_UTIME_H
+# include <utime.h>
+#endif
+/* Some nonstandard hosts don't declare this structure even in <utime.h>. */
+#if ! HAVE_STRUCT_UTIMBUF
+struct utimbuf
+{
+ time_t actime;
+ time_t modtime;
+};
+#endif
+
+/* An upper bound on the print length of a signed decimal line number.
+ Add one for the sign. */
+#define LINENUM_LENGTH_BOUND (sizeof (LINENUM) * CHAR_BIT / 3 + 1)
+
+XTERN enum backup_type backup_type;
+
+bool ok_to_reverse (char const *, ...) __attribute__ ((format (printf, 1, 2)));
+void ask (char const *, ...) __attribute__ ((format (printf, 1, 2)));
+void say (char const *, ...) __attribute__ ((format (printf, 1, 2)));
+
+void fatal (char const *, ...)
+ __attribute__ ((noreturn, format (printf, 1, 2)));
+void pfatal (char const *, ...)
+ __attribute__ ((noreturn, format (printf, 1, 2)));
+
+char *fetchname (char *, int, char **, time_t *);
+char *savebuf (char const *, size_t);
+char *savestr (char const *);
+char const *version_controller (char const *, bool, struct stat const *, char **, char **);
+bool version_get (char const *, char const *, bool, bool, char const *, struct stat *);
+int create_file (char const *, int, mode_t, bool);
+int systemic (char const *);
+char *format_linenum (char[LINENUM_LENGTH_BOUND + 1], LINENUM);
+void Fseek (FILE *, file_offset, int);
+void copy_file (char const *, char const *, struct stat *, int, mode_t, bool);
+void append_to_file (char const *, char const *);
+void exit_with_signal (int) __attribute__ ((noreturn));
+void ignore_signals (void);
+void init_backup_hash_table (void);
+void init_time (void);
+void xalloc_die (void) __attribute__ ((noreturn));
+void create_backup (char *, struct stat *, int *, bool);
+void move_file (char const *, int volatile *, struct stat const *, char *, mode_t, bool);
+void read_fatal (void) __attribute__ ((noreturn));
+void remove_prefix (char *, size_t);
+void removedirs (char *);
+void set_signals (bool);
+void write_fatal (void) __attribute__ ((noreturn));
+bool file_already_seen (struct stat const *);
--- /dev/null
+/* Print the version number. */
+
+#define XTERN extern
+#include <common.h>
+#undef XTERN
+#define XTERN
+#include <version.h>
+
+static char const copyright_string[] = "\
+Copyright (C) 1988 Larry Wall\n\
+Copyright (C) 2003 Free Software Foundation, Inc.";
+
+static char const free_software_msgid[] = "\
+This program comes with NO WARRANTY, to the extent permitted by law.\n\
+You may redistribute copies of this program\n\
+under the terms of the GNU General Public License.\n\
+For more information about these matters, see the file named COPYING.";
+
+static char const authorship_msgid[] = "\
+written by Larry Wall and Paul Eggert";
+
+void
+version (void)
+{
+ printf ("%s %s\n%s\n\n%s\n\n%s\n", PACKAGE_NAME, PACKAGE_VERSION,
+ copyright_string, free_software_msgid, authorship_msgid);
+}
--- /dev/null
+/* Print the version number. */
+
+void version (void);
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+# Starts at a line <= 1 and prefix context < suffix context: start of
+# file until hunk has become symmetric.
+
+cat > a.diff <<EOF
+--- a
++++ a
+@@ -1,3 +1,4 @@
+ 2
++2a
+ 3
+ 4
+EOF
+
+seq 1 5 > a
+
+check 'patch < a.diff' <<EOF
+patching file a
+Hunk #1 succeeded at 2 with fuzz 1 (offset 1 line).
+EOF
+
+seq 2 5 > a
+
+check 'patch < a.diff' <<EOF
+patching file a
+EOF
+
+# ==============================================================
+
+# Starts at a line > 1: anywhere in the file
+
+cat > a.diff <<EOF
+--- a
++++ a
+@@ -2,3 +2,4 @@
+ 2
++2a
+ 3
+ 4
+EOF
+
+seq 1 5 > a
+
+check 'patch < a.diff' <<EOF
+patching file a
+EOF
+
+# ==============================================================
+
+# Prefix context > suffix context: end of file until hunk has
+# become symmetric.
+
+cat > a.diff <<EOF
+--- a
++++ a
+@@ -2,3 +2,4 @@
+ 2
+ 3
++3a
+ 4
+EOF
+
+seq 1 5 > a
+
+check 'patch < a.diff' <<EOF
+patching file a
+Hunk #1 succeeded at 2 with fuzz 1.
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > ab.diff <<EOF
+--- a/f
++++ b/f
+@@ -1 +1 @@
+-one
++two
+EOF
+
+echo one > f
+check 'patch -b -p1 < ab.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f.orig' <<EOF
+one
+EOF
+
+echo one > f
+check 'patch -b -B prefix. -p1 < ab.diff' <<EOF
+patching file f
+EOF
+
+check 'cat prefix.f' <<EOF
+one
+EOF
+
+echo one > f
+check 'patch -b -z .suffix -p1 < ab.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f.suffix' <<EOF
+one
+EOF
+
+echo one > f
+check 'patch -b -B prefix. -z .suffix -p1 < ab.diff' <<EOF
+patching file f
+EOF
+
+check 'cat prefix.f.suffix' <<EOF
+one
+EOF
+
+export PATCH_VERSION_CONTROL=existing
+export SIMPLE_BACKUP_SUFFIX=.bak
+echo one > f
+check 'patch -b -p1 < ab.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f.bak' <<EOF
+one
+EOF
+
+touch f.~1~
+echo one > f
+check 'patch -b -p1 < ab.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f.~2~' <<EOF
+one
+EOF
+
+export PATCH_VERSION_CONTROL=numbered
+echo one > f
+check 'patch -b -p1 < ab.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f.~3~' <<EOF
+one
+EOF
+
+unset PATCH_VERSION_CONTROL SIMPLE_BACKUP_SUFFIX
+
+# ==============================================================
+
+cat > ab.diff <<EOF
+--- a/d/f
++++ b/d/f
+@@ -1 +1 @@
+-one
++two
+EOF
+
+mkdir d
+
+echo one > d/f
+check 'patch -b -p1 < ab.diff' <<EOF
+patching file d/f
+EOF
+
+check 'cat d/f.orig' <<EOF
+one
+EOF
+
+echo one > d/f
+check 'patch -b -B orig/ -p1 < ab.diff' <<EOF
+patching file d/f
+EOF
+
+check 'cat orig/d/f' <<EOF
+one
+EOF
+
+echo one > d/f
+check 'patch -b -B orig/ -z .orig -p1 < ab.diff' <<EOF
+patching file d/f
+EOF
+
+check 'cat orig/d/f.orig' <<EOF
+one
+EOF
+
+echo one > d/f
+check 'patch -b -Y .orig/ -p1 < ab.diff' <<EOF
+patching file d/f
+EOF
+
+check 'cat d/.orig/f' <<EOF
+one
+EOF
+
+echo one > d/f
+check 'patch -b -Y .orig/ -z .orig -p1 < ab.diff' <<EOF
+patching file d/f
+EOF
+
+check 'cat d/.orig/f.orig' <<EOF
+one
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+# Regression test for an off-by-one error:
+#
+# Date: Sun, 26 Aug 2007 13:50:45 +0200
+# From: Jim Meyering <jim@meyering.net>
+#
+# The problem arises when the input is a context diff and the second
+# byte on a line of context is not a space or tab.
+# Patch then happily gobbles/ignores that bogus byte and outputs
+# the rest of the line with an additional (NUL) byte at the end.
+
+seq 1 7 > a
+
+cat > ab.diff <<EOF
+*** a
+--- b
+***************
+*** 1,7 ****
+ 1
+ 2
+ 3
+- X
+ 5
+ 6
+ 7 yyy
+--- 1,6 ----
+EOF
+
+check 'patch a < ab.diff || echo "Status: $?"' <<EOF
+patching file a
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file a.rej
+Status: 1
+EOF
+
+check 'cat -A a.rej' <<EOF
+*** a$
+--- b$
+***************$
+*** 1,7 ****$
+ 1$
+ 2$
+ 3$
+- X$
+ 5$
+ 6$
+ 7 yyy$
+--- 1,6 ----$
+ 1$
+ 2$
+ 3$
+ 5$
+ 6$
+ 7 yyy$
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+# Bug #25970: intuit_diff_type: Assertion `i0 != NONE' failed.
+
+cat > f.diff <<EOF
+--- f
++++ f
+@@ -1 +0,0 @@
+-one
+EOF
+
+echo one > f
+check 'patch -f -p1 < f.diff || echo "Status: $?"' <<EOF
+can't find file to patch at input line 3
+Perhaps you used the wrong -p or --strip option?
+The text leading up to this was:
+--------------------------
+|--- f
+|+++ f
+--------------------------
+No file to patch. Skipping patch.
+1 out of 1 hunk ignored
+Status: 1
+EOF
+
+# ==============================================================
+
+echo one > f
+diff -u /dev/null f > f.diff
+
+check 'patch -f < f.diff || echo "Status: $?"' <<EOF
+The next patch would create the file f,
+which already exists! Applying it anyway.
+patching file f
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+# ==============================================================
+
+echo one > f
+diff -u f /dev/null > f.diff
+rm f
+check 'patch -p0 < f.diff || echo "Status: $?"' <<EOF
+The next patch would delete the file f,
+which does not exist! Assume -R? [n]
+Apply anyway? [n]
+Skipping patch.
+1 out of 1 hunk ignored
+Status: 1
+EOF
+
+# ==============================================================
+
+echo one > f
+diff -u f /dev/null > f.diff
+rm f
+check 'patch -p0 -f < f.diff || echo "Status: $?"' <<EOF
+The next patch would delete the file f,
+which does not exist! Applying it anyway.
+patching file f
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+# ==============================================================
+
+umask 022
+
+echo one > f
+diff -u f /dev/null > f.diff
+rm f
+check 'patch -f f < f.diff || echo "Status: $?"' <<EOF
+The next patch would delete the file f,
+which does not exist! Applying it anyway.
+patching file f
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'ls -l f.orig | sed "s,\(..........\).*,\1,"' <<EOF
+-rw-r--r--
+EOF
+
+# ==============================================================
+
+rm f.orig
+echo f > f.orig
+rm -f f
+touch f
+diff -u f.orig f > f.diff
+check 'patch -f < f.diff || echo "Status: $?"' <<EOF
+The next patch would empty out the file f,
+which is already empty! Applying it anyway.
+patching file f
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# LF vs. CRLF line endings
+
+. $srcdir/test-lib.sh
+
+require_diff
+use_local_patch
+use_tmpdir
+
+lf2crlf() {
+ while read l; do echo -e "$l\r"; done \
+}
+echo 1 > a
+echo 1b > b
+
+diff a b | lf2crlf > ab.diff
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch.)
+patching file c
+EOF
+
+diff -c a b | lf2crlf > ab.diff
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch.)
+patching file c
+EOF
+
+diff -u a b | lf2crlf > ab.diff
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch.)
+patching file c
+EOF
+
+if ! have_ed ; then
+ echo "The ed utility is not available; skipping ed related tests"
+else
+ diff -e a b > ab.ed | lf2crlf > ab.ed
+ echo 1 > c
+ ncheck 'patch c < ab.ed'
+fi
+
+# ==============================================================
+
+echo 1 | lf2crlf > a
+echo 1b | lf2crlf > b
+diff -u a b > ab.diff
+cp a c
+check 'patch c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -A c' <<EOF
+1b^M$
+EOF
+
+echo 1 > a
+echo 1b > b
+diff -u a b | lf2crlf > ab.diff
+cp a c
+check 'patch c < ab.diff' <<EOF
+(Stripping trailing CRs from patch.)
+patching file c
+EOF
+
+check 'cat -A c' <<EOF
+1b$
+EOF
+
+echo 1 | lf2crlf > c
+check 'patch --binary c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -A c' <<EOF
+1b^M$
+EOF
+
+# ==============================================================
+
+echo 1 > a
+echo 2 > b
+diff -u a b | sed -e 's,@@$,@@ context\r,' > ab.diff
+
+echo 1 > c
+check 'patch c < ab.diff' <<EOF
+patching file c
+EOF
+
+check 'cat -A c' <<EOF
+2$
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+# IEEE Std 1003.1-2008 requires that with -o outfile, multiple patches
+# for a single file shall be applied to the intermediate versions of the
+# file created by any previous patches, and shall result in multiple,
+# concatenated versions of the file being written to outfile.
+
+cat > a.diff <<EOF
+--- a
++++ a
+@@ -1 +1 @@
+-one
++two
+--- a
++++ a
+@@ -1 +1 @@
+-two
++three
+EOF
+
+echo one > a
+
+check 'patch -o a.new a < a.diff' <<EOF
+patching file a
+patching file a
+EOF
+
+check 'cat a.new' <<EOF
+two
+four
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# More than one reject to
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > ab.diff <<EOF
+--- a
++++ a
+@@ -1 +1 @@
+-one
++two
+--- b
++++ b
+@@ -1 +1 @@
+-three
++four
+EOF
+
+echo one > a
+echo three > b
+
+check 'patch -p0 < ab.diff' <<EOF
+patching file a
+patching file b
+EOF
+
+# ==============================================================
+
+check 'patch -p0 -f < ab.diff || echo "Status: $?"' <<EOF
+patching file a
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file a.rej
+patching file b
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file b.rej
+Status: 1
+EOF
+
+check 'cat a.rej' <<EOF
+--- a
++++ a
+@@ -1 +1 @@
+-one
++two
+EOF
+
+check 'cat b.rej' <<EOF
+--- b
++++ b
+@@ -1 +1 @@
+-three
++four
+EOF
+
+check 'patch -p0 -f -r ab.rej < ab.diff || echo "Status: $?"' <<EOF
+patching file a
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file ab.rej
+patching file b
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file ab.rej
+Status: 1
+EOF
+
+check 'cat ab.rej' <<EOF
+--- a
++++ a
+@@ -1 +1 @@
+-one
++two
+--- b
++++ b
+@@ -1 +1 @@
+-three
++four
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Don't recognize hunks before a filename has been specified/seen
+
+. $srcdir/test-lib.sh
+
+require_cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > f.diff <<EOF
+--- a
++++ b
+@@ -1 +1 @@
+-one
++two
+--- c
++++ d
+@@ -1 +1 @@
+-two
++three
+EOF
+
+echo one > x
+
+check 'patch x < f.diff' <<EOF
+patching file x
+patching file x
+EOF
+
+check 'cat x' <<EOF
+three
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+# Line number counting and reporting regression test
+
+cat > a.diff <<EOF
+--- a
++++ b
+@@ -1 +1 @@
+-1
++1b
+@@ -3 +3,2 @@
+-4
++4b
++4b
+@@ -6 +0 @@
+-6
++6b
+EOF
+
+seq 1 7 > a
+check 'patch -f --verbose a < a.diff | grep ^Hunk' <<EOF
+Hunk #1 succeeded at 1.
+Hunk #2 succeeded at 4 (offset 1 line).
+Hunk #3 succeeded at 7.
+EOF
+
+check 'cat a' <<EOF
+1b
+2
+3
+4b
+4b
+5
+6b
+7
+EOF
+
+seq 1 7 | sed -e '4d' > a
+check 'patch -f --verbose a < a.diff | grep ^Hunk' <<EOF
+Hunk #1 succeeded at 1.
+Hunk #2 FAILED at 3.
+Hunk #3 succeeded at 5 (offset -1 lines).
+EOF
+
+check 'cat a' <<EOF
+1b
+2
+3
+5
+6b
+7
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Test the --reject-format=FORMAT option
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+if ! patch --merge </dev/null 2>/dev/null ; then
+ echo "Merge support DISABLED; skipping this test"
+ exit
+fi
+
+# ==============================================================
+
+x() {
+ body=`seq 1 $1`
+ shift
+ echo "$body" > a
+ sed=
+ while test $# -gt 0 -a "$1" != -- ; do
+ sed="$sed -e $1"
+ shift
+ done
+ echo "$body" | sed$sed -e b > b
+ shift
+ sed=
+ while test $# -gt 0 ; do
+ sed="$sed -e $1"
+ shift
+ done
+ echo "$body" | sed$sed -e b > c
+ output=`diff -u a b | patch $ARGS -f --merge c`
+ status=$?
+ echo "$output" | sed -e '/^\(\|patching file c\)$/d'
+ cat c
+ test $status == 0 || echo "Status: $status"
+}
+
+unset ARGS
+
+# ==============================================================
+
+check 'x 3' <<EOF
+1
+2
+3
+EOF
+
+check 'x 3 2d' <<EOF
+1
+3
+EOF
+
+check 'x 2 2ib' <<EOF
+1
+b
+2
+EOF
+
+check 'x 3 2ib -- 3ic' <<EOF
+Hunk #1 merged at 2.
+1
+b
+2
+c
+3
+EOF
+
+# ==============================================================
+
+check 'x 3 2c2b -- 2c2c' <<EOF
+Hunk #1 NOT MERGED at 2-6.
+1
+<<<<<<<
+2c
+=======
+2b
+>>>>>>>
+3
+Status: 1
+EOF
+
+check 'x 3 2d -- 2d' <<EOF
+Hunk #1 already applied at 2.
+1
+3
+EOF
+
+check 'x 2 2ibc -- 2ibc' <<EOF
+Hunk #1 already applied at 2.
+1
+bc
+2
+EOF
+
+check 'x 4 2aa 2aa -- 2aa 2aa' <<EOF
+Hunk #1 already applied at 3-4.
+1
+2
+a
+a
+3
+4
+EOF
+
+# ==============================================================
+
+check 'x 4 2d -- 3d' <<EOF
+Hunk #1 NOT MERGED at 2-6.
+1
+<<<<<<<
+2
+=======
+3
+>>>>>>>
+4
+Status: 1
+EOF
+
+check 'x 4 3d -- 2d' <<EOF
+Hunk #1 NOT MERGED at 2-6.
+1
+<<<<<<<
+3
+=======
+2
+>>>>>>>
+4
+Status: 1
+EOF
+
+# ==============================================================
+
+check 'x 3 3ib -- 2d' <<EOF
+Hunk #1 NOT MERGED at 2-6.
+1
+<<<<<<<
+=======
+2
+b
+>>>>>>>
+3
+Status: 1
+EOF
+
+check 'x 3 2d -- 3ib' <<EOF
+Hunk #1 NOT MERGED at 2-6.
+1
+<<<<<<<
+2
+b
+=======
+>>>>>>>
+3
+Status: 1
+EOF
+
+# ==============================================================
+
+check 'x 1 1cb -- 1cc' <<EOF
+Hunk #1 NOT MERGED at 1-4.
+<<<<<<<
+=======
+b
+>>>>>>>
+c
+Status: 1
+EOF
+
+check 'x 4 2ca 3cb -- 2ca 3cc' <<EOF
+Hunk #1 NOT MERGED at 3-7.
+1
+a
+<<<<<<<
+c
+=======
+b
+>>>>>>>
+4
+Status: 1
+EOF
+
+check 'x 6 3c3b 4c4b -- 3c3c 4c4c' <<EOF
+Hunk #1 NOT MERGED at 3-9.
+1
+2
+<<<<<<<
+3c
+4c
+=======
+3b
+4b
+>>>>>>>
+5
+6
+Status: 1
+EOF
+
+check 'x 4 2cb 3ca -- 2cc 3ca' <<EOF
+Hunk #1 NOT MERGED at 2-6.
+1
+<<<<<<<
+c
+=======
+b
+>>>>>>>
+a
+4
+Status: 1
+EOF
+
+check 'x 3 2ib 3ib -- 2ic' <<EOF
+Hunk #1 NOT MERGED at 2-6, merged at 8.
+1
+<<<<<<<
+c
+=======
+b
+>>>>>>>
+2
+b
+3
+Status: 1
+EOF
+
+check 'x 3 2ib 3ib 3ib -- 2ic' <<EOF
+Hunk #1 NOT MERGED at 2-6, merged at 8-9.
+1
+<<<<<<<
+c
+=======
+b
+>>>>>>>
+2
+b
+b
+3
+Status: 1
+EOF
+
+check 'x 9 4ca 5cb 6ca -- 4ca 5cc 6ca' <<EOF
+Hunk #1 NOT MERGED at 5-9.
+1
+2
+3
+a
+<<<<<<<
+c
+=======
+b
+>>>>>>>
+a
+7
+8
+9
+Status: 1
+EOF
+
+check 'x 3 2ib 3ib -- 1i0' <<EOF
+0
+1
+b
+2
+b
+3
+EOF
+
+check 'x 4 2ib 4ib -- 1i0 3ic' <<EOF
+Hunk #1 merged at 3,7.
+0
+1
+b
+2
+c
+3
+b
+4
+EOF
+
+# ==============================================================
+
+check 'x 5 2,4d -- 3c3c' <<EOF
+Hunk #1 NOT MERGED at 2-7.
+1
+<<<<<<<
+2
+3c
+4
+=======
+>>>>>>>
+5
+Status: 1
+EOF
+
+check 'x 5 3c3c -- 2,4d' <<EOF
+Hunk #1 NOT MERGED at 2-7.
+1
+<<<<<<<
+=======
+2
+3c
+4
+>>>>>>>
+5
+Status: 1
+EOF
+
+# ==============================================================
+
+check 'x 3 1,2d -- 2ic' <<EOF
+Hunk #1 NOT MERGED at 1-6.
+<<<<<<<
+1
+c
+2
+=======
+>>>>>>>
+3
+Status: 1
+EOF
+
+check 'x 3 2ic -- 1,2d' <<EOF
+Hunk #1 NOT MERGED at 1-6.
+<<<<<<<
+=======
+1
+c
+2
+>>>>>>>
+3
+Status: 1
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Be tolerant about munged whitespace in context format
+
+. $srcdir/test-lib.sh
+
+require_cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > ab.diff <<EOF
+*** a 2009-03-27 23:32:33.000000000 +0100
+--- b 2009-03-27 23:32:40.000000000 +0100
+***************
+*** 1 ****
+--- 1,2 ----
+ one
++ two
+EOF
+
+echo one > a
+check 'patch < ab.diff' <<EOF
+patching file a
+EOF
+
+sed -e 's/^ / /' ab.diff > c.diff
+
+echo one > a
+check 'patch < c.diff' <<EOF
+patching file a
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Don't recognize hunks before a filename has been specified/seen
+
+. $srcdir/test-lib.sh
+
+require_cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > n.diff <<EOF
+0a1
+> one
+EOF
+
+check 'patch < n.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+check 'patch -f -n < n.diff || echo "Status: $?"' <<EOF
+can't find file to patch at input line 1
+No file to patch. Skipping patch.
+1 out of 1 hunk ignored
+Status: 1
+EOF
+
+touch f
+check 'patch f < n.diff' <<EOF
+patching file f
+EOF
+
+# ==============================================================
+
+if ! have_ed ; then
+ echo "The ed utility is not available; skipping ed related tests"
+else
+ cat > e.diff <<EOF
+0a
+one
+.
+EOF
+
+ check 'patch < e.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+ check 'patch -f -e < e.diff || echo "Status: $?"' <<EOF
+can't find file to patch at input line 1
+No file to patch. Skipping patch.
+Status: 1
+EOF
+
+ rm -f f
+ touch f
+ ncheck 'patch f < e.diff'
+
+ check 'cat f' <<EOF
+one
+EOF
+fi
+
+# ==============================================================
+
+cat > h+c.diff <<EOF
+*** /dev/null
+--- f
+***************
+*** 0 ****
+--- 1 ----
++ one
+EOF
+
+rm -f f
+check 'patch < h+c.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
+
+sed -e '1,2d' h+c.diff > c.diff
+
+check 'patch < c.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+rm -f f
+check 'patch f < c.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
+
+# ==============================================================
+
+cat > h+u.diff <<EOF
+--- /dev/null
++++ f
+@@ -0,0 +1 @@
++one
+EOF
+
+rm -f f
+check 'patch < h+u.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
+
+sed -e '1,2d' h+u.diff > u.diff
+
+check 'patch < u.diff || echo "Status: $?"' <<EOF
+$PATCH: **** Only garbage was found in the patch input.
+Status: 2
+EOF
+
+rm -f f
+check 'patch f < u.diff' <<EOF
+patching file f
+EOF
+
+check 'cat f' <<EOF
+one
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Regression test for Assertion `s && size' failed in savebuf
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+echo one > f
+
+cat > f.diff <<EOF
+--- f
++++ f
+@@ -1,2 +1,2 @@
+-1
++1a
+
+\ No newline at end of file
+EOF
+
+echo 1 > f
+
+check 'patch -p0 < f.diff' <<EOF
+patching file f
+Hunk #1 succeeded at 1 with fuzz 1.
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Preserve the "diff -p" output in reject files
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+cat > a <<EOF
+int foo()
+ {
+ /* waste a line */
+
+ return 1;
+ }
+EOF
+
+cat > b <<EOF
+int foo()
+ {
+ /* waste a line */
+
+ return 2;
+ }
+EOF
+
+diff -p -c -L a -L b a b > ab.diff
+touch c
+check 'patch c < ab.diff || cat c.rej' <<EOF
+patching file c
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file c.rej
+*** a
+--- b
+*************** int foo()
+*** 2,6 ****
+ {
+ /* waste a line */
+
+! return 1;
+ }
+--- 2,6 ----
+ {
+ /* waste a line */
+
+! return 2;
+ }
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+timestamp1="2009-03-13 00:00:00 +0000"
+timestamp2="2009-03-14 00:00:00 +0000"
+cat > f.diff <<EOF
+--- a/f $timestamp1
++++ b/f $timestamp2
+@@ -1 +1 @@
+-one
++two
+@@ -2 +2 @@
+-three
++four
+EOF
+
+cat > f <<EOF
+one
+three
+EOF
+
+touch -d "$timestamp1" f
+chmod 644 f
+
+touch f.orig
+chmod 600 f.orig
+
+check 'patch -p1 --backup --set-utc < f.diff' <<EOF
+patching file f
+EOF
+
+check 'date -u "+%Y-%m-%d %H:%M:%S %z" -r f' <<EOF
+$timestamp2
+EOF
+
+# POSIX allows a byte like '+' or '.' in position 11 to indicate the
+# presence of extended permissions like ACLs.
+
+check 'ls -l f.orig | sed "s,\(..........\).*,\1,"' <<EOF
+-rw-r--r--
+EOF
+
+# ==============================================================
+
+cat > f <<EOF
+one
+five
+EOF
+
+umask 022
+
+check 'patch -p1 --backup --set-utc < f.diff || echo "Status: $?"' <<EOF
+patching file f
+Hunk #2 FAILED at 2.
+Not setting time of file f (time mismatch)
+1 out of 2 hunks FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'ls -l f.rej | sed "s,\(..........\).*,\1,"' <<EOF
+-rw-r--r--
+EOF
+
+# ==============================================================
+
+cat > f <<EOF
+one
+five
+EOF
+
+umask 027
+
+check 'patch -p1 --backup --set-utc < f.diff || echo "Status: $?"' <<EOF
+patching file f
+Hunk #2 FAILED at 2.
+Not setting time of file f (time mismatch)
+1 out of 2 hunks FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'ls -l f.rej | sed "s,\(..........\).*,\1,"' <<EOF
+-rw-r-----
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Test the --reject-format=FORMAT option
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > f.orig <<EOF
+a() {
+2
+3
+
+5
+6
+}
+EOF
+
+sed -e 's/5/5a/' f.orig > f
+diff -p -c -L f.orig -L f f.orig f > f.diff
+
+check 'patch -f -F0 --no-backup-if-mismatch f < f.diff || echo "Status: $?"' <<EOF
+patching file f
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'cat f.rej' <<EOF
+*** f.orig
+--- f
+*************** a() {
+*** 2,7 ****
+ 2
+ 3
+
+! 5
+ 6
+ }
+--- 2,7 ----
+ 2
+ 3
+
+! 5a
+ 6
+ }
+EOF
+
+# --------------------------------------------------------------
+
+( echo "Index: f"; diff -p -u -L f.orig -L f f.orig f ) > f.diff
+check 'patch -f -F0 --no-backup-if-mismatch f < f.diff || echo "Status: $?"' <<EOF
+patching file f
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'cat f.rej' <<EOF
+Index: f
+--- f.orig
++++ f
+@@ -2,6 +2,6 @@
+ 2
+ 3
+
+-5
++5a
+ 6
+ }
+EOF
+
+# --------------------------------------------------------------
+
+diff -p -c -L f.orig -L f f.orig f > f.diff
+check 'patch -f -F0 --no-backup-if-mismatch --reject-format=unified f < f.diff || echo "Status: $?"' <<EOF
+patching file f
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'cat f.rej' <<EOF
+--- f.orig
++++ f
+@@ -2,6 +2,6 @@
+ 2
+ 3
+
+-5
++5a
+ 6
+ }
+EOF
+
+# --------------------------------------------------------------
+
+( echo "Index: f"; diff -p -u -L f.orig -L f f.orig f ) > f.diff
+check 'patch -f -F0 --no-backup-if-mismatch --reject-format=context f < f.diff || echo "Status: $?"' <<EOF
+patching file f
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'cat f.rej' <<EOF
+Index: f
+*** f.orig
+--- f
+*************** a() {
+*** 2,7 ****
+ 2
+ 3
+
+! 5
+ 6
+ }
+--- 2,7 ----
+ 2
+ 3
+
+! 5a
+ 6
+ }
+EOF
+
+# ==============================================================
+
+echo one > a
+echo two > b
+diff -u -L "a label of a" -L "b label of b" a b > ab.diff
+mv b a
+
+check 'patch -f < ab.diff || echo "Status: $?"' <<EOF
+patching file a
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file a.rej
+Status: 1
+EOF
+
+check 'cat a.rej' <<EOF
+--- a label of a
++++ b label of b
+@@ -1 +1 @@
+-one
++two
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Patch must not overwrite backup files it has created itself.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+echo one > f
+
+cat > f.diff <<EOF
+--- f.orig
++++ f
+@@ -2 +2 @@
+-one
++two
+--- f.orig
++++ f
+@@ -2 +2 @@
+-two
++three
+--- f.orig
++++ f
+@@ -2 +2 @@
+-three
++four
+EOF
+
+check 'patch -p0 < f.diff' <<EOF
+patching file f
+Hunk #1 succeeded at 1 (offset -1 lines).
+patching file f
+Hunk #1 succeeded at 1 (offset -1 lines).
+patching file f
+Hunk #1 succeeded at 1 (offset -1 lines).
+EOF
+
+check 'cat f.orig' <<EOF
+one
+EOF
+
+# ==============================================================
+
+# Hardlinks between source files
+
+echo one > f
+ln f g
+
+cat > fg.diff <<EOF
+--- f.orig
++++ f
+@@ -2 +2 @@
+-one
++two
+--- g.orig
++++ g
+@@ -2 +2 @@
+-one
++two
+EOF
+
+check 'patch -p0 < fg.diff' <<EOF
+patching file f
+Hunk #1 succeeded at 1 (offset -1 lines).
+patching file g
+Hunk #1 succeeded at 1 (offset -1 lines).
+EOF
+
+check 'cat f.orig' <<EOF
+one
+EOF
+
+check 'cat g.orig' <<EOF
+one
+EOF
+
+# ==============================================================
+
+# This test case failed with a permission denied error with a
+# previous version of the remember-backup-files patch.
+
+cat > f.diff <<EOF
+--- f.orig
++++ f
+@@ -1 +1 @@
+-one
++two
+--- f.orig
++++ f
+@@ -1 +1 @@
+-two
++three
+EOF
+
+echo one > f
+chmod a=r f
+
+check 'patch -p0 < f.diff' <<EOF
+patching file f
+patching file f
+EOF
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+echo one > f
+
+cat > f.diff <<EOF
+--- f.orig
++++ f
+@@ -2 +2 @@
+-two
++three
+--- f.orig
++++ f
+@@ -2 +2 @@
+-three
++four
+--- f.orig
++++ f
+@@ -2 +2 @@
+-four
++five
+EOF
+
+check 'patch -p0 < f.diff || echo "Status: $?"' <<EOF
+patching file f
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+patching file f
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+patching file f
+Hunk #1 FAILED at 2.
+1 out of 1 hunk FAILED -- saving rejects to file f.rej
+Status: 1
+EOF
+
+check 'cat f.rej' <<EOF
+--- f.orig
++++ f
+@@ -2 +2 @@
+-two
++three
+--- f.orig
++++ f
+@@ -2 +2 @@
+-three
++four
+--- f.orig
++++ f
+@@ -2 +2 @@
+-four
++five
+EOF
--- /dev/null
+# Library for simple test scripts
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+require_cat() {
+ if ! type cat > /dev/null 2> /dev/null; then
+ echo "This test requires the cat utility" >&2
+ exit 2
+ fi
+}
+
+require_diff() {
+ case "`diff --version 2> /dev/null`" in
+ *GNU*)
+ ;;
+ *)
+ echo "This test requires GNU diff" >&2
+ exit 2
+ esac
+}
+
+have_ed() {
+ type ed >/dev/null 2>/dev/null
+}
+
+use_tmpdir() {
+ tmpdir=`mktemp -d`
+ if test -z "$tmpdir" ; then
+ echo "This test requires the mktemp utility" >&2
+ exit 2
+ fi
+ cd "$tmpdir"
+}
+
+use_local_patch() {
+ test -n "$PATCH" || PATCH=$PWD/src/patch
+
+ eval 'patch() {
+ if test -n "$GDB" ; then
+ echo -e "\n" >&3
+ gdbserver localhost:53153 $PATCH "$@" 2>&3
+ else
+ $PATCH "$@"
+ fi
+ }'
+}
+
+clean_env() {
+ unset PATCH_GET POSIXLY_CORRECT QUOTING_STYLE SIMPLE_BACKUP_SUFFIX \
+ VERSION_CONTROL PATCH_VERSION_CONTROL GDB
+}
+
+_check() {
+ _start_test "$@"
+ expected=`cat`
+ if got=`set +x; eval "$*" 3>&2 </dev/null 2>&1` && \
+ test "$expected" = "$got" ; then
+ echo "ok"
+ checks_succeeded="$checks_succeeded + 1"
+ else
+ echo "FAILED"
+ if test "$expected" != "$got" ; then
+ echo "$expected" > expected~
+ echo "$got" > got~
+ diff -u -L expected -L got expected~ got~
+ rm -f expected~ got~
+ fi
+ checks_failed="$checks_failed + 1"
+ fi
+}
+
+check() {
+ _check "$@"
+}
+
+ncheck() {
+ _check "$@" < /dev/null
+}
+
+cleanup() {
+ checks_succeeded=`expr $checks_succeeded`
+ checks_failed=`expr $checks_failed`
+ checks_total=`expr $checks_succeeded + $checks_failed`
+ status=0
+ if test $checks_total -gt 0 ; then
+ if test $checks_failed -gt 0 ; then
+ status=1
+ fi
+ echo "$checks_total tests ($checks_succeeded passed," \
+ "$checks_failed failed)"
+ fi
+ if test -n "$tmpdir" ; then
+ set -e
+ cd /
+ chmod -R u+rwx "$tmpdir"
+ rm -rf "$tmpdir"
+ fi
+ exit $status
+}
+
+if test -z "`echo -n`"; then
+ if eval 'test -n "${BASH_LINENO[0]}" 2>/dev/null'; then
+ eval '
+ _start_test() {
+ echo -n "[${BASH_LINENO[2]}] $* -- "
+ }'
+ else
+ eval '
+ _start_test() {
+ echo -n "* $* -- "
+ }'
+ fi
+else
+ eval '
+ _start_test() {
+ echo "* $*"
+ }'
+fi
+
+require_cat
+clean_env
+
+checks_succeeded=0
+checks_failed=0
+trap cleanup 0
+
--- /dev/null
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+# Bug #25969: Patch replaces unmodified files
+#
+# When a patch doesn't actually modify a file (i.e., only rejects),
+# the file is still replaced.
+
+cat > a.diff <<EOF
+--- a
++++ a
+@@ -1 +1 @@
+-one
++two
+EOF
+
+echo three > a
+ln a a.first
+
+check 'patch -b -B backup/ a < a.diff || echo "Status: $?"' <<EOF
+patching file a
+Hunk #1 FAILED at 1.
+1 out of 1 hunk FAILED -- saving rejects to file a.rej
+Status: 1
+EOF
+
+ncheck 'test a -ef a.first'
+
+check 'cat backup/a' <<EOF
+three
+EOF
+
+# ==============================================================
+
+# When applying an empty patch to a file with -o, copy the input file.
+
+cat > a.diff <<EOF
+EOF
+
+echo three > a
+
+check 'patch -o b a < a.diff' <<EOF
+patching file a
+EOF
+
+check 'cat b' <<EOF
+three
+EOF
--- /dev/null
+# (Re)compute version from git repostitory
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# The version generated is of the form TAG[-SHORTREF[-dirty]], with
+# TAG being the closest tag to the current version and SHORTREF being
+# the first 8 hex digits of the the SHA-1 hash of HEAD. If there are
+# local changes in the repository, -dirty is added.
+
+version=$1
+
+if git rev-parse --verify HEAD >/dev/null 2>/dev/null \
+ && test -z "`git rev-parse --show-cdup`" ; then
+ set -- `git describe --tags HEAD 2> /dev/null || \
+ git rev-parse --short HEAD` \
+ `git update-index --refresh --unmerged > /dev/null
+ if git diff-index --name-only HEAD | read dummy; then
+ echo -dirty
+ fi`
+ if test "`expr substr "$1" 1 1`" = v ; then
+ set -- "`expr substr "$1" 2 "(" length "$1" - 1 ")"`" "$2"
+ fi
+ echo $1$2 > .$version.tmp
+ if test ! -e $version \
+ || ! cmp -s .$version.tmp $version ; then
+ mv .$version.tmp $version
+ else
+ rm -f .$version.tmp
+ fi
+fi