From f6bfe1451a98f3e5107a8b0e1626f1eb622e6778 Mon Sep 17 00:00:00 2001 From: Apple Date: Sat, 27 Feb 2016 21:02:18 +0100 Subject: [PATCH] gpatch-3 --- Makefile | 22 + dpkg/control | 10 + patch/AUTHORS | 9 + patch/COPYING | 340 ++ patch/ChangeLog | 2168 +++++++++ patch/INSTALL | 228 + patch/Makefile.in | 200 + patch/NEWS | 237 + patch/README | 54 + patch/aclocal.m4 | 495 ++ patch/addext.c | 114 + patch/ansi2knr.1 | 36 + patch/ansi2knr.c | 678 +++ patch/argmatch.c | 310 ++ patch/argmatch.h | 129 + patch/backupfile.c | 277 ++ patch/backupfile.h | 60 + patch/basename.c | 79 + patch/basename.h | 9 + patch/common.h | 321 ++ patch/config.guess | 1091 +++++ patch/config.hin | 275 ++ patch/config.sub | 1220 +++++ patch/configure | 8633 ++++++++++++++++++++++++++++++++++ patch/configure.ac | 75 + patch/configure.in | 59 + patch/dirname.c | 105 + patch/dirname.h | 47 + patch/error.c | 400 ++ patch/error.h | 78 + patch/exitfail.c | 31 + patch/exitfail.h | 20 + patch/getopt.c | 1067 +++++ patch/getopt.h | 179 + patch/getopt1.c | 187 + patch/inp.c | 468 ++ patch/inp.h | 29 + patch/install-sh | 251 + patch/m4/c-bs-a.m4 | 29 + patch/m4/ccstdc.m4 | 95 + patch/m4/d-ino.m4 | 42 + patch/m4/error.m4 | 13 + patch/m4/inttypes_h.m4 | 22 + patch/m4/jm-glibc-io.m4 | 14 + patch/m4/largefile.m4 | 115 + patch/m4/malloc.m4 | 35 + patch/m4/mbrtowc.m4 | 24 + patch/m4/mbstate_t.m4 | 38 + patch/m4/mkdir.m4 | 34 + patch/m4/prereq.m4 | 153 + patch/m4/protos.m4 | 25 + patch/m4/realloc.m4 | 35 + patch/m4/setmode.m4 | 38 + patch/m4/utimbuf.m4 | 40 + patch/maketime.c | 501 ++ patch/maketime.h | 39 + patch/malloc.c | 38 + patch/memchr.c | 216 + patch/mkdir.c | 76 + patch/mkinstalldirs | 101 + patch/partime.c | 956 ++++ patch/partime.h | 77 + patch/patch.c | 1370 ++++++ patch/patch.man | 1160 +++++ patch/patchlevel.h | 1 + patch/pc/chdirsaf.c | 34 + patch/pc/djgpp/README | 19 + patch/pc/djgpp/config.sed | 41 + patch/pc/djgpp/configure.bat | 27 + patch/pc/djgpp/configure.sed | 37 + patch/pch.c | 1951 ++++++++ patch/pch.h | 45 + patch/quote.c | 28 + patch/quote.h | 12 + patch/quotearg.c | 658 +++ patch/quotearg.h | 114 + patch/quotesys.c | 125 + patch/quotesys.h | 9 + patch/realloc.c | 44 + patch/rename.c | 68 + patch/rmdir.c | 87 + patch/strcasecmp.c | 66 + patch/strncasecmp.c | 2 + patch/unlocked-io.h | 69 + patch/util.c | 1009 ++++ patch/util.h | 59 + patch/version.c | 30 + patch/version.h | 5 + patch/xalloc.h | 82 + patch/xmalloc.c | 113 + patch_cmds.plist | 22 + 91 files changed, 30034 insertions(+) create mode 100644 Makefile create mode 100644 dpkg/control create mode 100644 patch/AUTHORS create mode 100644 patch/COPYING create mode 100644 patch/ChangeLog create mode 100644 patch/INSTALL create mode 100644 patch/Makefile.in create mode 100644 patch/NEWS create mode 100644 patch/README create mode 100644 patch/aclocal.m4 create mode 100644 patch/addext.c create mode 100644 patch/ansi2knr.1 create mode 100644 patch/ansi2knr.c create mode 100644 patch/argmatch.c create mode 100644 patch/argmatch.h create mode 100644 patch/backupfile.c create mode 100644 patch/backupfile.h create mode 100644 patch/basename.c create mode 100644 patch/basename.h create mode 100644 patch/common.h create mode 100644 patch/config.guess create mode 100644 patch/config.hin create mode 100644 patch/config.sub create mode 100755 patch/configure create mode 100644 patch/configure.ac create mode 100644 patch/configure.in create mode 100644 patch/dirname.c create mode 100644 patch/dirname.h create mode 100644 patch/error.c create mode 100644 patch/error.h create mode 100644 patch/exitfail.c create mode 100644 patch/exitfail.h create mode 100644 patch/getopt.c create mode 100644 patch/getopt.h create mode 100644 patch/getopt1.c create mode 100644 patch/inp.c create mode 100644 patch/inp.h create mode 100755 patch/install-sh create mode 100644 patch/m4/c-bs-a.m4 create mode 100644 patch/m4/ccstdc.m4 create mode 100644 patch/m4/d-ino.m4 create mode 100644 patch/m4/error.m4 create mode 100644 patch/m4/inttypes_h.m4 create mode 100644 patch/m4/jm-glibc-io.m4 create mode 100644 patch/m4/largefile.m4 create mode 100644 patch/m4/malloc.m4 create mode 100644 patch/m4/mbrtowc.m4 create mode 100644 patch/m4/mbstate_t.m4 create mode 100644 patch/m4/mkdir.m4 create mode 100644 patch/m4/prereq.m4 create mode 100644 patch/m4/protos.m4 create mode 100644 patch/m4/realloc.m4 create mode 100644 patch/m4/setmode.m4 create mode 100644 patch/m4/utimbuf.m4 create mode 100644 patch/maketime.c create mode 100644 patch/maketime.h create mode 100644 patch/malloc.c create mode 100644 patch/memchr.c create mode 100644 patch/mkdir.c create mode 100755 patch/mkinstalldirs create mode 100644 patch/partime.c create mode 100644 patch/partime.h create mode 100644 patch/patch.c create mode 100644 patch/patch.man create mode 100644 patch/patchlevel.h create mode 100644 patch/pc/chdirsaf.c create mode 100644 patch/pc/djgpp/README create mode 100644 patch/pc/djgpp/config.sed create mode 100644 patch/pc/djgpp/configure.bat create mode 100644 patch/pc/djgpp/configure.sed create mode 100644 patch/pch.c create mode 100644 patch/pch.h create mode 100644 patch/quote.c create mode 100644 patch/quote.h create mode 100644 patch/quotearg.c create mode 100644 patch/quotearg.h create mode 100644 patch/quotesys.c create mode 100644 patch/quotesys.h create mode 100644 patch/realloc.c create mode 100644 patch/rename.c create mode 100644 patch/rmdir.c create mode 100644 patch/strcasecmp.c create mode 100644 patch/strncasecmp.c create mode 100644 patch/unlocked-io.h create mode 100644 patch/util.c create mode 100644 patch/util.h create mode 100644 patch/version.c create mode 100644 patch/version.h create mode 100644 patch/xalloc.h create mode 100644 patch/xmalloc.c create mode 100644 patch_cmds.plist diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1f2da72 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +## +# Makefile for Patch +## + +# Project info +Project = patch +UserType = Developer +ToolType = Commands +Extra_CC_Flags = -mdynamic-no-pic +GnuAfterInstall = install-plist + +# It's a GNU Source project +include $(MAKEFILEPATH)/CoreOS/ReleaseControl/GNUSource.make + +OSV = $(DSTROOT)/usr/local/OpenSourceVersions +OSL = $(DSTROOT)/usr/local/OpenSourceLicenses + +install-plist: + $(MKDIR) $(OSV) + $(INSTALL_FILE) $(SRCROOT)/patch_cmds.plist $(OSV)/gpatch.plist + $(MKDIR) $(OSL) + $(INSTALL_FILE) $(Sources)/COPYING $(OSL)/gpatch.txt diff --git a/dpkg/control b/dpkg/control new file mode 100644 index 0000000..685cd6c --- /dev/null +++ b/dpkg/control @@ -0,0 +1,10 @@ +Package: patch-cmds +Maintainer: Darwin Developers +Vendor: GNU Project +Version: 2.5.4 +URL: ftp://prep.ai.mit.edu/pub/gnu/patch/ +Build-Depends: build-base, autoconf, gm4 +Description: Patch file applicator + Patch takes a patch file patchfile containing a difference listing + produced by the diff program and applies those differences to one or + more original files, producing patched versions. diff --git a/patch/AUTHORS b/patch/AUTHORS new file mode 100644 index 0000000..1cc569b --- /dev/null +++ b/patch/AUTHORS @@ -0,0 +1,9 @@ +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. diff --git a/patch/COPYING b/patch/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/patch/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + 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 +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/patch/ChangeLog b/patch/ChangeLog new file mode 100644 index 0000000..8922fe5 --- /dev/null +++ b/patch/ChangeLog @@ -0,0 +1,2168 @@ +2002-06-02 Paul Eggert + + * 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 + + * 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 + + * 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 . + + * 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 + + * 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 + + * patch.c (locate_hunk): Fixed updating of last_offset. + +2002-05-25 Paul Eggert + + * NEWS, README: Diffutils doc is up to date now. + Bug reporting address is now . + * 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 . + (main): Initialize exit_failure. + + * patch.man: Update copyright notice. + + * pch.c, util.c: Include , not . + + * version.c (copyright_string): Update copyright notice. + +2002-02-17 Paul Eggert + + * partime.c (parse_pattern_letter): Don't overrun buffer if it + contains only alphanumerics. Bug reported by Winni + . + +2001-07-28 Paul Eggert + + * 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" + + * util.c (PERFORCE_CO): New var. + (version_controller): Support Perforce. + * patch.man: Document this. + +2000-06-30 Paul Eggert + + * patch.man: Ignore comment lines. + + * NEWS, pch.c: Ignore lines beginning with "#". + +1999-10-24 Paul Eggert + + * 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 + + * patch.c (main): If we skipped an ed patch, exit with nonzero status. + +1999-10-17 Paul Eggert + + * 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 + + * 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 + + * patch.c (option_help): Updated bug report address + * configure.in (VERSION): Version 2.5.5 released. + +1999-09-01 Paul Eggert + + * patch.c (main): Default simple_backup_suffix to ".orig". + +1999-10-08 Paul Eggert + + * 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 + + 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 (): 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 (): 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 + + * 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 + + * patch.c (option_help): Update bug reporting address to gnu.org. + * patch.man: Fix copyright and bug reporting address. + +1998-03-16 Paul Eggert + + * 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 before . + Include . + + * 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 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 , . + + * 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 , . + (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 . + (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 , . + (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 + + * 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 + + * configure.in (VERSION): Version 2.5 released. + +1997-07-21 Paul Eggert + + * 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 + + * 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 + + * 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 + + * 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 + + * configure.in (VERSION): Version 2.4 released. + * NEWS: Patch is now verbose when patches do not match exactly. + +1997-06-17 Paul Eggert + + * 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 + + * 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 + + * 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 . + (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 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 + + * 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 for TM_LOCAL_ZONE. + Don't include 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 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 + + * 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 + + * 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 + + * 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 (, ): 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. + : 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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 + + * 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. + (): 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 + + 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 (): Include only if HAVE_CONFIG_H. + (): Include. + (): Include if HAVE_STRING_H, not if STDC_HEADERS. + (): Include if !HAVE_STRING_H. + (): Do not include. + (): Redo include as per current autoconf standards. + (): 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. + (): 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. + (): Include if either STDC_HEADERS or HAVE_STRING_H. + (memcmp, memcpy): Define if !STDC_HEADERS && !HAVE_STRING_H + && !HAVE_MEMCHR. + (): 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. + (): 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 (): Include here, not in common.h. + (vararg_start): New macro. + (va_dcl, va_start, va_arg, va_end): Define if neither + nor 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 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 . + + * 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 + * 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 + 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 + 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 + * pch.c: pch_swap didn't swap p_bfake and p_efake. + +1987-02-16 Larry Wall + * patch.c: Short replacement caused spurious "Out of sync" message. + +1987-01-30 Larry Wall + * 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 + * pch.c: New-style context diffs caused double call to free(). + +1986-11-21 Larry Wall + * patch.c: Fuzz factor caused offset of installed lines. + +1986-11-14 Larry Wall + * 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 + * pch.c: New-style delete triggers spurious assertion error. + +1986-10-29 Larry Wall + * patch.c: Backwards search could terminate prematurely. + * pch.c: Could falsely report new-style context diff. + +1986-09-17 Larry Wall + * 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 + * 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 + * patch.c: Frozen. + * patch.man: Frozen. + +1985-03-12 Larry Wall + * 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 + * patch.c: Made smarter about SCCS subdirectories. + +1984-12-05 Larry Wall + * patch.c: Added -l switch to do loose string comparison. + * patch.man: Added -l switch, and noted bistability bug. + +1984-12-04 Larry Wall + Branch for sdcrdcf changes. + * patch.c: Failed hunk count not reset on multiple patch file. + * patch.man: Baseline version. + +1984-11-29 Larry Wall + * 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 + * 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 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., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. diff --git a/patch/INSTALL b/patch/INSTALL new file mode 100644 index 0000000..ce83b00 --- /dev/null +++ b/patch/INSTALL @@ -0,0 +1,228 @@ +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. + diff --git a/patch/Makefile.in b/patch/Makefile.in new file mode 100644 index 0000000..39a60a2 --- /dev/null +++ b/patch/Makefile.in @@ -0,0 +1,200 @@ +# Makefile for GNU patch. + +# Copyright (C) 1993, 1997, 1998, 1999, 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; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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@ +transform = @program_transform_name@ + +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +DEFS = @DEFS@ +EXEEXT = @EXEEXT@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +OBJEXT = @OBJEXT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = $(exec_prefix)/bin + +# Where to put the manual pages. +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 = malloc.c memchr.c mkdir.c \ + realloc.c rename.c rmdir.c strcasecmp.c strncasecmp.c +SRCS = $(LIBSRCS) \ + addext.c argmatch.c backupfile.c \ + basename.c dirname.c \ + error.c exitfail.c \ + getopt.c getopt1.c inp.c \ + maketime.c partime.c \ + patch.c pch.c \ + quote.c quotearg.c quotesys.c \ + util.c version.c xmalloc.c +OBJS = $(LIBOBJS) \ + addext.$(OBJEXT) argmatch.$(OBJEXT) backupfile.$(OBJEXT) \ + basename.$(OBJEXT) dirname.$(OBJEXT) \ + error.$(OBJEXT) exitfail.$(OBJEXT) \ + getopt.$(OBJEXT) getopt1.$(OBJEXT) inp.$(OBJEXT) \ + maketime.$(OBJEXT) partime.$(OBJEXT) \ + patch.$(OBJEXT) pch.$(OBJEXT) \ + quote.$(OBJEXT) quotearg.$(OBJEXT) quotesys.$(OBJEXT) \ + util.$(OBJEXT) version.$(OBJEXT) xmalloc.$(OBJEXT) +HDRS = argmatch.h backupfile.h common.h dirname.h \ + error.h exitfail.h getopt.h \ + inp.h maketime.h partime.h patchlevel.h pch.h \ + quote.h quotearg.h quotesys.h \ + unlocked-io.h util.h version.h xalloc.h +MISC = AUTHORS COPYING ChangeLog INSTALL Makefile.in NEWS README \ + aclocal.m4 \ + config.hin configure configure.ac \ + install-sh mkinstalldirs patch.man +DISTFILES = $(MISC) $(SRCS) $(HDRS) +DISTFILES_M4 = $(ACINCLUDE_INPUTS) +DISTFILES_PC = pc/chdirsaf.c +DISTFILES_PC_DJGPP = pc/djgpp/README pc/djgpp/config.sed \ + pc/djgpp/configure.bat pc/djgpp/configure.sed + +patch_name = `echo patch | sed '$(transform)'` + +all:: patch$(EXEEXT) + +info:: +check:: +installcheck:: + +COMPILE = $(CC) -c $(CPPFLAGS) $(DEFS) -Ded_PROGRAM=\"$(ed_PROGRAM)\" \ + -I. -I$(srcdir) $(CFLAGS) + +.c.$(OBJEXT): + $(COMPILE) $< + +patch$(EXEEXT): $(OBJS) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) + +install:: all installdirs + $(INSTALL_PROGRAM) patch$(EXEEXT) $(bindir)/$(patch_name)$(EXEEXT) + -$(INSTALL_DATA) $(srcdir)/patch.man $(man1dir)/$(patch_name)$(man1ext) + +installdirs:: + $(SHELL) $(srcdir)/mkinstalldirs $(bindir) $(man1dir) + +install-strip:: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install + +uninstall:: + rm -f $(bindir)/$(patch_name)$(EXEEXT) + rm -f $(man1dir)/$(patch_name)$(man1ext) + +Makefile: Makefile.in $(CONFIG_STATUS) + $(SHELL) $(CONFIG_STATUS) +config.status: configure + $(SHELL) $(CONFIG_STATUS) --recheck +configure: configure.ac $(srcdir)/aclocal.m4 +config.hin: configure.ac $(srcdir)/aclocal.m4 + +M4DIR = $(srcdir)/m4 +ACINCLUDE_INPUTS = $(M4DIR)/c-bs-a.m4 $(M4DIR)/d-ino.m4 $(M4DIR)/error.m4 \ + $(M4DIR)/jm-glibc-io.m4 $(M4DIR)/malloc.m4 $(M4DIR)/mbstate_t.m4 \ + $(M4DIR)/mkdir.m4 $(M4DIR)/mbrtowc.m4 \ + $(M4DIR)/prereq.m4 $(M4DIR)/realloc.m4 \ + $(M4DIR)/setmode.m4 $(M4DIR)/utimbuf.m4 + +$(srcdir)/aclocal.m4: $(ACINCLUDE_INPUTS) + cat $(ACINCLUDE_INPUTS) >$(srcdir)/aclocal.m4 + +patchlevel.h: configure + echo '#define PATCH_VERSION "$(PACKAGE_VERSION)"' >patchlevel.h + +TAGS: $(HDRS) patchlevel.h $(SRCS) + etags $(HDRS) patchlevel.h $(SRCS) + +mostlyclean:: + rm -f core* *core *.$(OBJEXT) *_.c + +clean:: mostlyclean + rm -f patch$(EXEEXT) + +distclean:: clean + rm -f Makefile config.cache config.log config.status config.h + +maintainer-clean:: + @echo "This command is intended for maintainers to use;" + @echo "rebuilding the deleted files requires special tools." + $(MAKE) distclean + rm -f TAGS + +PV = $(PACKAGE_NAME)-$(PACKAGE_VERSION) + +dist:: $(DISTFILES) $(DISTFILES_M4) $(DISTFILES_PC) $(DISTFILES_PC_DJGPP) + rm -rf $(PV) + mkdir $(PV) $(PV)/m4 $(PV)/pc $(PV)/pc/djgpp + cp -p $(DISTFILES) $(PV) + cp -p $(DISTFILES_M4) $(PV)/m4 + cp -p $(DISTFILES_PC) $(PV)/pc + cp -p $(DISTFILES_PC_DJGPP) $(PV)/pc/djgpp + tar -chf - $(PV) | gzip -9 >$(PV).tar.gz + rm -rf $(PV) + +$(OBJS): config.h +addext.$(OBJEXT): backupfile.h dirname.h +argmatch.$(OBJEXT): argmatch.h error.h quote.h quotearg.h unlocked-io.h +backupfile.$(OBJEXT): argmatch.h backupfile.h dirname.h +basename.$(OBJEXT): dirname.h +error.$(OBJEXT): error.h unlocked-io.h +getopt.$(OBJEXT) getopt1.$(OBJEXT): getopt.h +inp.$(OBJEXT): backupfile.h common.h inp.h pch.h quotearg.h util.h xalloc.h +maketime.$(OBJEXT): maketime.h partime.h +mkdir.$(OBJEXT): dirname.h xalloc.h +partime.$(OBJEXT): partime.h +patch.$(OBJEXT): argmatch.h backupfile.h common.h exitfail.h getopt.h inp.h \ + pch.h quotearg.h util.h version.h xalloc.h +pch.$(OBJEXT): backupfile.h common.h dirname.h inp.h pch.h quotearg.h util.h +quotearg.$(OBJEXT): quotearg.h xalloc.h +quotesys.$(OBJEXT): quotesys.h +rename.$(OBJEXT): dirname.h xalloc.h +util.$(OBJEXT): backupfile.h common.h dirname.h maketime.h \ + partime.h quotearg.h quotesys.h util.h version.h xalloc.h +version.$(OBJEXT): common.h patchlevel.h util.h version.h +xmalloc.$(OBJEXT): exitfail.h xalloc.h diff --git a/patch/NEWS b/patch/NEWS new file mode 100644 index 0000000..8750752 --- /dev/null +++ b/patch/NEWS @@ -0,0 +1,237 @@ +Changes in version 2.5.8: 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 . + +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. + +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. + +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. + +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. + +Versions 2.0.12g9 through 2.0.12g11 fix various portability bugs. + +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. + + + +Copyright (C) 1992, 1993, 1997, 1998, 1999, 2000, 2001, 2002 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., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. diff --git a/patch/README b/patch/README new file mode 100644 index 0000000..db63301 --- /dev/null +++ b/patch/README @@ -0,0 +1,54 @@ +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 + * 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 +. + +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 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, +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. diff --git a/patch/aclocal.m4 b/patch/aclocal.m4 new file mode 100644 index 0000000..0c21d74 --- /dev/null +++ b/patch/aclocal.m4 @@ -0,0 +1,495 @@ +# c-bs-a.m4 serial 4 (fileutils-4.1.3) +dnl Copyright (C) 2000-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. + +dnl From Paul Eggert. + +AC_DEFUN([AC_C_BACKSLASH_A], +[ + AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a, + [AC_TRY_COMPILE([], + [ +#if '\a' == 'a' + syntax error; +#endif + char buf['\a' == 'a' ? -1 : 1]; + buf[0] = '\a'; + return buf[0] != "\a"[0]; + ], + ac_cv_c_backslash_a=yes, + ac_cv_c_backslash_a=no)]) + if test $ac_cv_c_backslash_a = yes; then + AC_DEFINE(HAVE_C_BACKSLASH_A, 1, + [Define if backslash-a works in C strings.]) + fi +]) +#serial 4 + +dnl From Jim Meyering. +dnl +dnl Check whether struct dirent has a member named d_ino. +dnl + +AC_DEFUN([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO], + [AC_REQUIRE([AC_HEADER_DIRENT])dnl + AC_CACHE_CHECK([for d_ino member in directory struct], + jm_cv_struct_dirent_d_ino, + [AC_TRY_LINK(dnl + [ +#include +#ifdef HAVE_DIRENT_H +# include +#else /* not HAVE_DIRENT_H */ +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* HAVE_SYS_NDIR_H */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* HAVE_SYS_DIR_H */ +# ifdef HAVE_NDIR_H +# include +# endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + ], + [struct dirent dp; dp.d_ino = 0;], + + jm_cv_struct_dirent_d_ino=yes, + jm_cv_struct_dirent_d_ino=no) + ] + ) + if test $jm_cv_struct_dirent_d_ino = yes; then + AC_DEFINE(D_INO_IN_DIRENT, 1, + [Define if there is a member named d_ino in the struct describing + directory headers.]) + fi + ] +) +#serial 4 + +dnl FIXME: put these prerequisite-only *.m4 files in a separate +dnl directory -- otherwise, they'll conflict with existing files. + +dnl These are the prerequisite macros for GNU's error.c file. +AC_DEFUN([jm_PREREQ_ERROR], +[ + AC_CHECK_FUNCS(strerror vprintf doprnt) + AC_CHECK_DECLS([strerror]) + AC_FUNC_STRERROR_R + AC_HEADER_STDC +]) +#serial 7 -*- autoconf -*- + +dnl From Jim Meyering. +dnl +dnl See if the glibc *_unlocked I/O macros are available. +dnl Use only those *_unlocked macros that are declared. +dnl + +AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO], + [AC_CHECK_DECLS( + [clearerr_unlocked, feof_unlocked, ferror_unlocked, + fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked, + fread_unlocked, fwrite_unlocked, getc_unlocked, + getchar_unlocked, putc_unlocked, putchar_unlocked])]) +#serial 6 + +dnl From Jim Meyering. +dnl Determine whether malloc accepts 0 as its argument. +dnl If it doesn't, arrange to use the replacement function. +dnl + +AC_DEFUN([jm_FUNC_MALLOC], +[ + dnl xmalloc.c requires that this symbol be defined so it doesn't + dnl mistakenly use a broken malloc -- as it might if this test were omitted. + AC_DEFINE(HAVE_DONE_WORKING_MALLOC_CHECK, 1, + [Define if the malloc check has been performed. ]) + + AC_CACHE_CHECK([whether malloc(0) returns a non-NULL pointer], + jm_cv_func_working_malloc, + [AC_TRY_RUN([ + char *malloc (); + int + main () + { + exit (malloc (0) ? 0 : 1); + } + ], + jm_cv_func_working_malloc=yes, + jm_cv_func_working_malloc=no, + dnl When crosscompiling, assume malloc(0) returns NULL. + jm_cv_func_working_malloc=no) + ]) + if test $jm_cv_func_working_malloc = no; then + AC_LIBOBJ(malloc) + AC_DEFINE(malloc, rpl_malloc, + [Define to rpl_malloc if the replacement function should be used.]) + fi +]) +# mbstate_t.m4 serial 9 (fileutils-4.1.3) +dnl Copyright (C) 2000-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. + +# From Paul Eggert. + +# BeOS 5 has but does not define mbstate_t, +# so you can't declare an object of that type. +# Check for this incompatibility with Standard C. + +# Include stdlib.h first, because otherwise this test would fail on Linux +# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits +# a syntax error in wchar.h due to the use of undefined __int32_t. + +AC_DEFUN([AC_MBSTATE_T], + [ + AC_CHECK_HEADERS(stdlib.h) + + AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t, + [AC_TRY_COMPILE([ +#if HAVE_STDLIB_H +# include +#endif +#include ], + [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,ma + [Define to 1 if declares mbstate_t.]) + else + AC_DEFINE(mbstate_t, int, + [Define to a type if does not define.]) + fi]) +#serial 1 + +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 +#include + ], + [mkdir (".", 0);], + , + [AC_TRY_COMPILE([ +#include +#include + ], + [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 + ] +) +# mbrtowc.m4 serial 4 (fileutils-4.1.3) +dnl Copyright (C) 2001-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. + +dnl From Paul Eggert + +AC_DEFUN([jm_FUNC_MBRTOWC], +[ + AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], + jm_cv_func_mbrtowc, + [AC_TRY_LINK( + [#include ], + [mbstate_t state; return ! (sizeof state && mbrtowc);], + jm_cv_func_mbrtowc=yes, + jm_cv_func_mbrtowc=no)]) + if test $jm_cv_func_mbrtowc = yes; then + AC_DEFINE(HAVE_MBRTOWC, 1, + [Define to 1 if mbrtowc and mbstate_t are properly declared.]) + fi +]) +#serial 22 + +dnl These are the prerequisite macros for files in the lib/ +dnl directories of the fileutils, sh-utils, and textutils packages. + +AC_DEFUN([jm_PREREQ], +[ + jm_PREREQ_ADDEXT + jm_PREREQ_CANON_HOST + jm_PREREQ_DIRNAME + jm_PREREQ_ERROR + jm_PREREQ_EXCLUDE + jm_PREREQ_GETPAGESIZE + jm_PREREQ_HARD_LOCALE + jm_PREREQ_HASH + jm_PREREQ_HUMAN + jm_PREREQ_MBSWIDTH + jm_PREREQ_MEMCHR + jm_PREREQ_PHYSMEM + jm_PREREQ_POSIXVER + jm_PREREQ_QUOTEARG + jm_PREREQ_READUTMP + jm_PREREQ_REGEX + jm_PREREQ_TEMPNAME # called by mkstemp + jm_PREREQ_XGETCWD + jm_PREREQ_XREADLINK +]) + +AC_DEFUN([jm_PREREQ_ADDEXT], +[ + dnl For addext.c. + AC_SYS_LONG_FILE_NAMES + AC_CHECK_FUNCS(pathconf) + AC_CHECK_HEADERS(limits.h string.h unistd.h) +]) + +AC_DEFUN([jm_PREREQ_CANON_HOST], +[ + dnl Add any libraries as early as possible. + dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1, + dnl so we have to add -lnsl to LIBS before checking for that function. + AC_SEARCH_LIBS(gethostbyname, [inet nsl]) + + dnl These come from -lnsl on Solaris5.5.1. + AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa) + + AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa) + AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \ + netinet/in.h arpa/inet.h) +]) + +AC_DEFUN([jm_PREREQ_DIRNAME], +[ + AC_HEADER_STDC + AC_CHECK_HEADERS(string.h) +]) + +AC_DEFUN([jm_PREREQ_EXCLUDE], +[ + AC_FUNC_FNMATCH_GNU([lib]) + AC_HEADER_STDBOOL +]) + +AC_DEFUN([jm_PREREQ_GETPAGESIZE], +[ + AC_CHECK_FUNCS(getpagesize) + AC_CHECK_HEADERS(OS.h unistd.h) +]) + +AC_DEFUN([jm_PREREQ_HARD_LOCALE], +[ + AC_C_PROTOTYPES + AC_CHECK_FUNCS(setlocale) + AC_CHECK_HEADERS(locale.h stdlib.h string.h) +]) + +AC_DEFUN([jm_PREREQ_HASH], +[ + AC_CHECK_HEADERS(stdlib.h) + AC_HEADER_STDBOOL + AC_REQUIRE([jm_CHECK_DECLS]) +]) + +# If you use human.c, you need the following files: +# inttypes.m4 ulonglong.m4 +AC_DEFUN([jm_PREREQ_HUMAN], +[ + AC_CHECK_HEADERS(limits.h stdlib.h string.h) + AC_CHECK_DECLS([getenv]) + AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) +]) + +AC_DEFUN([jm_PREREQ_MEMCHR], +[ + AC_CHECK_HEADERS(limits.h stdlib.h bp-sym.h) +]) + +AC_DEFUN([jm_PREREQ_PHYSMEM], +[ + AC_CHECK_HEADERS(sys/pstat.h unistd.h) + AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic) +]) + +AC_DEFUN([jm_PREREQ_POSIXVER], +[ + AC_CHECK_HEADERS(unistd.h) + AC_CHECK_DECLS([getenv]) +]) + +AC_DEFUN([jm_PREREQ_QUOTEARG], +[ + AC_CHECK_FUNCS(isascii iswprint) + jm_FUNC_MBRTOWC + AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h) + AC_HEADER_STDC + AC_C_BACKSLASH_A + AC_MBSTATE_T + AC_C_PROTOTYPES +]) + +AC_DEFUN([jm_PREREQ_REGEX], +[ + dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it. + dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary + dnl to get them. + AC_CHECK_FUNCS(bzero bcopy isascii btowc) + AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h) + AC_HEADER_STDC + AC_FUNC_ALLOCA +]) + +AC_DEFUN([jm_PREREQ_TEMPNAME], +[ + AC_HEADER_STDC + AC_HEADER_STAT + AC_CHECK_HEADERS(fcntl.h sys/time.h stdint.h unistd.h) + AC_CHECK_FUNCS(__secure_getenv gettimeofday) + AC_CHECK_DECLS([getenv]) +]) + +AC_DEFUN([jm_PREREQ_XGETCWD], +[ + AC_C_PROTOTYPES + AC_CHECK_HEADERS(limits.h stdlib.h sys/param.h unistd.h) + AC_CHECK_FUNCS(getcwd) + AC_FUNC_GETCWD_NULL +]) + +AC_DEFUN([jm_PREREQ_XREADLINK], +[ + AC_C_PROTOTYPES + AC_CHECK_HEADERS(limits.h stdlib.h sys/types.h unistd.h) +]) +#serial 6 + +dnl From Jim Meyering. +dnl Determine whether realloc works when both arguments are 0. +dnl If it doesn't, arrange to use the replacement function. +dnl + +AC_DEFUN([jm_FUNC_REALLOC], +[ + dnl xmalloc.c requires that this symbol be defined so it doesn't + dnl mistakenly use a broken realloc -- as it might if this test were omitted. + AC_DEFINE(HAVE_DONE_WORKING_REALLOC_CHECK, 1, + [Define if the realloc check has been performed. ]) + + AC_CACHE_CHECK([whether realloc(0,0) returns a non-NULL pointer], + jm_cv_func_working_realloc, + [AC_TRY_RUN([ + char *realloc (); + int + main () + { + exit (realloc (0, 0) ? 0 : 1); + } + ], + jm_cv_func_working_realloc=yes, + jm_cv_func_working_realloc=no, + dnl When crosscompiling, assume realloc(0,0) returns NULL. + jm_cv_func_working_realloc=no) + ]) + if test $jm_cv_func_working_realloc = no; then + AC_LIBOBJ(realloc) + AC_DEFINE(realloc, rpl_realloc, + [Define to rpl_realloc if the replacement function should be used.]) + fi +]) +# 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, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, 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 + #if HAVE_FCNTL_H + # include + #endif + #if HAVE_UNISTD_H + # include + #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]) +#serial 4 + +dnl From Jim Meyering + +dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared -- +dnl usually in . +dnl Some systems have utime.h but don't declare the struct anywhere. + +AC_DEFUN([jm_CHECK_TYPE_STRUCT_UTIMBUF], +[ + AC_CHECK_HEADERS(utime.h) + AC_REQUIRE([AC_HEADER_TIME]) + AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf, + [AC_TRY_COMPILE( + [ +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef HAVE_UTIME_H +# include +#endif + ], + [static struct utimbuf x; x.actime = x.modtime;], + fu_cv_sys_struct_utimbuf=yes, + fu_cv_sys_struct_utimbuf=no) + ]) + + if test $fu_cv_sys_struct_utimbuf = yes; then + AC_DEFINE(HAVE_STRUCT_UTIMBUF, 1, +[Define if struct utimbuf is declared -- usually in . + Some systems have utime.h but don't declare the struct anywhere. ]) + fi +]) diff --git a/patch/addext.c b/patch/addext.c new file mode 100644 index 0000000..571e3c2 --- /dev/null +++ b/patch/addext.c @@ -0,0 +1,114 @@ +/* addext.c -- add an extension to a file name + Copyright 1990, 1997, 1998, 1999, 2001 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie and Paul Eggert */ + +#if HAVE_CONFIG_H +# include +#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 + +#if HAVE_LIMITS_H +# include +#endif +#ifndef _POSIX_NAME_MAX +# define _POSIX_NAME_MAX 14 +#endif + +#include +#if HAVE_STRING_H +# include +#else +# include +#endif + +#if HAVE_UNISTD_H +# include +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#include "backupfile.h" +#include "dirname.h" + +/* Append to FILENAME the extension EXT, unless the result would be too long, + in which case just append the character E. */ + +void +addext (char *filename, char const *ext, int e) +{ + char *s = base_name (filename); + size_t slen = base_len (s); + size_t extlen = strlen (ext); + size_t slen_max = HAVE_LONG_FILE_NAMES ? 255 : _POSIX_NAME_MAX; + +#if HAVE_PATHCONF && defined _PC_NAME_MAX + if (_POSIX_NAME_MAX < slen + extlen || HAVE_DOS_FILE_NAMES) + { + /* The new base name is long enough to require a pathconf check. */ + long name_max; + errno = 0; + if (s == filename) + name_max = pathconf (".", _PC_NAME_MAX); + else + { + char c = *s; + if (! ISSLASH (c)) + *s = 0; + name_max = pathconf (filename, _PC_NAME_MAX); + *s = c; + } + if (0 <= name_max || errno == 0) + slen_max = name_max == (size_t) name_max ? name_max : -1; + } +#endif + + if (HAVE_DOS_FILE_NAMES && slen_max <= 12) + { + /* Live within DOS's 8.3 limit. */ + char *dot = strchr (s, '.'); + if (dot) + { + slen -= dot + 1 - s; + s = dot + 1; + slen_max = 3; + } + else + slen_max = 8; + extlen = 9; /* Don't use EXT. */ + } + + if (slen + extlen <= slen_max) + strcpy (s + slen, ext); + else + { + if (slen_max <= slen) + slen = slen_max - 1; + s[slen] = e; + s[slen + 1] = 0; + } +} diff --git a/patch/ansi2knr.1 b/patch/ansi2knr.1 new file mode 100644 index 0000000..f9ee5a6 --- /dev/null +++ b/patch/ansi2knr.1 @@ -0,0 +1,36 @@ +.TH ANSI2KNR 1 "19 Jan 1996" +.SH NAME +ansi2knr \- convert ANSI C to Kernighan & Ritchie C +.SH SYNOPSIS +.I ansi2knr +[--varargs] input_file [output_file] +.SH DESCRIPTION +If no output_file is supplied, output goes to stdout. +.br +There are no error messages. +.sp +.I ansi2knr +recognizes function definitions by seeing a non-keyword identifier at the left +margin, followed by a left parenthesis, with a right parenthesis as the last +character on the line, and with a left brace as the first token on the +following line (ignoring possible intervening comments). It will recognize a +multi-line header provided that no intervening line ends with a left or right +brace or a semicolon. These algorithms ignore whitespace and comments, except +that the function name must be the first thing on the line. +.sp +The following constructs will confuse it: +.br + - Any other construct that starts at the left margin and follows the +above syntax (such as a macro or function call). +.br + - Some macros that tinker with the syntax of the function header. +.sp +The --varargs switch is obsolete, and is recognized only for +backwards compatibility. The present version of +.I ansi2knr +will always attempt to convert a ... argument to va_alist and va_dcl. +.SH AUTHOR +L. Peter Deutsch wrote the original ansi2knr and +continues to maintain the current version; most of the code in the current +version is his work. ansi2knr also includes contributions by Francois +Pinard and Jim Avera . diff --git a/patch/ansi2knr.c b/patch/ansi2knr.c new file mode 100644 index 0000000..62b4686 --- /dev/null +++ b/patch/ansi2knr.c @@ -0,0 +1,678 @@ +/* Copyright (C) 1989, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. */ + +/*$Id: ansi2knr.c,v 1.1 2000/05/06 22:44:51 wsanchez Exp $*/ +/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ + +/* +ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY. No author or distributor accepts responsibility to anyone for the +consequences of using it or for whether it serves any particular purpose or +works at all, unless he says so in writing. Refer to the GNU General Public +License (the "GPL") for full details. + +Everyone is granted permission to copy, modify and redistribute ansi2knr, +but only under the conditions described in the GPL. A copy of this license +is supposed to have been given to you along with ansi2knr so you can know +your rights and responsibilities. It should be in a file named COPYLEFT, +or, if there is no file named COPYLEFT, a file named COPYING. Among other +things, the copyright notice and this notice must be preserved on all +copies. + +We explicitly state here what we believe is already implied by the GPL: if +the ansi2knr program is distributed as a separate set of sources and a +separate executable file which are aggregated on a storage medium together +with another program, this in itself does not bring the other program under +the GPL, nor does the mere fact that such a program or the procedures for +constructing it invoke the ansi2knr executable bring any other part of the +program under the GPL. +*/ + +/* + * Usage: + ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]] + * --filename provides the file name for the #line directive in the output, + * overriding input_file (if present). + * If no input_file is supplied, input is read from stdin. + * If no output_file is supplied, output goes to stdout. + * There are no error messages. + * + * ansi2knr recognizes function definitions by seeing a non-keyword + * identifier at the left margin, followed by a left parenthesis, + * with a right parenthesis as the last character on the line, + * and with a left brace as the first token on the following line + * (ignoring possible intervening comments), except that a line + * consisting of only + * identifier1(identifier2) + * will not be considered a function definition unless identifier2 is + * the word "void", and a line consisting of + * identifier1(identifier2, <>) + * will not be considered a function definition. + * ansi2knr will recognize a multi-line header provided + * that no intervening line ends with a left or right brace or a semicolon. + * These algorithms ignore whitespace and comments, except that + * the function name must be the first thing on the line. + * The following constructs will confuse it: + * - Any other construct that starts at the left margin and + * follows the above syntax (such as a macro or function call). + * - Some macros that tinker with the syntax of function headers. + */ + +/* + * The original and principal author of ansi2knr is L. Peter Deutsch + * . Other authors are noted in the change history + * that follows (in reverse chronological order): + lpd 1999-04-12 added minor fixes from Pavel Roskin + for clean compilation with + gcc -W -Wall + lpd 1999-03-22 added hack to recognize lines consisting of + identifier1(identifier2, xxx) as *not* being procedures + lpd 1999-02-03 made indentation of preprocessor commands consistent + lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an + endless loop; quoted strings within an argument list + confused the parser + lpd 1999-01-24 added a check for write errors on the output, + suggested by Jim Meyering + lpd 1998-11-09 added further hack to recognize identifier(void) + as being a procedure + lpd 1998-10-23 added hack to recognize lines consisting of + identifier1(identifier2) as *not* being procedures + lpd 1997-12-08 made input_file optional; only closes input and/or + output file if not stdin or stdout respectively; prints + usage message on stderr rather than stdout; adds + --filename switch (changes suggested by + ) + lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with + compilers that don't understand void, as suggested by + Tom Lane + lpd 1996-01-15 changed to require that the first non-comment token + on the line following a function header be a left brace, + to reduce sensitivity to macros, as suggested by Tom Lane + + lpd 1995-06-22 removed #ifndefs whose sole purpose was to define + undefined preprocessor symbols as 0; changed all #ifdefs + for configuration symbols to #ifs + lpd 1995-04-05 changed copyright notice to make it clear that + including ansi2knr in a program does not bring the entire + program under the GPL + lpd 1994-12-18 added conditionals for systems where ctype macros + don't handle 8-bit characters properly, suggested by + Francois Pinard ; + removed --varargs switch (this is now the default) + lpd 1994-10-10 removed CONFIG_BROKETS conditional + lpd 1994-07-16 added some conditionals to help GNU `configure', + suggested by Francois Pinard ; + properly erase prototype args in function parameters, + contributed by Jim Avera ; + correct error in writeblanks (it shouldn't erase EOLs) + lpd 1989-xx-xx original version + */ + +/* Most of the conditionals here are to make ansi2knr work with */ +/* or without the GNU configure machinery. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +#if HAVE_CONFIG_H + +/* + For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). + This will define HAVE_CONFIG_H and so, activate the following lines. + */ + +# if STDC_HEADERS || HAVE_STRING_H +# include +# else +# include +# endif + +#else /* not HAVE_CONFIG_H */ + +/* Otherwise do it the hard way */ + +# ifdef BSD +# include +# else +# ifdef VMS + extern int strlen(), strncmp(); +# else +# include +# endif +# endif + +#endif /* not HAVE_CONFIG_H */ + +#if STDC_HEADERS +# include +#else +/* + malloc and free should be declared in stdlib.h, + but if you've got a K&R compiler, they probably aren't. + */ +# ifdef MSDOS +# include +# else +# ifdef VMS + extern char *malloc(); + extern void free(); +# else + extern char *malloc(); + extern int free(); +# endif +# endif + +#endif + +/* Define NULL (for *very* old compilers). */ +#ifndef NULL +# define NULL (0) +#endif + +/* + * The ctype macros don't always handle 8-bit characters correctly. + * Compensate for this here. + */ +#ifdef isascii +# undef HAVE_ISASCII /* just in case */ +# define HAVE_ISASCII 1 +#else +#endif +#if STDC_HEADERS || !HAVE_ISASCII +# define is_ascii(c) 1 +#else +# define is_ascii(c) isascii(c) +#endif + +#define is_space(c) (is_ascii(c) && isspace(c)) +#define is_alpha(c) (is_ascii(c) && isalpha(c)) +#define is_alnum(c) (is_ascii(c) && isalnum(c)) + +/* Scanning macros */ +#define isidchar(ch) (is_alnum(ch) || (ch) == '_') +#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') + +/* Forward references */ +char *skipspace(); +char *scanstring(); +int writeblanks(); +int test1(); +int convert1(); + +/* The main program */ +int +main(argc, argv) + int argc; + char *argv[]; +{ FILE *in = stdin; + FILE *out = stdout; + char *filename = 0; + char *program_name = argv[0]; + char *output_name = 0; +#define bufsize 5000 /* arbitrary size */ + char *buf; + char *line; + char *more; + char *usage = + "Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n"; + /* + * In previous versions, ansi2knr recognized a --varargs switch. + * If this switch was supplied, ansi2knr would attempt to convert + * a ... argument to va_alist and va_dcl; if this switch was not + * supplied, ansi2knr would simply drop any such arguments. + * Now, ansi2knr always does this conversion, and we only + * check for this switch for backward compatibility. + */ + int convert_varargs = 1; + int output_error; + + while ( argc > 1 && argv[1][0] == '-' ) { + if ( !strcmp(argv[1], "--varargs") ) { + convert_varargs = 1; + argc--; + argv++; + continue; + } + if ( !strcmp(argv[1], "--filename") && argc > 2 ) { + filename = argv[2]; + argc -= 2; + argv += 2; + continue; + } + fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name, + argv[1]); + fprintf(stderr, usage); + exit(1); + } + switch ( argc ) + { + default: + fprintf(stderr, usage); + exit(0); + case 3: + output_name = argv[2]; + out = fopen(output_name, "w"); + if ( out == NULL ) { + fprintf(stderr, "%s: Cannot open output file %s\n", + program_name, output_name); + exit(1); + } + /* falls through */ + case 2: + in = fopen(argv[1], "r"); + if ( in == NULL ) { + fprintf(stderr, "%s: Cannot open input file %s\n", + program_name, argv[1]); + exit(1); + } + if ( filename == 0 ) + filename = argv[1]; + /* falls through */ + case 1: + break; + } + if ( filename ) + fprintf(out, "#line 1 \"%s\"\n", filename); + buf = malloc(bufsize); + if ( buf == NULL ) + { + fprintf(stderr, "Unable to allocate read buffer!\n"); + exit(1); + } + line = buf; + while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) + { +test: line += strlen(line); + switch ( test1(buf) ) + { + case 2: /* a function header */ + convert1(buf, out, 1, convert_varargs); + break; + case 1: /* a function */ + /* Check for a { at the start of the next line. */ + more = ++line; +f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ + goto wl; + if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) + goto wl; + switch ( *skipspace(more, 1) ) + { + case '{': + /* Definitely a function header. */ + convert1(buf, out, 0, convert_varargs); + fputs(more, out); + break; + case 0: + /* The next line was blank or a comment: */ + /* keep scanning for a non-comment. */ + line += strlen(line); + goto f; + default: + /* buf isn't a function header, but */ + /* more might be. */ + fputs(buf, out); + strcpy(buf, more); + line = buf; + goto test; + } + break; + case -1: /* maybe the start of a function */ + if ( line != buf + (bufsize - 1) ) /* overflow check */ + continue; + /* falls through */ + default: /* not a function */ +wl: fputs(buf, out); + break; + } + line = buf; + } + if ( line != buf ) + fputs(buf, out); + free(buf); + if ( output_name ) { + output_error = ferror(out); + output_error |= fclose(out); + } else { /* out == stdout */ + fflush(out); + output_error = ferror(out); + } + if ( output_error ) { + fprintf(stderr, "%s: error writing to %s\n", program_name, + (output_name ? output_name : "stdout")); + exit(1); + } + if ( in != stdin ) + fclose(in); + return 0; +} + +/* Skip over whitespace and comments, in either direction. */ +char * +skipspace(p, dir) + register char *p; + register int dir; /* 1 for forward, -1 for backward */ +{ for ( ; ; ) + { while ( is_space(*p) ) + p += dir; + if ( !(*p == '/' && p[dir] == '*') ) + break; + p += dir; p += dir; + while ( !(*p == '*' && p[dir] == '/') ) + { if ( *p == 0 ) + return p; /* multi-line comment?? */ + p += dir; + } + p += dir; p += dir; + } + return p; +} + +/* Scan over a quoted string, in either direction. */ +char * +scanstring(p, dir) + register char *p; + register int dir; +{ + for (p += dir; ; p += dir) + if (*p == '"' && p[-dir] != '\\') + return p + dir; +} + +/* + * Write blanks over part of a string. + * Don't overwrite end-of-line characters. + */ +int +writeblanks(start, end) + char *start; + char *end; +{ char *p; + for ( p = start; p < end; p++ ) + if ( *p != '\r' && *p != '\n' ) + *p = ' '; + return 0; +} + +/* + * Test whether the string in buf is a function definition. + * The string may contain and/or end with a newline. + * Return as follows: + * 0 - definitely not a function definition; + * 1 - definitely a function definition; + * 2 - definitely a function prototype (NOT USED); + * -1 - may be the beginning of a function definition, + * append another line and look again. + * The reason we don't attempt to convert function prototypes is that + * Ghostscript's declaration-generating macros look too much like + * prototypes, and confuse the algorithms. + */ +int +test1(buf) + char *buf; +{ register char *p = buf; + char *bend; + char *endfn; + int contin; + + if ( !isidfirstchar(*p) ) + return 0; /* no name at left margin */ + bend = skipspace(buf + strlen(buf) - 1, -1); + switch ( *bend ) + { + case ';': contin = 0 /*2*/; break; + case ')': contin = 1; break; + case '{': return 0; /* not a function */ + case '}': return 0; /* not a function */ + default: contin = -1; + } + while ( isidchar(*p) ) + p++; + endfn = p; + p = skipspace(p, 1); + if ( *p++ != '(' ) + return 0; /* not a function */ + p = skipspace(p, 1); + if ( *p == ')' ) + return 0; /* no parameters */ + /* Check that the apparent function name isn't a keyword. */ + /* We only need to check for keywords that could be followed */ + /* by a left parenthesis (which, unfortunately, is most of them). */ + { static char *words[] = + { "asm", "auto", "case", "char", "const", "double", + "extern", "float", "for", "if", "int", "long", + "register", "return", "short", "signed", "sizeof", + "static", "switch", "typedef", "unsigned", + "void", "volatile", "while", 0 + }; + char **key = words; + char *kp; + unsigned len = endfn - buf; + + while ( (kp = *key) != 0 ) + { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) + return 0; /* name is a keyword */ + key++; + } + } + { + char *id = p; + int len; + /* + * Check for identifier1(identifier2) and not + * identifier1(void), or identifier1(identifier2, xxxx). + */ + + while ( isidchar(*p) ) + p++; + len = p - id; + p = skipspace(p, 1); + if (*p == ',' || + (*p == ')' && (len != 4 || strncmp(id, "void", 4))) + ) + return 0; /* not a function */ + } + /* + * If the last significant character was a ), we need to count + * parentheses, because it might be part of a formal parameter + * that is a procedure. + */ + if (contin > 0) { + int level = 0; + + for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1)) + level += (*p == '(' ? 1 : *p == ')' ? -1 : 0); + if (level > 0) + contin = -1; + } + return contin; +} + +/* Convert a recognized function definition or header to K&R syntax. */ +int +convert1(buf, out, header, convert_varargs) + char *buf; + FILE *out; + int header; /* Boolean */ + int convert_varargs; /* Boolean */ +{ char *endfn; + register char *p; + /* + * The breaks table contains pointers to the beginning and end + * of each argument. + */ + char **breaks; + unsigned num_breaks = 2; /* for testing */ + char **btop; + char **bp; + char **ap; + char *vararg = 0; + + /* Pre-ANSI implementations don't agree on whether strchr */ + /* is called strchr or index, so we open-code it here. */ + for ( endfn = buf; *(endfn++) != '('; ) + ; +top: p = endfn; + breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); + if ( breaks == NULL ) + { /* Couldn't allocate break table, give up */ + fprintf(stderr, "Unable to allocate break table!\n"); + fputs(buf, out); + return -1; + } + btop = breaks + num_breaks * 2 - 2; + bp = breaks; + /* Parse the argument list */ + do + { int level = 0; + char *lp = NULL; + char *rp = NULL; + char *end = NULL; + + if ( bp >= btop ) + { /* Filled up break table. */ + /* Allocate a bigger one and start over. */ + free((char *)breaks); + num_breaks <<= 1; + goto top; + } + *bp++ = p; + /* Find the end of the argument */ + for ( ; end == NULL; p++ ) + { switch(*p) + { + case ',': + if ( !level ) end = p; + break; + case '(': + if ( !level ) lp = p; + level++; + break; + case ')': + if ( --level < 0 ) end = p; + else rp = p; + break; + case '/': + if (p[1] == '*') + p = skipspace(p, 1) - 1; + break; + case '"': + p = scanstring(p, 1) - 1; + break; + default: + ; + } + } + /* Erase any embedded prototype parameters. */ + if ( lp && rp ) + writeblanks(lp + 1, rp); + p--; /* back up over terminator */ + /* Find the name being declared. */ + /* This is complicated because of procedure and */ + /* array modifiers. */ + for ( ; ; ) + { p = skipspace(p - 1, -1); + switch ( *p ) + { + case ']': /* skip array dimension(s) */ + case ')': /* skip procedure args OR name */ + { int level = 1; + while ( level ) + switch ( *--p ) + { + case ']': case ')': + level++; + break; + case '[': case '(': + level--; + break; + case '/': + if (p > buf && p[-1] == '*') + p = skipspace(p, -1) + 1; + break; + case '"': + p = scanstring(p, -1) + 1; + break; + default: ; + } + } + if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) + { /* We found the name being declared */ + while ( !isidfirstchar(*p) ) + p = skipspace(p, 1) + 1; + goto found; + } + break; + default: + goto found; + } + } +found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) + { if ( convert_varargs ) + { *bp++ = "va_alist"; + vararg = p-2; + } + else + { p++; + if ( bp == breaks + 1 ) /* sole argument */ + writeblanks(breaks[0], p); + else + writeblanks(bp[-1] - 1, p); + bp--; + } + } + else + { while ( isidchar(*p) ) p--; + *bp++ = p+1; + } + p = end; + } + while ( *p++ == ',' ); + *bp = p; + /* Make a special check for 'void' arglist */ + if ( bp == breaks+2 ) + { p = skipspace(breaks[0], 1); + if ( !strncmp(p, "void", 4) ) + { p = skipspace(p+4, 1); + if ( p == breaks[2] - 1 ) + { bp = breaks; /* yup, pretend arglist is empty */ + writeblanks(breaks[0], p + 1); + } + } + } + /* Put out the function name and left parenthesis. */ + p = buf; + while ( p != endfn ) putc(*p, out), p++; + /* Put out the declaration. */ + if ( header ) + { fputs(");", out); + for ( p = breaks[0]; *p; p++ ) + if ( *p == '\r' || *p == '\n' ) + putc(*p, out); + } + else + { for ( ap = breaks+1; ap < bp; ap += 2 ) + { p = *ap; + while ( isidchar(*p) ) + putc(*p, out), p++; + if ( ap < bp - 1 ) + fputs(", ", out); + } + fputs(") ", out); + /* Put out the argument declarations */ + for ( ap = breaks+2; ap <= bp; ap += 2 ) + (*ap)[-1] = ';'; + if ( vararg != 0 ) + { *vararg = 0; + fputs(breaks[0], out); /* any prior args */ + fputs("va_dcl", out); /* the final arg */ + fputs(bp[0], out); + } + else + fputs(breaks[0], out); + } + free((char *)breaks); + return 0; +} diff --git a/patch/argmatch.c b/patch/argmatch.c new file mode 100644 index 0000000..75641ee --- /dev/null +++ b/patch/argmatch.c @@ -0,0 +1,310 @@ +/* argmatch.c -- find a match for a string in an array + Copyright (C) 1990, 1998, 1999, 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, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie + Modified by Akim Demaille */ + +#include "argmatch.h" + +#include +#ifdef STDC_HEADERS +# include +# include +#endif + +#if HAVE_LOCALE_H +# include +#endif + +#if ENABLE_NLS +# include +# define _(Text) gettext (Text) +#else +# define _(Text) Text +#endif + +#include "error.h" +#include "quotearg.h" +#include "quote.h" +#include "unlocked-io.h" + +/* 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 + +/* The following test is to work around the gross typo in + systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE + is defined to 0, not 1. */ +#if !EXIT_FAILURE +# undef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + +/* Non failing version of argmatch call this function after failing. */ +#ifndef ARGMATCH_DIE +# 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; + + +/* 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 SENSITIVE, comparison is case sensitive. + + 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'. */ + +static int +__argmatch_internal (const char *arg, const char *const *arglist, + const char *vallist, size_t valsize, + int case_sensitive) +{ + int i; /* Temporary index in ARGLIST. */ + size_t arglen; /* Length of ARG. */ + int matchind = -1; /* Index of first nonexact match. */ + int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */ + + arglen = strlen (arg); + + /* Test all elements for either exact match or abbreviated matches. */ + for (i = 0; arglist[i]; i++) + { + if (case_sensitive + ? !strncmp (arglist[i], arg, arglen) + : !strncasecmp (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 = 1; + } + } + } + } + if (ambiguous) + return -2; + else + return matchind; +} + +/* argmatch - case sensitive version */ +int +argmatch (const char *arg, const char *const *arglist, + const char *vallist, size_t valsize) +{ + return __argmatch_internal (arg, arglist, vallist, valsize, 1); +} + +/* argcasematch - case insensitive version */ +int +argcasematch (const char *arg, const char *const *arglist, + const char *vallist, size_t valsize) +{ + return __argmatch_internal (arg, arglist, vallist, valsize, 0); +} + +/* 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, int 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) +{ + int 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. */ + +int +__xargmatch_internal (const char *context, + const char *arg, const char *const *arglist, + const char *vallist, size_t valsize, + int case_sensitive, + argmatch_exit_fn exit_fn) +{ + int res = __argmatch_internal (arg, arglist, + vallist, valsize, + case_sensitive); + 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) +{ + int 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 + */ +char *program_name; +extern const char *getenv (); + +/* When to make backup files. */ +enum backup_type +{ + /* Never make backups. */ + none, + + /* Make simple backups of every file. */ + simple, + + /* Make numbered backups of files that already have numbered backups, + and simple backups of the others. */ + numbered_existing, + + /* Make numbered backups of every file. */ + numbered +}; + +/* 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[] = +{ + none, none, none, + simple, simple, + numbered_existing, numbered_existing, + numbered, numbered +}; + +int +main (int argc, const char *const *argv) +{ + const char *cp; + enum backup_type backup_type = none; + + 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 = XARGCASEMATCH ("$VERSION_CONTROL", cp, + backup_args, backup_vals); + + if (argc == 2) + backup_type = XARGCASEMATCH (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 diff --git a/patch/argmatch.h b/patch/argmatch.h new file mode 100644 index 0000000..b719300 --- /dev/null +++ b/patch/argmatch.h @@ -0,0 +1,129 @@ +/* argmatch.h -- definitions and prototypes for argmatch.c + Copyright (C) 1990, 1998, 1999, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie + Modified by Akim Demaille */ + +#ifndef ARGMATCH_H_ +# define ARGMATCH_H_ 1 + +# if HAVE_CONFIG_H +# include +# endif + +# include + +# ifndef PARAMS +# if PROTOTYPES || (defined (__STDC__) && __STDC__) +# define PARAMS(args) args +# else +# define PARAMS(args) () +# endif /* GCC. */ +# endif /* Not PARAMS. */ + +/* Assert there are as many real arguments as there are values + (argument list ends with a NULL guard). There is no execution + cost, since it will be statically evalauted to `assert (0)' or + `assert (1)'. Unfortunately there is no -Wassert-0. */ + +# undef ARRAY_CARDINALITY +# define ARRAY_CARDINALITY(Array) (sizeof ((Array)) / sizeof (*(Array))) + +# define ARGMATCH_ASSERT(Arglist, Vallist) \ + assert (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). */ + +int argmatch + PARAMS ((const char *arg, const char *const *arglist, + const char *vallist, size_t valsize)); +int argcasematch + PARAMS ((const char *arg, const char *const *arglist, + const char *vallist, size_t valsize)); + +# define ARGMATCH(Arg, Arglist, Vallist) \ + argmatch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist))) + +# define ARGCASEMATCH(Arg, Arglist, Vallist) \ + argcasematch ((Arg), (Arglist), (const char *) (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) PARAMS ((void)); +extern argmatch_exit_fn argmatch_die; + +/* Report on stderr why argmatch failed. Report correct values. */ + +void argmatch_invalid + PARAMS ((const char *context, const char *value, int 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 + PARAMS ((const char *const *arglist, + const char *vallist, size_t valsize)); + +# define ARGMATCH_VALID(Arglist, Vallist) \ + argmatch_valid (Arglist, (const char *) Vallist, sizeof (*(Vallist))) + + + +/* Same as argmatch, but upon failure, reports a explanation on the + failure, and exits using the function EXIT_FN. */ + +int __xargmatch_internal + PARAMS ((const char *context, + const char *arg, const char *const *arglist, + const char *vallist, size_t valsize, + int case_sensitive, argmatch_exit_fn exit_fn)); + +/* Programmer friendly interface to __xargmatch_internal. */ + +# define XARGMATCH(Context, Arg, Arglist, Vallist) \ + (Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \ + (const char *) (Vallist), \ + sizeof (*(Vallist)), \ + 1, argmatch_die)]) + +# define XARGCASEMATCH(Context, Arg, Arglist, Vallist) \ + (Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \ + (const char *) (Vallist), \ + sizeof (*(Vallist)), \ + 0, argmatch_die)]) + +/* Convert a value into a corresponding argument. */ + +const char *argmatch_to_argument + PARAMS ((char const *value, const char *const *arglist, + const char *vallist, size_t valsize)); + +# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \ + argmatch_to_argument ((Value), (Arglist), \ + (const char *) (Vallist), sizeof (*(Vallist))) + +#endif /* ARGMATCH_H_ */ diff --git a/patch/backupfile.c b/patch/backupfile.c new file mode 100644 index 0000000..b0c3976 --- /dev/null +++ b/patch/backupfile.c @@ -0,0 +1,277 @@ +/* backupfile.c -- make Emacs style backup file names + Copyright (C) 1990,91,92,93,94,95,96,97,98,99,2000, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie . + Some algorithms adapted from GNU Emacs. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#if HAVE_STRING_H +# include +#else +# include +#endif + +#if HAVE_DIRENT_H +# include +# define NLENGTH(direct) strlen ((direct)->d_name) +#else +# define dirent direct +# define NLENGTH(direct) ((size_t) (direct)->d_namlen) +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +#endif + +#if CLOSEDIR_VOID +/* Fake a return value. */ +# define CLOSEDIR(d) (closedir (d), 0) +#else +# define CLOSEDIR(d) closedir (d) +#endif + +#if HAVE_STDLIB_H +# include +#endif + +#ifndef HAVE_DECL_GETENV +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_GETENV +char *getenv (); +#endif + +#ifndef HAVE_DECL_MALLOC +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_MALLOC +char *malloc (); +#endif + +#if HAVE_DIRENT_H || HAVE_NDIR_H || HAVE_SYS_DIR_H || HAVE_SYS_NDIR_H +# define HAVE_DIR 1 +#else +# define HAVE_DIR 0 +#endif + +#if HAVE_LIMITS_H +# include +#endif +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif +/* Upper bound on the string length of an integer converted to string. + 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit; + add 1 for integer division truncation; add 1 more for a minus sign. */ +#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2) + +/* ISDIGIT differs from isdigit, as follows: + - Its arg may be any int or unsigned int; it need not be an unsigned char. + - It's guaranteed to evaluate its argument exactly once. + - It's typically faster. + POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to + ISDIGIT_LOCALE 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) (c) - '0' <= 9) + +#if D_INO_IN_DIRENT +# define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0) +#else +# define REAL_DIR_ENTRY(dp) 1 +#endif + +#include "argmatch.h" +#include "backupfile.h" +#include "dirname.h" + +/* The extension added to file names to produce a simple (as opposed + to numbered) backup file name. */ +const char *simple_backup_suffix = "~"; + +static int max_backup_version PARAMS ((const char *, const char *)); +static int version_number PARAMS ((const char *, const char *, size_t)); + +/* Return the name of the new backup file for file FILE, + allocated with malloc. Return 0 if out of memory. + FILE must not end with a '/' unless it is the root directory. + Do not call this function if backup_type == none. */ + +char * +find_backup_file_name (const char *file, enum backup_type backup_type) +{ + size_t backup_suffix_size_max; + size_t file_len = strlen (file); + size_t numbered_suffix_size_max = INT_STRLEN_BOUND (int) + 4; + char *s; + const char *suffix = simple_backup_suffix; + + /* Allow room for simple or `.~N~' backups. */ + backup_suffix_size_max = strlen (simple_backup_suffix) + 1; + if (HAVE_DIR && backup_suffix_size_max < numbered_suffix_size_max) + backup_suffix_size_max = numbered_suffix_size_max; + + s = malloc (file_len + 1 + + backup_suffix_size_max + numbered_suffix_size_max); + if (s) + { +#if HAVE_DIR + if (backup_type != simple) + { + int highest_backup; + size_t dirlen = dir_len (file); + + memcpy (s, file, dirlen); + if (dirlen == FILESYSTEM_PREFIX_LEN (file)) + s[dirlen++] = '.'; + s[dirlen] = '\0'; + highest_backup = max_backup_version (base_name (file), s); + if (! (backup_type == numbered_existing && highest_backup == 0)) + { + char *numbered_suffix = s + (file_len + backup_suffix_size_max); + sprintf (numbered_suffix, ".~%d~", highest_backup + 1); + suffix = numbered_suffix; + } + } +#endif /* HAVE_DIR */ + + strcpy (s, file); + addext (s, suffix, '~'); + } + return s; +} + +#if HAVE_DIR + +/* Return the number of the highest-numbered backup file for file + FILE in directory DIR. If there are no numbered backups + of FILE in DIR, or an error occurs reading DIR, return 0. + */ + +static int +max_backup_version (const char *file, const char *dir) +{ + DIR *dirp; + struct dirent *dp; + int highest_version; + int this_version; + size_t file_name_length; + + dirp = opendir (dir); + if (!dirp) + return 0; + + highest_version = 0; + file_name_length = base_len (file); + + while ((dp = readdir (dirp)) != 0) + { + if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) < file_name_length + 4) + continue; + + this_version = version_number (file, dp->d_name, file_name_length); + if (this_version > highest_version) + highest_version = this_version; + } + if (CLOSEDIR (dirp)) + return 0; + return highest_version; +} + +/* If BACKUP is a numbered backup of BASE, return its version number; + otherwise return 0. BASE_LENGTH is the length of BASE. + */ + +static int +version_number (const char *base, const char *backup, size_t base_length) +{ + int version; + const char *p; + + version = 0; + if (strncmp (base, backup, base_length) == 0 + && backup[base_length] == '.' + && backup[base_length + 1] == '~') + { + for (p = &backup[base_length + 2]; ISDIGIT (*p); ++p) + version = version * 10 + *p - '0'; + if (p[0] != '~' || p[1]) + version = 0; + } + return version; +} +#endif /* HAVE_DIR */ + +static const char * const backup_args[] = +{ + /* In a series of synonyms, present the most meaning full first, so + that argmatch_valid be more readable. */ + "none", "off", + "simple", "never", + "existing", "nil", + "numbered", "t", + 0 +}; + +static const enum backup_type backup_types[] = +{ + none, none, + simple, simple, + numbered_existing, numbered_existing, + numbered, numbered +}; + +/* Return the type of backup specified by VERSION. + If VERSION is NULL or the empty string, return numbered_existing. + If VERSION is invalid or ambiguous, fail with a diagnostic appropriate + for the specified CONTEXT. Unambiguous abbreviations are accepted. */ + +enum backup_type +get_version (const char *context, const char *version) +{ + if (version == 0 || *version == 0) + return numbered_existing; + 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 (const char *context, const char *version) +{ + if (version && *version) + return get_version (context, version); + else + return get_version ("$VERSION_CONTROL", getenv ("VERSION_CONTROL")); +} diff --git a/patch/backupfile.h b/patch/backupfile.h new file mode 100644 index 0000000..b9b973c --- /dev/null +++ b/patch/backupfile.h @@ -0,0 +1,60 @@ +/* backupfile.h -- declarations for making Emacs style backup file names + Copyright (C) 1990-1992, 1997-1999 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef BACKUPFILE_H_ +# define BACKUPFILE_H_ + +/* When to make backup files. */ +enum backup_type +{ + /* Never make backups. */ + none, + + /* Make simple backups of every file. */ + simple, + + /* Make numbered backups of files that already have numbered backups, + and simple backups of the others. */ + numbered_existing, + + /* Make numbered backups of every file. */ + numbered +}; + +# define VALID_BACKUP_TYPE(Type) \ + ((Type) == none \ + || (Type) == simple \ + || (Type) == numbered_existing \ + || (Type) == numbered) + +extern char const *simple_backup_suffix; + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +char *find_backup_file_name PARAMS ((char const *, enum backup_type)); +enum backup_type get_version PARAMS ((char const *context, char const *arg)); +enum backup_type xget_version PARAMS ((char const *context, char const *arg)); +void addext PARAMS ((char *, char const *, int)); + +#endif /* ! BACKUPFILE_H_ */ diff --git a/patch/basename.c b/patch/basename.c new file mode 100644 index 0000000..54f037e --- /dev/null +++ b/patch/basename.c @@ -0,0 +1,79 @@ +/* basename.c -- return the last element in a path + Copyright (C) 1990, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#if STDC_HEADERS || HAVE_STRING_H +# include +#endif +#include "dirname.h" + +/* 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 address of the last file name component of NAME. If + NAME has no file name components because it is all slashes, return + NAME if it is empty, the address of its last slash otherwise. */ + +char * +base_name (char const *name) +{ + char const *base = name + FILESYSTEM_PREFIX_LEN (name); + char const *p; + + for (p = base; *p; p++) + { + if (ISSLASH (*p)) + { + /* Treat multiple adjacent slashes like a single slash. */ + do p++; + while (ISSLASH (*p)); + + /* If the file name ends in slash, use the trailing slash as + the basename if no non-slashes have been found. */ + if (! *p) + { + if (ISSLASH (*base)) + base = p - 1; + break; + } + + /* *P is a non-slash preceded by a slash. */ + base = p; + } + } + + return (char *) base; +} + +/* Return the length of of the basename NAME. Typically NAME is the + value returned by base_name. Act like strlen (NAME), except omit + redundant trailing slashes. */ + +size_t +base_len (char const *name) +{ + size_t len; + + for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--) + continue; + + return len; +} diff --git a/patch/basename.h b/patch/basename.h new file mode 100644 index 0000000..90f7654 --- /dev/null +++ b/patch/basename.h @@ -0,0 +1,9 @@ +#ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +char *base_name PARAMS ((char const *name)); diff --git a/patch/common.h b/patch/common.h new file mode 100644 index 0000000..1646bf1 --- /dev/null +++ b/patch/common.h @@ -0,0 +1,321 @@ +/* common definitions for `patch' */ + +/* $Id: common.h,v 1.1.1.3 2003/05/08 18:38:01 rbraun Exp $ */ + +/* Copyright (C) 1986, 1988 Larry Wall + + Copyright (C) 1990, 1991, 1992, 1993, 1997, 1998, 1999, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef DEBUGGING +#define DEBUGGING 1 +#endif + +#include + +#include +#include +#include +#include + +#include +#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 +#ifdef MKDIR_TAKES_ONE_ARG +# define mkdir(name, mode) ((mkdir) (name)) +#endif + +#if HAVE_LIMITS_H +# include +#endif +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif +/* The extra casts work around common compiler bugs, + e.g. Cray C 5.0.3.0 time_t. */ +#define TYPE_SIGNED(t) ((t) -1 < (t) 0) +#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ + ? (t) (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)) \ + : (t) 0)) +#define TYPE_MAXIMUM(t) ((t) ((t) ~ (t) 0 - TYPE_MINIMUM (t))) +#ifndef CHAR_MAX +#define CHAR_MAX TYPE_MAXIMUM (char) +#endif +#ifndef INT_MAX +#define INT_MAX TYPE_MAXIMUM (int) +#endif +#ifndef LONG_MIN +#define LONG_MIN TYPE_MINIMUM (long) +#endif + +#if HAVE_INTTYPES_H +# include +#endif +#ifndef SIZE_MAX +/* On some nonstandard hosts, size_t is signed, + so SIZE_MAX != (size_t) -1. */ +#define SIZE_MAX TYPE_MAXIMUM (size_t) +#endif + +#include +/* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given + as an argument to 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 + + +#ifndef FILESYSTEM_PREFIX_LEN +#define FILESYSTEM_PREFIX_LEN(f) 0 +#endif + +#ifndef ISSLASH +#define ISSLASH(c) ((c) == '/') +#endif + + +/* constants */ + +/* AIX predefines these. */ +#ifdef TRUE +#undef TRUE +#endif +#ifdef FALSE +#undef FALSE +#endif +#define TRUE 1 +#define FALSE 0 + +/* handy definitions */ + +#define strEQ(s1,s2) (!strcmp(s1, s2)) +#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l)) + +/* typedefs */ + +typedef int bool; /* must promote to itself */ +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 * 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 int 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 int set_time; +XTERN int 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 +#if !STDC_HEADERS && !defined errno +extern int errno; +#endif + +#if STDC_HEADERS || HAVE_STRING_H +# include +#else +# if !HAVE_MEMCHR +# define memcmp(s1, s2, n) bcmp (s1, s2, n) +# define memcpy(d, s, n) bcopy (s, d, n) +void *memchr (); +# endif +#endif + +#if STDC_HEADERS +# include +#else +char *getenv (); +void *malloc (); +void *realloc (); +#endif + +#if HAVE_UNISTD_H +# include +#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 +#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 + +#if HAVE_SETMODE_DOS + XTERN int binary_transput; /* O_BINARY if binary i/o is desired */ +#else +# define binary_transput 0 +#endif + +#ifndef NULL_DEVICE +#define NULL_DEVICE "/dev/null" +#endif + +#ifndef TTY_DEVICE +#define TTY_DEVICE "/dev/tty" +#endif + +/* The official name of this program (e.g., no `g' prefix). */ +#define PROGRAM_NAME "patch" diff --git a/patch/config.guess b/patch/config.guess new file mode 100644 index 0000000..077bf35 --- /dev/null +++ b/patch/config.guess @@ -0,0 +1,1091 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 +# Free Software Foundation, Inc. +# +# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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. + +# Written by Per Bothner . +# The master version of this file is at the FSF in /home/gd/gnu/lib. +# Please send patches to . +# +# 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 system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# Use $HOST_CC if defined. $CC may point to a cross-compiler +if test x"$CC_FOR_BUILD" = x; then + if test x"$HOST_CC" != x; then + CC_FOR_BUILD="$HOST_CC" + else + if test x"$CC" != x; then + CC_FOR_BUILD="$CC" + else + CC_FOR_BUILD=cc + fi + fi +fi + + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +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 + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # 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. + cat <$dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + ./$dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + 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 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:NetBSD:*:*) + echo m68k-cbm-netbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + 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 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + 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 0 ;; + 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 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /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 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:NetBSD:*:*) + echo m68k-atari-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # 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 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:NetBSD:*:*) + echo m68k-sun-netbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:NetBSD:*:*) + echo m68k-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + macppc:NetBSD:*:*) + echo powerpc-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus + 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 $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${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 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????: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 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + 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 0 ;; + *:AIX:*:4) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -EHl ${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=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + sed 's/^ //' << EOF >$dummy.c + #include + #include + + 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 + ($CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + rm -f $dummy.c $dummy + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >$dummy.c + #include + 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 $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*T3E:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | i?86:BSD/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + if test -x /usr/bin/objformat; then + if test "elf" = "`/usr/bin/objformat`"; then + echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` + exit 0 + fi + fi + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + 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 i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + # uname on the ARM produces all sorts of strangeness, and we need to + # filter it out. + case "$UNAME_MACHINE" in + armv*) UNAME_MACHINE=$UNAME_MACHINE ;; + arm* | sa110*) UNAME_MACHINE="arm" ;; + esac + + # 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. + ld_help_string=`cd /; ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + *ia64) echo "${UNAME_MACHINE}-unknown-linux" ; exit 0 ;; + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc | elf32ppclinux) + # Determine Lib Version + cat >$dummy.c < +#if defined(__GLIBC__) +extern char __libc_version[]; +extern char __libc_release[]; +#endif +main(argc, argv) + int argc; + char *argv[]; +{ +#if defined(__GLIBC__) + printf("%s %s\n", __libc_version, __libc_release); +#else + printf("unkown\n"); +#endif + return 0; +} +EOF + LIBC="" + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null + if test "$?" = 0 ; then + ./$dummy | grep 1\.99 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f $dummy.c $dummy + echo powerpc-unknown-linux-gnu${LIBC} ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <$dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + LIBC="" + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + ./$dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + + objdump --private-headers $dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >$dummy.c </dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >$dummy.c < +#ifdef __cplusplus + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + fi ;; +# 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. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + 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 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:5:7*) + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585 + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE} + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # 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 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + 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 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*: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 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *: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 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + 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 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >$dummy.c < +# include +#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 + 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"); 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) + printf ("vax-dec-bsd\n"); exit (0); +#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 $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# 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 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/patch/config.hin b/patch/config.hin new file mode 100644 index 0000000..a1d4e83 --- /dev/null +++ b/patch/config.hin @@ -0,0 +1,275 @@ +/* config.hin. Generated from configure.ac by autoheader. */ + +/* Define to 1 if the `closedir' function returns void instead of `int'. */ +#undef CLOSEDIR_VOID + +/* Define if there is a member named d_ino in the struct describing directory + headers. */ +#undef D_INO_IN_DIRENT + +/* Define to 1 if you have the header file. */ +#undef HAVE_BP_SYM_H + +/* Define if backslash-a works in C strings. */ +#undef HAVE_C_BACKSLASH_A + +/* Define to 1 if you have the declaration of `free', and to 0 if you don't. + */ +#undef HAVE_DECL_FREE + +/* 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 `malloc', and to 0 if you don't. + */ +#undef HAVE_DECL_MALLOC + +/* 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 `strerror', and to 0 if you + don't. */ +#undef HAVE_DECL_STRERROR + +/* 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 header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define if the malloc check has been performed. */ +#undef HAVE_DONE_WORKING_MALLOC_CHECK + +/* Define if the realloc check has been performed. */ +#undef HAVE_DONE_WORKING_REALLOC_CHECK + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the 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 `getuid' function. */ +#undef HAVE_GETUID + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `isascii' function. */ +#undef HAVE_ISASCII + +/* Define to 1 if you have the `iswprint' function. */ +#undef HAVE_ISWPRINT + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you support file names longer than 14 characters. */ +#undef HAVE_LONG_FILE_NAMES + +/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ +#undef HAVE_MBRTOWC + +/* ma Define to 1 if declares mbstate_t. */ +#undef HAVE_MBSTATE_T + +/* Define to 1 if you have the `memchr' function. */ +#undef HAVE_MEMCHR + +/* Define to 1 if you have the `memcmp' function. */ +#undef HAVE_MEMCMP + +/* Define to 1 if you have the 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 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 to 1 if you have the `rename' function. */ +#undef HAVE_RENAME + +/* Define to 1 if you have the `rmdir' function. */ +#undef HAVE_RMDIR + +/* 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 you have the header file. */ +#undef HAVE_STDDEF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the `strerror_r' function. */ +#undef HAVE_STRERROR_R + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the 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 . Some systems + have utime.h but don't declare the struct anywhere. */ +#undef HAVE_STRUCT_UTIMBUF + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UTIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VARARGS_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCHAR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCTYPE_H + +/* Define to 1 if you have the `_doprintf' function. */ +#undef HAVE__DOPRINTF + +/* 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 the C compiler supports function prototypes. */ +#undef PROTOTYPES + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* 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 can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif + +/* 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 like PROTOTYPES; this can be used by system headers. */ +#undef __PROTOTYPES + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to a type if does not define. */ +#undef mbstate_t + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define to `long' if does not define. */ +#undef off_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to rpl_realloc if the replacement function should be used. */ +#undef realloc + +/* Define to `unsigned' if does not define. */ +#undef size_t diff --git a/patch/config.sub b/patch/config.sub new file mode 100644 index 0000000..cf5f3a7 --- /dev/null +++ b/patch/config.sub @@ -0,0 +1,1220 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc. +# 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., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, 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. + +# 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. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +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 + linux-gnu*) + 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) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -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/'` + ;; + -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. + tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \ + | 580 | i960 | h8300 \ + | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ + | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \ + | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \ + | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \ + | mips64orion | mips64orionel | mipstx39 | mipstx39el \ + | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ + | mips64vr5000 | miprs64vr5000el | mcore \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \ + | thumb | d10v) + basic_machine=$basic_machine-unknown + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65) + ;; + + # 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[34567]86) + 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. + # FIXME: clean up the formatting here. + vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ + | xmp-* | ymp-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \ + | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \ + | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ + | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ + | mipstx39-* | mipstx39el-* | mcore-* \ + | f301-* | armv*-* | t3e-* \ + | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ + | thumb-* | v850-* | d30v-* | tic30-* | c30-* ) + ;; + # 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 + ;; + 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 + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + 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 | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + 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 + ;; + 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 + os=-mvs + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[34567]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[34567]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[34567]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[34567]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 + ;; + i386-go32 | go32) + basic_machine=i386-unknown + os=-go32 + ;; + i386-mingw32 | mingw32) + basic_machine=i386-unknown + os=-mingw32 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + 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 + ;; + msdos) + basic_machine=i386-unknown + os=-msdos + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-corel + 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 + ;; + np1) + basic_machine=np1-gould + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + 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 + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-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/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-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 + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + 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 + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-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 + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc | sparcv9) + 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 + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *) + 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* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -openstep* | -darwin* | -oskit*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -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|'` + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -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) + os=-mint + ;; + -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 + *-acorn) + os=-riscix1.2 + ;; + arm*-corel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + 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 + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-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 + ;; + f301-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*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -*MiNT) + vendor=atari + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/patch/configure b/patch/configure new file mode 100755 index 0000000..64553c1 --- /dev/null +++ b/patch/configure @@ -0,0 +1,8633 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.53 for patch 2.5.8. +# +# Report bugs to . +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + + +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# NLS nuisances. +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +(set +x; test -n "`(LANG=C; export LANG) 2>&1`") && + { $as_unset LANG || test "${LANG+set}" != set; } || + { LANG=C; export LANG; } +(set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && + { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || + { LC_ALL=C; export LC_ALL; } +(set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && + { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || + { LC_TIME=C; export LC_TIME; } +(set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && + { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || + { LC_CTYPE=C; export LC_CTYPE; } +(set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && + { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || + { LANGUAGE=C; export LANGUAGE; } +(set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && + { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || + { LC_COLLATE=C; export LC_COLLATE; } +(set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && + { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || + { LC_NUMERIC=C; export LC_NUMERIC; } +(set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && + { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || + { LC_MESSAGES=C; export LC_MESSAGES; } + + +# Name of the executable. +as_me=`(basename "$0") 2>/dev/null || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conftest.sh + echo "exit 0" >>conftest.sh + chmod +x conftest.sh + if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conftest.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + 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=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # 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 before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, 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 + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { 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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } + + +# 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` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME='patch' +PACKAGE_TARNAME='patch' +PACKAGE_VERSION='2.5.8' +PACKAGE_STRING='patch 2.5.8' +PACKAGE_BUGREPORT='bug-patch@gnu.org' + +ac_unique_file="patch.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# 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. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_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 | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -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 ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -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 ;; + + -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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$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 && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + 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'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +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 + 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 + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + 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 + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# 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.5.8 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 \`..'] + +_ACEOF + + cat <<_ACEOF +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] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --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] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_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 +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of patch 2.5.8:";; + esac + cat <<\_ACEOF + +Optional Features: + --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 + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + 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 . +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style 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 + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF +patch configure 2.5.8 +generated by GNU Autoconf 2.53 + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +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 0 +fi +exec 5>config.log +cat >&5 <<_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.5.8, which was +generated by GNU Autoconf 2.53. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +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` +hostinfo = `(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=. + echo "PATH: $as_dir" +done + +} >&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. +# Also quote any args containing shell meta-characters. +ac_configure_args= +ac_sep= +for ac_arg +do + case $ac_arg in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n ) continue ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + ac_sep=" " ;; + esac + # Get rid of the leading space. +done + +# 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: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +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, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf 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 -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >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 explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +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 + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; 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,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +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 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`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 + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +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 $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + + +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$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" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +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 + set dummy "$as_dir/$ac_word" ${1+"$@"} + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + 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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH" >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH" >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe" +# 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. +echo "$as_me:$LINENO: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +for ac_file in `ls a_out.exe a.exe conftest.exe 2>/dev/null; + ls a.out conftest 2>/dev/null; + ls a.* conftest.* 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb | *.xSYM ) ;; + a.out ) # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool --akim. + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables" >&5 +echo "$as_me: error: C compiler cannot create executables" >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&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' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + 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 + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + 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 `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link" >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile" >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$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 +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +$ac_declaration +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_declaration +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +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 +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&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 + echo $ECHO_N "(cached) $ECHO_C" >&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. + # 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 +#line $LINENO "configure" +#include "confdefs.h" +#include + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 + cat 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 non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 + cat 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 +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$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. + # 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 +#line $LINENO "configure" +#include "confdefs.h" +#include + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 + cat 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 non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 + cat 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 + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check" >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&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 + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# 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" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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/* | \ + /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 $as_executable_p "$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 + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$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' + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="${MAKE}"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Use ed_PROGRAM, not ED_PROGRAM, +# because 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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_ed_PROGRAM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ed_PROGRAM="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + 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 + echo "$as_me:$LINENO: result: $ed_PROGRAM" >&5 +echo "${ECHO_T}$ed_PROGRAM" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + + + + +echo "$as_me:$LINENO: checking for AIX" >&5 +echo $ECHO_N "checking for AIX... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#ifdef _AIX + yes +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "yes" >/dev/null 2>&1; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +cat >>confdefs.h <<\_ACEOF +#define _ALL_SOURCE 1 +_ACEOF + +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest* + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#include +#include + +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest.err 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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +if test "${ac_cv_header_minix_config_h+set}" = set; then + echo "$as_me:$LINENO: checking for minix/config.h" >&5 +echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 +if test "${ac_cv_header_minix_config_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 +echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking minix/config.h usability" >&5 +echo $ECHO_N "checking minix/config.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking minix/config.h presence" >&5 +echo $ECHO_N "checking minix/config.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: minix/config.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: minix/config.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: minix/config.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for minix/config.h" >&5 +echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 +if test "${ac_cv_header_minix_config_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_minix_config_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 +echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 + +fi +if test $ac_cv_header_minix_config_h = 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 + +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#include +#include +/* 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; +} +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; +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +echo "$as_me:$LINENO: checking for library containing strerror" >&5 +echo $ECHO_N "checking for library containing strerror... $ECHO_C" >&6 +if test "${ac_cv_search_strerror+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_strerror=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strerror (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +strerror (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_strerror="none required" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_strerror" = no; then + for ac_lib in cposix; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strerror (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +strerror (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_strerror="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_strerror" >&5 +echo "${ECHO_T}$ac_cv_search_strerror" >&6 +if test "$ac_cv_search_strerror" != no; then + test "$ac_cv_search_strerror" = "none required" || LIBS="$ac_cv_search_strerror $LIBS" + +fi + +# Check whether --enable-largefile or --disable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval="$enable_largefile" + +fi; +if test "$enable_largefile" != no; then + + echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 +echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 +#line $LINENO "configure" +#include "confdefs.h" +#include + /* 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]; +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext + CC="$CC -n32" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_largefile_CC=' -n32'; break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_file_offset_bits+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + ac_cv_sys_file_offset_bits=no + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include + /* 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]; +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#define _FILE_OFFSET_BITS 64 +#include + /* 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]; +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_file_offset_bits=64; break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 +if test "$ac_cv_sys_file_offset_bits" != no; then + +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF + +fi +rm -f conftest* + echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 +echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_large_files+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + ac_cv_sys_large_files=no + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include + /* 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]; +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#define _LARGE_FILES 1 +#include + /* 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]; +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_large_files=1; break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +echo "${ECHO_T}$ac_cv_sys_large_files" >&6 +if test "$ac_cv_sys_large_files" != no; then + +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF + +fi +rm -f conftest* +fi + + + +echo "$as_me:$LINENO: checking for function prototypes" >&5 +echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6 +if test "$ac_cv_prog_cc_stdc" != no; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define PROTOTYPES 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define __PROTOTYPES 1 +_ACEOF + +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_c_const=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + + + + + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include <$ac_hdr> + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `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 + echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_opendir=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="none required" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_opendir" = no; then + for ac_lib in dir; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6 +if test "$ac_cv_search_opendir" != no; then + test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" + +fi + +else + echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_opendir=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="none required" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_opendir" = no; then + for ac_lib in x; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6 +if test "$ac_cv_search_opendir" != no; then + test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" + +fi + +fi + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#include +#include + +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest.err 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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$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 limits.h string.h unistd.h utime.h varargs.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking for mode_t" >&5 +echo $ECHO_N "checking for mode_t... $ECHO_C" >&6 +if test "${ac_cv_type_mode_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +if ((mode_t *) 0) + return 0; +if (sizeof (mode_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_mode_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_mode_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5 +echo "${ECHO_T}$ac_cv_type_mode_t" >&6 +if test $ac_cv_type_mode_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define mode_t int +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for off_t" >&5 +echo $ECHO_N "checking for off_t... $ECHO_C" >&6 +if test "${ac_cv_type_off_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +if ((off_t *) 0) + return 0; +if (sizeof (off_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_off_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_off_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6 +if test $ac_cv_type_off_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define off_t long +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 +if test "${ac_cv_type_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +if ((pid_t *) 0) + return 0; +if (sizeof (pid_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_pid_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_pid_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6 +if test $ac_cv_type_pid_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + +echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#ifdef signal +# undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_signal=void +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_signal=int +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6 + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + +echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +if ((size_t *) 0) + return 0; +if (sizeof (size_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_size_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#include + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_header_time=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6 +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + + + +for ac_header in utime.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + echo "$as_me:$LINENO: checking for struct utimbuf" >&5 +echo $ECHO_N "checking for struct utimbuf... $ECHO_C" >&6 +if test "${fu_cv_sys_struct_utimbuf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef HAVE_UTIME_H +# include +#endif + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +static struct utimbuf x; x.actime = x.modtime; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + fu_cv_sys_struct_utimbuf=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fu_cv_sys_struct_utimbuf=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: $fu_cv_sys_struct_utimbuf" >&5 +echo "${ECHO_T}$fu_cv_sys_struct_utimbuf" >&6 + + if test $fu_cv_sys_struct_utimbuf = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRUCT_UTIMBUF 1 +_ACEOF + + fi + + + + echo "$as_me:$LINENO: checking for long file names" >&5 +echo $ECHO_N "checking for long file names... $ECHO_C" >&6 +if test "${ac_cv_sys_long_file_names+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 +# eval it to expand exec_prefix. +# $TMPDIR if set, where it might want to write temporary files +# if $TMPDIR is not set: +# /tmp where it might want to write temporary files +# /var/tmp likewise +# /usr/tmp likewise +if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then + ac_tmpdirs=$TMPDIR +else + ac_tmpdirs='/tmp /var/tmp /usr/tmp' +fi +for ac_dir in . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do + test -d $ac_dir || continue + 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 + (echo 1 >$ac_tf1) 2>/dev/null + (echo 2 >$ac_tf2) 2>/dev/null + ac_val=`cat $ac_tf1 2>/dev/null` + if test ! -f $ac_tf1 || test "$ac_val" != 1; then + ac_cv_sys_long_file_names=no + rm -rf $ac_xdir 2>/dev/null + break + fi + rm -rf $ac_xdir 2>/dev/null +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_long_file_names" >&5 +echo "${ECHO_T}$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 pathconf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + +for ac_header in limits.h string.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#include +#include + +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest.err 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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$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 string.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + +for ac_func in strerror vprintf doprnt +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + echo "$as_me:$LINENO: checking whether strerror is declared" >&5 +echo $ECHO_N "checking whether strerror is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_strerror+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +#ifndef strerror + char *p = (char *) strerror; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_strerror=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_have_decl_strerror=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_strerror" >&5 +echo "${ECHO_T}$ac_cv_have_decl_strerror" >&6 +if test $ac_cv_have_decl_strerror = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRERROR 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRERROR 0 +_ACEOF + + +fi + + + echo "$as_me:$LINENO: checking whether strerror_r is declared" >&5 +echo $ECHO_N "checking whether strerror_r is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_strerror_r+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +#ifndef strerror_r + char *p = (char *) strerror_r; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_strerror_r=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_have_decl_strerror_r=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_strerror_r" >&5 +echo "${ECHO_T}$ac_cv_have_decl_strerror_r" >&6 +if test $ac_cv_have_decl_strerror_r = 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=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +echo "$as_me:$LINENO: checking whether strerror_r returns char *" >&5 +echo $ECHO_N "checking whether strerror_r returns char *... $ECHO_C" >&6 +if test "${ac_cv_func_strerror_r_char_p+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + char buf[100]; + char x = *strerror_r (0, buf, sizeof buf); + char *p = strerror_r (0, buf, sizeof buf); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_strerror_r_char_p=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f 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 +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default + extern char *strerror_r (); +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +char buf[100]; + char x = *strerror_r (0, buf, sizeof buf); + exit (!isalpha (x)); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_strerror_r_char_p=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + fi + +fi +echo "$as_me:$LINENO: result: $ac_cv_func_strerror_r_char_p" >&5 +echo "${ECHO_T}$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 + + echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#include +#include + +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest.err 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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$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 limits.h stdlib.h bp-sym.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + +for ac_func in isascii iswprint +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + echo "$as_me:$LINENO: checking whether mbrtowc and mbstate_t are properly declared" >&5 +echo $ECHO_N "checking whether mbrtowc and mbstate_t are properly declared... $ECHO_C" >&6 +if test "${jm_cv_func_mbrtowc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +mbstate_t state; return ! (sizeof state && mbrtowc); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + jm_cv_func_mbrtowc=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +jm_cv_func_mbrtowc=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $jm_cv_func_mbrtowc" >&5 +echo "${ECHO_T}$jm_cv_func_mbrtowc" >&6 + if test $jm_cv_func_mbrtowc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MBRTOWC 1 +_ACEOF + + fi + + + + + + + +for ac_header in limits.h stddef.h stdlib.h string.h wchar.h wctype.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#include +#include +#include + +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest.err 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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include + +_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 +#line $LINENO "configure" +#include "confdefs.h" +#include +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + + + echo "$as_me:$LINENO: checking whether backslash-a works in strings" >&5 +echo $ECHO_N "checking whether backslash-a works in strings... $ECHO_C" >&6 +if test "${ac_cv_c_backslash_a+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + +#if '\a' == 'a' + syntax error; +#endif + char buf['\a' == 'a' ? -1 : 1]; + buf[0] = '\a'; + return buf[0] != "\a"[0]; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_backslash_a=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_c_backslash_a=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_backslash_a" >&5 +echo "${ECHO_T}$ac_cv_c_backslash_a" >&6 + if test $ac_cv_c_backslash_a = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_C_BACKSLASH_A 1 +_ACEOF + + fi + + + +for ac_header in stdlib.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + echo "$as_me:$LINENO: checking for mbstate_t" >&5 +echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6 +if test "${ac_cv_type_mbstate_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_STDLIB_H +# include +#endif +#include +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +mbstate_t x; return sizeof x; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_mbstate_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_mbstate_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_mbstate_t" >&5 +echo "${ECHO_T}$ac_cv_type_mbstate_t" >&6 + if test $ac_cv_type_mbstate_t = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MBSTATE_T 1 +_ACEOF + + else + +cat >>confdefs.h <<\_ACEOF +#define mbstate_t int +_ACEOF + + fi + echo "$as_me:$LINENO: checking for function prototypes" >&5 +echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6 +if test "$ac_cv_prog_cc_stdc" != no; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define PROTOTYPES 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define __PROTOTYPES 1 +_ACEOF + +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + + +echo "$as_me:$LINENO: checking whether free is declared" >&5 +echo $ECHO_N "checking whether free is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_free+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +#ifndef free + char *p = (char *) free; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_free=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_have_decl_free=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_free" >&5 +echo "${ECHO_T}$ac_cv_have_decl_free" >&6 +if test $ac_cv_have_decl_free = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FREE 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FREE 0 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking whether getenv is declared" >&5 +echo $ECHO_N "checking whether getenv is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_getenv+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +#ifndef getenv + char *p = (char *) getenv; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_getenv=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_have_decl_getenv=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_getenv" >&5 +echo "${ECHO_T}$ac_cv_have_decl_getenv" >&6 +if test $ac_cv_have_decl_getenv = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETENV 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETENV 0 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking whether malloc is declared" >&5 +echo $ECHO_N "checking whether malloc is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_malloc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +#ifndef malloc + char *p = (char *) malloc; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_malloc=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_have_decl_malloc=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_malloc" >&5 +echo "${ECHO_T}$ac_cv_have_decl_malloc" >&6 +if test $ac_cv_have_decl_malloc = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_MALLOC 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_MALLOC 0 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking whether mktemp is declared" >&5 +echo $ECHO_N "checking whether mktemp is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_mktemp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +#ifndef mktemp + char *p = (char *) mktemp; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_mktemp=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_have_decl_mktemp=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_mktemp" >&5 +echo "${ECHO_T}$ac_cv_have_decl_mktemp" >&6 +if test $ac_cv_have_decl_mktemp = 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 _doprintf geteuid getuid isascii memcmp mktemp \ + pathconf raise sigaction sigprocmask sigsetmask strerror +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + + +for ac_func in memchr mkdir rename rmdir strncasecmp +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + LIBOBJS="$LIBOBJS $ac_func.$ac_objext" +fi +done + + +echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 +echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_source+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + ac_cv_sys_largefile_source=no + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +return !fseeko; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#define _LARGEFILE_SOURCE 1 +#include +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +return !fseeko; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_largefile_source=1; break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6 +if test "$ac_cv_sys_largefile_source" != no; then + +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF + +fi +rm -f 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. +echo "$as_me:$LINENO: checking for fseeko" >&5 +echo $ECHO_N "checking for fseeko... $ECHO_C" >&6 +if test "${ac_cv_func_fseeko+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +return fseeko && fseeko (stdin, 0, 0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_fseeko=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_fseeko=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_fseeko" >&5 +echo "${ECHO_T}$ac_cv_func_fseeko" >&6 +if test $ac_cv_func_fseeko = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FSEEKO 1 +_ACEOF + +fi + + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DONE_WORKING_MALLOC_CHECK 1 +_ACEOF + + + echo "$as_me:$LINENO: checking whether malloc(0) returns a non-NULL pointer" >&5 +echo $ECHO_N "checking whether malloc(0) returns a non-NULL pointer... $ECHO_C" >&6 +if test "${jm_cv_func_working_malloc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + jm_cv_func_working_malloc=no +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + + char *malloc (); + int + main () + { + exit (malloc (0) ? 0 : 1); + } + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + jm_cv_func_working_malloc=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +jm_cv_func_working_malloc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + +fi +echo "$as_me:$LINENO: result: $jm_cv_func_working_malloc" >&5 +echo "${ECHO_T}$jm_cv_func_working_malloc" >&6 + if test $jm_cv_func_working_malloc = no; then + LIBOBJS="$LIBOBJS malloc.$ac_objext" + +cat >>confdefs.h <<\_ACEOF +#define malloc rpl_malloc +_ACEOF + + fi + + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DONE_WORKING_REALLOC_CHECK 1 +_ACEOF + + + echo "$as_me:$LINENO: checking whether realloc(0,0) returns a non-NULL pointer" >&5 +echo $ECHO_N "checking whether realloc(0,0) returns a non-NULL pointer... $ECHO_C" >&6 +if test "${jm_cv_func_working_realloc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + jm_cv_func_working_realloc=no +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + + char *realloc (); + int + main () + { + exit (realloc (0, 0) ? 0 : 1); + } + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + jm_cv_func_working_realloc=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +jm_cv_func_working_realloc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + +fi +echo "$as_me:$LINENO: result: $jm_cv_func_working_realloc" >&5 +echo "${ECHO_T}$jm_cv_func_working_realloc" >&6 + if test $jm_cv_func_working_realloc = no; then + LIBOBJS="$LIBOBJS realloc.$ac_objext" + +cat >>confdefs.h <<\_ACEOF +#define realloc rpl_realloc +_ACEOF + + fi + +echo "$as_me:$LINENO: checking whether closedir returns void" >&5 +echo $ECHO_N "checking whether closedir returns void... $ECHO_C" >&6 +if test "${ac_cv_func_closedir_void+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_closedir_void=yes +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header_dirent> +#ifndef __cplusplus +int closedir (); +#endif + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +exit (closedir (opendir (".")) != 0); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_closedir_void=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +ac_cv_func_closedir_void=yes +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_func_closedir_void" >&5 +echo "${ECHO_T}$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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + echo "$as_me:$LINENO: checking for DOS-style setmode" >&5 +echo $ECHO_N "checking for DOS-style setmode... $ECHO_C" >&6 +if test "${ac_cv_func_setmode_dos+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include + #if HAVE_FCNTL_H + # include + #endif + #if HAVE_UNISTD_H + # include + #endif +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +int ret = setmode && setmode (1, O_BINARY); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_setmode_dos=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_setmode_dos=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_setmode_dos" >&5 +echo "${ECHO_T}$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=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +echo "$as_me:$LINENO: checking for _doprnt" >&5 +echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 +if test "${ac_cv_func__doprnt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char _doprnt (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char _doprnt (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub__doprnt) || defined (__stub____doprnt) +choke me +#else +f = _doprnt; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func__doprnt=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func__doprnt=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 +echo "${ECHO_T}$ac_cv_func__doprnt" >&6 +if test $ac_cv_func__doprnt = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DOPRNT 1 +_ACEOF + +fi + +fi +done + + + +for ac_func in mkdir +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + echo "$as_me:$LINENO: checking whether mkdir takes only one argument" >&5 +echo $ECHO_N "checking whether mkdir takes only one argument... $ECHO_C" >&6 +if test "${patch_cv_mkdir_takes_one_arg+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + patch_cv_mkdir_takes_one_arg=no + if test $ac_cv_func_mkdir = yes; then + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include +#include + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +mkdir (".", 0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include +#include + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +mkdir ("."); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + patch_cv_mkdir_takes_one_arg=yes + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +fi +rm -f conftest.$ac_objext conftest.$ac_ext + fi + + +fi +echo "$as_me:$LINENO: result: $patch_cv_mkdir_takes_one_arg" >&5 +echo "${ECHO_T}$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 + + + +echo "$as_me:$LINENO: checking for long file names" >&5 +echo $ECHO_N "checking for long file names... $ECHO_C" >&6 +if test "${ac_cv_sys_long_file_names+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 +# eval it to expand exec_prefix. +# $TMPDIR if set, where it might want to write temporary files +# if $TMPDIR is not set: +# /tmp where it might want to write temporary files +# /var/tmp likewise +# /usr/tmp likewise +if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then + ac_tmpdirs=$TMPDIR +else + ac_tmpdirs='/tmp /var/tmp /usr/tmp' +fi +for ac_dir in . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do + test -d $ac_dir || continue + 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 + (echo 1 >$ac_tf1) 2>/dev/null + (echo 2 >$ac_tf2) 2>/dev/null + ac_val=`cat $ac_tf1 2>/dev/null` + if test ! -f $ac_tf1 || test "$ac_val" != 1; then + ac_cv_sys_long_file_names=no + rm -rf $ac_xdir 2>/dev/null + break + fi + rm -rf $ac_xdir 2>/dev/null +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_long_file_names" >&5 +echo "${ECHO_T}$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 + + echo "$as_me:$LINENO: checking for d_ino member in directory struct" >&5 +echo $ECHO_N "checking for d_ino member in directory struct... $ECHO_C" >&6 +if test "${jm_cv_struct_dirent_d_ino+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include +#ifdef HAVE_DIRENT_H +# include +#else /* not HAVE_DIRENT_H */ +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* HAVE_SYS_NDIR_H */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* HAVE_SYS_DIR_H */ +# ifdef HAVE_NDIR_H +# include +# endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +struct dirent dp; dp.d_ino = 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + jm_cv_struct_dirent_d_ino=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +jm_cv_struct_dirent_d_ino=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + + +fi +echo "$as_me:$LINENO: result: $jm_cv_struct_dirent_d_ino" >&5 +echo "${ECHO_T}$jm_cv_struct_dirent_d_ino" >&6 + if test $jm_cv_struct_dirent_d_ino = yes; then + +cat >>confdefs.h <<\_ACEOF +#define D_INO_IN_DIRENT 1 +_ACEOF + + 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 overriden 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, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *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 \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if cmp -s $cache_file confcache; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + 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}' + +# 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 + +DEFS=-DHAVE_CONFIG_H + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $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 +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# NLS nuisances. +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +(set +x; test -n "`(LANG=C; export LANG) 2>&1`") && + { $as_unset LANG || test "${LANG+set}" != set; } || + { LANG=C; export LANG; } +(set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && + { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || + { LC_ALL=C; export LC_ALL; } +(set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && + { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || + { LC_TIME=C; export LC_TIME; } +(set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && + { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || + { LC_CTYPE=C; export LC_CTYPE; } +(set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && + { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || + { LANGUAGE=C; export LANGUAGE; } +(set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && + { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || + { LC_COLLATE=C; export LC_COLLATE; } +(set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && + { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || + { LC_NUMERIC=C; export LC_NUMERIC; } +(set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && + { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || + { LC_MESSAGES=C; export LC_MESSAGES; } + + +# Name of the executable. +as_me=`(basename "$0") 2>/dev/null || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conftest.sh + echo "exit 0" >>conftest.sh + chmod +x conftest.sh + if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conftest.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + 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=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # 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 before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, 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 + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by patch $as_me 2.5.8, which was +generated by GNU Autoconf 2.53. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -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 ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +patch config.status 2.5.8 +configured by $0, generated by GNU Autoconf 2.53, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + shift + set dummy "$ac_option" "$ac_optarg" ${1+"$@"} + shift + ;; + -*);; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_need_defaults=false;; + esac + + case $1 in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion" + exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;; +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + shift + CONFIG_FILES="$CONFIG_FILES $1" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + shift + CONFIG_HEADERS="$CONFIG_HEADERS $1" + ac_need_defaults=false;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +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" ;; + + esac + shift +done + +_ACEOF + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +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 + +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. +: ${TMPDIR=/tmp} +{ + tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=$TMPDIR/cs$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in $TMPDIR" >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@CPP@,$CPP,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@ed_PROGRAM@,$ed_PROGRAM,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # 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. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;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,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # egrep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # 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. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if cmp -s $ac_file $tmp/config.h 2>/dev/null; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# 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=: + exec 5>/dev/null + $SHELL $CONFIG_STATUS || 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 + diff --git a/patch/configure.ac b/patch/configure.ac new file mode 100644 index 0000000..a37a3a9 --- /dev/null +++ b/patch/configure.ac @@ -0,0 +1,75 @@ +# Configure `patch'. +# Copyright (C) 1993, 1997, 1998, 1999, 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, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +AC_PREREQ(2.53) +AC_INIT(patch, 2.5.8, bug-patch@gnu.org) +AC_CONFIG_SRCDIR(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 reserves symbols starting with `E'. +AC_PATH_PROG(ed_PROGRAM, ed, ed) + +AC_AIX +AC_MINIX +AC_PROG_CC_STDC +AC_ISC_POSIX +AC_SYS_LARGEFILE +AC_EXEEXT + +AC_C_PROTOTYPES +AC_C_CONST + +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h limits.h string.h unistd.h utime.h varargs.h) + +AC_TYPE_MODE_T +AC_TYPE_OFF_T +AC_TYPE_PID_T +AC_TYPE_SIGNAL +AC_TYPE_SIZE_T +jm_CHECK_TYPE_STRUCT_UTIMBUF + +jm_PREREQ_ADDEXT +jm_PREREQ_DIRNAME +jm_PREREQ_ERROR +jm_PREREQ_MEMCHR +jm_PREREQ_QUOTEARG + +AC_CHECK_DECLS([free, getenv, malloc, mktemp]) +AC_CHECK_FUNCS(_doprintf geteuid getuid isascii memcmp mktemp \ + pathconf raise sigaction sigprocmask sigsetmask strerror) +AC_REPLACE_FUNCS(memchr mkdir rename rmdir strncasecmp) +AC_FUNC_FSEEKO +jm_FUNC_MALLOC +jm_FUNC_REALLOC +AC_FUNC_CLOSEDIR_VOID +AC_FUNC_SETMODE_DOS +AC_FUNC_VPRINTF +PATCH_FUNC_MKDIR_TAKES_ONE_ARG + +AC_SYS_LONG_FILE_NAMES +jm_CHECK_TYPE_STRUCT_DIRENT_D_INO + +AC_OUTPUT(Makefile) diff --git a/patch/configure.in b/patch/configure.in new file mode 100644 index 0000000..b07b76a --- /dev/null +++ b/patch/configure.in @@ -0,0 +1,59 @@ +# Configure `patch'. +# Copyright 1993, 1997-1998, 1999 Free Software Foundation, Inc. +dnl Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.12) +AC_INIT(patch.c) +AC_CONFIG_HEADER(config.h:config.hin) +AC_ARG_PROGRAM +AC_CANONICAL_HOST + +PACKAGE=patch +VERSION=2.5.4 +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) + +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_MAKE_SET +# Use ed_PROGRAM, not ED_PROGRAM, +# because reserves symbols starting with `E'. +AC_PATH_PROG(ed_PROGRAM, ed, ed) + +AC_SYS_LARGEFILE + +AC_AIX +AC_MINIX +AC_ISC_POSIX +AC_EXEEXT + +AM_C_PROTOTYPES +AC_C_CONST + +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h limits.h string.h unistd.h utime.h varargs.h) +jm_AC_HEADER_INTTYPES_H + +AC_TYPE_MODE_T +AC_TYPE_OFF_T +AC_TYPE_PID_T +AC_TYPE_SIGNAL +AC_TYPE_SIZE_T +jm_STRUCT_UTIMBUF + +AC_CHECK_FUNC(getopt_long, , [LIBOBJS="$LIBOBJS getopt1\$U.o getopt\$U.o"]) +AC_SUBST(LIBOBJS) +AC_CHECK_FUNCS(_doprintf isascii fseeko memcmp mktemp \ + pathconf raise setmode sigaction sigprocmask sigsetmask strerror) +AC_REPLACE_FUNCS(memchr mkdir rename rmdir) +jm_FUNC_MALLOC +jm_FUNC_REALLOC +AC_FUNC_CLOSEDIR_VOID +AC_FUNC_VPRINTF + +AC_SYS_LONG_FILE_NAMES +jm_STRUCT_DIRENT_D_INO + +AC_OUTPUT(Makefile) diff --git a/patch/dirname.c b/patch/dirname.c new file mode 100644 index 0000000..9fb5f09 --- /dev/null +++ b/patch/dirname.c @@ -0,0 +1,105 @@ +/* dirname.c -- return all but the last element in a path + Copyright 1990, 1998, 2000, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#if STDC_HEADERS || HAVE_STRING_H +# include +#endif + +#include "dirname.h" +#include "xalloc.h" + +/* Return the length of `dirname (PATH)', or zero if PATH is + in the working directory. Works properly even if + there are trailing slashes (by effectively ignoring them). */ +size_t +dir_len (char const *path) +{ + size_t prefix_length = FILESYSTEM_PREFIX_LEN (path); + size_t length; + + /* Strip the basename and any redundant slashes before it. */ + for (length = base_name (path) - path; prefix_length < length; length--) + if (! ISSLASH (path[length - 1])) + return length; + + /* But don't strip the only slash from "/". */ + return prefix_length + ISSLASH (path[prefix_length]); +} + +/* Return the leading directories part of PATH, + allocated with xmalloc. + Works properly even if there are trailing slashes + (by effectively ignoring them). */ + +char * +dir_name (char const *path) +{ + size_t length = dir_len (path); + int append_dot = (length == FILESYSTEM_PREFIX_LEN (path)); + char *newpath = xmalloc (length + append_dot + 1); + memcpy (newpath, path, length); + if (append_dot) + newpath[length++] = '.'; + newpath[length] = 0; + return newpath; +} + +#ifdef TEST_DIRNAME +/* + +Run the test like this (expect no output): + gcc -DHAVE_CONFIG_H -DTEST_DIRNAME -I.. -O -Wall \ + basename.c dirname.c xmalloc.c + sed -n '/^BEGIN-DATA$/,/^END-DATA$/p' dirname.c|grep -v DATA|./a.out + +BEGIN-DATA +foo//// . +bar/foo//// bar +foo/ . +/ / +. . +a . +END-DATA + +*/ + +# define MAX_BUFF_LEN 1024 +# include + +int +main () +{ + char buff[MAX_BUFF_LEN + 1]; + + buff[MAX_BUFF_LEN] = 0; + while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0]) + { + char path[MAX_BUFF_LEN]; + char expected_result[MAX_BUFF_LEN]; + char const *result; + sscanf (buff, "%s %s", path, expected_result); + result = dir_name (path); + if (strcmp (result, expected_result)) + printf ("%s: got %s, expected %s\n", path, result, expected_result); + } + return 0; +} +#endif diff --git a/patch/dirname.h b/patch/dirname.h new file mode 100644 index 0000000..cea14c0 --- /dev/null +++ b/patch/dirname.h @@ -0,0 +1,47 @@ +/* Copyright (C) 1998, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef DIRNAME_H_ +# define DIRNAME_H_ 1 + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +# ifndef DIRECTORY_SEPARATOR +# define DIRECTORY_SEPARATOR '/' +# endif + +# ifndef ISSLASH +# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) +# endif + +# ifndef FILESYSTEM_PREFIX_LEN +# define FILESYSTEM_PREFIX_LEN(Filename) 0 +# endif + +char *base_name PARAMS ((char const *path)); +char *dir_name PARAMS ((char const *path)); +size_t base_len PARAMS ((char const *path)); +size_t dir_len PARAMS ((char const *path)); + +int strip_trailing_slashes PARAMS ((char *path)); + +#endif /* not DIRNAME_H_ */ diff --git a/patch/error.c b/patch/error.c new file mode 100644 index 0000000..902519c --- /dev/null +++ b/patch/error.c @@ -0,0 +1,400 @@ +/* Error handler for noninteractive utilities + Copyright (C) 1990-1998, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in /gd/gnu/lib. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#if HAVE_LIBINTL_H +# include +#endif +#ifdef _LIBC +# include +# define mbsrtowcs __mbsrtowcs +#endif + +#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC +# if __STDC__ +# include +# define VA_START(args, lastarg) va_start(args, lastarg) +# else +# include +# define VA_START(args, lastarg) va_start(args) +# endif +#else +# define va_alist a1, a2, a3, a4, a5, a6, a7, a8 +# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; +#endif + +#if STDC_HEADERS || _LIBC +# include +# include +#else +void exit (); +#endif + +#include "error.h" +#include "unlocked-io.h" + +#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) ( +#if __STDC__ - 0 + void +#endif + ); + +/* 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 + +/* 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 + +# ifdef USE_IN_LIBIO +# include +# define fflush(s) _IO_fflush (s) +# endif + +#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 +# else +# if HAVE_STRERROR +# ifndef HAVE_DECL_STRERROR +"this configure-time declaration test was not run" +# endif +# if !HAVE_DECL_STRERROR +char *strerror (); +# endif +# else +static char * +private_strerror (int errnum) +{ + extern char *sys_errlist[]; + extern int sys_nerr; + + if (errnum > 0 && errnum <= sys_nerr) + return _(sys_errlist[errnum]); + return _("Unknown system error"); +} +# define strerror private_strerror +# endif /* HAVE_STRERROR */ +# 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 && USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + { + __fwprintf (stderr, L": %s", s); + return; + } +#endif + + fprintf (stderr, ": %s", s); +} + +#ifdef VA_START +static void +error_tail (int status, int errnum, const char *message, va_list args) +{ +# if HAVE_VPRINTF || _LIBC +# if _LIBC && USE_IN_LIBIO + 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; + + do + { + if (len < ALLOCA_LIMIT) + wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); + else + { + if (wmessage != NULL && len / 2 < ALLOCA_LIMIT) + wmessage = NULL; + + wmessage = (wchar_t *) realloc (wmessage, + len * sizeof (wchar_t)); + + if (wmessage == NULL) + { + fputws_unlocked (L"out of memory\n", stderr); + return; + } + } + + memset (&st, '\0', sizeof (st)); + tmp =message; + } + while ((res = mbsrtowcs (wmessage, &tmp, len, &st)) == len); + + if (res == (size_t) -1) + /* The string cannot be converted. */ + wmessage = (wchar_t *) L"???"; + + __vfwprintf (stderr, wmessage, args); + } + else +# endif + vfprintf (stderr, message, args); +# else + _doprnt (message, args, stderr); +# endif + va_end (args); + + ++error_message_count; + if (errnum) + print_errno_message (errnum); +# if _LIBC && USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + putwc (L'\n', stderr); + else +# endif + putc ('\n', stderr); + fflush (stderr); + if (status) + exit (status); +} +#endif + + +/* 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. */ +/* VARARGS */ +void +#if defined VA_START && __STDC__ +error (int status, int errnum, const char *message, ...) +#else +error (status, errnum, message, va_alist) + int status; + int errnum; + char *message; + va_dcl +#endif +{ +#ifdef VA_START + va_list args; +#endif + + fflush (stdout); +#ifdef _LIBC +# ifdef USE_IN_LIBIO + _IO_flockfile (stderr); +# else + __flockfile (stderr); +# endif +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC && USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s: ", program_name); + else +#endif + fprintf (stderr, "%s: ", program_name); + } + +#ifdef VA_START + VA_START (args, message); + error_tail (status, errnum, message, args); +#else + fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); + + ++error_message_count; + if (errnum) + print_errno_message (errnum); + putc ('\n', stderr); + fflush (stderr); + if (status) + exit (status); +#endif + +#ifdef _LIBC +# ifdef USE_IN_LIBIO + _IO_funlockfile (stderr); +# else + __funlockfile (stderr); +# endif +#endif +} + +/* 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 +#if defined VA_START && __STDC__ +error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, ...) +#else +error_at_line (status, errnum, file_name, line_number, message, va_alist) + int status; + int errnum; + const char *file_name; + unsigned int line_number; + char *message; + va_dcl +#endif +{ +#ifdef VA_START + va_list args; +#endif + + 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; + } + + fflush (stdout); +#ifdef _LIBC +# ifdef USE_IN_LIBIO + _IO_flockfile (stderr); +# else + __flockfile (stderr); +# endif +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC && USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s: ", program_name); + else +#endif + fprintf (stderr, "%s:", program_name); + } + + if (file_name != NULL) + { +#if _LIBC && USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s:%d: ", file_name, line_number); + else +#endif + fprintf (stderr, "%s:%d: ", file_name, line_number); + } + +#ifdef VA_START + VA_START (args, message); + error_tail (status, errnum, message, args); +#else + fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); + + ++error_message_count; + if (errnum) + print_errno_message (errnum); + putc ('\n', stderr); + fflush (stderr); + if (status) + exit (status); +#endif + +#ifdef _LIBC +# ifdef USE_IN_LIBIO + _IO_funlockfile (stderr); +# else + __funlockfile (stderr); +# 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 diff --git a/patch/error.h b/patch/error.h new file mode 100644 index 0000000..177b2dc --- /dev/null +++ b/patch/error.h @@ -0,0 +1,78 @@ +/* Declaration for error-reporting function + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + + + 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 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#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 + +#if defined (__STDC__) && __STDC__ + +/* 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); + +#else +void error (); +void error_at_line (); +extern void (*error_print_progname) (); +#endif + +/* 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 */ diff --git a/patch/exitfail.c b/patch/exitfail.c new file mode 100644 index 0000000..eec8234 --- /dev/null +++ b/patch/exitfail.c @@ -0,0 +1,31 @@ +/* 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 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#if HAVE_STDLIB_H +# include +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + +int volatile exit_failure = EXIT_FAILURE; diff --git a/patch/exitfail.h b/patch/exitfail.h new file mode 100644 index 0000000..cf5ab71 --- /dev/null +++ b/patch/exitfail.h @@ -0,0 +1,20 @@ +/* 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 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +extern int volatile exit_failure; diff --git a/patch/getopt.c b/patch/getopt.c new file mode 100644 index 0000000..ed32692 --- /dev/null +++ b/patch/getopt.c @@ -0,0 +1,1067 @@ +/* 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 + 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 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +# define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +# ifndef const +# define const +# endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +# include +# include +#endif /* GNU C library. */ + +#ifdef VMS +# include +# if HAVE_STRING_H - 0 +# include +# endif +#endif + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. */ +# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC +# include +# ifndef _ +# define _(msgid) gettext (msgid) +# endif +# else +# define _(msgid) (msgid) +# endif +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' 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. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the 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.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; + +/* Formerly, initialization of getopt depended on optind==0, which + causes problems with re-calling getopt as programs generally don't + know that. */ + +int __getopt_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. */ + +static char *nextchar; + +/* 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 = '?'; + +/* 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. + + 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. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +# include +# define my_index strchr +#else + +# if HAVE_STRING_H +# include +# else +# include +# endif + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#ifndef getenv +extern char *getenv (); +#endif + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +# if (!defined __STDC__ || !__STDC__) && !defined strlen +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +# endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* 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. */ + +static int first_nonopt; +static int last_nonopt; + +#ifdef _LIBC +/* 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; + +static int nonoption_flags_max_len; +static int nonoption_flags_len; +#endif + +static int original_argc; +static char *const *original_argv; + +/* Make sure the environment variable bash 2.0 puts in the environment + is valid for the getopt call we must make sure that the ARGV passed + to getopt is that one passed to the process. */ +static void +__attribute__ ((unused)) +store_args_and_env (int argc, char *const *argv) +{ + /* 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). */ + original_argc = argc; + original_argv = argv; +} +# ifdef text_set_element +text_set_element (__libc_subinit, store_args_and_env); +# endif /* text_set_element */ + +# ifdef USE_NONOPTION_FLAGS +# define SWAP_FLAGS(ch1, ch2) \ + if (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. */ + +#if defined __STDC__ && __STDC__ +static void exchange (char **); +#endif + +static void +exchange (argv) + char **argv; +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = 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 (nonoption_flags_len > 0 && top >= 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) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + 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. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +#if defined __STDC__ && __STDC__ +static const char *_getopt_initialize (int, char *const *, const char *); +#endif +static const char * +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + /* 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. */ + + first_nonopt = last_nonopt = optind; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + if (posixly_correct == NULL + && argc == original_argc && argv == original_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; +#endif + + return optstring; +} + +/* 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. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + 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. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + int print_errors = opterr; + if (optstring[0] == ':') + print_errors = 0; + + if (argc < 1) + return -1; + + optarg = NULL; + + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_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[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) +#else +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#endif + + if (nextchar == NULL || *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 (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = 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 (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + 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 (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = 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 (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[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[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[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 = 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, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - 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) + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + 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) + optarg = nameend + 1; + else + { + if (print_errors) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + _("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + _("%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); + } + + nextchar += strlen (nextchar); + + optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (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[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (print_errors) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (print_errors) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, _("%s: invalid option -- %c\n"), + argv[0], c); + } + 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 (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = 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, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - 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) + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + 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) + optarg = nameend + 1; + else + { + if (print_errors) + fprintf (stderr, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + 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 (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + 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 */ diff --git a/patch/getopt.h b/patch/getopt.h new file mode 100644 index 0000000..18e1026 --- /dev/null +++ b/patch/getopt.h @@ -0,0 +1,179 @@ +/* Declarations for getopt. + Copyright (C) 1989-1994, 1996-1999, 2001 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 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#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 , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in 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 +#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 +{ +# if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +# else + char *name; +# endif + /* 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 '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if (defined __STDC__ && __STDC__) || defined __cplusplus +# ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int __argc, char *const *__argv, const char *__shortopts); +# else /* not __GNU_LIBRARY__ */ +extern int getopt (); +# endif /* __GNU_LIBRARY__ */ + +# ifndef __need_getopt +extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, + const struct option *__longopts, int *__longind); +extern int getopt_long_only (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only); +# endif +#else /* not __STDC__ */ +extern int getopt (); +# ifndef __need_getopt +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +# endif +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/patch/getopt1.c b/patch/getopt1.c new file mode 100644 index 0000000..62c55cf --- /dev/null +++ b/patch/getopt1.c @@ -0,0 +1,187 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 + 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 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "getopt.h" + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +#include +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +/* 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 (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); +} + + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +#include + +int +main (argc, argv) + 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 */ diff --git a/patch/inp.c b/patch/inp.c new file mode 100644 index 0000000..8a51a01 --- /dev/null +++ b/patch/inp.c @@ -0,0 +1,468 @@ +/* inputting files to be patched */ + +/* $Id: inp.c,v 1.1.1.3 2003/05/08 18:38:02 rbraun Exp $ */ + +/* Copyright (C) 1986, 1988 Larry Wall + Copyright (C) 1991, 1992, 1993, 1997, 1998, 1999, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define XTERN extern +#include +#include +#include +#include +#include +#include +#undef XTERN +#define XTERN +#include + +/* 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 (int); +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 (int 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) +{ + int elsewhere = strcmp (filename, outname); + char const *cs; + char *diffbuf; + char *getbuf; + + if (inerrno == -1) + inerrno = stat (inname, &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 (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf, + &instat)) + inerrno = 0; + + free (getbuf); + if (diffbuf) + free (diffbuf); + + } else if (inerrno && !pch_says_nonexistent (reverse)) + { + errno = inerrno; + pfatal ("Can't find file %s", quotearg (filename)); + } + + 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]; + int found_revision = 0; + 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 = 1; + 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 int 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); + 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, (off_t) 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, int 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 = 0; + else if (tiline[1] == baseline) + whichbuf = 1; + else { + tiline[whichbuf] = baseline; + if (lseek (tifd, (off_t) (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; + } +} diff --git a/patch/inp.h b/patch/inp.h new file mode 100644 index 0000000..4296f7a --- /dev/null +++ b/patch/inp.h @@ -0,0 +1,29 @@ +/* inputting files to be patched */ + +/* $Id: inp.h,v 1.1.1.3 2003/05/08 18:38:02 rbraun Exp $ */ + +/* Copyright (C) 1986, 1988 Larry Wall + Copyright (C) 1991, 1992, 1993, 1997, 1998, 1999, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +XTERN LINENUM input_lines; /* how long is input file in lines */ + +char const *ifetch (LINENUM, int, size_t *); +void get_input_file (char const *, char const *); +void re_input (void); +void scan_input (char *); diff --git a/patch/install-sh b/patch/install-sh new file mode 100755 index 0000000..398a88e --- /dev/null +++ b/patch/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# 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. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + : +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=$mkdirprog + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + : + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + : + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + : + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' + ' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + : + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + : + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/patch/m4/c-bs-a.m4 b/patch/m4/c-bs-a.m4 new file mode 100644 index 0000000..1c7eb1c --- /dev/null +++ b/patch/m4/c-bs-a.m4 @@ -0,0 +1,29 @@ +# c-bs-a.m4 serial 4 (fileutils-4.1.3) +dnl Copyright (C) 2000-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. + +dnl From Paul Eggert. + +AC_DEFUN([AC_C_BACKSLASH_A], +[ + AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a, + [AC_TRY_COMPILE([], + [ +#if '\a' == 'a' + syntax error; +#endif + char buf['\a' == 'a' ? -1 : 1]; + buf[0] = '\a'; + return buf[0] != "\a"[0]; + ], + ac_cv_c_backslash_a=yes, + ac_cv_c_backslash_a=no)]) + if test $ac_cv_c_backslash_a = yes; then + AC_DEFINE(HAVE_C_BACKSLASH_A, 1, + [Define if backslash-a works in C strings.]) + fi +]) diff --git a/patch/m4/ccstdc.m4 b/patch/m4/ccstdc.m4 new file mode 100644 index 0000000..9a34791 --- /dev/null +++ b/patch/m4/ccstdc.m4 @@ -0,0 +1,95 @@ +# The following is taken from automake 1.4, +# except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE" +# because only the former supports 64-bit integral types on HP-UX 10.20. + +## ----------------------------------------- ## +## ANSIfy the C compiler whenever possible. ## +## From Franc,ois Pinard ## +## ----------------------------------------- ## + +# serial 2 + +# @defmac AC_PROG_CC_STDC +# @maindex PROG_CC_STDC +# @ovindex CC +# If the C compiler in not in ANSI C mode by default, try to add an option +# to output variable @code{CC} to make it so. This macro tries various +# options that select ANSI C on some system or another. It considers the +# compiler to be in ANSI C mode if it handles function prototypes correctly. +# +# If you use this macro, you should check after calling it whether the C +# compiler has been set to accept ANSI C; if not, the shell variable +# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source +# code in ANSI C, you can make an un-ANSIfied copy of it by using the +# program @code{ansi2knr}, which comes with Ghostscript. +# @end defmac + +AC_DEFUN(AM_PROG_CC_STDC, +[AC_REQUIRE([AC_PROG_CC]) +AC_BEFORE([$0], [AC_C_INLINE]) +AC_BEFORE([$0], [AC_C_CONST]) +dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require +dnl a magic option to avoid problems with ANSI preprocessor commands +dnl like #elif. +dnl FIXME: can't do this because then AC_AIX won't work due to a +dnl circular dependency. +dnl AC_BEFORE([$0], [AC_PROG_CPP]) +AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) +AC_CACHE_VAL(am_cv_prog_cc_stdc, +[am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + AC_TRY_COMPILE( +[#include +#include +#include +#include +/* 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; +} +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; +], [ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; +], +[am_cv_prog_cc_stdc="$ac_arg"; break]) +done +CC="$ac_save_CC" +]) +if test -z "$am_cv_prog_cc_stdc"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT($am_cv_prog_cc_stdc) +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac +]) diff --git a/patch/m4/d-ino.m4 b/patch/m4/d-ino.m4 new file mode 100644 index 0000000..6ca60dc --- /dev/null +++ b/patch/m4/d-ino.m4 @@ -0,0 +1,42 @@ +#serial 4 + +dnl From Jim Meyering. +dnl +dnl Check whether struct dirent has a member named d_ino. +dnl + +AC_DEFUN([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO], + [AC_REQUIRE([AC_HEADER_DIRENT])dnl + AC_CACHE_CHECK([for d_ino member in directory struct], + jm_cv_struct_dirent_d_ino, + [AC_TRY_LINK(dnl + [ +#include +#ifdef HAVE_DIRENT_H +# include +#else /* not HAVE_DIRENT_H */ +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* HAVE_SYS_NDIR_H */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* HAVE_SYS_DIR_H */ +# ifdef HAVE_NDIR_H +# include +# endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + ], + [struct dirent dp; dp.d_ino = 0;], + + jm_cv_struct_dirent_d_ino=yes, + jm_cv_struct_dirent_d_ino=no) + ] + ) + if test $jm_cv_struct_dirent_d_ino = yes; then + AC_DEFINE(D_INO_IN_DIRENT, 1, + [Define if there is a member named d_ino in the struct describing + directory headers.]) + fi + ] +) diff --git a/patch/m4/error.m4 b/patch/m4/error.m4 new file mode 100644 index 0000000..3fddb5c --- /dev/null +++ b/patch/m4/error.m4 @@ -0,0 +1,13 @@ +#serial 4 + +dnl FIXME: put these prerequisite-only *.m4 files in a separate +dnl directory -- otherwise, they'll conflict with existing files. + +dnl These are the prerequisite macros for GNU's error.c file. +AC_DEFUN([jm_PREREQ_ERROR], +[ + AC_CHECK_FUNCS(strerror vprintf doprnt) + AC_CHECK_DECLS([strerror]) + AC_FUNC_STRERROR_R + AC_HEADER_STDC +]) diff --git a/patch/m4/inttypes_h.m4 b/patch/m4/inttypes_h.m4 new file mode 100644 index 0000000..750639d --- /dev/null +++ b/patch/m4/inttypes_h.m4 @@ -0,0 +1,22 @@ +#serial 3 + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN(jm_AC_HEADER_INTTYPES_H, +[ + AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_inttypes_h=yes, + jm_ac_cv_header_inttypes_h=no)]) + if test $jm_ac_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, +[Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) diff --git a/patch/m4/jm-glibc-io.m4 b/patch/m4/jm-glibc-io.m4 new file mode 100644 index 0000000..e8054f0 --- /dev/null +++ b/patch/m4/jm-glibc-io.m4 @@ -0,0 +1,14 @@ +#serial 7 -*- autoconf -*- + +dnl From Jim Meyering. +dnl +dnl See if the glibc *_unlocked I/O macros are available. +dnl Use only those *_unlocked macros that are declared. +dnl + +AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO], + [AC_CHECK_DECLS( + [clearerr_unlocked, feof_unlocked, ferror_unlocked, + fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked, + fread_unlocked, fwrite_unlocked, getc_unlocked, + getchar_unlocked, putc_unlocked, putchar_unlocked])]) diff --git a/patch/m4/largefile.m4 b/patch/m4/largefile.m4 new file mode 100644 index 0000000..9515f7e --- /dev/null +++ b/patch/m4/largefile.m4 @@ -0,0 +1,115 @@ +#serial 5 + +dnl By default, many hosts won't let programs access large files; +dnl one must use special compiler options to get large-file access to work. +dnl For more details about this brain damage please see: +dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html + +dnl Written by Paul Eggert . + +dnl Internal subroutine of AC_SYS_LARGEFILE. +dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME) +AC_DEFUN(AC_SYS_LARGEFILE_FLAGS, + [AC_CACHE_CHECK([for $1 value to request large file support], + ac_cv_sys_largefile_$1, + [ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || { + ac_cv_sys_largefile_$1=no + ifelse($1, CFLAGS, + [case "$host_os" in + # IRIX 6.2 and later require cc -n32. +changequote(, )dnl + irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*) +changequote([, ])dnl + if test "$GCC" != yes; then + ac_cv_sys_largefile_CFLAGS=-n32 + fi + ac_save_CC="$CC" + CC="$CC $ac_cv_sys_largefile_CFLAGS" + AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no) + CC="$ac_save_CC" + esac]) + }])]) + +dnl Internal subroutine of AC_SYS_LARGEFILE. +dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL) +AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND, + [case $2 in + no) ;; + ?*) + case "[$]$1" in + '') $1=$2 ;; + *) $1=[$]$1' '$2 ;; + esac ;; + esac]) + +dnl Internal subroutine of AC_SYS_LARGEFILE. +dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT) +AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, + [AC_CACHE_CHECK([for $1], $2, + [$2=no +changequote(, )dnl + $4 + for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do + case "$ac_flag" in + -D$1) + $2=1 ;; + -D$1=*) + $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;; + esac + done +changequote([, ])dnl + ]) + if test "[$]$2" != no; then + AC_DEFINE_UNQUOTED([$1], [$]$2, [$3]) + fi]) + +AC_DEFUN(AC_SYS_LARGEFILE, + [AC_REQUIRE([AC_CANONICAL_HOST]) + AC_ARG_ENABLE(largefile, + [ --disable-largefile omit support for large files]) + if test "$enable_largefile" != no; then + AC_CHECK_TOOL(GETCONF, getconf) + AC_SYS_LARGEFILE_FLAGS(CFLAGS) + AC_SYS_LARGEFILE_FLAGS(LDFLAGS) + AC_SYS_LARGEFILE_FLAGS(LIBS) + + for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do + case "$ac_flag" in + no) ;; + -D_FILE_OFFSET_BITS=*) ;; + -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;; + -D_LARGE_FILES | -D_LARGE_FILES=*) ;; + -D?* | -I?*) + AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;; + *) + AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;; + esac + done + AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS") + AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS") + AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, + ac_cv_sys_file_offset_bits, + [Number of bits in a file offset, on hosts where this is settable.], + [case "$host_os" in + # HP-UX 10.20 and later + hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*) + ac_cv_sys_file_offset_bits=64 ;; + esac]) + AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, + ac_cv_sys_largefile_source, + [Define to make fseeko etc. visible, on some hosts.], + [case "$host_os" in + # HP-UX 10.20 and later + hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*) + ac_cv_sys_largefile_source=1 ;; + esac]) + AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, + ac_cv_sys_large_files, + [Define for large files, on AIX-style hosts.], + [case "$host_os" in + # AIX 4.2 and later + aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*) + ac_cv_sys_large_files=1 ;; + esac]) + fi + ]) diff --git a/patch/m4/malloc.m4 b/patch/m4/malloc.m4 new file mode 100644 index 0000000..cb5cff3 --- /dev/null +++ b/patch/m4/malloc.m4 @@ -0,0 +1,35 @@ +#serial 6 + +dnl From Jim Meyering. +dnl Determine whether malloc accepts 0 as its argument. +dnl If it doesn't, arrange to use the replacement function. +dnl + +AC_DEFUN([jm_FUNC_MALLOC], +[ + dnl xmalloc.c requires that this symbol be defined so it doesn't + dnl mistakenly use a broken malloc -- as it might if this test were omitted. + AC_DEFINE(HAVE_DONE_WORKING_MALLOC_CHECK, 1, + [Define if the malloc check has been performed. ]) + + AC_CACHE_CHECK([whether malloc(0) returns a non-NULL pointer], + jm_cv_func_working_malloc, + [AC_TRY_RUN([ + char *malloc (); + int + main () + { + exit (malloc (0) ? 0 : 1); + } + ], + jm_cv_func_working_malloc=yes, + jm_cv_func_working_malloc=no, + dnl When crosscompiling, assume malloc(0) returns NULL. + jm_cv_func_working_malloc=no) + ]) + if test $jm_cv_func_working_malloc = no; then + AC_LIBOBJ(malloc) + AC_DEFINE(malloc, rpl_malloc, + [Define to rpl_malloc if the replacement function should be used.]) + fi +]) diff --git a/patch/m4/mbrtowc.m4 b/patch/m4/mbrtowc.m4 new file mode 100644 index 0000000..0379847 --- /dev/null +++ b/patch/m4/mbrtowc.m4 @@ -0,0 +1,24 @@ +# mbrtowc.m4 serial 4 (fileutils-4.1.3) +dnl Copyright (C) 2001-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. + +dnl From Paul Eggert + +AC_DEFUN([jm_FUNC_MBRTOWC], +[ + AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], + jm_cv_func_mbrtowc, + [AC_TRY_LINK( + [#include ], + [mbstate_t state; return ! (sizeof state && mbrtowc);], + jm_cv_func_mbrtowc=yes, + jm_cv_func_mbrtowc=no)]) + if test $jm_cv_func_mbrtowc = yes; then + AC_DEFINE(HAVE_MBRTOWC, 1, + [Define to 1 if mbrtowc and mbstate_t are properly declared.]) + fi +]) diff --git a/patch/m4/mbstate_t.m4 b/patch/m4/mbstate_t.m4 new file mode 100644 index 0000000..deab38e --- /dev/null +++ b/patch/m4/mbstate_t.m4 @@ -0,0 +1,38 @@ +# mbstate_t.m4 serial 9 (fileutils-4.1.3) +dnl Copyright (C) 2000-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. + +# From Paul Eggert. + +# BeOS 5 has but does not define mbstate_t, +# so you can't declare an object of that type. +# Check for this incompatibility with Standard C. + +# Include stdlib.h first, because otherwise this test would fail on Linux +# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits +# a syntax error in wchar.h due to the use of undefined __int32_t. + +AC_DEFUN([AC_MBSTATE_T], + [ + AC_CHECK_HEADERS(stdlib.h) + + AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t, + [AC_TRY_COMPILE([ +#if HAVE_STDLIB_H +# include +#endif +#include ], + [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,ma + [Define to 1 if declares mbstate_t.]) + else + AC_DEFINE(mbstate_t, int, + [Define to a type if does not define.]) + fi]) diff --git a/patch/m4/mkdir.m4 b/patch/m4/mkdir.m4 new file mode 100644 index 0000000..86315d0 --- /dev/null +++ b/patch/m4/mkdir.m4 @@ -0,0 +1,34 @@ +#serial 1 + +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 +#include + ], + [mkdir (".", 0);], + , + [AC_TRY_COMPILE([ +#include +#include + ], + [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 + ] +) diff --git a/patch/m4/prereq.m4 b/patch/m4/prereq.m4 new file mode 100644 index 0000000..552e6a7 --- /dev/null +++ b/patch/m4/prereq.m4 @@ -0,0 +1,153 @@ +#serial 22 + +dnl These are the prerequisite macros for files in the lib/ +dnl directories of the fileutils, sh-utils, and textutils packages. + +AC_DEFUN([jm_PREREQ], +[ + jm_PREREQ_ADDEXT + jm_PREREQ_CANON_HOST + jm_PREREQ_DIRNAME + jm_PREREQ_ERROR + jm_PREREQ_EXCLUDE + jm_PREREQ_GETPAGESIZE + jm_PREREQ_HARD_LOCALE + jm_PREREQ_HASH + jm_PREREQ_HUMAN + jm_PREREQ_MBSWIDTH + jm_PREREQ_MEMCHR + jm_PREREQ_PHYSMEM + jm_PREREQ_POSIXVER + jm_PREREQ_QUOTEARG + jm_PREREQ_READUTMP + jm_PREREQ_REGEX + jm_PREREQ_TEMPNAME # called by mkstemp + jm_PREREQ_XGETCWD + jm_PREREQ_XREADLINK +]) + +AC_DEFUN([jm_PREREQ_ADDEXT], +[ + dnl For addext.c. + AC_SYS_LONG_FILE_NAMES + AC_CHECK_FUNCS(pathconf) + AC_CHECK_HEADERS(limits.h string.h unistd.h) +]) + +AC_DEFUN([jm_PREREQ_CANON_HOST], +[ + dnl Add any libraries as early as possible. + dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1, + dnl so we have to add -lnsl to LIBS before checking for that function. + AC_SEARCH_LIBS(gethostbyname, [inet nsl]) + + dnl These come from -lnsl on Solaris5.5.1. + AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa) + + AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa) + AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \ + netinet/in.h arpa/inet.h) +]) + +AC_DEFUN([jm_PREREQ_DIRNAME], +[ + AC_HEADER_STDC + AC_CHECK_HEADERS(string.h) +]) + +AC_DEFUN([jm_PREREQ_EXCLUDE], +[ + AC_FUNC_FNMATCH_GNU([lib]) + AC_HEADER_STDBOOL +]) + +AC_DEFUN([jm_PREREQ_GETPAGESIZE], +[ + AC_CHECK_FUNCS(getpagesize) + AC_CHECK_HEADERS(OS.h unistd.h) +]) + +AC_DEFUN([jm_PREREQ_HARD_LOCALE], +[ + AC_C_PROTOTYPES + AC_CHECK_FUNCS(setlocale) + AC_CHECK_HEADERS(locale.h stdlib.h string.h) +]) + +AC_DEFUN([jm_PREREQ_HASH], +[ + AC_CHECK_HEADERS(stdlib.h) + AC_HEADER_STDBOOL + AC_REQUIRE([jm_CHECK_DECLS]) +]) + +# If you use human.c, you need the following files: +# inttypes.m4 ulonglong.m4 +AC_DEFUN([jm_PREREQ_HUMAN], +[ + AC_CHECK_HEADERS(limits.h stdlib.h string.h) + AC_CHECK_DECLS([getenv]) + AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) +]) + +AC_DEFUN([jm_PREREQ_MEMCHR], +[ + AC_CHECK_HEADERS(limits.h stdlib.h bp-sym.h) +]) + +AC_DEFUN([jm_PREREQ_PHYSMEM], +[ + AC_CHECK_HEADERS(sys/pstat.h unistd.h) + AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic) +]) + +AC_DEFUN([jm_PREREQ_POSIXVER], +[ + AC_CHECK_HEADERS(unistd.h) + AC_CHECK_DECLS([getenv]) +]) + +AC_DEFUN([jm_PREREQ_QUOTEARG], +[ + AC_CHECK_FUNCS(isascii iswprint) + jm_FUNC_MBRTOWC + AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h) + AC_HEADER_STDC + AC_C_BACKSLASH_A + AC_MBSTATE_T + AC_C_PROTOTYPES +]) + +AC_DEFUN([jm_PREREQ_REGEX], +[ + dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it. + dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary + dnl to get them. + AC_CHECK_FUNCS(bzero bcopy isascii btowc) + AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h) + AC_HEADER_STDC + AC_FUNC_ALLOCA +]) + +AC_DEFUN([jm_PREREQ_TEMPNAME], +[ + AC_HEADER_STDC + AC_HEADER_STAT + AC_CHECK_HEADERS(fcntl.h sys/time.h stdint.h unistd.h) + AC_CHECK_FUNCS(__secure_getenv gettimeofday) + AC_CHECK_DECLS([getenv]) +]) + +AC_DEFUN([jm_PREREQ_XGETCWD], +[ + AC_C_PROTOTYPES + AC_CHECK_HEADERS(limits.h stdlib.h sys/param.h unistd.h) + AC_CHECK_FUNCS(getcwd) + AC_FUNC_GETCWD_NULL +]) + +AC_DEFUN([jm_PREREQ_XREADLINK], +[ + AC_C_PROTOTYPES + AC_CHECK_HEADERS(limits.h stdlib.h sys/types.h unistd.h) +]) diff --git a/patch/m4/protos.m4 b/patch/m4/protos.m4 new file mode 100644 index 0000000..0079f74 --- /dev/null +++ b/patch/m4/protos.m4 @@ -0,0 +1,25 @@ +## ------------------------------- ## +## Check for function prototypes. ## +## From Franc,ois Pinard ## +## ------------------------------- ## + +# serial 1 + +AC_DEFUN(AM_C_PROTOTYPES, +[AC_REQUIRE([AM_PROG_CC_STDC]) +AC_REQUIRE([AC_PROG_CPP]) +AC_MSG_CHECKING([for function prototypes]) +if test "$am_cv_prog_cc_stdc" != no; then + AC_MSG_RESULT(yes) + AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes]) + U= ANSI2KNR= +else + AC_MSG_RESULT(no) + U=_ ANSI2KNR=./ansi2knr + # Ensure some checks needed by ansi2knr itself. + AC_HEADER_STDC + AC_CHECK_HEADERS(string.h) +fi +AC_SUBST(U)dnl +AC_SUBST(ANSI2KNR)dnl +]) diff --git a/patch/m4/realloc.m4 b/patch/m4/realloc.m4 new file mode 100644 index 0000000..7695e89 --- /dev/null +++ b/patch/m4/realloc.m4 @@ -0,0 +1,35 @@ +#serial 6 + +dnl From Jim Meyering. +dnl Determine whether realloc works when both arguments are 0. +dnl If it doesn't, arrange to use the replacement function. +dnl + +AC_DEFUN([jm_FUNC_REALLOC], +[ + dnl xmalloc.c requires that this symbol be defined so it doesn't + dnl mistakenly use a broken realloc -- as it might if this test were omitted. + AC_DEFINE(HAVE_DONE_WORKING_REALLOC_CHECK, 1, + [Define if the realloc check has been performed. ]) + + AC_CACHE_CHECK([whether realloc(0,0) returns a non-NULL pointer], + jm_cv_func_working_realloc, + [AC_TRY_RUN([ + char *realloc (); + int + main () + { + exit (realloc (0, 0) ? 0 : 1); + } + ], + jm_cv_func_working_realloc=yes, + jm_cv_func_working_realloc=no, + dnl When crosscompiling, assume realloc(0,0) returns NULL. + jm_cv_func_working_realloc=no) + ]) + if test $jm_cv_func_working_realloc = no; then + AC_LIBOBJ(realloc) + AC_DEFINE(realloc, rpl_realloc, + [Define to rpl_realloc if the replacement function should be used.]) + fi +]) diff --git a/patch/m4/setmode.m4 b/patch/m4/setmode.m4 new file mode 100644 index 0000000..1af6bca --- /dev/null +++ b/patch/m4/setmode.m4 @@ -0,0 +1,38 @@ +# 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, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, 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 + #if HAVE_FCNTL_H + # include + #endif + #if HAVE_UNISTD_H + # include + #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]) diff --git a/patch/m4/utimbuf.m4 b/patch/m4/utimbuf.m4 new file mode 100644 index 0000000..4ea4952 --- /dev/null +++ b/patch/m4/utimbuf.m4 @@ -0,0 +1,40 @@ +#serial 4 + +dnl From Jim Meyering + +dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared -- +dnl usually in . +dnl Some systems have utime.h but don't declare the struct anywhere. + +AC_DEFUN([jm_CHECK_TYPE_STRUCT_UTIMBUF], +[ + AC_CHECK_HEADERS(utime.h) + AC_REQUIRE([AC_HEADER_TIME]) + AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf, + [AC_TRY_COMPILE( + [ +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef HAVE_UTIME_H +# include +#endif + ], + [static struct utimbuf x; x.actime = x.modtime;], + fu_cv_sys_struct_utimbuf=yes, + fu_cv_sys_struct_utimbuf=no) + ]) + + if test $fu_cv_sys_struct_utimbuf = yes; then + AC_DEFINE(HAVE_STRUCT_UTIMBUF, 1, +[Define if struct utimbuf is declared -- usually in . + Some systems have utime.h but don't declare the struct anywhere. ]) + fi +]) diff --git a/patch/maketime.c b/patch/maketime.c new file mode 100644 index 0000000..fd8b283 --- /dev/null +++ b/patch/maketime.c @@ -0,0 +1,501 @@ +/* Convert struct partime into time_t. */ + +/* Copyright 1992, 1993, 1994, 1995, 1997 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 has_conf_h +# include +#else +# if HAVE_CONFIG_H +# include +# else +# ifndef __STDC__ +# define const +# endif +# endif + /* MIPS RISCOS4.52 defines time_t in not . */ +# include +# if HAVE_LIMITS_H +# include +# endif +# ifndef LONG_MIN +# define LONG_MIN (-1-2147483647L) +# endif +# if STDC_HEADERS +# include +# endif +# include +# ifdef __STDC__ +# define P(x) x +# else +# define P(x) () +# endif +#endif + +#include +#include + +char const maket_id[] = + "$Id: maketime.c,v 1.1.1.2 2000/05/06 22:44:53 wsanchez Exp $"; + +static int isleap P ((int)); +static int month_days P ((struct tm const *)); +static time_t maketime P ((struct partime const *, time_t)); + +/* 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 (y) + 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 (tm) + 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 (unixtime, localzone) + 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 (a, b) + 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 (t, seconds) + 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 (tm, localzone) + 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 (pt, default_time) + 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 (source, default_time, default_zone) + 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 +int +main (argc, argv) + int argc; + char **argv; +{ + time_t default_time = time ((time_t *) 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 diff --git a/patch/maketime.h b/patch/maketime.h new file mode 100644 index 0000000..2f977c4 --- /dev/null +++ b/patch/maketime.h @@ -0,0 +1,39 @@ +/* Yield time_t from struct partime yielded by partime. */ + +/* Copyright 1993, 1994, 1995 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Report problems and direct all questions to: + + rcs-bugs@cs.purdue.edu + + */ + +#if defined __STDC__ || has_prototypes +# define __MAKETIME_P(x) x +#else +# define __MAKETIME_P(x) () +#endif + +struct tm *time2tm __MAKETIME_P ((time_t, int)); +time_t difftm __MAKETIME_P ((struct tm const *, struct tm const *)); +time_t str2time __MAKETIME_P ((char const **, time_t, long)); +time_t tm2time __MAKETIME_P ((struct tm *, int)); +void adjzone __MAKETIME_P ((struct tm *, long)); diff --git a/patch/malloc.c b/patch/malloc.c new file mode 100644 index 0000000..5e7674b --- /dev/null +++ b/patch/malloc.c @@ -0,0 +1,38 @@ +/* Work around bug on some systems where malloc (0) fails. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* written by Jim Meyering */ + +#if HAVE_CONFIG_H +# include +#endif +#undef malloc + +#include + +char *malloc (); + +/* Allocate an N-byte block of memory from the heap. + If N is zero, allocate a 1-byte block. */ + +char * +rpl_malloc (size_t n) +{ + if (n == 0) + n = 1; + return malloc (n); +} diff --git a/patch/memchr.c b/patch/memchr.c new file mode 100644 index 0000000..4b28e48 --- /dev/null +++ b/patch/memchr.c @@ -0,0 +1,216 @@ +/* Copyright (C) 1991,93,96,97,99,2000 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 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#undef __ptr_t +#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) +# define __ptr_t void * +#else /* Not C++ or ANSI C. */ +# define __ptr_t char * +#endif /* C++ or ANSI C. */ + +#if defined _LIBC +# include +# include +#else +# define reg_char char +#endif + +#if HAVE_STDLIB_H || defined _LIBC +# include +#endif + +#if HAVE_LIMITS_H || defined _LIBC +# include +#endif + +#define LONG_MAX_32_BITS 2147483647 + +#ifndef LONG_MAX +# define LONG_MAX LONG_MAX_32_BITS +#endif + +#include +#if HAVE_BP_SYM_H || defined _LIBC +# include +#else +# define BP_SYM(sym) sym +#endif + +#undef memchr +#undef __memchr + +/* Search no more than N bytes of S for C. */ +__ptr_t +__memchr (s, c_in, n) + const __ptr_t s; + int c_in; + size_t n; +{ + const unsigned char *char_ptr; + const unsigned long int *longword_ptr; + unsigned long int longword, magic_bits, charmask; + unsigned reg_char c; + + c = (unsigned char) c_in; + + /* Handle the first few characters by reading one character at a time. + Do this until CHAR_PTR is aligned on a longword boundary. */ + for (char_ptr = (const unsigned char *) s; + n > 0 && ((unsigned long int) char_ptr + & (sizeof (longword) - 1)) != 0; + --n, ++char_ptr) + if (*char_ptr == c) + return (__ptr_t) char_ptr; + + /* All these elucidatory comments refer to 4-byte longwords, + but the theory applies equally well to 8-byte longwords. */ + + longword_ptr = (unsigned long int *) char_ptr; + + /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits + the "holes." Note that there is a hole just to the left of + each byte, with an extra at the end: + + bits: 01111110 11111110 11111110 11111111 + bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD + + The 1-bits make sure that carries propagate to the next 0-bit. + The 0-bits provide holes for carries to fall into. */ + + if (sizeof (longword) != 4 && sizeof (longword) != 8) + abort (); + +#if LONG_MAX <= LONG_MAX_32_BITS + magic_bits = 0x7efefeff; +#else + magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff; +#endif + + /* Set up a longword, each of whose bytes is C. */ + charmask = c | (c << 8); + charmask |= charmask << 16; +#if LONG_MAX > LONG_MAX_32_BITS + charmask |= charmask << 32; +#endif + + /* Instead of the traditional loop which tests each character, + 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 zero. */ + while (n >= sizeof (longword)) + { + /* We tentatively exit the loop if adding MAGIC_BITS to + LONGWORD fails to change any of the hole bits of LONGWORD. + + 1) Is this safe? Will it catch all the zero bytes? + Suppose there is a byte with all zeros. Any carry bits + propagating from its left will fall into the hole at its + least significant bit and stop. Since there will be no + carry from its most significant bit, the LSB of the + byte to the left will be unchanged, and the zero will be + detected. + + 2) Is this worthwhile? Will it ignore everything except + zero bytes? Suppose every byte of LONGWORD has a bit set + somewhere. There will be a carry into bit 8. If bit 8 + is set, this will carry into bit 16. If bit 8 is clear, + one of bits 9-15 must be set, so there will be a carry + into bit 16. Similarly, there will be a carry into bit + 24. If one of bits 24-30 is set, there will be a carry + into bit 31, so all of the hole bits will be changed. + + The one misfire occurs when bits 24-30 are clear and bit + 31 is set; in this case, the hole at bit 31 is not + changed. If we had access to the processor carry flag, + we could close this loophole by putting the fourth hole + at bit 32! + + So it ignores everything except 128's, when they're aligned + properly. + + 3) But wait! Aren't we looking for C, not zero? + Good point. So what we do is XOR LONGWORD with a longword, + each of whose bytes is C. This turns each byte that is C + into a zero. */ + + longword = *longword_ptr++ ^ charmask; + + /* Add MAGIC_BITS to LONGWORD. */ + if ((((longword + magic_bits) + + /* Set those bits that were unchanged by the addition. */ + ^ ~longword) + + /* Look at only the hole bits. If any of the hole bits + are unchanged, most likely one of the bytes was a + zero. */ + & ~magic_bits) != 0) + { + /* Which of the bytes was C? If none of them were, it was + a misfire; continue the search. */ + + const unsigned char *cp = (const unsigned char *) (longword_ptr - 1); + + if (cp[0] == c) + return (__ptr_t) cp; + if (cp[1] == c) + return (__ptr_t) &cp[1]; + if (cp[2] == c) + return (__ptr_t) &cp[2]; + if (cp[3] == c) + return (__ptr_t) &cp[3]; +#if LONG_MAX > 2147483647 + if (cp[4] == c) + return (__ptr_t) &cp[4]; + if (cp[5] == c) + return (__ptr_t) &cp[5]; + if (cp[6] == c) + return (__ptr_t) &cp[6]; + if (cp[7] == c) + return (__ptr_t) &cp[7]; +#endif + } + + n -= sizeof (longword); + } + + char_ptr = (const unsigned char *) longword_ptr; + + while (n-- > 0) + { + if (*char_ptr == c) + return (__ptr_t) char_ptr; + else + ++char_ptr; + } + + return 0; +} +#ifdef weak_alias +weak_alias (__memchr, BP_SYM (memchr)) +#endif diff --git a/patch/mkdir.c b/patch/mkdir.c new file mode 100644 index 0000000..7c756a2 --- /dev/null +++ b/patch/mkdir.c @@ -0,0 +1,76 @@ +/* On some systems, mkdir ("foo/", 0700) fails because of the trailing + slash. On those systems, this wrapper removes the trailing slash. + Copyright (C) 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* written by Jim Meyering */ + +#include + +/* Disable the definition of mkdir to rpl_mkdir (from config.h) in this + file. Otherwise, we'd get conflicting prototypes for rpl_mkdir on + most systems. */ +#undef mkdir + +#include +#include +#include +#if HAVE_STDLIB_H +# include +#endif + +#if HAVE_STRING_H +# include +#else +# include +#endif + +#include "dirname.h" +#include "xalloc.h" + +#ifndef HAVE_DECL_FREE +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_FREE +void free (); +#endif + +/* This function is required at least for NetBSD 1.5.2. */ + +int +rpl_mkdir (char const *dir, mode_t mode) +{ + int ret_val; + char *tmp_dir; + size_t len = strlen (dir); + + if (len && dir[len - 1] == '/') + { + tmp_dir = xstrdup (dir); + strip_trailing_slashes (tmp_dir); + } + else + { + tmp_dir = (char *) dir; + } + + ret_val = mkdir (tmp_dir, mode); + + if (tmp_dir != dir) + free (tmp_dir); + + return ret_val; +} diff --git a/patch/mkinstalldirs b/patch/mkinstalldirs new file mode 100755 index 0000000..cda2f84 --- /dev/null +++ b/patch/mkinstalldirs @@ -0,0 +1,101 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1.1.3 2003/05/08 18:38:03 rbraun Exp $ + +errstatus=0 +dirmode="" + +usage="\ +Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." + +# process command line arguments +while test $# -gt 0 ; do + case "${1}" in + -h | --help | --h* ) # -h for help + echo "${usage}" 1>&2; exit 0 ;; + -m ) # -m PERM arg + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + dirmode="${1}" + shift ;; + -- ) shift; break ;; # stop option processing + -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option + * ) break ;; # first non-opt arg + esac +done + +for file +do + if test -d "$file"; then + shift + else + break + fi +done + +case $# in +0) exit 0 ;; +esac + +case $dirmode in +'') + if mkdir -p -- . 2>/dev/null; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + fi ;; +*) + if mkdir -m "$dirmode" -p -- . 2>/dev/null; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + fi ;; +esac + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + 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: 3 +# End: +# mkinstalldirs ends here diff --git a/patch/partime.c b/patch/partime.c new file mode 100644 index 0000000..87625ae --- /dev/null +++ b/patch/partime.c @@ -0,0 +1,956 @@ +/* Parse a string, yielding a struct partime that describes it. */ + +/* Copyright (C) 1993, 1994, 1995, 1997, 2002 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Report problems and direct all questions to: + + rcs-bugs@cs.purdue.edu + + */ + +#if has_conf_h +# include +#else +# if HAVE_CONFIG_H +# include +# else +# ifndef __STDC__ +# define const +# endif +# endif +# if HAVE_LIMITS_H +# include +# endif +# ifndef LONG_MIN +# define LONG_MIN (-1-2147483647L) +# endif +# if HAVE_STDDEF_H +# include +# endif +# if STDC_HEADERS +# include +# endif +# include +# ifdef __STDC__ +# define P(x) x +# else +# define P(x) () +# endif +#endif + +#ifndef offsetof +#define offsetof(aggregate, member) ((size_t) &((aggregate *) 0)->member) +#endif + +#include +#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) + +#include + +char const partime_id[] = + "$Id: partime.c,v 1.1.1.3 2003/05/08 18:38:03 rbraun Exp $"; + + +/* 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_decimal P ((char const *, int, int, int, int, int *, int *)); +static char const *parse_fixed P ((char const *, int, int *)); +static char const *parse_pattern_letter P ((char const *, int, struct partime *)); +static char const *parse_prefix P ((char const *, char const **, struct partime *)); +static char const *parse_ranged P ((char const *, int, int, int, int *)); +static char const *parse_varying P ((char const *, int *)); +static int lookup P ((char const *, struct name_val const[])); +static int merge_partime P ((struct partime *, struct partime const *)); +static void undefine P ((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 (s, table) + 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 (t) + 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 (str, patterns, t) + 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 (s, digits, res) + char const *s; + int digits, *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 (s, res) + 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 (s, digits, lo, hi, res) + char const *s; + int digits, lo, hi, *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 (s, digits, lo, hi, resolution, res, fres) + char const *s; + int digits, lo, hi, resolution, *res, *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 (s, c, t) + 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); + 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 (t, u) + 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; +} diff --git a/patch/partime.h b/patch/partime.h new file mode 100644 index 0000000..1f4d31a --- /dev/null +++ b/patch/partime.h @@ -0,0 +1,77 @@ +/* Parse a string, yielding a struct partime that describes it. */ + +/* Copyright 1993, 1994, 1995, 1997 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Report problems and direct all questions to: + + rcs-bugs@cs.purdue.edu + + */ + +#define TM_UNDEFINED (-1) +#define TM_DEFINED(x) (0 <= (x)) + +/* #include if you want to use these symbols. */ +#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; + }; + +#if defined __STDC__ || has_prototypes +# define __PARTIME_P(x) x +#else +# define __PARTIME_P(x) () +#endif + +char *partime __PARTIME_P ((char const *, struct partime *)); +char *parzone __PARTIME_P ((char const *, long *)); diff --git a/patch/patch.c b/patch/patch.c new file mode 100644 index 0000000..c849973 --- /dev/null +++ b/patch/patch.c @@ -0,0 +1,1370 @@ +/* patch - a program to apply diffs to original files */ + +/* $Id: patch.c,v 1.1.1.3 2003/05/08 18:38:03 rbraun Exp $ */ + +/* Copyright (C) 1984, 1985, 1986, 1987, 1988 Larry Wall + + Copyright (C) 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define XTERN +#include +#undef XTERN +#define XTERN extern +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if HAVE_UTIME_H +# include +#endif +/* Some nonstandard hosts don't declare this structure even in . */ +#if ! HAVE_STRUCT_UTIMBUF +struct utimbuf +{ + time_t actime; + time_t modtime; +}; +#endif + +/* Output stream state. */ +struct outstate +{ + FILE *ofp; + int after_newline; + int zero_output; +}; + +/* procedures */ + +static FILE *create_output_file (char const *, int); +static LINENUM locate_hunk (LINENUM); +static bool apply_hunk (struct outstate *, LINENUM); +static bool copy_till (struct outstate *, LINENUM); +static bool patch_match (LINENUM, LINENUM, LINENUM, LINENUM); +static bool similar (char const *, size_t, char const *, size_t); +static bool spew_output (struct outstate *); +static char const *make_temp (char); +static int numeric_string (char const *, int, char const *); +static void abort_hunk (void); +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 int make_backups; +static int backup_if_mismatch; +static char const *version_control; +static char const *version_control_context; +static int remove_empty_files; + +/* TRUE if -R was specified on command line. */ +static int reverse_flag_specified; + +/* how many input lines have been irretractably output */ +static LINENUM last_frozen_line; + +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 last_offset; +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; + char numbuf[LINENUM_LENGTH_BOUND + 1]; + + exit_failure = 2; + program_name = argv[0]; + init_time (); + + setbuf(stderr, serrbuf); + + xalloc_fail_func = memory_fatal; + 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, 1, "PATCH_GET value") + : posixly_correct - 1); + + 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_output (outfile, 0, &outstate); + + /* Make sure we clean up in case of disaster. */ + set_signals(0); + + for ( + open_patch_file (patchname); + there_is_another_patch(); + reinitialize_almost_everything() + ) { /* for each patch in patch file */ + int hunk = 0; + int failed = 0; + int mismatch = 0; + char *outname = outfile ? outfile : inname; + + if (!skip_rest_of_patch) + get_input_file (inname, outname); + + if (diff_type == ED_DIFF) { + outstate.zero_output = 0; + somefailed |= skip_rest_of_patch; + do_ed_script (outstate.ofp); + if (! dry_run && ! outfile) + { + struct stat statbuf; + if (stat (TMPOUTNAME, &statbuf) != 0) + pfatal ("%s", TMPOUTNAME); + outstate.zero_output = statbuf.st_size == 0; + } + } else { + int got_hunk; + int apply_anyway = 0; + + /* 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 prefix_context = pch_prefix_context (); + LINENUM suffix_context = pch_suffix_context (); + LINENUM context = (prefix_context < suffix_context + ? suffix_context : prefix_context); + LINENUM mymaxfuzz = (maxfuzz < context ? maxfuzz : context); + hunk++; + if (!skip_rest_of_patch) { + do { + where = locate_hunk(fuzz); + if (! where || fuzz || last_offset) + mismatch = 1; + 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 ^= 1; + else + { + /* Put it back to normal. */ + if (! pch_swap ()) + fatal ("lost hunk on alloc error!"); + if (where) + { + apply_anyway = 1; + 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 = pch_newfirst() + last_offset; + if (skip_rest_of_patch) { + abort_hunk(); + failed++; + if (verbosity == VERBOSE) + say ("Hunk #%d ignored at %s.\n", hunk, + format_linenum (numbuf, newwhere)); + } + else if (!where + || (where == 1 && pch_says_nonexistent (reverse) == 2 + && instat.st_size)) { + + if (where) + say ("Patch attempted to create file %s, which already exists.\n", + quotearg (inname)); + + abort_hunk(); + failed++; + if (verbosity != SILENT) + say ("Hunk #%d FAILED at %s.\n", hunk, + format_linenum (numbuf, newwhere)); + } + else if (! apply_hunk (&outstate, where)) { + abort_hunk (); + failed++; + if (verbosity != SILENT) + say ("Hunk #%d FAILED at %s.\n", hunk, + format_linenum (numbuf, newwhere)); + } else { + if (verbosity == VERBOSE + || (verbosity != SILENT && (fuzz || last_offset))) { + say ("Hunk #%d succeeded at %s", hunk, + format_linenum (numbuf, newwhere)); + if (fuzz) + say (" with fuzz %s", format_linenum (numbuf, fuzz)); + if (last_offset) + say (" (offset %s line%s)", + format_linenum (numbuf, last_offset), + "s" + (last_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. */ + assert (hunk); + if (! spew_output (&outstate)) + { + say ("Skipping patch.\n"); + skip_rest_of_patch = TRUE; + } + } + } + + /* and put the output where desired */ + ignore_signals (); + if (! skip_rest_of_patch && ! outfile) { + if (outstate.zero_output + && (remove_empty_files + || (pch_says_nonexistent (reverse ^ 1) == 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 ((char *) 0, (int *) 0, outname, (mode_t) 0, + (make_backups + || (backup_if_mismatch && (mismatch | failed)))); + removedirs (outname); + } + } + else + { + if (! outstate.zero_output + && pch_says_nonexistent (reverse ^ 1)) + { + mismatch = 1; + if (verbosity != SILENT) + say ("File %s is not empty after patch, as expected\n", + quotearg (outname)); + } + + if (! dry_run) + { + time_t t; + + move_file (TMPOUTNAME, &TMPOUTNAME_needs_removal, + outname, instat.st_mode, + (make_backups + || (backup_if_mismatch && (mismatch | failed)))); + + if ((set_time | set_utc) + && (t = pch_timestamp (reverse ^ 1)) != (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 && chmod (outname, instat.st_mode) != 0) + pfatal ("Can't set permissions on file %s", + quotearg (outname)); + } + } + } + if (diff_type != ED_DIFF) { + if (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) { + char *rej = rejname; + if (!rejname) { + rej = xmalloc (strlen (outname) + 5); + strcpy (rej, outname); + addext (rej, ".rej", '#'); + } + say (" -- saving rejects to file %s", quotearg (rej)); + if (! dry_run) + { + move_file (TMPREJNAME, &TMPREJNAME_needs_removal, + rej, instat.st_mode, FALSE); + if (! inerrno + && (chmod (rej, (instat.st_mode + & ~(S_IXUSR|S_IXGRP|S_IXOTH))) + != 0)) + pfatal ("can't set permissions on file %s", + quotearg (rej)); + } + if (!rejname) + free (rej); + } + say ("\n"); + } + } + set_signals (1); + } + 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) { + free (inname); + inname = 0; + } + + last_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:lnNo: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'}, + {"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}, + {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.", +" -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.", +#if HAVE_SETMODE_DOS +" --binary Read and write data in binary mode.", +#else +" --binary Read and write data in binary mode (no effect on this platform).", +#endif +"", +" -v --version Output version info.", +" --help Output this help.", +"", +"Report bugs to .", +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 = 1; + /* 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, 0, "fuzz factor"); + break; + case 'g': + patch_get = numeric_string (optarg, 1, "get option value"); + break; + case 'i': + patchname = savestr (optarg); + break; + case 'l': + canonicalize = TRUE; + break; + case 'n': + diff_type = NORMAL_DIFF; + break; + case 'N': + noreverse = TRUE; + break; + case 'o': + if (strcmp (optarg, "-") == 0) + fatal ("can't output patches to standard output"); + outfile = savestr (optarg); + break; + case 'p': + strippath = numeric_string (optarg, 0, "strip count"); + break; + case 'r': + rejname = savestr (optarg); + break; + case 'R': + reverse = 1; + reverse_flag_specified = 1; + break; + case 's': + verbosity = SILENT; + break; + case 't': + batch = TRUE; + break; + case 'T': + set_time = 1; + 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, 1, "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"); + simple_backup_suffix = savestr (optarg); + break; + case 'Z': + set_utc = 1; + break; + case CHAR_MAX + 1: + dry_run = TRUE; + break; + case CHAR_MAX + 2: + verbosity = VERBOSE; + break; + case CHAR_MAX + 3: +#if HAVE_SETMODE_DOS + binary_transput = O_BINARY; +#endif + break; + case CHAR_MAX + 4: + usage (stdout, 0); + case CHAR_MAX + 5: + backup_if_mismatch = 1; + break; + case CHAR_MAX + 6: + backup_if_mismatch = 0; + break; + case CHAR_MAX + 7: + posixly_correct = 1; + 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; + default: + usage (stderr, 2); + } + } + + /* Process any filename args. */ + if (optind < Argc) + { + inname = savestr (Argv[optind++]); + 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, + int 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 () + last_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) + { + /* 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)) + { + last_offset += offset; + return first_guess + offset; + } + else + return 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)) + { + last_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, last_offset), + format_linenum (numbuf1, last_offset + offset)); + last_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, last_offset), + format_linenum (numbuf1, last_offset - offset)); + last_offset -= offset; + return first_guess-offset; + } + } + return 0; +} + +/* We did not find the pattern, dump out the hunk so they can handle it. */ + +static void +abort_hunk (void) +{ + register LINENUM i; + register LINENUM pat_end = pch_end (); + /* add in last_offset to guess the same as the previous successful hunk */ + LINENUM oldfirst = pch_first() + last_offset; + LINENUM newfirst = pch_newfirst() + last_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 ? " ----" : " -----"; + + fprintf(rejfp, "***************\n"); + 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"); + } + if (ferror (rejfp)) + write_fatal (); + } +} + +/* 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) { + fprintf (fp, outstate->after_newline + else_defined); + def_state = IN_ELSE; + } + if (ferror (fp)) + write_fatal (); + outstate->after_newline = pch_write_line (old, fp); + outstate->zero_output = 0; + } + 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) { + fprintf (fp, outstate->after_newline + else_defined); + 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 = 0; + new++; + } + else if (pch_char(new) != pch_char(old)) { + 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)); + } + 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) { + fprintf (fp, outstate->after_newline + else_defined); + 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 = 0; + } + else { + assert(pch_char(new) == ' '); + old++; + new++; + if (R_do_defines && def_state != OUTSIDE) { + fprintf (fp, outstate->after_newline + end_defined); + if (ferror (fp)) + write_fatal (); + outstate->after_newline = 1; + 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) { + fprintf (fp, outstate->after_newline + else_defined); + def_state = IN_ELSE; + } + if (ferror (fp)) + write_fatal (); + outstate->zero_output = 0; + } + + do + { + if (! outstate->after_newline && putc ('\n', fp) == EOF) + write_fatal (); + outstate->after_newline = pch_write_line (new, fp); + outstate->zero_output = 0; + new++; + } + while (new <= pat_end && pch_char (new) == '+'); + } + if (R_do_defines && def_state != OUTSIDE) { + fprintf (fp, outstate->after_newline + end_defined); + if (ferror (fp)) + write_fatal (); + outstate->after_newline = 1; + } + 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); + 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) +{ + outstate->ofp = name ? create_output_file (name, open_flags) : (FILE *) 0; + outstate->after_newline = 1; + outstate->zero_output = 1; +} + +/* 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. */ + +static 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, 0, &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 = 0; + } + } + 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) +{ + 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 (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? */ + +static 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); +} diff --git a/patch/patch.man b/patch/patch.man new file mode 100644 index 0000000..d62b65e --- /dev/null +++ b/patch/patch.man @@ -0,0 +1,1160 @@ +.\" patch man page +.de Id +.ds Dt \\$4 +.. +.Id $Id: patch.man,v 1.1.1.3 2003/05/08 18:38:03 rbraun Exp $ +.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 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.) +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). +(The rejected hunk comes out in ordinary context diff form regardless of +the input patch's form. +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 +Prefix +.I pref +to a file name when generating its simple 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 +Read and write all files in binary mode, +except for standard output and +.BR /dev/tty . +This option has no effect on \s-1POSIX\s0-conforming systems. +On systems like \s-1DOS\s0 where this option makes a difference, +the patch should be generated by +.BR "diff\ \-a\ \*=binary" . +.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 if +.B patch +is conforming to \s-1POSIX\s0, negative otherwise. +.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\-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. +.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. +.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\-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 +Prefix +.I pref +to the basename of a file name when generating its simple 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 +.I suffix +as the simple backup suffix. +For example, with +.B "\-z\ -" +the simple backup file name for +.B src/patch/util.c +is +.BR src/patch/util.c- . +The backup suffix may also be specified by the +.B SIMPLE_BACKUP_SUFFIX +environment variable, which is overridden by this option. +.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) +.Sp +Marshall T. Rose and Einar A. Stefferud, +Proposed Standard for Message Encapsulation, +Internet RFC 934 (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, +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. +Until a suitable interactive interface is added, 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 . +.PP +.B patch +could be smarter about partial matches, excessively deviant offsets and +swapped code, but that would take an extra pass. +.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. +.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 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. diff --git a/patch/patchlevel.h b/patch/patchlevel.h new file mode 100644 index 0000000..d4a5a24 --- /dev/null +++ b/patch/patchlevel.h @@ -0,0 +1 @@ +#define PATCH_VERSION "2.5.8" diff --git a/patch/pc/chdirsaf.c b/patch/pc/chdirsaf.c new file mode 100644 index 0000000..0598f78 --- /dev/null +++ b/patch/pc/chdirsaf.c @@ -0,0 +1,34 @@ +/* A safer version of chdir, which returns back to the + initial working directory when the program exits. */ + +#include +#include +#include + +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); +} diff --git a/patch/pc/djgpp/README b/patch/pc/djgpp/README new file mode 100644 index 0000000..063480e --- /dev/null +++ b/patch/pc/djgpp/README @@ -0,0 +1,19 @@ +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 for +suggestions and ideas for this DJGPP port. diff --git a/patch/pc/djgpp/config.sed b/patch/pc/djgpp/config.sed new file mode 100644 index 0000000..70589c0 --- /dev/null +++ b/patch/pc/djgpp/config.sed @@ -0,0 +1,41 @@ +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 doesn't define correctly. */\ +#include + +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:" diff --git a/patch/pc/djgpp/configure.bat b/patch/pc/djgpp/configure.bat new file mode 100644 index 0000000..c4e06d1 --- /dev/null +++ b/patch/pc/djgpp/configure.bat @@ -0,0 +1,27 @@ +@echo off +Rem Configure patch for DJGPP v2. +Rem $Id: configure.bat,v 1.4 1997/06/17 06:52:12 eggert Exp $ + +Rem The DOS shell has fixed-size environment storage. +Rem When the environment is full, the shell prints +Rem "Out of environment space" and truncates the string at will. +Rem Since people often ignore these messages, +Rem test whether the environment variable got the correct value. + +Rem Where is our source directory? +set srcdir=. +if not "%srcdir%" == "." goto SmallEnv +if not "%1" == "" set srcdir=%1 +if not "%1" == "" if not "%srcdir%" == "%1" goto SmallEnv + +Rem Create Makefile +sed -f %srcdir%/pc/djgpp/configure.sed -e "s,@srcdir@,%srcdir%,g" %srcdir%/Makefile.in >Makefile +sed -n -e "/^VERSION/p" %srcdir%/configure.in >>Makefile + +goto Exit + +:SmallEnv +echo Your environment size is too small. Please enlarge it and run me again. + +:Exit +set srcdir= diff --git a/patch/pc/djgpp/configure.sed b/patch/pc/djgpp/configure.sed new file mode 100644 index 0000000..4b93fa1 --- /dev/null +++ b/patch/pc/djgpp/configure.sed @@ -0,0 +1,37 @@ +# Edit Makefile.in to produce Makefile for DJGPP v2 +# $Id: configure.sed,v 1.1.1.2 2000/05/06 22:44:56 wsanchez 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 diff --git a/patch/pch.c b/patch/pch.c new file mode 100644 index 0000000..b940734 --- /dev/null +++ b/patch/pch.c @@ -0,0 +1,1951 @@ +/* reading patches */ + +/* $Id: pch.c,v 1.4 2003/05/22 20:10:31 rbraun Exp $ */ + +/* Copyright (C) 1986, 1987, 1988 Larry Wall + + Copyright (C) 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define XTERN extern +#include +#include +#include +#include +#include +#include +#undef XTERN +#define XTERN +#include + +#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 time_t p_timestamp[2]; /* timestamps in patch headers */ +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 int p_indent; /* indent to patch */ +static int p_strip_trailing_cr; /* nonzero if stripping trailing \r */ +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 */ + +enum nametype { OLD, NEW, INDEX, NONE }; + +static char *scan_linenum (char *, LINENUM *); +static enum diff intuit_diff_type (void); +static enum nametype best_name (char * const *, int const *); +static int prefix_components (char *, int); +static size_t pget_line (int, int, int); +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); + +/* 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 = 0; +} + +/* 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 0 && HAVE_SETMODE /* Disbled; conflicting setmode() implementations. This is not the BSD setmode(). -wsanchez */ + 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), + "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) + memory_fatal (); + /* 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; +} + +/* True if the remainder of the patch file contains a diff of some sort. */ + +bool +there_is_another_patch (void) +{ + 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(); + 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 %d space%s.)\n", p_indent, p_indent==1?"":"s"); + 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)); + 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) { + if (force || batch) { + say ("No file to patch. Skipping patch.\n"); + skip_rest_of_patch = TRUE; + return TRUE; + } + ask ("File to patch: "); + inname = fetchname (buf, 0, (time_t *) 0); + if (inname) + { + 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 (void) +{ + register file_offset this_line = 0; + register file_offset first_command_line = -1; + LINENUM fcl_line = 0; /* Pacify `gcc -W'. */ + register bool this_is_a_command = FALSE; + register bool stars_this_line = FALSE; + enum nametype i; + char *name[3]; + struct stat st[3]; + int stat_errno[3]; + int version_controlled[3]; + register enum diff retval; + + name[OLD] = name[NEW] = name[INDEX] = 0; + 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 int indent = 0; + int strip_trailing_cr; + size_t chars_read; + + this_line = file_tell (pfp); + chars_read = pget_line (0, 0, 0); + if (chars_read == (size_t) -1) + memory_fatal (); + if (! chars_read) { + if (first_command_line >= 0) { + /* 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++; + } + for (t = s; ISDIGIT (*t) || *t == ','; t++) + continue; + this_is_a_command = (ISDIGIT (*s) && + (*t == 'd' || *t == 'c' || *t == 'a') ); + if (first_command_line < 0 && this_is_a_command) { + first_command_line = this_line; + 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)) + name[OLD] = fetchname (s+4, strippath, &p_timestamp[OLD]); + else if (strnEQ(s, "+++ ", 4)) + /* Swap with NEW below. */ + name[OLD] = fetchname (s+4, strippath, &p_timestamp[OLD]); + else if (strnEQ(s, "Index:", 6)) + name[INDEX] = fetchname (s+6, strippath, (time_t *) 0); + 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 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; + name[NEW] = fetchname (t+4, strippath, ×tamp); + if (timestamp != (time_t) -1) + { + p_timestamp[NEW] = timestamp; + p_rfc934_nesting = (t - s) >> 1; + } + } + } + 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)) { + + /* `name' and `p_timestamp' are backwards; swap them. */ + time_t ti = p_timestamp[OLD]; + p_timestamp[OLD] = p_timestamp[NEW]; + p_timestamp[NEW] = ti; + t = name[OLD]; + name[OLD] = name[NEW]; + name[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_strip_trailing_cr = strip_trailing_cr; + p_start = this_line; + p_sline = p_input_line; + retval = UNI_DIFF; + if (! ((name[OLD] || ! p_timestamp[OLD]) + && (name[NEW] || ! p_timestamp[NEW])) + && ! name[INDEX]) + { + 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, 0) + && ! p_repl_lines && p_newfirst == 1) + p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW]; + next_intuit_at (saved_p_base, saved_p_bline); + } + + if (! ((name[OLD] || ! p_timestamp[OLD]) + && (name[NEW] || ! p_timestamp[NEW])) + && ! name[INDEX]) + { + 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 && (name[OLD] || name[NEW]) && name[INDEX]) + { + free (name[INDEX]); + name[INDEX] = 0; + } + + for (i = OLD; i <= INDEX; i++) + if (name[i]) + { + if (i0 != NONE && strcmp (name[i0], 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 (name[i], &st[i]) != 0) + stat_errno[i] = errno; + else + { + stat_errno[i] = 0; + if (posixly_correct) + break; + } + i0 = i; + } + + if (! posixly_correct) + { + int is_empty; + + i = best_name (name, stat_errno); + + if (i == NONE && patch_get) + { + enum nametype nope = NONE; + + for (i = OLD; i <= INDEX; i++) + if (name[i]) + { + char const *cs; + char *getbuf; + char *diffbuf; + int readonly = outfile && strcmp (outfile, name[i]) != 0; + + if (nope == NONE || strcmp (name[nope], name[i]) != 0) + { + cs = (version_controller + (name[i], readonly, (struct stat *) 0, + &getbuf, &diffbuf)); + version_controlled[i] = !! cs; + if (cs) + { + if (version_get (name[i], cs, 0, 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; + } + } + + is_empty = i == NONE || st[i].st_size == 0; + if ((! is_empty) < p_says_nonexistent[reverse ^ is_empty]) + { + assert (i0 != NONE); + if (ok_to_reverse + ("The next patch%s would %s the file %s,\nwhich %s!", + reverse ? ", when reversed," : "", + (i == NONE ? "delete" + : st[i].st_size == 0 ? "empty out" + : "create"), + quotearg (name[i == NONE || st[i].st_size == 0 ? i0 : i]), + (i == NONE ? "does not exist" + : st[i].st_size == 0 ? "is already empty" + : "already exists"))) + reverse ^= 1; + } + + 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 (name[i]) + { + newdirs[i] = (prefix_components (name[i], 0) + - prefix_components (name[i], 1)); + if (newdirs[i] < newdirs_min) + newdirs_min = newdirs[i]; + } + + for (i = OLD; i <= INDEX; i++) + if (name[i]) + distance_from_minimum[i] = newdirs[i] - newdirs_min; + + i = best_name (name, distance_from_minimum); + } + } + } + + if (i == NONE) + inerrno = -1; + else + { + inname = name[i]; + name[i] = 0; + inerrno = stat_errno[i]; + invc = version_controlled[i]; + instat = st[i]; + } + + for (i = OLD; i <= INDEX; i++) + if (name[i]) + free (name[i]); + + if (inname) + { + /* If inname starts with "../" ends with "/.." or contains + "/../", then issue a fatal error. */ + size_t len = strlen (inname); + if (len >= 3 + && (strnEQ (inname, "../", 3) + || strnEQ (inname + len - 3, "/..", 3) + || strstr (inname, "/../"))) + fatal ("rejecting file name with \"..\" component: %s", + quotearg (inname)); + } + + return retval; +} + +/* Count the path name components in FILENAME's prefix. + If CHECKDIRS is nonzero, count only existing directories. */ +static int +prefix_components (char *filename, int checkdirs) +{ + int count = 0; + struct stat stat_buf; + int stat_result; + char *f = filename + FILESYSTEM_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], 0); + if (components_min < components[i]) + continue; + components_min = components[i]; + + /* Of those, take the names with the shortest basename. */ + basename_len[i] = strlen (base_name (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; + int overflow = 0; + 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, int 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; + + 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; + } + 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 >= 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 >= 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; + if (! (p_line[p_end] = savebuf (s, chars_read))) { + 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; + if (! (p_line[p_end] = savebuf (buf, chars_read))) { + 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; + if (! (p_line[p_end] = savebuf (buf + 2, chars_read))) { + 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 (!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 >= 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 (!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 (!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 >= 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; + if (! (p_line[i] = savebuf (buf + 2, chars_read))) { + 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; + if (! (p_line[i] = savebuf (buf + 2, chars_read))) { + 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"); + if (debug & 2) { + LINENUM i; + char special; + + for (i=0; i <= p_end; i++) { + if (i == p_ptrn_lines) + special = '^'; + else + special = ' '; + fprintf (stderr, "%s %c %c ", format_linenum (numbuf0, i), + p_Char[i], special); + pch_write_line (i, stderr); + fflush (stderr); + } + } + if (p_end+1 < hunkmax) /* paranoia reigns supreme... */ + p_Char[p_end+1] = '^'; /* add a stopper for apply_hunk */ + return 1; +} + +static size_t +get_line (void) +{ + return pget_line (p_indent, p_rfc934_nesting, p_strip_trailing_cr); +} + +/* 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 "- ". + Ignore any resulting lines that begin with '#'; they're comments. + If STRIP_TRAILING_CR is nonzero, remove any trailing carriage-return. + 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 (int indent, int rfc934_nesting, int strip_trailing_cr) +{ + register FILE *fp = pfp; + register int c; + register int 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) + memory_fatal (); + 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 == '#'); + + 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; + if (tp_line) + free (tp_line); + if (tp_len) + free (tp_len); + if (tp_char) + free (tp_char); + return TRUE; +} + +/* Return whether file WHICH (0 = old, 1 = new) appears to nonexistent. + Return 1 for empty, 2 for nonexistent. */ + +bool +pch_says_nonexistent (int which) +{ + return p_says_nonexistent[which]; +} + +/* Return timestamp of patch header for file WHICH (0 = old, 1 = new), + or -1 if there was no timestamp or an error in the timestamp. */ + +time_t +pch_timestamp (int 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. */ + +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; +} + +/* Apply an ed script by feeding ed itself. */ + +void +do_ed_script (FILE *ofp) +{ + static char const ed_program[] = ed_PROGRAM; + + register char *t; + register file_offset beginning_of_this_line; + register bool this_line_is_command = FALSE; + 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, exclusive, instat.st_mode); + 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 (;;) { + 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; + } + for (t = buf; ISDIGIT (*t) || *t == ','; t++) + continue; + this_line_is_command = (ISDIGIT (*buf) && + (*t == 'd' || *t == 'c' || *t == 'a' || *t == 'i' || *t == 's') ); + if (this_line_is_command) { + if (pipefp) + if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) + write_fatal (); + if (*t != 'd' && *t != 's') { + 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; + } + } + } + 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 (); + } +} diff --git a/patch/pch.h b/patch/pch.h new file mode 100644 index 0000000..e8264bf --- /dev/null +++ b/patch/pch.h @@ -0,0 +1,45 @@ +/* reading patches */ + +/* $Id: pch.h,v 1.1.1.3 2003/05/08 18:38:03 rbraun Exp $ */ + +/* Copyright (C) 1986, 1987, 1988 Larry Wall + + Copyright (C) 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +LINENUM pch_end (void); +LINENUM pch_first (void); +LINENUM pch_hunk_beg (void); +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 (void); +char *pfetch (LINENUM); +char pch_char (LINENUM); +int another_hunk (enum diff, int); +int pch_says_nonexistent (int); +size_t pch_line_len (LINENUM); +time_t pch_timestamp (int); +void do_ed_script (FILE *); +void open_patch_file (char const *); +void re_patch (void); +void set_hunkmax (void); diff --git a/patch/quote.c b/patch/quote.c new file mode 100644 index 0000000..0ce935c --- /dev/null +++ b/patch/quote.c @@ -0,0 +1,28 @@ +/* Written by Paul Eggert */ + +#if HAVE_CONFIG_H +# include +#endif + +#if HAVE_STDDEF_H +# include /* For the definition of size_t on windows w/MSVC. */ +#endif +#include +#include +#include + +/* Return an unambiguous printable representated, allocated in slot N, + for NAME, 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); +} diff --git a/patch/quote.h b/patch/quote.h new file mode 100644 index 0000000..5de896b --- /dev/null +++ b/patch/quote.h @@ -0,0 +1,12 @@ +/* prototypes for quote.c */ + +#ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +char const *quote_n PARAMS ((int n, char const *name)); +char const *quote PARAMS ((char const *name)); diff --git a/patch/quotearg.c b/patch/quotearg.c new file mode 100644 index 0000000..9d43956 --- /dev/null +++ b/patch/quotearg.c @@ -0,0 +1,658 @@ +/* quotearg.c - quote arguments for output + Copyright (C) 1998, 1999, 2000, 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, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert */ + +#if HAVE_CONFIG_H +# include +#endif + +#if HAVE_STDDEF_H +# include /* For the definition of size_t on windows w/MSVC. */ +#endif +#include +#include +#include + +#include + +#if ENABLE_NLS +# include +# define _(text) gettext (text) +#else +# define _(text) text +#endif +#define N_(text) text + +#if HAVE_LIMITS_H +# include +#endif +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif +#ifndef UCHAR_MAX +# define UCHAR_MAX ((unsigned char) -1) +#endif +#ifndef UINT_MAX +# define UINT_MAX ((unsigned int) -1) +#endif + +#if HAVE_C_BACKSLASH_A +# define ALERT_CHAR '\a' +#else +# define ALERT_CHAR '\7' +#endif + +#if HAVE_STDLIB_H +# include +#endif + +#if HAVE_STRING_H +# include +#endif + +#if HAVE_WCHAR_H + +/* BSD/OS 4.1 wchar.h requires FILE and struct tm to be declared. */ +# include +# include + +# include +#endif + +#if !HAVE_MBRTOWC +/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the + other macros are defined only for documentation and to satisfy C + syntax. */ +# undef MB_CUR_MAX +# define MB_CUR_MAX 1 +# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0) +# define mbsinit(ps) 1 +# define iswprint(wc) ISPRINT ((unsigned char) (wc)) +#endif + +#ifndef iswprint +# if HAVE_WCTYPE_H +# include +# endif +# if !defined iswprint && !HAVE_ISWPRINT +# define iswprint(wc) 1 +# endif +#endif + +#define INT_BITS (sizeof (int) * CHAR_BIT) + +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +/* Undefine to protect against the definition in wctype.h of solaris2.6. */ +#undef ISPRINT +#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) + +struct quoting_options +{ + /* Basic quoting style. */ + enum quoting_style style; + + /* Quote the characters indicated by this bit vector even if the + quoting style would not normally require them to be quoted. */ + int quote_these_too[(UCHAR_MAX / INT_BITS) + 1]; +}; + +/* Names of quoting styles. */ +char const *const quoting_style_args[] = +{ + "literal", + "shell", + "shell-always", + "c", + "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, + 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) +{ + struct quoting_options *p + = (struct quoting_options *) xmalloc (sizeof (struct quoting_options)); + *p = *(o ? o : &default_quoting_options); + 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; + 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; +} + +/* 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 and the + non-quoting-style part of O 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 -1, use the string length of the argument for ARGSIZE. + + This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG, + ARGSIZE, O), except it uses QUOTING_STYLE instead of the quoting + style specified by O, and O may not be null. */ + +static size_t +quotearg_buffer_restyled (char *buffer, size_t buffersize, + char const *arg, size_t argsize, + enum quoting_style quoting_style, + struct quoting_options const *o) +{ + size_t i; + size_t len = 0; + char const *quote_string = 0; + size_t quote_string_len = 0; + int backslash_escapes = 0; + int unibyte_locale = MB_CUR_MAX == 1; + +#define STORE(c) \ + do \ + { \ + if (len < buffersize) \ + buffer[len] = (c); \ + len++; \ + } \ + while (0) + + switch (quoting_style) + { + case c_quoting_style: + STORE ('"'); + backslash_escapes = 1; + quote_string = "\""; + quote_string_len = 1; + break; + + case escape_quoting_style: + backslash_escapes = 1; + break; + + case locale_quoting_style: + case clocale_quoting_style: + { + /* 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. */ + + char const *left = gettext_quote (N_("`"), quoting_style); + char const *right = gettext_quote (N_("'"), quoting_style); + for (quote_string = left; *quote_string; quote_string++) + STORE (*quote_string); + backslash_escapes = 1; + quote_string = right; + quote_string_len = strlen (quote_string); + } + break; + + case shell_always_quoting_style: + STORE ('\''); + quote_string = "'"; + quote_string_len = 1; + break; + + default: + break; + } + + for (i = 0; ! (argsize == (size_t) -1 ? 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) + STORE ('\\'); + + c = arg[i]; + switch (c) + { + case '\0': + if (backslash_escapes) + { + STORE ('\\'); + STORE ('0'); + STORE ('0'); + c = '0'; + } + break; + + case '?': + switch (quoting_style) + { + case shell_quoting_style: + goto use_shell_always_quoting_style; + + case c_quoting_style: + if (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. */ + i += 2; + c = arg[i + 2]; + STORE ('?'); + STORE ('\\'); + STORE ('?'); + break; + } + break; + + default: + break; + } + break; + + case ALERT_CHAR: 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; goto c_and_shell_escape; + + c_and_shell_escape: + if (quoting_style == shell_quoting_style) + goto use_shell_always_quoting_style; + c_escape: + if (backslash_escapes) + { + c = esc; + goto store_escape; + } + break; + + case '#': case '~': + if (i != 0) + break; + /* Fall through. */ + case ' ': + case '!': /* special in bash */ + case '"': case '$': case '&': + case '(': case ')': case '*': case ';': + case '<': 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_quoting_style) + goto use_shell_always_quoting_style; + break; + + case '\'': + switch (quoting_style) + { + case shell_quoting_style: + goto use_shell_always_quoting_style; + + case shell_always_quoting_style: + STORE ('\''); + STORE ('\\'); + STORE ('\''); + break; + + default: + break; + } + 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 '=': + 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': + case '{': case '}': + /* 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; + + int printable; + + if (unibyte_locale) + { + m = 1; + printable = ISPRINT (c); + } + else + { + mbstate_t mbstate; + memset (&mbstate, 0, sizeof mbstate); + + m = 0; + printable = 1; + if (argsize == (size_t) -1) + 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 = 0; + break; + } + else if (bytes == (size_t) -2) + { + printable = 0; + while (i + m < argsize && arg[i + m]) + m++; + break; + } + else + { + if (! iswprint (w)) + printable = 0; + 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) + { + 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 + && o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))) + goto store_c; + + store_escape: + STORE ('\\'); + + store_c: + STORE (c); + } + + if (quote_string) + for (; *quote_string; quote_string++) + STORE (*quote_string); + + if (len < buffersize) + buffer[len] = '\0'; + return len; + + use_shell_always_quoting_style: + return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, + shell_always_quoting_style, o); +} + +/* 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. */ +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; + return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, + p->style, p); +} + +/* Use storage slot N to return a quoted version of argument ARG. + ARG is of size ARGSIZE, but if that is -1, 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) +{ + /* 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; + unsigned int n0 = n; + struct slotvec + { + size_t size; + char *val; + }; + static struct slotvec slotvec0 = {sizeof slot0, slot0}; + static struct slotvec *slotvec = &slotvec0; + + if (n < 0) + abort (); + + if (nslots <= n0) + { + unsigned int n1 = n0 + 1; + size_t s = n1 * sizeof *slotvec; + + if (SIZE_MAX / UINT_MAX <= sizeof *slotvec + && n1 != s / sizeof *slotvec) + xalloc_die (); + + if (slotvec == &slotvec0) + { + slotvec = (struct slotvec *) xmalloc (sizeof *slotvec); + *slotvec = slotvec0; + } + slotvec = (struct slotvec *) xrealloc (slotvec, s); + memset (slotvec + nslots, 0, (n1 - nslots) * sizeof *slotvec); + nslots = n1; + } + + { + size_t size = slotvec[n].size; + char *val = slotvec[n].val; + size_t qsize = quotearg_buffer (val, size, arg, argsize, options); + + if (size <= qsize) + { + slotvec[n].size = size = qsize + 1; + slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size); + quotearg_buffer (val, size, arg, argsize, options); + } + + return val; + } +} + +char * +quotearg_n (int n, char const *arg) +{ + return quotearg_n_options (n, arg, (size_t) -1, &default_quoting_options); +} + +char * +quotearg (char const *arg) +{ + return quotearg_n (0, arg); +} + +/* 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; + memset (o.quote_these_too, 0, sizeof o.quote_these_too); + return o; +} + +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_t) -1, &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_char (char const *arg, char ch) +{ + struct quoting_options options; + options = default_quoting_options; + set_char_quoting (&options, ch, 1); + return quotearg_n_options (0, arg, (size_t) -1, &options); +} + +char * +quotearg_colon (char const *arg) +{ + return quotearg_char (arg, ':'); +} diff --git a/patch/quotearg.h b/patch/quotearg.h new file mode 100644 index 0000000..1134a51 --- /dev/null +++ b/patch/quotearg.h @@ -0,0 +1,114 @@ +/* quotearg.h - quote arguments for output + Copyright (C) 1998, 1999, 2000, 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, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert */ + +/* Basic quoting styles. */ +enum quoting_style + { + literal_quoting_style, /* --quoting-style=literal */ + shell_quoting_style, /* --quoting-style=shell */ + shell_always_quoting_style, /* --quoting-style=shell-always */ + c_quoting_style, /* --quoting-style=c */ + escape_quoting_style, /* --quoting-style=escape */ + locale_quoting_style, /* --quoting-style=locale */ + clocale_quoting_style /* --quoting-style=clocale */ + }; + +/* 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; + +#ifndef PARAMS +# if defined PROTOTYPES || defined __STDC__ +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +/* 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 + PARAMS ((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 PARAMS ((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 PARAMS ((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 PARAMS ((struct quoting_options *o, char c, 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. */ +size_t quotearg_buffer PARAMS ((char *buffer, size_t buffersize, + char const *arg, size_t argsize, + 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. */ +char *quotearg_n PARAMS ((int n, char const *arg)); + +/* Equivalent to quotearg_n (0, ARG). */ +char *quotearg PARAMS ((char const *arg)); + +/* 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 PARAMS ((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 PARAMS ((int n, enum quoting_style s, + char const *arg, size_t argsize)); + +/* Equivalent to quotearg_n_style (0, S, ARG). */ +char *quotearg_style PARAMS ((enum quoting_style s, char const *arg)); + +/* Like quotearg (ARG), except also quote any instances of CH. */ +char *quotearg_char PARAMS ((char const *arg, char ch)); + +/* Equivalent to quotearg_char (ARG, ':'). */ +char *quotearg_colon PARAMS ((char const *arg)); diff --git a/patch/quotesys.c b/patch/quotesys.c new file mode 100644 index 0000000..528f382 --- /dev/null +++ b/patch/quotesys.c @@ -0,0 +1,125 @@ +/* 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +/* 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++; + } +} diff --git a/patch/quotesys.h b/patch/quotesys.h new file mode 100644 index 0000000..0d0d825 --- /dev/null +++ b/patch/quotesys.h @@ -0,0 +1,9 @@ +/* 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 *)); diff --git a/patch/realloc.c b/patch/realloc.c new file mode 100644 index 0000000..d0d3e4a --- /dev/null +++ b/patch/realloc.c @@ -0,0 +1,44 @@ +/* Work around bug on some systems where realloc (NULL, 0) fails. + Copyright (C) 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; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* written by Jim Meyering */ + +#if HAVE_CONFIG_H +# include +#endif +#undef realloc + +#include + +char *malloc (); +char *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. */ + +char * +rpl_realloc (p, n) + char *p; + size_t n; +{ + if (n == 0) + n = 1; + if (p == 0) + return malloc (n); + return realloc (p, n); +} diff --git a/patch/rename.c b/patch/rename.c new file mode 100644 index 0000000..70ff130 --- /dev/null +++ b/patch/rename.c @@ -0,0 +1,68 @@ +/* Work around the bug in some systems whereby rename fails when the source + path has a trailing slash. The rename functions of SunOS 4.1.1_U1 and + mips-dec-ultrix4.4 have this bug. + 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, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* written by Volker Borchert */ + +#include +#include +#if HAVE_STDLIB_H +# include +#endif + +#if HAVE_STRING_H +# include +#else +# include +#endif + +#include "dirname.h" +#include "xalloc.h" + +#ifndef HAVE_DECL_FREE +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_FREE +void free (); +#endif + +/* Rename the file SRC_PATH to DST_PATH, removing any trailing + slashes from SRC_PATH. Needed for SunOS 4.1.1_U1. */ + +int +rpl_rename (const char *src_path, const char *dst_path) +{ + char *src_temp; + int ret_val; + size_t s_len = strlen (src_path); + + if (s_len && src_path[s_len - 1] == '/') + { + src_temp = xstrdup (src_path); + strip_trailing_slashes (src_temp); + } + else + src_temp = (char *) src_path; + + ret_val = rename (src_temp, dst_path); + + if (src_temp != src_path) + free (src_temp); + + return ret_val; +} diff --git a/patch/rmdir.c b/patch/rmdir.c new file mode 100644 index 0000000..2a92803 --- /dev/null +++ b/patch/rmdir.c @@ -0,0 +1,87 @@ +/* BSD compatible remove directory function for System V + Copyright (C) 1988, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include +#ifndef errno +extern int errno; +#endif + +#if STAT_MACROS_BROKEN +# undef S_ISDIR +#endif + +#if !defined(S_ISDIR) && defined(S_IFDIR) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* rmdir adapted from GNU tar. */ + +/* Remove directory DPATH. + Return 0 if successful, -1 if not. */ + +int +rmdir (dpath) + char *dpath; +{ + pid_t cpid; + int status; + struct stat statbuf; + + if (stat (dpath, &statbuf) != 0) + return -1; /* errno already set */ + + if (!S_ISDIR (statbuf.st_mode)) + { + errno = ENOTDIR; + return -1; + } + + cpid = fork (); + switch (cpid) + { + case -1: /* cannot fork */ + return -1; /* errno already set */ + + case 0: /* child process */ + execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); + _exit (1); + + default: /* parent process */ + + /* Wait for kid to finish. */ + + while (wait (&status) != cpid) + /* Do nothing. */ ; + + if (status) + { + + /* /bin/rmdir failed. */ + + errno = EIO; + return -1; + } + return 0; + } +} diff --git a/patch/strcasecmp.c b/patch/strcasecmp.c new file mode 100644 index 0000000..ae7601d --- /dev/null +++ b/patch/strcasecmp.c @@ -0,0 +1,66 @@ +/* strcasecmp.c -- case insensitive string comparator + Copyright (C) 1998, 1999 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#ifdef LENGTH_LIMIT +# define STRXCASECMP_FUNCTION strncasecmp +# define STRXCASECMP_DECLARE_N , size_t n +# define LENGTH_LIMIT_EXPR(Expr) Expr +#else +# define STRXCASECMP_FUNCTION strcasecmp +# define STRXCASECMP_DECLARE_N /* empty */ +# define LENGTH_LIMIT_EXPR(Expr) 0 +#endif + +#include +#include + +#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) + +/* Compare {{no more than N characters 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. */ + +int +STRXCASECMP_FUNCTION (const char *s1, const char *s2 STRXCASECMP_DECLARE_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 || LENGTH_LIMIT_EXPR (n == 0)) + return 0; + + do + { + c1 = TOLOWER (*p1); + c2 = TOLOWER (*p2); + + if (LENGTH_LIMIT_EXPR (--n == 0) || c1 == '\0') + break; + + ++p1; + ++p2; + } + while (c1 == c2); + + return c1 - c2; +} diff --git a/patch/strncasecmp.c b/patch/strncasecmp.c new file mode 100644 index 0000000..68d95aa --- /dev/null +++ b/patch/strncasecmp.c @@ -0,0 +1,2 @@ +#define LENGTH_LIMIT +#include "strcasecmp.c" diff --git a/patch/unlocked-io.h b/patch/unlocked-io.h new file mode 100644 index 0000000..19fdcb3 --- /dev/null +++ b/patch/unlocked-io.h @@ -0,0 +1,69 @@ +#ifndef UNLOCKED_IO_H +# define UNLOCKED_IO_H 1 + +# ifndef USE_UNLOCKED_IO +# define USE_UNLOCKED_IO 1 +# endif + +# if USE_UNLOCKED_IO + +/* These are wrappers for functions/macros from GNU libc. + 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. */ + +# if HAVE_DECL_CLEARERR_UNLOCKED +# undef clearerr +# define clearerr(x) clearerr_unlocked (x) +# endif +# if HAVE_DECL_FEOF_UNLOCKED +# undef feof +# define feof(x) feof_unlocked (x) +# endif +# if HAVE_DECL_FERROR_UNLOCKED +# undef ferror +# define ferror(x) ferror_unlocked (x) +# endif +# if HAVE_DECL_FFLUSH_UNLOCKED +# undef fflush +# define fflush(x) fflush_unlocked (x) +# endif +# if HAVE_DECL_FGETS_UNLOCKED +# undef fgets +# define fgets(x,y,z) fgets_unlocked (x,y,z) +# endif +# if HAVE_DECL_FPUTC_UNLOCKED +# undef fputc +# define fputc(x,y) fputc_unlocked (x,y) +# endif +# if HAVE_DECL_FPUTS_UNLOCKED +# undef fputs +# define fputs(x,y) fputs_unlocked (x,y) +# endif +# if HAVE_DECL_FREAD_UNLOCKED +# undef fread +# define fread(w,x,y,z) fread_unlocked (w,x,y,z) +# endif +# if HAVE_DECL_FWRITE_UNLOCKED +# undef fwrite +# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) +# endif +# if HAVE_DECL_GETC_UNLOCKED +# undef getc +# define getc(x) getc_unlocked (x) +# endif +# if HAVE_DECL_GETCHAR_UNLOCKED +# undef getchar +# define getchar() getchar_unlocked () +# endif +# if HAVE_DECL_PUTC_UNLOCKED +# undef putc +# define putc(x,y) putc_unlocked (x,y) +# endif +# if HAVE_DECL_PUTCHAR_UNLOCKED +# undef putchar +# define putchar(x) putchar_unlocked (x) +# endif + +# endif /* USE_UNLOCKED_IO */ +#endif /* UNLOCKED_IO_H */ diff --git a/patch/util.c b/patch/util.c new file mode 100644 index 0000000..da5d631 --- /dev/null +++ b/patch/util.c @@ -0,0 +1,1009 @@ +/* utility functions for `patch' */ + +/* $Id: util.c,v 1.1.1.3 2003/05/08 18:38:04 rbraun Exp $ */ + +/* Copyright (C) 1986 Larry Wall + + Copyright (C) 1992, 1993, 1997, 1998, 1999, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define XTERN extern +#include +#include +#include +#include +#include +#include +#undef XTERN +#define XTERN +#include +#include + +#include +#include + +#include +#if !defined SIGCHLD && defined SIGCLD +#define SIGCHLD SIGCLD +#endif +#if ! HAVE_RAISE && ! defined raise +# define raise(sig) kill (getpid (), sig) +#endif + +#include + +static void makedirs (char *); + +/* Move a file FROM (where *FROM_NEEDS_REMOVAL is nonzero if FROM + needs removal when cleaning up at the end of execution) + 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 (ignoring FROMSTAT). + FROM_NEEDS_REMOVAL must be nonnull if FROM is nonnull. + Back up TO if BACKUP is nonzero. */ + +void +move_file (char const *from, int volatile *from_needs_removal, + char *to, mode_t mode, int backup) +{ + struct stat to_st; + int to_errno = ! backup ? -1 : stat (to, &to_st) == 0 ? 0 : errno; + + if (backup) + { + int try_makedirs_errno = 0; + char *bakname; + + if (origprae || origbase) + { + char const *p = origprae ? origprae : ""; + char const *b = origbase ? origbase : ""; + char const *o = base_name (to); + size_t plen = strlen (p); + size_t tlen = o - to; + size_t blen = strlen (b); + size_t osize = strlen (o) + 1; + bakname = xmalloc (plen + tlen + blen + osize); + memcpy (bakname, p, plen); + memcpy (bakname + plen, to, tlen); + memcpy (bakname + plen + tlen, b, blen); + memcpy (bakname + plen + tlen + blen, o, osize); + for (p += FILESYSTEM_PREFIX_LEN (p); *p; p++) + if (ISSLASH (*p)) + { + try_makedirs_errno = ENOENT; + break; + } + } + else + { + bakname = find_backup_file_name (to, backup_type); + if (!bakname) + memory_fatal (); + } + + if (to_errno) + { + int fd; + + if (debug & 4) + say ("Creating empty unreadable file %s\n", quotearg (bakname)); + + try_makedirs_errno = ENOENT; + unlink (bakname); + while ((fd = creat (bakname, 0)) < 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 (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) + pfatal ("Can't rename file %s to %s", + quotearg_n (0, to), quotearg_n (1, bakname)); + makedirs (bakname); + try_makedirs_errno = 0; + } + } + + free (bakname); + } + + 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) + *from_needs_removal = 0; + else + { + int to_dir_known_to_exist = 0; + + if (errno == ENOENT + && (to_errno == -1 || to_errno == ENOENT)) + { + makedirs (to); + to_dir_known_to_exist = 1; + if (rename (from, to) == 0) + { + *from_needs_removal = 0; + return; + } + } + + if (errno == EXDEV) + { + if (! backup) + { + if (unlink (to) == 0) + to_dir_known_to_exist = 1; + else if (errno != ENOENT) + pfatal ("Can't remove file %s", quotearg (to)); + } + if (! to_dir_known_to_exist) + makedirs (to); + copy_file (from, to, 0, mode); + return; + } + + pfatal ("Can't rename file %s to %s", + quotearg_n (0, from), quotearg_n (1, to)); + } + } + else if (! backup) + { + if (debug & 4) + say ("Removing file %s\n", quotearg (to)); + if (unlink (to) != 0) + 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) +{ + int fd; + mode |= S_IRUSR | S_IWUSR; + mode &= ~ (S_IXUSR | S_IXGRP | S_IXOTH); + if (! (O_CREAT && O_TRUNC)) + close (creat (file, mode)); + fd = open (file, O_CREAT | O_TRUNC | open_flags, mode); + if (fd < 0) + pfatal ("Can't create file %s", quotearg (file)); + return fd; +} + +/* Copy a file. */ + +void +copy_file (char const *from, char const *to, int to_flags, mode_t mode) +{ + int tofd; + int fromfd; + size_t i; + + if ((fromfd = open (from, O_RDONLY | O_BINARY)) < 0) + pfatal ("Can't reopen file %s", quotearg (from)); + tofd = create_file (to, O_WRONLY | O_BINARY | to_flags, mode); + while ((i = read (fromfd, buf, bufsize)) != 0) + { + if (i == (size_t) -1) + read_fatal (); + if (write (tofd, buf, i) != i) + write_fatal (); + } + if (close (fromfd) != 0) + read_fatal (); + 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 nonzero 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, int readonly, + struct stat const *filestat, char **getbuf, char **diffbuf) +{ + struct stat cstat; + char const *filebase = base_name (filename); + char const *dotslash = *filename == '-' ? "./" : ""; + size_t dirlen = filebase - filename; + size_t filenamelen = strlen (filename); + size_t maxfixlen = sizeof "SCCS/" - 1 + sizeof SCCSPREFIX - 1; + size_t maxtrysize = filenamelen + maxfixlen + 1; + size_t quotelen = quote_system_arg (0, filename); + 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; + + strcpy (trybuf, filename); + +#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); + return r; +} + +/* Get FILENAME from version control system CS. The file already exists if + EXISTS is nonzero. Only readonly access is needed if READONLY is nonzero. + Use the command GETBUF to actually get the named file. + Store the resulting file status into *FILESTAT. + Return nonzero if successful. */ +int +version_get (char const *filename, char const *cs, int exists, int 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; + + assert (s && size); + rv = malloc (size); + + if (! rv) + { + if (! using_plan_a) + memory_fatal (); + } + 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; +} + +#if !HAVE_VPRINTF +#define vfprintf my_vfprintf +static int +vfprintf (FILE *stream, char const *format, va_list args) +{ +#if !HAVE_DOPRNT && HAVE__DOPRINTF +# define _doprnt _doprintf +#endif +#if HAVE_DOPRNT || HAVE__DOPRINTF + _doprnt (format, args, stream); + return ferror (stream) ? -1 : 0; +#else + int *a = (int *) args; + return fprintf (stream, format, + a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]); +#endif +} +#endif /* !HAVE_VPRINTF */ + +/* 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 +memory_fatal (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. */ + +void +say (char const *format, ...) +{ + va_list args; + va_start (args, format); + vfprintf (stdout, format, args); + va_end (args); + fflush (stdout); +} + +/* Get a response from the user, somehow or other. */ + +void +ask (char const *format, ...) +{ + static int ttyfd = -2; + int 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) + memory_fatal (); + } + 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. */ + +int +ok_to_reverse (char const *format, ...) +{ + int r = 0; + + if (noreverse || ! (force && verbosity == SILENT)) + { + va_list args; + va_start (args, format); + vfprintf (stdout, format, args); + va_end (args); + } + + if (noreverse) + { + printf (" Skipping patch.\n"); + skip_rest_of_patch = TRUE; + r = 0; + } + else if (force) + { + if (verbosity != SILENT) + printf (" Applying it anyway.\n"); + r = 0; + } + else if (batch) + { + say (reverse ? " Ignoring -R.\n" : " Assuming -R.\n"); + r = 1; + } + 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 (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 RETSIGTYPE fatal_exit_handler (int) __attribute__ ((noreturn)); +static RETSIGTYPE +fatal_exit_handler (int sig) +{ + signal (sig, SIG_IGN); + fatal_exit (sig); +} +#endif + +void +set_signals (int 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++) + { + int 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 + FILESYSTEM_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, time_t *pstamp) +{ + char *name; + 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; + } + /* Allow file names with internal spaces, + but only if a tab separates the file name from the date. */ + else if (*t == '\t' + || (ISSPACE ((unsigned char) *t) && ! strchr (t + 1, '\t'))) + { + char const *u = t; + + 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) + 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; + return 0; + } + + /* Ignore the name if it doesn't have enough slashes to strip off. */ + if (0 < sleading) + return 0; + + if (pstamp) + *pstamp = stamp; + + return savestr (name); +} + +void +Fseek (FILE *stream, file_offset offset, int ptrname) +{ + if (file_seek (stream, offset, ptrname) != 0) + pfatal ("fseek"); +} diff --git a/patch/util.h b/patch/util.h new file mode 100644 index 0000000..b0c5d11 --- /dev/null +++ b/patch/util.h @@ -0,0 +1,59 @@ +/* utility functions for `patch' */ + +/* $Id: util.h,v 1.1.1.3 2003/05/08 18:38:04 rbraun Exp $ */ + +/* Copyright (C) 1986 Larry Wall + + Copyright (C) 1992, 1993, 1997, 1998, 1999, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* 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; + +int 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, time_t *); +char *savebuf (char const *, size_t); +char *savestr (char const *); +char const *version_controller (char const *, int, struct stat const *, char **, char **); +int version_get (char const *, char const *, int, int, char const *, struct stat *); +int create_file (char const *, int, mode_t); +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 *, int, mode_t); +void exit_with_signal (int) __attribute__ ((noreturn)); +void ignore_signals (void); +void init_time (void); +void memory_fatal (void) __attribute__ ((noreturn)); +void move_file (char const *, int volatile *, char *, mode_t, int); +void read_fatal (void) __attribute__ ((noreturn)); +void remove_prefix (char *, size_t); +void removedirs (char *); +void set_signals (int); +void write_fatal (void) __attribute__ ((noreturn)); diff --git a/patch/version.c b/patch/version.c new file mode 100644 index 0000000..ab88fc6 --- /dev/null +++ b/patch/version.c @@ -0,0 +1,30 @@ +/* Print the version number. */ + +/* $Id: version.c,v 1.1.1.3 2003/05/08 18:38:04 rbraun Exp $ */ + +#define XTERN extern +#include +#undef XTERN +#define XTERN +#include +#include + +static char const copyright_string[] = "\ +Copyright (C) 1988 Larry Wall\n\ +Copyright (C) 2002 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", PROGRAM_NAME, PATCH_VERSION, + copyright_string, free_software_msgid, authorship_msgid); +} diff --git a/patch/version.h b/patch/version.h new file mode 100644 index 0000000..abde187 --- /dev/null +++ b/patch/version.h @@ -0,0 +1,5 @@ +/* Print the version number. */ + +/* $Id: version.h,v 1.1.1.3 2003/05/08 18:38:04 rbraun Exp $ */ + +void version (void); diff --git a/patch/xalloc.h b/patch/xalloc.h new file mode 100644 index 0000000..aabfea4 --- /dev/null +++ b/patch/xalloc.h @@ -0,0 +1,82 @@ +/* xalloc.h -- malloc with out-of-memory checking + Copyright (C) 1990-1998, 1999, 2000, 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, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef XALLOC_H_ +# define XALLOC_H_ + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +# ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ +# define __attribute__(x) +# endif +# endif + +# ifndef ATTRIBUTE_NORETURN +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# endif + +/* If this pointer is non-zero, run the specified function upon each + allocation failure. It is initialized to zero. */ +extern void (*xalloc_fail_func) PARAMS ((void)); + +/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this + message is output. It is translated via gettext. + Its value is "memory exhausted". */ +extern char const xalloc_msg_memory_exhausted[]; + +/* This function is always triggered when memory is exhausted. It is + in charge of honoring the three previous items. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN; + +void *xmalloc PARAMS ((size_t n)); +void *xcalloc PARAMS ((size_t n, size_t s)); +void *xrealloc PARAMS ((void *p, size_t n)); +char *xstrdup PARAMS ((const char *str)); + +# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items))) +# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items))) +# define XREALLOC(Ptr, Type, N_items) \ + ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items))) + +/* Declare and alloc memory for VAR of type TYPE. */ +# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1) + +/* Free VAR only if non NULL. */ +# define XFREE(Var) \ + do { \ + if (Var) \ + free (Var); \ + } while (0) + +/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */ +# define CCLONE(Src, Num) \ + (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num))) + +/* Return a malloc'ed copy of SRC. */ +# define CLONE(Src) CCLONE (Src, 1) + + +#endif /* !XALLOC_H_ */ diff --git a/patch/xmalloc.c b/patch/xmalloc.c new file mode 100644 index 0000000..49351bb --- /dev/null +++ b/patch/xmalloc.c @@ -0,0 +1,113 @@ +/* xmalloc.c -- malloc with out of memory checking + Copyright (C) 1990-1999, 2000, 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, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include + +#if STDC_HEADERS +# include +#else +void *calloc (); +void *malloc (); +void *realloc (); +void free (); +#endif + +#if ENABLE_NLS +# include +# define _(Text) gettext (Text) +#else +# define textdomain(Domain) +# define _(Text) Text +#endif +#define N_(Text) Text + +#include "error.h" +#include "exitfail.h" +#include "xalloc.h" + +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + +#ifndef HAVE_DONE_WORKING_MALLOC_CHECK +"you must run the autoconf test for a properly working malloc -- see malloc.m4" +#endif + +#ifndef HAVE_DONE_WORKING_REALLOC_CHECK +"you must run the autoconf test for a properly working realloc --see realloc.m4" +#endif + +/* If non NULL, call this function when memory is exhausted. */ +void (*xalloc_fail_func) PARAMS ((void)) = 0; + +/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message + before exiting when memory is exhausted. Goes through gettext. */ +char const xalloc_msg_memory_exhausted[] = N_("memory exhausted"); + +void +xalloc_die (void) +{ + if (xalloc_fail_func) + (*xalloc_fail_func) (); + error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted)); + /* The `noreturn' cannot be given to error, since it may return if + its first argument is 0. To help compilers understand the + xalloc_die does terminate, call exit. */ + exit (EXIT_FAILURE); +} + +/* Allocate N bytes of memory dynamically, with error checking. */ + +void * +xmalloc (size_t n) +{ + void *p; + + p = malloc (n); + if (p == 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 == 0) + xalloc_die (); + return p; +} + +/* Allocate memory for N elements of S bytes, with error checking. */ + +void * +xcalloc (size_t n, size_t s) +{ + void *p; + + p = calloc (n, s); + if (p == 0) + xalloc_die (); + return p; +} diff --git a/patch_cmds.plist b/patch_cmds.plist new file mode 100644 index 0000000..d4f47cf --- /dev/null +++ b/patch_cmds.plist @@ -0,0 +1,22 @@ + + + + + OpenSourceImportDate + 2003-05-08 + OpenSourceLicense + GPL + OpenSourceLicenseFile + gpatch.txt + OpenSourceProject + patch + OpenSourceVersion + 2.5.8 + OpenSourceSHA1 + ae3fe3837818041162039e41a7da8eb7ede14292 + OpenSourceURL + http://ftp.gnu.org/gnu/patch/patch-2.5.8.tar.gz + OpenSourceWebsiteURL + http://www.gnu.org/software/patch/ + +