From 0ec16ad8f3387117932b28e20a6db5928a4fde52 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 8 Jun 2002 07:47:23 +0000 Subject: Virgin import (trimmed) of GNU Sort, textutils 2.0.21 --- contrib/gnu-sort/ABOUT-NLS | 393 ++ contrib/gnu-sort/AUTHORS | 10 + contrib/gnu-sort/COPYING | 340 ++ contrib/gnu-sort/ChangeLog | 8574 +++++++++++++++++++++++++++++++++++ contrib/gnu-sort/INSTALL | 231 + contrib/gnu-sort/NEWS | 452 ++ contrib/gnu-sort/README | 41 + contrib/gnu-sort/README-alpha | 3 + contrib/gnu-sort/THANKS | 340 ++ contrib/gnu-sort/TODO | 93 + contrib/gnu-sort/lib/argmatch.c | 309 ++ contrib/gnu-sort/lib/argmatch.h | 129 + contrib/gnu-sort/lib/closeout.h | 17 + contrib/gnu-sort/lib/dup-safer.c | 62 + contrib/gnu-sort/lib/error.c | 401 ++ contrib/gnu-sort/lib/error.h | 78 + contrib/gnu-sort/lib/fopen-safer.c | 76 + contrib/gnu-sort/lib/getopt.c | 772 ++++ contrib/gnu-sort/lib/getopt.h | 131 + contrib/gnu-sort/lib/getopt1.c | 182 + contrib/gnu-sort/lib/hard-locale.c | 87 + contrib/gnu-sort/lib/hard-locale.h | 18 + contrib/gnu-sort/lib/human.c | 366 ++ contrib/gnu-sort/lib/human.h | 39 + contrib/gnu-sort/lib/long-options.c | 91 + contrib/gnu-sort/lib/long-options.h | 35 + contrib/gnu-sort/lib/memcoll.c | 79 + contrib/gnu-sort/lib/memcoll.h | 18 + contrib/gnu-sort/lib/pathmax.h | 54 + contrib/gnu-sort/lib/physmem.c | 94 + contrib/gnu-sort/lib/physmem.h | 19 + contrib/gnu-sort/lib/posixver.c | 58 + contrib/gnu-sort/lib/posixver.h | 1 + contrib/gnu-sort/lib/quote.c | 28 + contrib/gnu-sort/lib/quote.h | 12 + contrib/gnu-sort/lib/quotearg.c | 658 +++ contrib/gnu-sort/lib/quotearg.h | 114 + contrib/gnu-sort/lib/stdio-safer.h | 9 + contrib/gnu-sort/lib/unistd-safer.h | 9 + contrib/gnu-sort/lib/version-etc.c | 71 + contrib/gnu-sort/lib/version-etc.h | 38 + contrib/gnu-sort/lib/xalloc.h | 87 + contrib/gnu-sort/lib/xmalloc.c | 116 + contrib/gnu-sort/lib/xmemcoll.c | 70 + contrib/gnu-sort/lib/xmemcoll.h | 2 + contrib/gnu-sort/lib/xstrtol.c | 302 ++ contrib/gnu-sort/lib/xstrtol.h | 82 + contrib/gnu-sort/lib/xstrtoul.c | 4 + contrib/gnu-sort/lib/xstrtoumax.c | 31 + contrib/gnu-sort/man/sort.1 | 113 + contrib/gnu-sort/src/sort.c | 2502 ++++++++++ contrib/gnu-sort/src/sys2.h | 565 +++ contrib/gnu-sort/src/system.h | 286 ++ 53 files changed, 18692 insertions(+) create mode 100644 contrib/gnu-sort/ABOUT-NLS create mode 100644 contrib/gnu-sort/AUTHORS create mode 100644 contrib/gnu-sort/COPYING create mode 100644 contrib/gnu-sort/ChangeLog create mode 100644 contrib/gnu-sort/INSTALL create mode 100644 contrib/gnu-sort/NEWS create mode 100644 contrib/gnu-sort/README create mode 100644 contrib/gnu-sort/README-alpha create mode 100644 contrib/gnu-sort/THANKS create mode 100644 contrib/gnu-sort/TODO create mode 100644 contrib/gnu-sort/lib/argmatch.c create mode 100644 contrib/gnu-sort/lib/argmatch.h create mode 100644 contrib/gnu-sort/lib/closeout.h create mode 100644 contrib/gnu-sort/lib/dup-safer.c create mode 100644 contrib/gnu-sort/lib/error.c create mode 100644 contrib/gnu-sort/lib/error.h create mode 100644 contrib/gnu-sort/lib/fopen-safer.c create mode 100644 contrib/gnu-sort/lib/getopt.c create mode 100644 contrib/gnu-sort/lib/getopt.h create mode 100644 contrib/gnu-sort/lib/getopt1.c create mode 100644 contrib/gnu-sort/lib/hard-locale.c create mode 100644 contrib/gnu-sort/lib/hard-locale.h create mode 100644 contrib/gnu-sort/lib/human.c create mode 100644 contrib/gnu-sort/lib/human.h create mode 100644 contrib/gnu-sort/lib/long-options.c create mode 100644 contrib/gnu-sort/lib/long-options.h create mode 100644 contrib/gnu-sort/lib/memcoll.c create mode 100644 contrib/gnu-sort/lib/memcoll.h create mode 100644 contrib/gnu-sort/lib/pathmax.h create mode 100644 contrib/gnu-sort/lib/physmem.c create mode 100644 contrib/gnu-sort/lib/physmem.h create mode 100644 contrib/gnu-sort/lib/posixver.c create mode 100644 contrib/gnu-sort/lib/posixver.h create mode 100644 contrib/gnu-sort/lib/quote.c create mode 100644 contrib/gnu-sort/lib/quote.h create mode 100644 contrib/gnu-sort/lib/quotearg.c create mode 100644 contrib/gnu-sort/lib/quotearg.h create mode 100644 contrib/gnu-sort/lib/stdio-safer.h create mode 100644 contrib/gnu-sort/lib/unistd-safer.h create mode 100644 contrib/gnu-sort/lib/version-etc.c create mode 100644 contrib/gnu-sort/lib/version-etc.h create mode 100644 contrib/gnu-sort/lib/xalloc.h create mode 100644 contrib/gnu-sort/lib/xmalloc.c create mode 100644 contrib/gnu-sort/lib/xmemcoll.c create mode 100644 contrib/gnu-sort/lib/xmemcoll.h create mode 100644 contrib/gnu-sort/lib/xstrtol.c create mode 100644 contrib/gnu-sort/lib/xstrtol.h create mode 100644 contrib/gnu-sort/lib/xstrtoul.c create mode 100644 contrib/gnu-sort/lib/xstrtoumax.c create mode 100644 contrib/gnu-sort/man/sort.1 create mode 100644 contrib/gnu-sort/src/sort.c create mode 100644 contrib/gnu-sort/src/sys2.h create mode 100644 contrib/gnu-sort/src/system.h (limited to 'contrib/gnu-sort') diff --git a/contrib/gnu-sort/ABOUT-NLS b/contrib/gnu-sort/ABOUT-NLS new file mode 100644 index 0000000..f083395 --- /dev/null +++ b/contrib/gnu-sort/ABOUT-NLS @@ -0,0 +1,393 @@ +Notes on the Free Translation Project +************************************* + + Free software is going international! The Free Translation Project +is a way to get maintainers of free software, translators, and users all +together, so that will gradually become able to speak many languages. +A few packages already provide translations for their messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do _not_ +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work at translations should contact the appropriate team. + + When reporting bugs in the `intl/' directory or bugs which may be +related to internationalization, you should tell about the version of +`gettext' which is used. The information can be found in the +`intl/VERSION' file, in internationalized packages. + +Quick configuration advice +========================== + + If you want to exploit the full power of internationalization, you +should configure it using + + ./configure --with-included-gettext + +to force usage of internationalizing routines provided within this +package, despite the existence of internationalizing capabilities in the +operating system where this package is being installed. So far, only +the `gettext' implementation in the GNU C library version 2 provides as +many features (such as locale alias, message inheritance, automatic +charset conversion or plural form handling) as the implementation here. +It is also not possible to offer this additional functionality on top +of a `catgets' implementation. Future versions of GNU `gettext' will +very likely convey even more functionality. So it might be a good idea +to change to GNU `gettext' as soon as possible. + + So you need _not_ provide this option if you are using GNU libc 2 or +you have installed a recent copy of the GNU gettext package with the +included `libintl'. + +INSTALL Matters +=============== + + Some packages are "localizable" when properly installed; the +programs they contain can be made to speak your own native language. +Most such packages use GNU `gettext'. Other packages have their own +ways to internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system already +provides the GNU `gettext' functions. If not, the GNU `gettext' own +library will be used. This library is wholly contained within this +package, usually in the `intl/' subdirectory, so prior installation of +the GNU `gettext' package is _not_ required. Installers may use +special options at configuration time for changing the default +behaviour. The commands: + + ./configure --with-included-gettext + ./configure --disable-nls + +will respectively bypass any pre-existing `gettext' to use the +internationalizing routines provided within this package, or else, +_totally_ disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl.a' file and +will decide to use this. This might be not what is desirable. You +should use the more recent version of the GNU `gettext' library. I.e. +if the file `intl/VERSION' shows that the library which comes with this +package is more recent, you should use + + ./configure --with-included-gettext + +to prevent auto-detection. + + The configuration process will not test for the `catgets' function +and therefore it will not be used. The reason is that even an +emulation of `gettext' on top of `catgets' could not provide all the +extensions of the GNU `gettext' library. + + Internationalized packages have usually many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +Using This Package +================== + + As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, +and `CC' is an ISO 3166 two-letter country code. For example, let's +suppose that you speak German and live in Germany. At the shell +prompt, merely execute `setenv LANG de_DE' (in `csh'), +`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). +This can be done from your `.login' or `.profile' file, once and for +all. + + You might think that the country code specification is redundant. +But in fact, some languages have dialects in different countries. For +example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The +country code serves to distinguish the dialects. + + The locale naming convention of `LL_CC', with `LL' denoting the +language and `CC' denoting the country, is the one use on systems based +on GNU libc. On other systems, some variations of this scheme are +used, such as `LL' or `LL_CC.ENCODING'. You can get the list of +locales supported by your system for your country by running the command +`locale -a | grep '^LL''. + + Not all programs have translations for all languages. By default, an +English message is shown in place of a nonexistent translation. If you +understand other languages, you can set up a priority list of languages. +This is done through a different environment variable, called +`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' +for the purpose of message handling, but you still need to have `LANG' +set to the primary language; this is required by other parts of the +system libraries. For example, some Swedish users who would rather +read translations in German than English for when Swedish is not +available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. + + In the `LANGUAGE' environment variable, but not in the `LANG' +environment variable, `LL_CC' combinations can be abbreviated as `LL' +to denote the language's main dialect. For example, `de' is equivalent +to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' +(Portuguese as spoken in Portugal) in this context. + +Translating Teams +================= + + For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list. The up-to-date list of +teams can be found at the Free Translation Project's homepage, +`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" +area. + + If you'd like to volunteer to _work_ at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is _not_ the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request@li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +_actively_ in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `translation@iro.umontreal.ca' to reach the +coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skill are praised more than +programming skill, here. + +Available Packages +================== + + Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of January +2002. The matrix shows, in regard of each package, for which languages +PO files have been submitted to translation coordination, with a +translation percentage of at least 50%. + + Ready PO files bg ca cs da de el en eo es et fi fr + +-------------------------------------+ + a2ps | [] [] [] [] | + bash | [] [] [] [] | + bfd | [] [] | + binutils | [] [] | + bison | [] [] [] | + clisp | [] [] [] [] | + cpio | [] [] [] [] | + diffutils | [] [] [] [] [] [] | + enscript | [] [] | + error | [] [] | + fetchmail | () [] [] [] () | + fileutils | [] [] [] [] [] | + findutils | [] [] [] [] [] | + flex | [] [] [] | + gas | [] | + gawk | [] [] | + gcal | [] [] | + gcc | [] [] | + gettext | [] [] [] [] [] | + gnupg | [] [] [] [] [] [] | + gprof | [] [] | + grep | [] [] [] [] [] [] | + hello | [] [] [] [] [] [] [] [] | + id-utils | [] [] [] | + indent | [] [] [] [] | + jpilot | () [] [] [] | + jwhois | [] [] | + kbd | [] | + ld | [] [] | + libc | [] [] [] [] [] [] [] | + lilypond | [] [] | + lynx | [] [] [] [] | + m4 | [] [] [] [] [] | + make | [] [] [] [] | + mysecretdiary | [] [] | + nano | [] () [] [] [] [] | + nano_1_0 | [] () [] [] [] [] | + opcodes | [] [] [] | + parted | [] [] [] [] | + ptx | [] [] [] [] [] | + python | | + recode | [] [] [] [] [] [] | + sed | [] [] [] [] [] [] [] [] | + sh-utils | [] [] [] [] [] [] [] [] | + sharutils | [] [] [] [] [] [] | + sketch | () [] () | + soundtracker | [] [] [] | + sp | | + tar | [] [] [] [] [] [] | + texinfo | [] [] [] [] [] | + textutils | [] [] [] [] | + util-linux | [] [] [] [] | + wdiff | [] [] [] [] [] | + wget | [] [] [] [] [] [] [] [] | + +-------------------------------------+ + bg ca cs da de el en eo es et fi fr + 0 8 12 31 36 9 1 9 37 15 1 49 + + gl he hr hu id it ja ko lv nb nl nn + +-------------------------------------+ + a2ps | () () [] | + bash | | + bfd | [] | + binutils | [] | + bison | [] | + clisp | [] | + cpio | [] [] [] | + diffutils | [] [] | + enscript | [] | + error | [] | + fetchmail | | + fileutils | [] [] | + findutils | [] [] [] [] [] [] | + flex | [] | + gas | | + gawk | [] | + gcal | | + gcc | [] | + gettext | [] | + gnupg | [] [] [] | + gprof | | + grep | [] [] | + hello | [] [] [] [] [] [] [] [] [] | + id-utils | [] | + indent | [] [] [] | + jpilot | () () | + jwhois | | + kbd | | + ld | | + libc | [] [] [] [] | + lilypond | [] [] | + lynx | [] [] | + m4 | [] [] [] [] | + make | [] [] [] [] | + mysecretdiary | | + nano | [] [] [] () () [] | + nano_1_0 | [] [] [] () () [] | + opcodes | | + parted | [] [] [] | + ptx | [] [] [] [] | + python | | + recode | [] [] [] | + sed | [] [] [] [] [] [] [] | + sh-utils | [] [] [] [] [] | + sharutils | [] [] [] | + sketch | () | + soundtracker | [] | + sp | | + tar | [] [] [] | + texinfo | [] [] [] | + textutils | [] [] | + util-linux | () [] | + wdiff | | + wget | [] [] [] [] [] | + +-------------------------------------+ + gl he hr hu id it ja ko lv nb nl nn + 20 6 1 3 6 11 22 9 1 6 17 4 + + no pl pt pt_BR ru sk sl sv tr uk zh + +-------------------------------------+ + a2ps | () () () [] [] [] () | 8 + bash | | 4 + bfd | [] [] | 5 + binutils | [] | 4 + bison | [] [] [] | 7 + clisp | | 5 + cpio | [] [] [] [] | 11 + diffutils | [] [] [] | 11 + enscript | [] [] [] | 6 + error | [] [] | 5 + fetchmail | () () | 3 + fileutils | [] [] [] [] | 11 + findutils | [] [] [] [] [] [] | 17 + flex | [] [] | 6 + gas | [] | 2 + gawk | [] [] | 5 + gcal | [] | 3 + gcc | [] | 4 + gettext | [] [] [] [] | 10 + gnupg | [] [] [] | 12 + gprof | [] [] | 4 + grep | [] [] [] [] [] | 13 + hello | [] [] [] [] [] [] [] | 24 + id-utils | [] [] | 6 + indent | [] [] [] [] | 11 + jpilot | () () | 3 + jwhois | () () | 2 + kbd | [] [] | 3 + ld | [] [] | 4 + libc | [] [] [] [] [] [] | 17 + lilypond | [] | 5 + lynx | [] [] [] | 9 + m4 | [] [] [] | 12 + make | [] [] [] [] | 12 + mysecretdiary | [] | 3 + nano | () [] [] [] | 12 + nano_1_0 | () [] [] [] | 12 + opcodes | [] [] | 5 + parted | [] [] [] | 10 + ptx | [] [] [] [] [] [] | 15 + python | | 0 + recode | [] [] [] [] | 13 + sed | [] [] [] [] [] [] | 21 + sh-utils | [] [] [] [] [] [] [] [] [] | 22 + sharutils | [] [] | 11 + sketch | () | 1 + soundtracker | | 4 + sp | | 0 + tar | [] [] [] [] [] [] [] | 16 + texinfo | [] [] | 10 + textutils | [] [] | 8 + util-linux | [] [] [] | 8 + wdiff | [] [] [] [] | 9 + wget | [] [] [] [] [] [] | 19 + +-------------------------------------+ + 35 teams no pl pt pt_BR ru sk sl sv tr uk zh + 54 domains 5 12 2 11 25 10 11 39 29 4 1 463 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If January 2002 seems to be old, you may fetch a more recent copy of +this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date +matrix with full percentage details can be found at +`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. + +Using `gettext' in new packages +=============================== + + If you are writing a freely available program and want to +internationalize it you are welcome to use GNU `gettext' in your +package. Of course you have to respect the GNU Library General Public +License which covers the use of the GNU `gettext' library. This means +in particular that even non-free programs can use `libintl' as a shared +library, whereas only free software can use `libintl' as a static +library or use modified versions of `libintl'. + + Once the sources are changed appropriately and the setup can handle +to use of `gettext' the only thing missing are the translations. The +Free Translation Project is also available for packages which are not +developed inside the GNU project. Therefore the information given above +applies also for every other Free Software Project. Contact +`translation@iro.umontreal.ca' to make the `.pot' files available to +the translation teams. + diff --git a/contrib/gnu-sort/AUTHORS b/contrib/gnu-sort/AUTHORS new file mode 100644 index 0000000..43f5b2d --- /dev/null +++ b/contrib/gnu-sort/AUTHORS @@ -0,0 +1,10 @@ +Authors of parts of GNU textutils. + +The following contributions warranted legal paper exchanges with the +Free Software Foundation. Also see files ChangeLog and THANKS. + +GPTX François Pinard CANADA, 1949 +Assigns the program. + +GPTX Odyssee Recherches Appliquees +Disclaims work by François Pinard diff --git a/contrib/gnu-sort/COPYING b/contrib/gnu-sort/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/contrib/gnu-sort/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/contrib/gnu-sort/ChangeLog b/contrib/gnu-sort/ChangeLog new file mode 100644 index 0000000..87e22a2 --- /dev/null +++ b/contrib/gnu-sort/ChangeLog @@ -0,0 +1,8574 @@ +2002-02-18 Jim Meyering + + * Version 2.0.21. + + * tests/tail/Test.pm: For tests matching /^(obs|err-[134])/, + put _POSIX2_VERSION=199209 in the environment, so the tests succeed + even when the environment would have contained _POSIX2_VERSION=200112. + * tests/uniq/Test.pm (test_vector): Rename tests of obsolete usage + to have prefix of `obs'. Adjust environment for those tests as above. + + * tests/mk-script: When getting input via a pipe, apply the + environment settings to the command in question, not to `cat'. + No longer allow more than one element in the $Test::env or + $Test::env_default arrays. No caller used that feature. + +2002-02-17 Jim Meyering + + * tests/head/Test.pm: Accept pre-POSIX 1003.1-2001 options. + * tests/pr/Test.pm: Likewise. + * tests/sort/Test.pm: Likewise. + + * Makefile.cfg (wget_files): Reflect new location of these files. + +2002-02-16 Jim Meyering + + * ABOUT-NLS, intl/*: Update to Gettext 0.11. + * INSTALL: Update to Autoconf 2.52h. + + * src/Makefile.am (datadir): Use `share' in place of @DATADIRNAME@, + per Gettext-0.11. + (LDADD): Use @LIBINTL@ instead of @INTLLIBS@, per Gettext-0.11. + + * configure.ac (AC_CONFIG_AUX_DIR): New macro invocation. + (ALL_LINGUAS): Remove: now in po/LINGUAS as per Gettext 0.11. + + * config: New subdirectory, containing the following files from .: + config.guess, config.sub, depcomp, missing, install-sh, mkinstalldirs. + Move the following files here from doc: texinfo.tex, mdate-sh. + +2002-02-15 Paul Eggert + + Add support for _POSIX2_VERSION, which lets you pick which POSIX + version you want the utilities to conform to. Remove warnings about + failure to conform to a future POSIX version. + + * NEWS, doc/coreutils.texi: Document _POSIX2_VERSION. + * doc/coreutils.texi (Standards Conformance): New section. + + * src/expand.c: Include posixver.h. + (usage): Document only the intersection of the old and new behaviors, + to encourage portability. + * src/fold.c: Likewise. + * src/head.c: Likewise. + * src/od.c: Likewise. + * src/pr.c: Likewise. + * src/sort.c: Likewise. + * src/split.c: Likewise. + * src/uniq.c: Likewise. + * src/tail.c: Likewise. + * src/unexpand.c: Likewise. + + * src/expand.c (shortopts): Remove; no longer needed. + * src/od.c (short_options): Likewise. + * src/pr.c (short_options): Likewise. + * src/sort.c (short_options): Likewise. + * src/split.c (shortopts): Likewise. + * src/uniq.c (shortopts): Likewise. + * src/unexpand.c (shortopts): Likewise. + + * src/od.c (COMMON_SHORT_OPTIONS): New macro. + * src/pr.c (COMMON_SHORT_OPTIONS): Likewise. + * src/sort.c (COMMON_SHORT_OPTIONS): Likewise. + + * src/expand.c (main): Revert to previous behavior, except report + an error and exit if the obsolete syntax is used and if conforming + to the new standard. + * src/fold.c (main): Likewise. + * src/head.c (main): Likewise. + * src/split.c (main): Likewise. + * src/uniq.c (main): Likewise. + * src/tail.c (main, parse_obsolescent_option): Likewise. + * src/unexpand.c (main): Likewise. + + * src/od.c (STRINGS_OPTION, WIDTH_OPTION): Remove; no longer needed. + All uses changed back to the corresponding short options. + * src/pr.c (SEP_STRING_OPTION): Likewise. + + * src/od.c (main): Parse options using POSIX 1003.1-2001 rules if + conforming to that standard. Do not warn of obsolete options. + * src/pr.c (main): Likewise. + * src/sort.c (main): Likewise. + + * src/system.h (_POSIX2_VERSION, POSIX2_VERSION): Remove definitions. + (OPTARG_POSIX, OBSOLETE_OPTION_WARNINGS): Likewise. + +2002-02-16 Jim Meyering + + * tests/misc/split-a: New test for change of 2002-02-05. + * tests/misc/Makefile.am (TESTS): Add split-a. + +2002-02-12 Jim Meyering + + * src/split.c (DEFAULT_SUFFIX_LENGTH): Define constant. + (suffix_length): Use it here. + (usage): Use it here. + +2002-02-05 Paul Eggert + + Change 'split' to conform to POSIX. It now accepts an -a or + --suffix-length option, and refuses to generate more files + than there are suffixes. + + * NEWS, doc/coreutils.texi: Document this. + * src/split.c: Include "dirname.h". + (outbase): Now a global var. + (outfile_end): Remove. + (suffix_length): New var. + (shortopts, longopts, main): Add -a or --suffix-length. + (next_file_name): Implement -a. Do not extend the suffix length. + Check for file names that are too long. + (main): Move outfile initialization to next_file_name. + + * src/split.c (shortopts): Remove -v (a typo). + +2002-02-11 Jim Meyering + + * tests/misc/head-pos: New file/test for the change of 2002-02-08. + * tests/misc/Makefile.am (TESTS): Add head-pos. + + * src/tr.c (unquote): Make comment a little clearer. + +2002-02-08 Paul Eggert + + * src/head.c (head_lines): If we have read too much data, try + to seek back to the position we would have gotten to had we + been reading one byte at a time. POSIX currently doesn't + require this, but it's easy to do and some software relies on it. + +2002-02-02 Jim Meyering + + * src/uniq.c (main): Prepend `warning: ' to the diagnostic, so it's + consistent with all of the other `... is obsolete...' diagnostics. + +2002-01-31 Paul Eggert + + Add more support for POSIX 1003.1-2001, which requires removal for + support of obsolete "-N" option syntax in expand, head, fold, + split, tail, unexpand, uniq, and which prohibits options with + optional arguments in od and pr. + + * NEWS: Document this. + * doc/coreutils.texi: Likewise. + * src/expand.c (usage): Likewise. + * src/fold.c (usage): Likewise. + * src/head.c (usage): Likewise. + * src/od.c (usage): Likewise. + * src/pr.c (usage): Likewise. + * src/split.c (usage): Likewise. + * src/unexpand.c (usage): Likewise. + * src/uniq.c (usage): Likewise. + + * NEWS: Improve doc for previous fix in this area. + + * src/expand.c (shortopts): New constant. + * src/od.c (short_options): Likewise. + * src/pr.c (short_options): Likewise. + * src/sort.c (short_options): Likewise. + * src/split.c (shortopts): Likewise. + * src/unexpand.c (shortopts): Likewise. + * src/uniq.c (shortopts): Likewise. + + * src/expand.c (main): Check for obsolete options. + * src/fold.c (main): Likewise. + * src/head.c (main): Likewise. + * src/od.c (main): Likewise. + * src/pr.c (main): Likewise. + * src/sort.c (main): Likewise. + * src/split.c (main): Likewise. + * src/tail.c (parse_obsolescent_option, main): Likewise. + * src/unexpand.c (main): Likewise. + * src/uniq.c (main): Likewise. + + * src/head.c (header_mode_option): New constant. + + * src/od.c: New enum for long options. + + * src/pr.c (SEP_STRING_OPTION): New enum value. + (long_options): Use it. + + * src/split.c (main): Use -1, not EOF, for getopt_long. + + * src/system.h (OPTARG_POSIX, OBSOLETE_OPTION_WARNINGS): New macros. + + * src/fold.c (main): Fix bug: -- -N was treated as -N --. + +2002-02-01 Jim Meyering + + * src/tail.c (start_lines): Handle the case in which bytes_read is zero. + +2002-01-28 Jim Meyering + + * Makefile.maint (ac-check): Remove, now that we no longer have + to duplicate that information. + (local-check): Remove ac-check. + + * Makefile.am (AUTOMAKE_OPTIONS): Require automake-1.5d. + + * configure.ac (AM_INIT_AUTOMAKE): Use zero-arg form of this macro. + (ALL_LINGUAS): Add the bokmċl dialect of Norwegian (nb). + +2002-01-27 Jim Meyering + + tail -n +2 would perform an extra read after encountering EOF + * src/tail.c (start_lines): Detect EOF, inform caller. + (tail_lines): Upon EOF in start_lines, return immediately. + +2002-01-22 Jim Meyering + + * Version 2.0.20. + +2002-01-22 Paul Eggert + + * src/od.c (skip): Remove redundant check for overflow. + fseeko's seek argument is already known to be in range, + since it is less than the file size. + +2002-01-22 Jim Meyering + + * po/POTFILES.in: Add lib/xmemcoll.c. + +2002-01-22 Paul Eggert + + * src/tac.c (save_stdin): Report proper errno value after + fwrite failures. Do not bother to rewind the temp file, as + it'll be read backwards anyway. + +2002-01-22 Paul Eggert + + * src/ptx.c (swallow_file_in_memory): Work even if `open' returns 0. + Check for `close' error. + +2002-01-22 Paul Eggert + + Port to glibc 2.2.5, whose mmap stdio positions the underlying + file descriptor at a nonzero offset after an fopen. + + * m4/jm-macros.m4 (jm_MACROS): Require AC_FUNC_FSEEKO. + * src/od.c (skip): Use fseeko rather than lseek. + (Also, check for overflow when converting uintmax_t to off_t.) + * src/sys2.h (EOVERFLOW, fseeko): New macros. + +2001-01-21 Paul Eggert + + * src/comm.c: Include xmemcoll.h, not memcoll.h. + Use xmemcoll instead of memcoll. + * src/join.c: Likewise. + * src/sort.c: Likewise. + + * src/sort.c (die): Do not invoke cleanup; atexit does this now. + (main): Use atexit to invoke cleanup on exit. + Set xmemcoll_exit_failure to SORT_FAILURE. + +2002-01-20 Paul Eggert + + * src/comm.c (compare_files): Don't assume that the difference + between two size_t values can be stored in an int; this doesn't + work, for example, on 64-bit Solaris. + * src/sort.c (CMP_WITH_IGNORE): Likewise. + * src/join.c (keycmp): Likewise. Also, fix the type of two locals + to be size_t instead of int. + +2002-01-20 Paul Eggert + + * src/csplit.c: Don't include "xalloc.h", as system.h already + does that via sys2.h. + * src/sort.c: Likewise. + +2002-01-19 Jim Meyering + + * configure.ac: Remove code that set LIBOBJS in support of ansi2knr. + The latest version of autoconf objected to it, and besides, I don't + care too much about K&R support these days. + +2002-01-18 Jim Meyering + + Fix tr so it no longer gets a failed assertion for [::] or [==]. + + * src/tr.c (xmemdup): Rename from `substr' and rewrite to + take only pointer/length parameters. + (build_spec_list): Update sole caller. + Properly diagnose the invalid specs [::] and [==]. + Pawel Prokop reported that `tr '[::]' x' elicits a failed assertion. + * tests/tr/Test.pm: Add tests for the above fix. + +2002-01-14 Paul Eggert + + * src/sort.c (main): Issue a warning for obsolete usage, unless + POSIXLY_CORRECT. + * src/tail.c (parse_obsolescent_option): Likewise. + * src/uniq.c (main): Likewise. + +2002-01-14 Paul Eggert + + Add support for POSIX 1003.1-2001, which requires removal for + support of obsolete "+" option syntax in sort, tail, and uniq. + + * NEWS: Document this. + + * src/sort.c (usage, main): Implement this. + * src/tail.c (usage, parse_obsolescent_option): Likewise. + * src/uniq.c (usage, main): Likewise. + * src/system.h (_POSIX2_VERSION, POSIX2_VERSION): New macros. + + * src/sys2.h (ISDIGIT, S_ISVTX, S_IXUGO): Comment fix. + +2002-01-14 Jim Meyering + + * tests/misc/sort: New test, for just-fixed bug. + * tests/misc/Makefile.am (TESTS): Add sort. + (TESTS_ENVIRONMENT): Add PROG=$$tst. This is a gross kludge + that depends on the name of an automake-generated local variable. + +2002-01-13 Paul Eggert + + * src/sort.c (mergefps): Fix bug when eliminating empty files. + Bug reported by James Hutt. + +2002-01-13 Jim Meyering + + * tests/help-version: Tweak to work with the programs in diffutils. + +2002-01-09 Jim Meyering + + * configure.in (ALL_LINGUAS): Add Turkish (tr). + +2001-12-18 Paul Eggert + + * src/sort.c (usage, specify_sort_size): Accept 'K' (which is + now preferred, as it connotes 1024) as well as 'k'. + * NEWS: Document this change. + +2001-12-17 Jim Meyering + + * src/uniq.c (usage): Remove stray `)' in --help output. + Reported by Padraig Brady. + + * Makefile.maint (real_dir): Remove unused variable. + (url_dir_list): Don't set define it here, but... + * Makefile.cfg (url_dir_list): ...define it here instead. + (hosts, a_host, b_host): Remove now-unused variables. + (alpha_subdir, a_url_dir, b_url_dir): Remove now-unused variables. + +2001-12-12 Bruno Haible + Paul Eggert + + * src/wc.c (wc): Use ISSPACE and iswspace in addition to hard-coding + the ASCII space character. + +2001-12-08 Jim Meyering + + * Version 2.0.19. + + * Makefile.cfg (wget_files): Remove ansi2knr.c, since it's + no longer available at that location. + +2001-12-03 Jim Meyering + + * src/od.c, src/tail.c, src/tr.c (usage): I will not split translatable + strings in the middle of a sentence. I will not split translatable + strings in the middle of a sentence. I will not split translatable + strings in the middle of a sentence. ... + * src/join.c (usage): Merge lone "\n" into adjacent string. + * src/md5sum.c (usage): Likewise. + * src/paste.c (usage): Likewise. + Reported by Karl Eichwalder. + +2001-12-02 Jim Meyering + + * Makefile.maint (emit-upload-commands): Fix typo: s/distdir/PACKAGE/. + +2001-12-01 Jim Meyering + + * Version 2.0.18. + + * Makefile.maint (po-check): Check for uses of _() not just in .c + files, but also in .h files. + + Ideally, there would be just one translation for all --help + and --version description strings. Before this change, they + differed only in the number of blanks between the option name + and the description. Someday gettext may be smart enough + to merge such strings and to reconstruct the proper spacing at + run time. In the mean time, now there is one string for each, + and those descriptions in the --help output are no longer aligned + with the others. + * src/sys2.h (HELP_OPTION_DESCRIPTION): New macro. + (VERSION_OPTION_DESCRIPTION): New macro. + * src/cat.c, src/cksum.c, src/comm.c, src/csplit.c, src/cut.c: + * src/expand.c, src/fmt.c, src/fold.c, src/head.c, src/join.c: + * src/md5sum.c, src/nl.c, src/od.c, src/paste.c, src/pr.c, src/ptx.c: + * src/sort.c, src/split.c, src/sum.c, src/sys2.h, src/tac.c: + * src/tail.c, src/tr.c, src/tsort.c, src/unexpand.c, src/uniq.c: + * src/wc.c (usage): Use new macros, HELP_OPTION_DESCRIPTION and + VERSION_OPTION_DESCRIPTION instead of hard-coding --help and + --version descriptions. + * po/POTFILES.in: Add src/sys2.h. + +2001-11-27 Jim Meyering + + * src/system.h (SET_MODE) [O_BINARY]: Call setmode, not set_mode. + From Matthew Smith. + +2001-11-26 Jim Meyering + + * src/cat.c (cat): Don't test whether the full_write return value + (of type size_t) is less than 0. Reported by Nelson H. F. Beebe, + as a warning from Irix 6.5's C compiler. + +2001-11-25 Jim Meyering + + * src/cksum.c (usage): Indent --help and --version strings to + start in the 7th column. + * src/pr.c (usage): Likewise. + +2001-11-23 Jim Meyering + + Factor out some common strings to make translation easier. + + * cat.c, cksum.c, comm.c, csplit.c, cut.c, expand.c, fmt.c, fold.c: + * head.c, join.c, md5sum.c, nl.c, od.c, paste.c, pr.c, ptx.c: + * sort.c, split.c, sum.c, tac.c, tail.c, tr.c, tsort.c, unexpand.c: + * uniq.c, wc.c: Split usage strings so that --help and --version + descriptions are alone in their own string. + Likewise for the one that says ``Mandatory arguments to long + options are mandatory for short options too.'' + Suggestion from Karl Eichwalder. + + * src/ptx.c (main): Don't split copyright string in the middle + of a sentence. + +2001-11-22 Jim Meyering + + * Version 2.0.17. + + csplit could get a failed assertion: printf 'a\n\n'|csplit - '/^$/' 2 + * src/csplit.c: No longer include assert.h. + (process_line_count): Remove invalid assertion. The test that caused + the failure has been in the code since before 1992-11-08, but since + 1996 it's been in an assertion. That assertion was disabled by default + until textutils-1.22g (1999-01-10). Reported by Eric Pemente. + + * tests/misc/csplit: New file. Test for the above fix and others. + * tests/misc/Makefile.am (TESTS): Add csplit. + * tests/Makefile.am (EXTRA_DIST): Add lang-default. + +2001-11-19 Jim Meyering + + * src/tail.c (xlseek): New function. + Call it instead of lseek, in most cases, so any failure is reported. + +2001-11-18 Jim Meyering + + * config.sub: Update from master repository. + * config.guess: Likewise. + +2001-11-17 Jim Meyering + + * Makefile.cfg ($(srcdir)/m4/jm-glibc-io.m4): Use $(move_if_change), + not the literal `move-if-change'. + + * src/tail.c (tail_forever): Add a cast. + + Avoid compiler warnings. + * src/fmt.c: Remove `unsigned' attribute from type of global `prefix'. + (copy_rest): Cast to (unsigned char *) before dereferencing. + (get_prefix): Likewise. + + * configure.ac: Replace use of the one-arg form of AC_INIT + with a use of the 3-arg form and a use of AC_CONFIG_SRCDIR. + +2001-11-14 Paul Eggert + + * src/tail.c (file_lines): Remove unnecessary cast. + (tail_lines): Could have called file_lines even though the first + lseek failed. Fix that. + +2001-11-14 Jim Meyering + + * src/tail.c (file_lines): Add a parameter, start_pos. + Work properly even when the read pointer is not at beginning of file. + (tail_lines): Call file_lines for any regular file, as long as lseek + can be used to seek to its end, not just when the initial read pointer + is at beginning of file. + +2001-11-13 Jim Meyering + + * src/tail.c (tail_lines): Move declaration of local `length' + into scope where it's used. + (tail_file): Likewise for local `stats'. + + * tests/tail-2/Makefile.am (TESTS): Add proc-ksyms and start-middle. + * tests/tail-2/start-middle: New test, for the bug fixed on 1995-07-24. + + `tail /proc/ksyms' would segfault on Linux. + * src/tail.c (tail_lines): Use status of lseek (...SEEK_END) call + in deciding whether to call file_lines or pipe_lines. + From Herbert Xu. + * tests/tail-2/proc-ksyms: New test, for the above fix. + +2001-11-11 Jim Meyering + + * src/od.c (struct tspec): Declare function pointer with prototype. + + * src/sum.c (main): Declare function pointer with prototype. + + * src/tsort.c (count_items): Mark parameter as unused. + + * src/sort.c (struct_month_cmp): Guard definition with the same + cpp condition that guards the use. + + * src/tail.c (xwrite): Remove assertion that size_t N >= 0. + + * src/pr.c (struct COLUMN) [print_func]: Declare with a protype. + (struct COLUMN) [char_func]: Declare with a protype. + + * src/od.c (parse_old_offset): Declare to be static. + + * src/join.c (make_blank): Declare to be static. + (prfield): Declare local to be of type size_t, not int. + + Some help strings were very long. Split them so that + they're no longer than the magic length 509 that ISO C89 + compilers are required to support. Sorry, translators :-( + + * src/md5sum.c (usage): Split --help output into smaller pieces. + * src/ptx.c (main, usage): Likewise. + * src/fmt.c (usage): Likewise. + + * src/wc.c (usage): Split --help output into smaller pieces. + Use fputs, not printf. + * src/cat.c (usage): Likewise. + * src/cut.c (usage): Likewise. + * src/csplit.c (usage): Likewise. + * src/expand.c (usage): Likewise. + * src/head.c (usage): Likewise. + * src/join.c (usage): Likewise. + * src/nl.c (usage): Likewise. + * src/od.c (usage): Likewise. + * src/pr.c (usage): Likewise. + * src/sort.c (usage): Likewise. + * src/split.c (usage): Likewise. + * src/tac.c (usage): Likewise. + * src/tr.c (usage): Likewise. + * src/unexpand.c (usage): Likewise. + * src/uniq.c (usage): Likewise. + * src/tail.c (usage): Likewise. + + * src/sys2.h (alloca) [__GNUC__]: Define only if not already defined. + + * src/Makefile.am (sort_LDADD): Reflect spelling change: + s/POW_LIBM/POW_LIB/. + +2001-11-10 Jim Meyering + + * src/nl.c (proc_text): Use `puts' to output a string of spaces, + not printf. This avoids a warning from gcc's -Wformat-security. + +2001-11-09 Jim Meyering + + * configure.ac: Use AC_CONFIG_FILES(...) and call AC_OUTPUT with no + arguments. + +2001-11-05 Jim Meyering + + * src/sort.c (usage): Don't recommend setting LC_COLLATE=C. + That can cause problems (now documented in coreutils.texi). + +2001-11-04 Jim Meyering + + * uniq.c, unexpand.c, tail.c, tac.c, split.c, sort.c, pr.c, paste.c: + * od.c, nl.c, head.c, fold.c, expand.c, cut.c, csplit.c (usage): + Say that ``Mandatory arguments to long options are mandatory for + short options too.'' + + * src/ptx.c (usage): Add one-line description. + +2001-10-28 Jim Meyering + + * tests/sum/sysv: New test for the fix below. + * tests/sum/Makefile.am (TESTS): Add sysv. + +2001-10-27 Paul Eggert + + * src/sum.c: Include human.h. + (ROTATE_RIGHT): Remove; it was slow and the comment was + misleading anyway. + (bsd_sum_file): Avoid unsigned and long when they're not needed. + Compute total input bytes as uintmax_t, not long, so that the + code works even with files whose size does not fit in 'long'. + (sysv_sum_file): Likewise. + (sysv_sum_file): Do not reduce checksum until the end; this is + what System V does. + Reported by Nick Lawes. + +2001-10-27 Jim Meyering + + Give an accurate diagnostic when `head --bytes=30M' fails. + * src/head.c (string_to_integer): Check explicitly for overflow, + and lump everything else together as `invalid'. + +2001-10-04 Jim Meyering + + Rename --all-repeated argument `precede' to `prepend'. + * src/uniq.c (enum delimit_method): s/DM_PRECEDE/DM_PREPEND/ + and change all uses. + (delimit_method_string): s/precede/prepend/ + * tests/uniq/Test.pm: Adjust tests accordingly. + Patches by Padraig Brady. + + * src/uniq.c (usage): Correct typo in description of --all-repeated. + Patch by Padraig Brady. + +2001-09-30 Jim Meyering + + * Version 2.0.16. + + tail -F would segfault + * src/tail.c (parse_options): Add missing `break;' from last change. + +2001-09-28 Jim Meyering + + * configure.ac: Tell automake to use the file name `config.hin' + rather than the two-`.' config.h.in. + +2001-09-26 Jim Meyering + + * man/Makefile.am (common_dep): Define it, so we depend on configure.ac. + + * configure.ac: Renamed from configure.in. + +2001-09-25 Jim Meyering + + * src/Makefile.am (sort_DEPENDENCIES): Remove definition altogether. + It adds nothing to the existing: $(PROGRAMS): ../lib/libfetish.a. + +2001-09-24 Paul Eggert + + * src/Makefile.am (sort_DEPENDENCIES): Depend only on + ../lib/libfetish.a, not on $(LDADD), since the latter may + contain `-lintl'. This resembles yesterday's patch for the + `$(PROGRAMS)' rule. + +2001-09-23 Jim Meyering + + * Version 2.0.15. + + * src/Makefile.am ($(PROGRAMS)): Depend only on ../lib/libfetish.a, + not on $(LDADD), since the former may contain `-lintl'. + + * Makefile.am (SUBDIRS): When using newer gettext (in which + intl/libintl.h is created by rules intl/Makefile) + `intl' must precede `lib'. + +2001-09-22 Jim Meyering + + * ABOUT-NLS: Upgrade to gettext 0.10.40 + * intl: Upgrade entire directory to gettext 0.10.40 + * po/ChangeLog: New file. + + * Makefile.am (DISTCLEANFILES): Remove definition, since intl/libintl.h + is no longer created via configure. + + * tests/od/od-N: New test for the 2001-09-19 fix by Ian Bruce. + * tests/od/Makefile.am: New file. + * tests/od: New directory. + * tests/Makefile.am (SUBDIRS): Add od. + * configure.in (AC_OUTPUT): Add tests/od/Makefile. + +2001-09-19 Paul Eggert + + * src/od.c (MAX_ADDRESS_LENGTH, pseudo_offset, format_address, + n_bytes_to_skip, skip, format_address_none, + format_address_std, format_address_paren, + format_address_label, write_block, parse_old_offset, dump, + dump_strings, main): + Use uintmax_t, not off_t, for file addresses, so that we can + handle multiple large files even if the sum of their sizes + exceeds off_t limits. + + (print_s_char, print_char, print_s_short, print_short, + print_int, print_long, print_long_long, print_float, + print_double, print_long_double, dump_hexl_mode_trailer, + print_named_ascii, print_ascii, decode_one_format): + Use size_t, not off_t, for in-memory byte counts. + + (end_offset): New var. + (dump, dump_strings): Use it. + (main): Set it, but check for overflow while doing so. + + (skip): Report an error if an in-range lseek fails on a + regular file, as something's seriously wrong. Check for + negative regular file sizes (possible with some broken NFS + implementations). + + (parse_old_offset): Now all offsets are valid, so return a + success boolean and take a pointer to an offset as an argument. + All callers changed. + + (dump_strings): Check for overflow when computing end_offset - + string_min. + + (main): Remove OFF_T_MAX checks that are no longer needed. + Don't bother assigning through temporary when there's no size + limit to check. + +2001-09-19 Jim Meyering + + * src/od.c (open_next_file): Use SETVBUF, not setbuf. + (skip): Revert part of last change: use lseek, not fseek. + + When --read-bytes=N (-N N) is used, disable input buffering in + the standard I/O library. Otherwise, od would read more input + than requested. This could have caused problems when reading + from pipes, character devices, or open file descriptors inherited + from a parent process. + + * src/od.c (open_next_file): New function, factored out of... + (skip): Adapt to use open_next_file. + (read_char): Likewise. + (read_block): Likewise. + (main): Likewise. + (dump): Fix an off-by-one error that could have made od fail to + report a read error when reading from a named file (not stdin). + (check_and_close): Account for the fact that in_stream may now be NULL. + (usage): Correct descriptions of -j and -N options. + Patch by Ian Bruce. + +2001-09-16 Jim Meyering + + * Makefile.am (AUTOMAKE_OPTIONS): Require automake-1.5. + + * man/Makefile.am: Revamp this file, as for fileutils. + + * src/md5sum.c (digest_check): On systems for which setmode actually + does something, arrange to read the file containing checksum strings + in text mode. Based on a patch from Chris Faylor. + * src/system.h (SET_MODE): Define. + +2001-09-12 Jim Meyering + + The command `echo a|./fmt -2147483647' would cause fmt to segfault. + * src/fmt.c (fmt_paragraph): Test for sentinal directly, rather than + doing arithmetic with it's potentially large (INT_MAX) length. + * tests/fmt/basic: Add tests for the above. + + tail: accept new option: -F, equivalent to `--follow=name --retry', + for compatibility with FreeBSD and NetBSD versions of tail. + + * src/tail.c (usage): Describe new option. + (parse_options): Accept it. + Patch by Christian Kurz, via Herbert Xu. + + The command `echo foo|fmt -w N' for N>=32K would cause fmt to segfault. + + * src/fmt.c [struct Word]: Declare members length, space, and + line_length to be of type `int', not short. + (MAXCOST): Define using TYPE_MAXIMUM. + Reported by Herbert Xu. + +2001-08-31 Jim Meyering + + * src/fmt.c (bool): Remove typedef, now that it's in system.h. + (TRUE): Define to `true', not 1. + (FALSE): Define to `false', not 0. + +2001-08-30 Paul Eggert + + * src/cat.c: Include full-write.h. + (full_write): Remove decl; not needed. + * src/split.c: Likewise. + + * src/cat.c (simple_cat, cat): + Don't assume read and write size fits in int. + +2001-08-28 Jim Meyering + + * src/fmt.c (main): Correct the diagnostic for invalid argument to -w. + (main): Diagnose an invalid, old-style width option. + +2001-08-27 Jim Meyering + + * Makefile.maint: Undo last change. Instead, simply remove `N_(', + since the `Copyright ...' line should not be translated. + +2001-08-26 Jim Meyering + + * Makefile.maint (copyright-check): Update to reflect fact that + the copyright year is now defined separately. + +2001-08-08 Charles Randall + + * src/sort.c (mergefps): Do not allocate at least sort_size + bytes for each merge buffer. Instead, allocate at least + sort_size bytes total. + +2001-08-25 Jim Meyering + + * tests/uniq/Test.pm: Re-enable some commented-out tests. + +2001-08-25 Paul Eggert + + * src/uniq.c (main): Fix a typo in the previous patch: missing + a bounds check for examples like `uniq a b c'. + + * uniq.c (main): Fix some more incompatibilities with POSIX.2, + (e.g. `uniq +3 --' did not work) by invoking getopt_long with + leading '-', resembling what was done to 'sort' on 2001-03-20. + Recognize an +N option only if it is an integer in range, and + (if POSIXLY_CORRECT) only if a file name argument has not been seen; + otherwise silently treat it as a file name. + + If the user specifies too many operands, output the first one + in the error message, as a diagnostic aid. + +2001-08-24 Paul Eggert + + * src/uniq.c (main): Don't report an error when given the + valid options `+3 -d'. + +2001-08-24 Paul Eggert + + * src/uniq.c (different): Don't assume that lengths can fit + into size_t. Tune code for the common case where the line + lengths differ: we avoid comparing them entirely in that case. + +2001-08-25 Jim Meyering + + * tests/uniq/Test.pm: Add tests for -s 0 and -w 0. + +2001-08-24 Paul Eggert + + Remove arbitrary restrictions on sizes, fixing a bug reported + by Geoff Whale. + + * src/uniq.c (skip_fields, skip_chars, check_chars): Now size_t, + not int. + (size_opt): New function. Do not arbitrarily reject size zero. + Change the wording of the error message slightly, for convenience. + (find_field): Use size_t, not int, to compute sizes. + (different, main): check_chars==0 is no longer a special case, as + it defaults to SIZE_MAX. + (main): Check for overflow with args like -234234234234234. + Use 'size_opt' to convert optional arguments to sizes. + +2001-08-25 Jim Meyering + + * tests/uniq/Test.pm: Add new test, #54, for the just-fixed bug. + +2001-08-24 Paul Eggert + + * src/uniq.c (find_field): Don't count trailing newline to be + part of the field. This disagrees with POSIX.2, but it's + gotta be a bug in the standard. An interpretations request + has been submitted to PASC. + Reported by Geoff Whale. + +2001-08-18 Jim Meyering + + * Makefile.maint: Merge in changes from autoconf. + + * Makefile.maint ($(v_etc_file)): Define. + (copyright-check): Use the new variable. + (my-distcheck): Depend on local-check so those checks are once + again run by `make distcheck'. + + * src/head.c (head_bytes): Read no more than the specified + number of bytes. Patch by Ian Bruce. + + * tests/misc/head-c: New test for the above. + * tests/misc/Makefile.am: New file. + * tests/misc: New directory. + * tests/Makefile.am (SUBDIRS): Add misc. + * configure.in (AC_OUTPUT): Add tests/misc/Makefile. + +2001-08-14 Jim Meyering + + * src/Makefile.am (INCLUDES): Add -I../lib so sys2.h can include + the new, generated file, unlocked-io.h. + +2001-08-13 Jim Meyering + + * src/cat.c (AUTHORS): Mark string for translation, since it + contains the English word `and'. + * src/comm.c: Likewise + * src/csplit.c: Likewise + * src/cut.c: Likewise + * src/md5sum.c: Likewise + * src/nl.c: Likewise + * src/paste.c: Likewise + * src/pr.c: Likewise + * src/sort.c: Likewise + * src/split.c: Likewise + * src/sum.c: Likewise + * src/tac.c: Likewise + * src/uniq.c: Likewise + * src/wc.c: Likewise + +2001-08-12 Jim Meyering + + * tests/mk-script ($program_name): Define. + (main): Use $program_name, rather than long-inaccurate `build-script'. + (main): Iterate over the sorted keys (rather than `while...each...'), + so this script produces the same output regardless of which version + of perl (e.g., perl5.6) is used. + +2001-08-04 Jim Meyering + + * Makefile.am (EXTRA_DIST): Add Makefile.cfg. + + * man/Makefile.am (EXTRA_DIST): Remove duplicate definition. + +2001-07-08 Jim Meyering + + * src/tail.c (usage): Reformat so help2man generates a properly + indented man page. Patch by Herbert Xu. + +2001-07-04 Jim Meyering + + * Makefile.cfg: New file with package-specific definitions. + * Makefile.am (EXTRA_DIST): Add Makefile.cfg. + +2001-07-01 Jim Meyering + + * src/sort.c (usage): Suggest setting LC_COLLATE=C, rather + than LC_ALL=C. + +2001-06-10 Jim Meyering + + * tests/sort/Test.pm: Add a test based on a report from Herbert Xu. + +2001-05-20 Jim Meyering + + * src/uniq.c: Rename new option values: s/all/precede/ and + s/minimum/separate/. + * tests/uniq/Test.pm: Reflect the above renamings. + +2001-05-12 Bruno Haible + + * src/tail.c (parse_obsolescent_option): Accept a b suffix. + +2001-05-19 Jim Meyering + + msgmerge-0.10.37 complains about some `invalid multibyte sequences.' + * po/el.po: Remove the offending entries. + * po/ko.po: Likewise. + * po/zh.po: Likewise. + +2001-05-19 Jim Meyering + + Support new modes for uniq's --all-repeated option. + The default behavior is unchanged. + + * src/uniq.c: Include argmatch.h. + (usage): Update. + (check_file): Implement it. + (main): Handle new, optional arguments. + * tests/uniq/Test.pm: New tests for the above. + Patch by Padraig Brady. + +2001-05-12 Bruno Haible + + * src/tail.c (parse_obsolescent_option): Use t_count_lines, not + count_lines, in error message. + +2001-05-05 Jim Meyering + + * src/comm.c (usage): Correct description of -3. + Reported by Soeren Sonnenburg. + +2001-04-22 Jim Meyering + + * Version 2.0.14. + + * configure: Regenerate using a patched copy of autoconf-2.49e to + work around a bug in its test for a working memcmp function. + +2001-03-28 Paul Eggert + + * src/cksum.c: Fix bugs when computing length of large files. + Add overflow and write error checks. Use uint_fast32_t, not + unsigned long, to do checksum calculation, as C99 says + uint_fast32_t should be no slower and might be faster. + + Include and "system.h" even if CRCTAB is defined, + so that the code will compile if CRCTAB is defined. + Include "human.h" if CRCTAB is not defined. + (uint_fast32_t): Define if it appears that stdint.h didn't. + (BIT, remainder, main, crctab): Use uint_fast32_t, not unsigned long, + for checksums. + (fill_r, remainder, main): Use ANSI prototypes. + (fill_r, remainder, main): Omit duplicate code. + (main): Use uintmax_t, not unsigned long, for file lengths. + Use size_t, not long, for result of fread. + Check for overflow when computing file lengths. + Check for write error immediately after printing a line, so that + we don't write to stdout indefinitely after an error. + +2001-04-14 Paul Eggert + + * src/sort.c (default_sort_size): Leave a 1/16 margin for RSS. + Suggestion from Solar Designer. + +2001-04-14 Jim Meyering + + * src/wc.c (usage): Tweak --help output: s/line,/newline,/ + +2001-04-13 Jim Meyering + + * src/sort.c (main): Add a comment justifying the use of + `multi-character' rather than `multibyte' in a diagnostic. + From Paul Eggert. + +2001-04-12 Paul Eggert + + * src/sort.c (RLIMIT_AS): Do not define; just use conditional + code, since RLIMIT_RSS is similar (and is not standardized). + (default_sort_size): Don't allocate more than the RSS limit, + if this host has such a limit. + +2001-03-20 Paul Eggert + + * NEWS, doc/textutils.texi: sort now accepts long options and + checks POSIX option syntax. + + * doc/textutils.texi: Document --, -, sort long options, and + sort -o after files. + + * src/sort.c: Include . + (usage, main): Add support for long options, and check option + syntax as POSIX requires, though (as usual for GNU apps) + options can follow file names unless POSIXLY_CORRECT is set. + Many diagnostic revamped. + (long_options): New constant. + (badfieldspec): New arg MSGID. Mark as noreturn. + (parse_field_count): New arg MSGID; if null, just return null on error. + (new_key): Renamed from key_init. All callers changed. Now allocates + the new key. + +2001-03-18 Jim Meyering + + * Version 2.0.13. + + * tests/Fetish.pm: If the $DJDIR envvar is defined, set SHELL + to $DJDIR/bin/bash.exe. Patch from Richard Dawe, based on a + suggestion from Eli Zaretskii. + +2001-03-17 Paul Eggert + + * src/sort.c, src/tail.c, src/uniq.c (usage): + Warn that the +N form will be withdrawn. + * doc/textutils.texi: Likewise. + +2001-03-08 Paul Eggert + + * NEWS, doc/textutils.texi: Document pr changes. + + * src/pr.c: Include mbswidth.h. + (standard_header, header, test_suite): Remove. + (date_format, date_text, file_text, header_width_available): New vars. + (long_options, main, init_header, usage): + Add new -D or --date-format option. + (CHARS_FOR_DATE_AND_PAGE, T_BUF_FMT, T_BUF_SIZE, NO_DATE): Remove. + (init_header): Allow arbitrary width for date format. Change + "Page %5d" to "Page %d", since the code no longer assumes fixed width. + Do not assume that localtime succeeds. + (init_header, print_header, usage): Do not truncate headers. + (init_header, print_header): Defer width calculations until + page is printed, since "Page 100000" is wider than "Page 1". + Count columns, not bytes, in page headers. + Custom headers take up only the center, not the whole header. + (print_header): Use printf rather than fprintf(stdout). + + * po/Makefile.in.in (install-data-yes): Install LC_TIME locale + for all packages, not just for fileutils. + (uninstall): Remove LC_TIME locale too. + + * src/sys2.h (INT_STRLEN_BOUND): New macro. + + * tests/pr/0F, tests/pr/0FF, tests/pr/2-S_f-t_notab, + tests/pr/2-Sf-t_notab, tests/pr/2f-t_notab, + tests/pr/2s_f-t_notab, tests/pr/2s_w60f-t_nota, + tests/pr/2sf-t_notab, tests/pr/2sw60f-t_notab, + tests/pr/2w60f-t_notab, tests/pr/3-0F, tests/pr/3-5l17f-t, + tests/pr/3-FF, tests/pr/3a2l17-FF, tests/pr/3a3f-0F, + tests/pr/3a3l15-t, tests/pr/3a3l8f-t, tests/pr/3b2l17-FF, + tests/pr/3b3f-0F, tests/pr/3b3f-0FF, tests/pr/3b3f-FF, + tests/pr/3b3l15-t, tests/pr/3b3l8f-t, tests/pr/3f-0F, + tests/pr/3f-FF, tests/pr/3l17f-t, tests/pr/3l24-t, + tests/pr/3ml17f-t, tests/pr/3ml24-FF, tests/pr/3ml24-t, + tests/pr/3ml24-t-FF, tests/pr/4-7l24-FF, tests/pr/4l24-FF, + tests/pr/a2l15-FF, tests/pr/a2l17-FF, tests/pr/a3-0F, + tests/pr/a3f-0F, tests/pr/a3f-0FF, tests/pr/a3f-FF, + tests/pr/a3l15-t, tests/pr/a3l17f-lm, tests/pr/a3l8f-t, + tests/pr/b2l15-FF, tests/pr/b2l17-FF, tests/pr/b3-0F, + tests/pr/b3f-0F, tests/pr/b3f-0FF, tests/pr/b3f-FF, + tests/pr/b3l15-t, tests/pr/b3l17f-lm, tests/pr/b3l8f-t, + tests/pr/FF, tests/pr/Ja3l17f-lm, tests/pr/Jb3l17f-lm, + tests/pr/Jml17f-lm-lo, tests/pr/l17f-t, tests/pr/l24-FF, + tests/pr/l24-t, tests/pr/ml17f-0F, tests/pr/ml17f-lm-lo, + tests/pr/ml17f-t, tests/pr/ml17f-t-0F, tests/pr/ml20-FF-t, + tests/pr/ml24-FF, tests/pr/ml24-t, tests/pr/ml24-t-FF, + tests/pr/n+2-5l17f-0FF, tests/pr/n+2l17f-0FF, + tests/pr/n+2l17f-bl, tests/pr/n+3-7l24-FF, + tests/pr/n+3l17f-0FF, tests/pr/n+3l17f-bl, + tests/pr/n+3ml13f-bl-FF, tests/pr/n+3ml17f-bl-tn, + tests/pr/n+3ml17f-tn-bl, tests/pr/n+4-8a2l17-FF, + tests/pr/n+4b2l10f-0FF, tests/pr/n+5-8b3l10f-FF, + tests/pr/n+5a3l6f-0FF, tests/pr/n+6a2l17-FF, + tests/pr/n+6b3l6f-FF, tests/pr/n+7l24-FF, + tests/pr/n+8l20-FF, tests/pr/nJml17f-lmlmlo, + tests/pr/nJml17f-lmlolm, tests/pr/nl17f-bl, + tests/pr/nN1+3l17f-bl, tests/pr/nN15l17f-bl, + tests/pr/nSml13-bl-FF, tests/pr/nSml13-t-t-FF, + tests/pr/nSml13-t-tFFFF, tests/pr/nSml17-bl-FF, + tests/pr/nSml17-t-t-FF, tests/pr/nSml17-t-tFFFF, + tests/pr/o3a3l17f-tn, tests/pr/o3a3Sl17f-tn, + tests/pr/o3a3Snl17f-tn, tests/pr/o3b3l17f-tn, + tests/pr/o3b3Sl17f-tn, tests/pr/o3b3Snl17f-tn, + tests/pr/o3Jml17f-lm-lo, tests/pr/o3ml17f-bl-tn, + tests/pr/o3mSl17f-bl-tn, tests/pr/o3mSnl17fbltn, + tests/pr/Test.pm, tests/pr/W-72l17f-ll, tests/pr/W20l17f-ll, + tests/pr/W26l17f-ll, tests/pr/W27l17f-ll, + tests/pr/W28l17f-ll, tests/pr/W35a3l17f-lm, + tests/pr/W35b3l17f-lm, tests/pr/W35Ja3l17f-lm, + tests/pr/W35Jb3l17f-lm, tests/pr/W35Jml17f-lmlo, + tests/pr/W35ml17f-lm-lo, tests/pr/W72Jl17f-ll, + tests/pr/w72l17f-ll: + Adjust to minor spacing changes in pr headers. + +2001-03-11 Paul Eggert + + * src/sort.c (die): New message arg, to describe failures + better. All callers changed. + +2001-03-11 Paul Eggert + + * src/sort.c: Decrease buffer size when only merging or checking. + (sort_size): Now the user-specified sort size. + (MIN_MERGE_BUFFER_SIZE): New macro. + (MIN_SORT_SIZE): Use it. + (merge_buffer_size): New variable. + (fillbuf): Increase merge_buffer_size if a longer line is encountered. + (checkfp, mergefps): Do not allocate a buffer smaller than + merge_buffer_size. + (sort): Use the default_sort_size if sort_size is zero. + (main): Do not set sort_size to default_sort_size. + +2001-03-06 Paul Eggert + + * src/sort.c (sort): If all the input files are empty, create + an empty output file. + * tests/sort/Test.pm: Test for this. + +2001-03-13 Jim Meyering + + * src/sort.c (merge): Move declarations of local variables into + the inner scope where they're used. + (sort): Likewise. + +2001-03-06 Paul Eggert + + Avoid the need for a copy of the input file when the input and + output overlap, e.g. 'sort F -o F'. With -m, though, a copy + is still needed sometimes. + + * doc/textutils.texi: 'sort F -o F' no longer needs to copy F. + + * src/sort.c: Do not include closeout.h. + (xfopen): Use stdout if *how != 'r'. + (mergefps): Remove FPS arg. + Open all input files, and close all files when done. + If OFP is null, open the output file (but after opening input files). + All callers changed. + (first_same_file): New function. + (sort, merge): Remove arg OFP; we now open the output file as needed. + All callers changed. + (merge): New arg MAX_MERGE. All callers changed. + (sort): For "sort F -o F", close the input before opening the output. + (main): Do not use close_stdout; 'sort' and 'merge' now close stdout. + (This also fixes a close-stdout-twice bug.) + Remove test for overlapping input and output files, as 'sort' no longer + needs to worry about overlap, and 'merge' checks for overlap itself. + Use first_same_file to inform 'merge' about how much to merge at + the top level, to avoid overlap. + +2001-03-12 Jim Meyering + + `fmt --prefix=S' would not work properly for any string S containing + a byte with the high bit set. + * src/fmt.c (prefix): Declare to be of type unsigned char, not `char'. + (get_prefix): Likewise for local, `p'. + Reported by François Pinard. + + Add a test for the above-fixed problem. + * tests/fmt: New directory/files. + * configure.in (AC_OUTPUT): Add tests/fmt/Makefile. + * tests/Makefile.am (SUBDIRS): Add fmt. + +2001-03-05 Andreas Schwab + + * src/tac.c (save_stdin): Use mkstemp to create temporary file. + +2001-03-09 Jim Meyering + + * Makefile.maint (my_distdir): Define new variable, and use this + in place of most old uses of $(distdir). + + * tests/help-version: Ensure that /dev/full is a character device + (using test -c) as well as being writable, before trying to write to it. + Otherwise, the test could mistakenly append a newline to an existing, + regular, writable, /dev/full file. + Suggested by Ulrich Drepper. + +2001-03-08 Jim Meyering + + * tests/sha1sum/sample-vec: Insert the `--text' argument for each test. + Reported by Matthew Smith. + +2001-03-04 Jim Meyering + + * Makefile.maint (my_distdir): Define. + Use it in place of $(distdir) almost everywhere. + + * Version 2.0.12. + + * Makefile.maint (alpha): Use $(PACKAGE)-$(VERSION), not $(distdir), + since the latter now has a `$(top_distdir)/' prefix. + +2001-03-01 Paul Eggert + + * src/sort.c (die): New function. + (create_temp_file, xfopen, xfclose, write_bytes, sort_buffer_size, + fillbuf, main): Use it to regularize error messages. The only change + in behavior is that write_bytes and the final close used to say "write + error" but now give just the output file name, which should be enough. + +2001-03-01 Paul Eggert + + * src/sort.c (xfclose): Add FILE arg, and report the file name + on error. All callers changed. + +2001-03-01 Paul Eggert + + * src/sort.c (main): When fclose (stdin) fails, do not mention + the output file in the error message; mention "-" instead. + +2001-02-28 Paul Eggert + + * src/sort.c (xfopen): Set have_read_stdin to 1 only if file is "-". + Use fopen_safer, not fopen, to avoid subtle bugs when fopen returns + stdin, stdout, or stderr. + (xfclose): stdout is no longer a special case. + (main): Close output file, don't just flush it; there might be + an error on the close. + +2001-02-27 Paul Eggert + + * src/sort.c (initbuf): If the desired size cannot be + allocated, repeatedly halve it until allocation succeeds. + Reported by Solar Designer. + +2001-02-26 Paul Eggert + + * src/sort.c (parse_field_count): Comment fix. + +2001-02-25 Paul Eggert + + * src/sort.c: Tune allocation and comparison of nodes + representing temp files. This improved CPU performance of + 'sort -S 1 *.[ch]' by 17% on my host. + + (struct tempnode): name member now uses struct hack. + (temphead): Now a pointer, not a structure. All uses changed. + (create_temp_file): Allocate node using struct hack. + (zaptemp): Free node using struct hack. Use pointer comparison, not + string comparison. + +2001-02-25 Paul Eggert + + * src/sort.c (eolchar, trim_trailing_blanks): Now static. + +2001-02-25 Paul Eggert + + 'sort' race condition fixes. + + Defend against a DoS attack where someone else creates a + temporary file with the same name as ours. Use mkstemp to do + this, supplying our own mkstemp if the system doesn't have one. + + Also, fix a race condition during cleanup on hosts without + sigaction. + + * src/sort.c (NAME_MAX_IN_DIR): Remove. + (sigprocmask, sigset_t): New macros, defined only on older hosts. + (caught_signals): New var. + (xtmpfopen, tempname): Removed. + (create_temp_file): New function, combining the functions of the old + xtmpfopen and tempname. All callers changed. + Use mkstemp to create the file. + (sighandler): On hosts without sigaction, ignore signals while + cleaning up, instead of letting them interrupt cleanup. + (main): Initialize caught_signals. On hosts with sigaction, block all + caught signals while handling one. Remove duplicate code. + +2001-02-22 Jim Meyering + + * src/sort.c (keycompare): Move declarations of locals, lena and lenb, + into the inner scope where they are used. + +2001-02-19 Jim Meyering + + * src/sort.c (AUTHORS): Add Paul Eggert. + + * src/wc.c (wc): Rename innermost `buf' to avoid shadowing warning. + (wc): Rename local `wc' to avoid shadowing function name. + +2001-02-18 Paul Eggert + + Fix a race condition: freed storage accessed during a signal handler. + + * src/sort.c (struct tempnode.next): Now volatile. + (zaptemp): Free the file name after removing it from the temp list, + not before, because a signal can arrive between the two actions + and cleanup () traverses the list. + +2001-02-18 Paul Eggert + + Check for input size, and do not overallocate memory. + Also check for memory quotas. + + Revamp storage management so that line tables and character data are + taken from the same buffer. Line tables are now in reverse order, + since they grow down while the character data grow up. + + * src/sort.c: + (): Include if HAVE_SYS_RESOURCE_H. + (struct rlimit, getrlimit): Define a replacement if RLIMIT_DATA + is not defined. + (RLIMIT_AS): Define to RLIMIT_DATA if not defined. + (struct lines): Remove. + (struct buffer): New members nlines, line_bytes, eof. + Remove member newline_free; no longer needed, since the code no longer + runs out of line table space. + (SORTALLOC_MIN, SORTALLOC_DEFAULT_MIN): Remove. + (sort_size): Renamed from sortalloc; now applies to the sum of the + character data and the line table, not just the character data. + (MIN_SORT_SIZE, INPUT_FILE_SIZE_GUESS): New macros. + (linelength): remove. + (specify_sort_size): Don't worry about the distinction between the + character data and the line table; that is now the caller's + responsibility. + (default_sort_size): Return the value, instead of being executed for + side effect. Return half of available memory, or 1/16 of total memory, + whichever is greater; except do not exceed 1/2 of quota. + (sort_buffer_size): New function. + (initbuf): New arg LINE_BYTES. Ensure that the line array is properly + aligned. Initialize the new set of struct buffer members. + (buffer_linelim): New function. + (fillbuf): Return int, not size_t, since the callers merely care + whether the result is nonzero. New arg FILE so that error messages + can report the file name. Keep track of eof. Initialize the line + table too, taking its memory from the input buffer's memory; this + subsumes the old findlines function and removes the need for worrying + about running out of line table entries. + (checkfp, mergefps, sortlines, merge, sort): Adjust to the new storage + management regime, in particular the fact that line tables are now + filled in by fillbuf and are in reverse order. + (checkfp): Now takes char *, not const char *, since subroutines + require that now. Rewrite to avoid lint and duplicate code. + If line length alloc calculation overflows, + simply allocate enough memory to hold the line. + (mergefps): New arg FILES, used for buffer size calculation and error + messages. Rewrite to avoid lint. Do not loop if savealloc*2 + overflows. + (mergefps, merge): Zap temporary files eagerly rather than lazily; + this is needed because we now pass FILES to mergefps. + (sortlines): Args now point at end of arrays, not at beginnings. + (sort): Do not allocate temporary line array for sortlines; + instead, take the space from the same buffer. + (main): Adjust to sort_size and default_sort_size changes. + +2001-02-18 Jim Meyering + + Rename test input files to avoid conflicts on case-insensitive + file systems. + * tests/pr/2-Sf-t_notab: Rename from 2Sf-t_notab. + * tests/pr/2-S_f-t_notab: Rename from 2S_f-t_notab. + * tests/pr/W-72l17f-ll: Rename from W72l17f-ll. + * tests/pr/Test.pm: Update file names to reflect renamings. + Reported by Matthew Smith. + +2001-01-20 Jim Meyering + + * configure.in: Remove jm_CHECK_ALL_TYPES. + Now it's invoked by jm_MACROS. + +2001-01-17 Jim Meyering + + * src/cksum.c (main): Use PACKAGE, not GNU_PACKAGE. + * src/tsort.c (main): Likewise. + * src/sort.c (main): Likewise. + (usage): Convert each TAB in --help output to a sequence of 8 spaces. + +2001-01-07 Jim Meyering + + * src/tail.c (usage): Split a string that was longer than 2048 bytes. + +2001-01-03 Jim Meyering + + * src/sort.c (main): Remove embedded \n from diagnostic. + +2001-01-02 Jim Meyering + + * src/od.c (ulonglong_t): Define place-holder type to avoid some #if + directives. + (LONGEST_INTEGRAL_TYPE): Remove definition. + (MAX_INTEGRAL_TYPE_SIZE): Use ulonglong_t instead of + LONGEST_INTEGRAL_TYPE. + (print_long_long): Compile this function even on systems without + long long support. + (decode_one_format): Remove #if directive. + + * src/od.c (decode_one_format): Guard use of print_long_long with + `#if HAVE_UNSIGNED_LONG_LONG'. From Darren Salt. + Change all `#ifdef HAVE_UNSIGNED_LONG_LONG' to use `#if' instead. + +2000-12-23 Jim Meyering + + * src/sys2.h [HAVE_INTTYPES_H]: Include . + +2000-12-19 Jim Meyering + + * Version 2.0.11. + +2000-12-18 Paul Eggert + + * NEWS, doc/textutils.texi: New "sort" option -S SIZE. + + * src/sys2.h (UINTMAX_MAX): New macro, taken from C99. + + * src/sort.c: Include physmem.h. + (SORTALLOC, mergealloc, LINEALLOC): Remove. + (sortalloc): Default to zero at program startup. + (SORTALLOC_MIN, SORTALLOC_DEFAULT_MIN): New macros. + (usage, main): Add support for new -S SIZE option. + (specify_sort_size, default_sort_size): New functions. + (initlines): Do not let alloc exceed limit. + (findlines): Likewise. + (checkfp, mergefps, sort): Use sortalloc to size everything + else, instead of relying on precomputed sizes. + +2000-12-17 Jim Meyering + + * doc/texinfo.tex: Update from master repository. + * config.sub: Likewise. + * config.guess: Likewise. + +2000-12-11 Jim Meyering + + * Version 2.0.10. + +2000-12-07 Jim Meyering + + * src/od.c (address_base): Declare to be static. + +2000-12-06 Paul Eggert + + * src/od.c (address_base, address_pad_len): New var. + (output_address_fmt_string, address_fmt_buffer, address_pad): Remove. + (flag_pseudo_start): Now int, not long int. + (pseudo_offset): Now off_t, not long int. + (n_specs, n_specs_allocated): Now size_t, not unsigned int. + (format_address, format_address_none, format_address_std, + format_address_label): Now accepts an extra char argument (an extra + char to print if nonzero), and prints instead of returning a string. + All callers changed. + (bytes_per_block): Now size_t, not int. + (format_address_none): Do not even print the extra char argument. + This simplifies the callers. + (format_address_std, format_address_label): Print off_t ourself + instead of trying to use autoconfigured format. This is faster and + more portable. + (format_address_paren): New function. + (dump): Remove unnecessary cast. + (expand_address_fmt): Remove. + (main): Use size_t, off_t, etc. instead of builtin types where this is + advisable. Adjust to above changes. Remove unnecessary cast. + +2000-12-03 Jim Meyering + + * src/tail.c (tail_file): Initialize ignore, dev, and ino members, + when tailing forever and the open failed. Otherwise, we could get + uninitialized memory references of those fields in recheck. + * tests/tail-2/Makefile.am (TESTS): Add assert-2. + * tests/tail-2/assert-2: New file. + + * Version 2.0.9. + + Make od print valid addresses for offsets of 2^32 and larger, and + allow byte offset (-j) and byte count (-N) to be 2^32 and larger. + + * src/od.c (MAX_ADDRESS_LENGTH): Don't hard-code as a literal. + Rather, define in terms of the type, off_t. + (string_min): Declare to be of type size_t. + (flag_dump_strings): Declare to be of type int. + (print_s_char): Declare the n_bytes parameter and the local, `i', + to be of type off_t. + (print_char): Likewise. + (print_s_short): Likewise. + (print_short): Likewise. + (print_int): Likewise. + (print_long): Likewise. + (print_long_long): Likewise. + (print_float): Likewise. + (print_double): Likewise. + (print_long_double): Likewise. + (dump_hexl_mode_trailer): Likewise. + (print_named_ascii): Likewise. + (print_ascii): Likewise. + (write_block): Likewise. + (print_ascii): Declare local, `print_function' with a prototype. + Change a few `>' comparisons to the equivalent `<' form. + (parse_options): Declare `tmp' to be of type uintmax_t. + Use xstrtoumax, not xstrtoul. + Fail if the specified offset if larger than OFF_T_MAX. + (dump_strings): Declare local `i' to be of type size_t. + Remove the now-unnecessary cast-to-off_t. + (main) [IF_LINT]: Initialize desired_width to avoid a warning. + Declare `tmp' to be of type uintmax_t. + Use xstrtoumax, not xstrtoul. + Fail if minimum string length is larger than SIZE_MAX. + Fail if specified width is larger than ULONG_MAX. + + * src/od.c (format_address): Use off_t, not long unsigned_int as the + parameter type. + (format_address_none): Likewise. Mark parameter as unused. + (format_address_std): Likewise. + (format_address_label): Likewise. + (print_ascii): Mark format string parameter as unused. + (write_block): Use off_t, not long unsigned_int as offset type. + (expand_address_fmt): New function. + (main): Use it to expand each address format string template. + Reported by Mark Nudelman, via Andreas Jaeger. + + * src/sys2.h (OFF_T_MIN): Define here instead. + (OFF_T_MAX): Likewise. + (CHAR_BIT): Define. + + * src/tail.c (parse_options): Use xstrtoumax to parse the byte and line + offset. Give a better diagnostic when the requested offset is still + representable but larger than OFF_T_MAX. + (OFF_T_MIN): Remove definition. + (OFF_T_MAX): Likewise. + +2000-12-02 Jim Meyering + + * src/sort.c (checkfp): Rename local `buf' to avoid shadowing previous + declaration. + + * src/sort.c (NONZERO): Define and use it to make the code a tiny + bit more readable. + + * doc/textutils.texi (sort invocation): Clarify how -t works + when a sort key specifies a range of fields. From Karl O. Pinc. + +2000-11-26 Paul Eggert + + * src/od.c (skip): Use lseek instead of worrying about fseeko or fseek. + This should be portable, as we seek before doing any I/O. + (fseeko): Remove; no longer used. + +2000-11-30 Jim Meyering + + * src/sort.c: s/SIZE_T_MAX/SIZE_MAX/. + +2000-11-30 Paul Eggert + + * src/sys2.h: Include if HAVE_STDINT_H. + (SIZE_MAX): Renamed from SIZE_T_MAX, as C99 uses SIZE_MAX. + All uses changed. + +2000-11-30 Jim Meyering + + * src/sort.c: SIZE_MAX is not defined, so s/SIZE_MAX/SIZE_T_MAX/, and... + * src/sys2.h (SIZE_T_MAX): ... define. + +2000-11-29 Paul Eggert + + Port GNU "sort" to hosts where sizes don't fit in "int", + e.g. 64-bit Solaris (sparc). + + * src/sort.c ("human.h", "xstrtol.h"): Include. + (struct line): length member is now size_t, not int. + (struct lines): Likewise for used, alloc, limit members. + (struct buffer): Likewise for used, alloc, left, newline_free members. + (struct keyfield): Likewise for sword, schar, eword, echar members. + (sortalloc, mergealloc, linelength): Now size_t, not int. + + (initbuf, fillbuf, initlines, begfield, limfield, findlines, + numcompare, getmonth, keycompare, compare, checkfp, mergefps, + sortlines, sort): Accept, return, and use size_t for sizes, not int. + + (fillbuf, initlines, findlines, checkfp, sort): Check for overflow + when computing buffer sizes. + + (begfield, limfield): Do not index past end of array. + + (checkfp): Return a boolean, not a line number, as the line + number may not fit in int. All callers changed. Use + uintmax_t for line numbers, not int. + + (sort): Don't allocate tmp until we need it (and know the right size). + + (parse_field_count): New function. + + (main): Use it to check for overflow in field counts. + "outfile" is now a pointer to const. + +2000-11-27 Jim Meyering + + * src/checksum.h: Don't include system.h here. + * src/md5.c: Include config.h, stdio.h, sys/types.h. and system.h here + instead. + * src/sha1sum.c: Likewise. + +2000-11-18 Paul Eggert + + * src/pr.c (main): Do not assume EOF == -1. + Handle the case correctly when digits options immediately precede a + non-option. + +2000-11-18 Jim Meyering + + * doc/textutils.texi: Change GNU to @sc{gnu} in many places. + Update to use the Free Documentation Licence. + + * configure, config.h.in, Makefile.in, etc.: Regenerate using the + very latest version (in CVS) of autoconf. + +2000-11-17 Jim Meyering + + * GNUmakefile (.NOTPARALLEL): New target. Prevent unwanted parallelism. + Suggestion from Ulrich Drepper. + +2000-11-16 John David Anglin + + * tsort.c: Include sys/types.h before system.h. + +2000-11-16 Jim Meyering + + * src/join.c: Declare global `tab' to be of type *unsigned* char, + so join works with 8-bit delimiter characters. + Reported by Antonio Rendas. + * tests/join/Test.pm (8-bit-t): New test for the above fix. + +2000-11-13 Paul Eggert + + * src/sys2.h (ST_TIME_CMP_NS): Fix typo: ST_MTIM_NSEC should + be tested with #ifdef, not with #if. + +2000-11-11 Jim Meyering + + * doc/textutils.texi: More minor rewording and grammar correction. + From Brian Youmans. + +2000-11-06 Paul Eggert + + * src/od.c (skip): st_size is not defined for directories. + +2000-11-03 Jim Meyering + + * tests/sha1sum/sample-vec: New file, with tests derived from + http://csrc.nist.gov/cryptval/shs/sha1-vectors.zip + * tests/sha1sum/Makefile.am (TESTS): Add sample-vec. + +2000-10-30 Jim Meyering + + * configure, config.h.in, Makefile.in, etc.: Regenerate using the + very latest version (in CVS) of autoconf. + + * src/wc.c: Include "system.h" after wctype.h (not before) + to avoid a compilation error on Solaris 5.5.1 systems. + Reported by Vin Shelton. + +2000-10-23 Jim Meyering + + * Makefile.maint: Clean up version-related variables. + + * Version 2.0.8. + + * Makefile.am (EXTRA_DIST): Add .prev-version. + +2000-10-22 Jim Meyering + + * tests/Makefile.am (SUBDIRS): Add sha1sum. + * tests/sha1sum/basic-1: New file. + * configure.in (AC_OUTPUT): Add tests/sha1sum/Makefile. + + * src/Makefile.am (bin_PROGRAMS): Add sha1sum. + (md5sum_SOURCES): Define. + (sha1sum_SOURCES): Define. + (noinst_HEADERS): Add checksum.h. + + * src/md5sum.c: Factor out the differences between MD5 and SHA1, + and parameterize so this code may be used by both md5sum and the new + program, sha1sum. Loosely based on a patch from Scott Miller. + * src/checksum.h: New file. + * src/md5.c: New file that simply defines `algorithm'. + * src/sha1sum.c: Likewise. + + * man/Makefile.am (man_MANS): Add sha1sum.1. + * man/sha1sum.x: New file. + + Support 8-byte integers, assuming they're printable with e.g., %lld. + * src/od.c: Add support for printing data as unsigned + long long integers. + +2000-10-21 Jim Meyering + + The command, `yes ''|./cat -n' would stop printing after INT_MAX lines. + * src/cat.c (cat): Never let `newlines' exceed 3. + +2000-10-21 Jim Meyering + + Prevent a counter buffer overrun when numbering lines and when + processing 100 billion lines (or more) of input. + * src/cat.c (LINE_COUNTER_BUF_LEN): Define to allow numbering as + many as 10^18 - 1 lines (the old limit was 10^11 - 1, and could + be exceeded without too much trouble). Use this symbol rather + than hard-coding the constant everywhere. + (next_line_num): Rather than overrunning for input with more lines, + mark the line number by putting a `>' in the leftmost slot. + Patch by Jan Nieuwenhuizen. + + * src/sort.c (SORT_OUT_OF_ORDER): Define. + (main): Use it instead of hard-coding the `1'. + +2000-10-10 Jim Meyering + + * src/sort.c (main): Use EXIT_SUCCESS rather than 0. + Fail when checking (-c) with more than one file argument, + rather than simply ignoring the extra arguments. + +2000-09-07 Jim Meyering + + * src/cut.c: Remove obsolete comment block. + (usage): Note that when using -f, lines with no delimiters are + also printed. + * doc/textutils.texi (cut invocation): Likewise. + +2000-08-23 Jim Meyering + + * src/md5sum.c: Include unconditionally, to be consistent + with all the other programs in this directory. + * src/tsort.c: Likewise. + +2000-08-19 Jim Meyering + + * src/comm.c (writeline): Correct comments. From Bruno Haible. + +2000-08-11 Paul Eggert + + * doc/textutils.texi: + + Portable shell scripts should specify global options before + key fields. + + Move global LC_CTYPE remark to each sort option that depends + on LC_CTYPE. + + sort -g depends on LC_NUMERIC. + + Add @vindex where it's missing. + + "radix character" -> "decimal-point character", to match Standard C + terminology, which is easier for most people to follow. + + "comm" does not consider trailing newlines to be significant. + +2000-08-10 Paul Eggert + + * doc/textutils.texi: Recommend against the System V syntax + for tr ranges, and don't use it in examples. Use POSIX + classes rather than ranges, for portability. + * src/tr.c (usage): Don't describe System V syntax, as it + doesn't always work. + + * src/sort.c (usage): Describe -d and -i in a locale-independent way. + + * doc/Makefile.am (constants.texi): Use the C locale so that + [A-Z] works as expected. + +2000-08-07 Paul Eggert + + * src/cut.c (cut_fields): Invoke xalloc_die instead of printing + our own message. + (cut_fields): Check for I/O error as well as end-of-file + +2000-08-06 Bruno Haible + + * src/wc.c: Add support for multi-byte locales. + (iswprint, mbrtowc, wcwidth): Provide default definitions. + (total_bytes): New variable. + (print_bytes): New variable. + (longopts): Change abbreviation for --chars from 'c' to 'm'. + (usage): Update. + (write_counts): Add `bytes' argument. + (wc): New variables `bytes', `count_bytes', `count_chars', + `count_complicated'. The old code determines `bytes', not `chars'. + New case for MB_CUR_MAX > 1. A non-printable non-space character does + not increment the line position or start a word. Update `total_bytes'. + (main): Initialize `print_bytes' and `total_bytes' to 0. Accept 'm' + option. Pass `total_bytes' to write_counts. + * doc/textutils.texi (wc invocation): Update accordingly. + +2000-08-06 Bruno Haible + + * src/head.c (head): Call write_header here. + (head_file): ... not here. + + * src/cat.c (closeout_func): Remove variable. + (close_stdout_wrapper): Remove unused function. + (main): Remove assignment to closeout_func. + + * src/fold.c (fold_file): Remove ferror(stdout) check, already done + in close_stdout. + +2000-08-06 Paul Eggert + + * src/sort.c (usage): Warn more succinctly about the effects of + the locale on sort order. + +2000-08-06 Jim Meyering + + * Version 2.0g. + + * src/tail.c (pipe_lines): Declare local `cp' to be const. + +2000-08-04 Greg McGary + + * src/tail.c (pipe_lines): Add variable `nbytes' so we can free + `tmp' immediately after read loop. Don't process an empty file. + [This fixes a buffer-underrun error -- detected thanks to + bounded pointers -jmm] + +2000-08-05 Jim Meyering + + Fix buffer-overrun error. + * src/pr.c (init_header): Allocated buffer was sometimes too small. + Reported by Greg McGary (who found this bug using his + bounded-pointers-enabled gcc). + (init_header): Move declarations of several variables into the + inner scope where they are used. + * tests/pr/Test.pm (narrow-1): New test, for the above. + + * src/csplit.c (MAX): Remove definition (It's in sys2.h). + +2000-08-04 Jim Meyering + + * src/sort.c (main): Rename local `t' to `tmp_dir' to avoid shadowing + a previous local by that name. + (usage): Warn that GNU sort is now locale-aware, and suggest + people put LC_ALL=POSIX in their environment. + + * src/pr.c (store_columns): Remove conjunct that would dereference + an out-of-bounds pointer. Reported by Greg McGary (who found this + bug using his bounded-pointers-enabled gcc). + +2000-08-03 Jim Meyering + + * tests/Makefile.am.in ($(srcdir)/$x-tests): Use -I$(srcdir), not `-I.'. + (Makefile.am): Likewise. Reported by Greg McGary. + +2000-08-01 Jim Meyering + + * doc/textutils.texi (tr invocation): Note that ranges are not portable. + Update examples not to use ranges. + +2000-07-31 Jim Meyering + + * src/cut.c (cut_fields): Use `virtual memory exhausted', + not `Memory exhausted'. + +2000-07-30 Jim Meyering + + * src/help-version: Remove file. Move it to ... + * tests/help-version: ...here + * tests/Makefile.am (TESTS): Set to help-version. + (TESTS_ENVIRONMENT): Define. + (EXTRA_DIST): Add $(TESTS). + * src/Makefile.am (EXTRA_DIST): Remove help-version. + (TESTS): Remove definition. + (TESTS_ENVIRONMENT): Remove definition. + +2000-07-28 Paul Eggert + + sort's -T option can now appear multiple times. + Thanks to Charles Randall for suggesting this idea. + + * doc/textutils.texi, NEWS: Document this. + + * src/sort.c (temp_dir): Remove. + (temp_dirs, temp_dir_count, temp_dir_alloc): New vars. + (process_id): New var. + (usage): Describe new use of -T. + (add_temp_dir): New function. + (tempname): Use new temp_dirs array. + Do not discard information from the process-id or sequence + number, unless we have short file names. + (sighandle): Use process_id instead of getpid. + (main): Initialize process_id. + Add support for the new use of -T. + +2000-07-23 Jim Meyering + + * tests/head/Test.pm: Rename tests (and hence files) to have a short + enough prefix so that they're not truncated on 8+3 file systems. + Reported by Eli Zaretskii. + +2000-07-09 Jim Meyering + + * config.guess: Update from FSF. + * config.sub: Likewise. + +2000-07-02 Jim Meyering + + * Version 2.0f. + +2000-07-01 Jim Meyering + + * src/cut.c: Change type of global, field_1_bufsize, from int to size_t. + +2000-06-29 Jim Meyering + + * src/tr.c (find_bracketed_repeat): Add a cast to suppress a warning. + Reported by Gerhard Poul. + + * src/tail.c (enum): Remove comma from end of enumerator list. + From Gerhard Poul. + +2000-06-25 Jim Meyering + + * configure.in (ALL_LINGUAS): Add Danish (da). + +2000-06-24 Jim Meyering + + * doc/textutils.texi: Lots of minor rewording and grammar correction. + From Brian Youmans. + + * tests/sum/basic-1: New file. + * tests/sum/Makefile.am: New file. + * configure.in (AC_OUTPUT): Add tests/md5sum/Makefile. + * tests/Makefile.am (SUBDIRS): Add sum. + +2000-06-22 Bruno Haible + + * src/sum.c (sysv_sum_file): Avoid overflowing 32-bit accumulator + on files whose bytes sum to 2^32 or larger. The smallest such file + contains 16,843,010 bytes, nearly all of which have the value 0xff. + +2000-06-22 Bruno Haible + + * src/cat.c (main): Correct a comment. + +2000-06-21 Jim Meyering + + * src/cut.c (getstr): Remove private (and out of date) version of + this function. + (cut_fields): Adjust caller to use the just-extended one in ../lib. + Reported by Paul Sauer. + +2000-06-20 Jim Meyering + + * src/uniq.c (main): Fix off-by-argc test, so +N-style options are + recognized once again. Reported by Geoff Keunning. + Fix typo in diagnostic: s/compare/skip/. + +2000-05-27 Jim Meyering + + * src/tail.c: Arrange to call close_stdout upon exit. + Don't close stdout explicitly. + (usage): Add missing backslash at end of line. + (write_header): Remove now-unused COMMENT parameter. + Update all callers. + +2000-05-24 Jim Meyering + + * src/head.c (head_file): Use STDIN_FILENO in place of `0'. + (main): Likewise. + +2000-05-20 Jim Meyering + + * src/cat.c: Arrange to call close_stdout upon exit. + Don't close stdout explicitly. Replace uses of global constant, + output_desc, with uses of STDOUT_FILENO. + + Arrange to call close_stdout upon exit. Don't close stdout explicitly. + * src/cksum.c: Likewise. + * src/comm.c: Likewise. + * src/csplit.c: Likewise. + * src/cut.c: Likewise. + * src/expand.c: Likewise. + * src/fmt.c: Likewise. + * src/fold.c: Likewise. + * src/head.c: Likewise. + * src/join.c: Likewise. + * src/md5sum.c: Likewise. + * src/nl.c: Likewise. + * src/od.c: Likewise. + * src/paste.c: Likewise. + * src/pr.c: Likewise. + * src/ptx.c: Likewise. + * src/sort.c: Likewise. (but set exit status and file name, too) + * src/split.c: Likewise. + * src/sum.c: Likewise. + * src/tac.c: Likewise. + * src/tr.c: Likewise. + * src/tsort.c: Likewise. + * src/unexpand.c: Likewise. + * src/uniq.c: Likewise. + * src/wc.c:: Likewise. + +2000-05-13 Jim Meyering + + * src/help-version: Run each program successfully at least once. + +2000-05-12 Jim Meyering + + * src/head.c (string_to_integer): Restrict base to 10. + Reported by Joseph S. Myers. + * tests/head/Test.pm: Add a few tests for this. + + New option: --first-only + * src/unexpand.c (anonymous enum) [CONVERT_FIRST_ONLY_OPTION]: Define. + (long_options): Add `first-only'. + (main): Handle new option. + +2000-05-11 Jim Meyering + + * tests/unexpand/basic-1: New tests. + +2000-04-17 Bruno Haible + + * src/system.h [__BEOS__]: Ignore O_BINARY and O_TEXT. + +2000-04-16 Jim Meyering + + * src/tail.c: Prepare to remove option: --max-consecutive-size-changes. + Doesn't seem useful. + (usage): Remove description. + * doc/textutils.texi (tail invocation): Remove description. + +2000-04-12 Jim Meyering + + * src/tail.c (usage): Tweak --help output. Suggestions from Karl Berry. + + Move some macros into m4/. + * configure.in (_GNU_SOURCE): Don't define here. + (AC_SYS_LARGEFILE): Don't use here. + (AM_C_PROTOTYPES): Don't use here. + * acconfig.h: Remove now-unused file. + +2000-04-09 Jim Meyering + + * doc/textutils.texi: Include constants.texi. + (tail invocation): Use `@value's instead of referring to the + output of `tail --help' for defaults. + * doc/Makefile.am (constants.texi): New rule. + (EXTRA_DIST): Add constants.texi. + (MAINTAINERCLEANFILES): Add it here, too. + (textutils.dvi, textutils.info): Depend on constants.texi. + + * src/tail.c (usage): Clarify descriptions of the --max-* options. + From Karl Berry. + +2000-04-03 Jim Meyering + + * configure.in (AC_CHECK_HEADERS): Remove langinfo.h. Now it's in m4/. + (AC_CHECK_FUNCS): Remove nl_langinfo. Now it's in m4/. + +2000-03-17 Jim Meyering + + * configure.in (ALL_LINGUAS): Add Slovenian (sl). + +2000-03-12 Jim Meyering + + Merge from fileutils. + * src/system.h "pathmax.h": Include. + : Include if appropriate. + : Likewise. + : Likewise. + : Likewise. + : Likewise. + (major, minor, makedev): Define if needed. + (struct utimbuf): Declare if missing. + (ST_BLKSIZE, ST_NBLOCKS, ST_NBLOCKSIZE): Define. + + * src/cksum.c (usage): Correct --help output. + Prompted by a report from Gregory Leblanc. + +2000-03-05 Paul Eggert + + * src/sort.c (struct buffer.newline_free): New member. + (initbuf, findlines): Set it. + (fillbuf): Do not double the size of a full buffer to append a newline + unless the buffer is known to be newline free. + +2000-03-05 Jim Meyering + + * Version 2.0e. + +2000-03-04 Jim Meyering + + Don't get failed assertion for `tail -f directory'. + * src/tail.c: Revert most of 1999-10-20 change. Instead, ... + (IS_TAILABLE_FILE_TYPE): Define to produce similar result. + (recheck): Use it here. + (tail_file): Use it here. + Reported by François Pinard. + + Once we encounter a file that is not of IS_TAILABLE_FILE_TYPE, + marke it as such and ignore it forever after. + * src/tail.c (struct File_spec): New member. + (recheck): Initialize new member. + (tail_file): Likewise. + (tail_forever): Skip the file if it's marked as ignorable. + +2000-03-03 Jim Meyering + + * src/sort.c (fillbuf): Move declaration of local, cc, into scope of + `while' loop where it's used. + +2000-03-02 Paul Eggert + + Big performance improvement when sorting many small files, + building on a suggestion by Charles Randall. + + * src/sort.c (fillbuf): Skip memmove if it would be a no-op, + as many memmove implementations are slow in that case. + Don't examine leftover bytes for eolchar, since they may be left + over from a previous file, and we want to read from this file. + + (sort): At end of file, if there is more input and buffer room, + concatenate the next input file. + +2000-02-29 Jim Meyering + + * src/join.c (make_blank): Add an explicit cast to `unsigned char *' + to placate HPUX's C compiler. Reported by Bob Proulx. + +2000-01-30 Jim Meyering + + * Version 2.0d. + + * Makefile.maint (my-distcheck): Depend on po-check, so I'll be warned + about any required changes at `make distcheck' time rather than at + `make alpha' time. + (writable-files): New target. + (my-distcheck): Depend on it. + (alpha): Likewise. + + * po/POTFILES.in: Add these: lib/makepath.c, lib/rpmatch.c, + and lib/same.c + +2000-01-29 Jim Meyering + + * configure.in: Remove lib-check for cposix now that we use + m4/isc-posix.m4. + (jm_LIB_CHECK): Use this even though the library checks aren't + required for this patchage (so all three lib/Makefile.in files + will be the same). + +2000-01-24 Mark Kettenis + + * src/tsort.c (exit_status): New variable. + (loop): New varibale. + (count_items, scan_zeroes): Change return type to int. + (detect_loop): Complete rewrite to correctly implement detection + of loops. Also change return type to int. + (recurse_tree): Stop if ACTION returns non-zero. This involves + changing the return type of this function and ACTION to int. + (walk_tree): Change return type of ACTION to int. + (tsort): Continue sort after a loop has been detected (and + broken). Set exit_status to 1 if a loop was detected. + (main): Use exit_status to determine exit code. + * tests/tsort/basic-1: Change expected output for cycle-1 and + cycle-2 tests. + +2000-01-23 Jim Meyering + + * configure.in (AM_FUNC_STRTOD): Move to m4/. + (AC_SUBST(POW_LIBM)): Likewise. + +2000-01-22 Jim Meyering + + * src/sort.c (keycompare): Use global, hard_LC_COLLATE in place of + local that is sometimes undeclared. + + * configure.in (ALL_LINGUAS): Add Brazilian Portuguese (pt_BR). + (AC_CHECK_HEADERS): Move these checks into m4/. + + * src/tr.c ("xstrtol.h"): Include. + (Filter): Rename from PFL. + (non_neg_strtol): Remove function. + (find_bracketed_repeat): Use xstrtoul instead of non_neg_strtol. + (squeeze_filter, set_initialize, main): Use size_t and ssize_t in + place of long and int in several decls. + (read_and_delete, read_and_xlate): Likewise, and remove assertion. + * tests/tr/Test.pm (o-rep-1, o-rep-2): New tests. + + * src/cut.c: Correct copying notice to use GPL, per author's request. + * src/paste.c: Likewise. + (AUTHORS): Add djm. + +1999-09-19 Bruno Haible + + * src/tr.c (PFI): Return `long', not `int'. + (PFL): Rename from PFI now that it returns long. + (squeeze_filter): Declare as `long': i, nr, out_len. + +2000-01-17 Paul Eggert + + Tweak sort performance. + + * src/sort.c (hard_LC_CTYPE): Remove. + (keylist): Renamed from keyhead. Now a pointer, not a + mostly-unused struct. All uses changed. + (findlines, keycompare, CMP_WITH_IGNORE, compare, checkfp, mergefps, + sort): Tune and use a more consistent style for reallocation. + (keycompare, main): Don't worry about LC_CTYPE; + it's buggy with multibyte chars anyway. + (compare): Invoke alloca (0) after each call to keycompare, + not just the ones that return nonzero. This avoids a memory + leak on architectures without builtin alloca that occurs + sometimes when a file contains all duplicate lines. + +2000-01-17 Paul Eggert + + * src/csplit.c (interrupt_handler, main): + Don't use SA_INTERRUPT to decide whether to call sigaction, as + POSIX.1 doesn't require SA_INTERRUPT and some systems + (e.g. Solaris 7) don't define it. Use SA_NOCLDSTOP instead; + it's been part of POSIX.1 since day 1 (in 1988). + * src/sort.c (sighandler, main): Likewise. + +2000-01-16 Jim Meyering + + * lib/Makefile.am: Merge with fileutils/lib/Makefile.am. + + * configure.in: Remove AM_FUNC_ERROR_AT_LINE, jm_FUNC_STRFTIME, + AC_FUNC_VPRINTF, and AC_FUNC_ALLOCA. Now they're in m4/. + +2000-01-15 Jim Meyering + + * configure.in (AC_REPLACE_FUNCS): Remove these: memcpy memset stpcpy + strpbrk strtol strtoul. Now that's in m4/. + + unexpand could infloop + * src/unexpand.c (TAB_STOP_SENTINEL): Define. + (unexpand): Use it instead of INT_MAX. + Declare column and pending to be `unsigned'. + Increment pending and column counters only if column is smaller + than TAB_STOP_SENTINEL. + * tests/Makefile.am (SUBDIRS): Add unexpand. + * tests/unexpand/basic-1: New tests for the above-fixed bug. + * configure.in (AC_OUTPUT): Add tests/unexpand/Makefile. + Reported by John Kodis. + +2000-01-12 Paul Eggert + + * src/sort.c (fillbuf): Avoid quadratic behavior with long lines. + Also, stop worrying about ancient memchr bug (misbehavior when + size is zero), since other code doesn't worry either. + +2000-01-11 Jim Meyering + + Sync lib/ directories of sh-utils, and textutils. + + * lib/Makefile.am (libfetish_a_SOURCES): Add getdate.y, posixtm.c, + basename.c, canon-host.c, readutmp.c, stripslash.c, xgetcwd.c, + xgethostname.c. + (noinst_HEADERS): Add getdate.h, group-member.h, posixtm.h, + pathmax.h, readutmp.h + + * lib/Makefile.am: s/tu/fetish/ + * src/Makefile.am: s/libtu/libfetish/ + +2000-01-10 Jim Meyering + + * Version 2.0c. + + * Makefile.maint (announcement): Include URLs for xdelta files. + (alpha): Use scp, not ncftp. + + * lib/Makefile.am (noinst_HEADERS): Add nanosleep.h. + +2000-01-08 Jim Meyering + + * Version 2.0b. + + More nits. + * src/cut.c (OUTPUT_DELIMITER_OPTION): Define this and use it + instead of `CHAR_MAX + n'. + * src/pr.c (PAGES_OPTION, COLUMNS_OPTION): Likewise. + +2000-01-07 Jim Meyering + + * tests/tsort/Makefile.am (TESTS_ENVIRONMENT): Add `pwd`/ prefix + to exported PATH value (though not strictly necessary, here). + * tests/md5sum/Makefile.am: Likewise. + + Nits. + * lib/memcasecmp.c: Use `#if' instead of `#ifdef' for `HAVE_CONFIG_H'. + Capitalize all macro parameters. + (memcasecmp): Ansideclify. + Don't cast away `const'ness of parameters. + * lib/strpbrk.c (strpbrk): Ansideclify. + Use `#if' instead of `#ifdef' for `HAVE_CONFIG_H'. + Suggestions from François Pinard. + +2000-01-06 Jim Meyering + + * tests/tail-2/assert: Tell the user just before sleeping for 7 seconds. + + * tests/tail-2/Makefile.am (TESTS): Remove fflush test. It didn't + test the losing behavior, and left a stray tail process to boot. + +2000-01-01 Jim Meyering + + * Version 2.0a. + + * lib/Makefile.am (lstat.c): Adapt rule to handle new parts of xstat.in. + +1999-12-12 Jim Meyering + + Move 120+ lines of stat.h-related macros from system.h (not shared) + to sys2.h, which is shared between fileutils, sh-utils, textutils. + * src/system.h: Move them from here... + * src/sys2.h: ... to here. + +1999-12-09 Jim Meyering + + * configure.in (ALL_LINGUAS): Add Galician (gl). + +1999-12-06 Jim Meyering + + * tests/tail-2/fflush: New test for latest change. + * tests/tail-2/Makefile.am (TESTS): Add fflush. + +1999-10-26 Marc Boucher + + * src/tail.c (main): Flush stdout before switching to unbuffered mode + and calling tail_forever. Required only on Solaris2.7 -- on other + systems, using setvbuf to switch to unbufferd mode does the flush. + +1999-11-22 Jim Meyering + + * lib/Makefile.am (DISTCLEANFILES): Put $(BUILT_SOURCES) here rather + than in $(MAINTAINERCLEANFILES). + + * src/tail.c (recheck): Handle a race condition (including + reuse) that would lead to a failed assertion. + Reported by Ken Pizzini. + (tail_forever): Record errno before using it in call to `error' + which might change it. + (tail_file): Likewise. + + New test for the above. + * tests/tail-2/assert: New file. + * tests/tail-2/Makefile.am: New file. + * tests/tail-2: New directory. + * tests/Makefile.am (SUBDIRS): Add tail-2. + * configure.in (AC_OUTPUT): Add tests/tail-2/Makefile. + +1999-11-05 Jim Meyering + + * src/system.h: Use HAVE_STRUCT_STAT_ST_BLKSIZE not HAVE_ST_BLKSIZE. + + * configure.in: Move some type/header/member tests into + m4/jm-macros.m4 (jm_CHECK_ALL_TYPES) so they are shared by all of + fileutils, textutils, and sh-utils. + +1999-11-04 Paul Eggert + + * src/sort.c (SORTALLOC): New macro. + (sortalloc, mergealloc, LINEALLOC): Use it. + (sortalloc, mergealloc, linelength): Now const. + (sortalloc): Increase from 0.5 to 8 MB. + (mergealloc): Increase from 16 to 256 kB. + (LINEALLOC): Increase from 0.25 to 4 MB. + +1999-11-03 Paul Eggert + + * NEWS, doc/textutils.texi: + Do not consider newline to be part of a line when comparing lines + in `sort' and `comm'. POSIX.2 requires that we consider newline, + but this is a bug in the spec and the bug will likely be fixed. + * src/comm.c (compare_files): Likewise. + * src/sort.c (begfield, limfield, findlines, keycompare, compare): + Likewise. + * tests/sort/Test.pm: Update tests `use-nl' and `11d' to reflect + this change. + + * lib/linebuffer.c (readline): Do not leave room for an extra + byte after the newline; it's no longer needed. + * src/sort.c (sortalloc, mergealloc, fillbuf, checkfp, mergefps): + Likewise. + + * lib/memcoll.c (memcoll): The two arguments cannot be + adjacent any more, so remove the alloca/copy workaround for + that case. + +1999-11-03 Jim Meyering + + Fix so that `tail -fn 2 file' works again. + * src/tail.c (anonymous enum) [LONG_FOLLOW_OPTION]: Define. + (long_options): Use LONG_FOLLOW_OPTION here, instead of 'f'. + (main): Remove the `::' after the `f' in getopt_long string. + Add `case LONG_FOLLOW_OPTION' after `case 'f':'. + Based on a patch from Tim Waugh. + + * src/tail.c (anonymous enum) [RETRY_OPTION]: Define. + [MAX_UNCHANGED_STATS_OPTION]: Likewise. + [MAX_CONSECUTIVE_SIZE_CHANGES_OPTION]: Likewise. + [PID_OPTION]: Likewise. + (long_options): Use *_OPTION instead of CHAR_MAX + N. + (main): Likewise. + +1999-11-02 Jim Meyering + + * man/help2man: Import version 1.018. + * man/Makefile.maint ($(man_MANS)): Remove use of --name=... option. + * man/*.x: Include one-line summary in [NAME] section. + * man/Makefile.summ (cat-summary): Remove now-unused file. + * man/Makefile.am (EXTRA_DIST): Remove Makefile.summ. + * man/Makefile.maint: Include Makefile.summ with leading `-'. + This file is shared by fileutils and sh-utils, both of which still + have the file (albeit nearly empty now). + Suggestion for clean-up from Akim Demaille. + +1999-11-01 Jim Meyering + + * lib/Makefile.am (MAINTAINERCLEANFILES): Set to $(BUILT_SOURCES). + +1999-10-20 Jim Meyering + + * src/tail.c (recheck): Don't refuse to tail a non-regular, non-pipe. + (tail_file): Likewise. + +1999-10-07 Jim Meyering + + * configure.in (ALL_LINGUAS): Add Japanese (ja). + +1999-10-04 Jim Meyering + + * depcomp: New file, for automake's new dependency support. + * missing: New version, from automake's user-dep-gen-branch. + +1999-09-28 Jim Meyering + + * src/system.h: Update from the system.h from fileutils. + + * lib/error.c (error_at_line): Use strerror portably here, too, + just as was done in error. + +1999-09-02 Jim Meyering + + * src/cut.c: Remove xstrdup declaration. + * src/sort.c: Likewise. + * src/tsort.c: Likewise. + +1999-08-22 Jim Meyering + + * src/tsort.c (detect_loop): There's no loop if k->top is NULL. + Niklas Edmundsson showed how to make tsort segfault. + + * tests/tsort/Makefile.am: Rewrite to use Fetish.pm-based framework. + * tests/tsort/basic-1: New file. + Add a few more tests. + * tests/tsort/Test.pm: Remove. + + * man/help2man: Escape backslashes so tr's manual comes out right. + Reported by Andreas Schwab. + + * src/tsort.c (usage): Correct address for bug reports. + (tsort): Remove trailing `\n' in error format. + + * src/md5sum.c (md5_check): Remove trailing `\n' in error format. + + * src/sys2.h (IF_LINT): Define new macro. + * src/od.c (dump): Use IF_LINT macro instead of #ifdef lint... + (main): Likewise. + * src/paste.c (paste_parallel): Likewise. + * src/pr.c (read_line): Likewise. + * src/sort.c (checkfp): Likewise. + (mergefps): Likewise. + + * src/cksum.c (cksum): Constify a char*. + * src/comm.c (writeline): Likewise. + + * src/uniq.c (check_file): Move declarations of local variables + into the scopes where they're used. + (min): Remove macro definition. + (different): Use MIN, not min. + (SWAP_LINES): New macro. + (check_file): Use it here. + + * src/uniq.c (check_file): Generate each line of output earlier, + when possible. It is possible when using none of these options: + --count, -repeated, --all-repeated, --unique. + Based on a patch from Ian Turner. + +1999-08-15 Jim Meyering + + * src/tail.c (ENOSYS): Define to a bogus value if not already defined. + +1999-08-13 Eli Zaretskii + + * src/tail.c (parse_options): Warn if --pid=PID is used and kill() + returns ENOSYS (e.g. when compiled with DJGPP). + +1999-08-13 Jim Meyering + + * src/tsort.c (usage): Use consistent bug-reporting address. + + * tests/tsort/Test.pm: New file. + * tests/tsort/Makefile.am: New file. + * tests/tsort: New directory. + * tests/Makefile.am (SUBDIRS): Add tsort. + * configure.in (AC_OUTPUT): Add tests/tsort/Makefile. + +1999-08-11 Paul Eggert + + * doc/textutils.texi: Document how to ignore newline during sort. + +1999-08-07 Jim Meyering + + * po/POTFILES.in: Add lots of lib/*.c files. Remove src/system.h. + +1999-08-06 Jim Meyering + + * Version 2.0. + + * src/sort.c: Include file name in `write error' diagnostics. + (write_bytes): Add output_file parameter and use it. Update callers. + (mergefps): Likewise. + (merge): Likewise. + (sort): Likewise. + Reported by John Summerfield. + +1999-08-05 Jim Meyering + + * src/tail.c (Follow_mode): Remove comma at end of enumerator list. + Reported by Kaveh Ghazi. + + * config.sub: Update from autoconf. + * config.guess: Update from autoconf. + +1999-08-04 Jim Meyering + + * Version 1.22q. + + * configure.in: Remove inadequate getline-testing code. md5sum would + segfault on HPUX because of the getline function in their C library. + Use the AM_FUNC_GETLINE test in m4/ instead. + +1999-08-03 Jim Meyering + + * src/tail.c (tail_forever): When following by name and calling recheck + because of exceeding max_n_consecutive_size_changes_between_opens, + `continue' so we don't fall through and (assuming the file finally grew) + get the erroneous `file truncated' message. This was hard to reproduce. + +1999-08-01 Jim Meyering + + * Version 1.22p. + + * configure.in (AM_C_PROTOTYPES): Move test to precede a few + header tests -- merely on principle. + +1999-08-01 Paul Eggert + + * configure.in (AC_SYS_LARGEFILE): Renamed from AC_LFS. + +1999-07-16 Paul Eggert + + * lib/quotearg.c (quotearg_buffer): + Don't quote spaces if C quoting style. + +1999-07-31 Jim Meyering + + * src/tail.c (tail_forever): Don't call kill if pid is 0. + Detect when `writer_is_dead' also when the writer is some other user. + From Karl Heuer. + + * src/tail.c (parse_options): Warn if --pid=PID is used without -f. + +1999-07-30 Jim Meyering + + * Version 1.22o. + + * src/tail.c: New option: --pid=PID. + Include signal.h for kill prototype. + (pid): New global. + (long_options): Add `pid'. + (usage): Describe it. + (tail_forever): Implement it. + (parse_options): Handle the new option and required arg. + Suggestion and pseudo-code from Karl Heuer. + +1999-07-27 Jim Meyering + + * lib/linebuffer.c: Include now that linebuffer.h uses + size_t. This is required on at least SunOS4. From Kaveh Ghazi. + +1999-07-26 Jim Meyering + + * src/sys2.h (PID_T_MAX): Define. + + * src/tail.c (struct File_spec) [n_stat_calls]: Remove unused member. + +1999-07-25 Jim Meyering + + * src/pr.c (usage): Remove `NEWS'-style paragraph (sorry to have + let that in, translators). + + * Version 1.22n. + +1999-06-01 Volker Borchert + + * tests/Makefile.am: Make envvar-check depend on check-recursive rather + than on `check' so that its tests are performed before any real tests. + +1999-07-20 Jim Meyering + + * configure.in (AC_REPLACE_FUNCS) Remove memmove, now that it's + AC_REPLACE...'d in m4/jm-macros.m4. + + * src/wc.c (posixly_correct): Declare global. + (write_counts): Use it to select printf formats. + (main): Set posixly_correct from the POSIXLY_CORRECT envvar. + From Peter Moulder. + +1999-07-15 Jim Meyering + + * tests/md5sum/Makefile.am: Revert the 1999-02-15 change. + * tests/md5sum/basic-1, newine-1: Add --text for each individual test. + Reported by Eli Zaretskii. + +1999-07-12 Jim Meyering + + * configure.in (ALL_LINGUAS): Add Slovak (sk). + +1999-07-11 Jim Meyering + + * src/tail.c (recheck): Use assert instead of unnecessary close_fd. + Remove a couple of unnecessary FIXME comments. + +1999-07-10 Jim Meyering + + * doc/textutils.texi: Document new tail options. + + * src/tail.c (struct File_spec) [tailable]: Rename from `missing' and + document. Change all uses and locals like was_missing to was_tailable. + Invert expressions as appropriate. + (reopen_inaccessible_files): Rename from allow_missing. + (sleep_interval): Describe. + (--allow-missing): Deprecate. + (--retry): New option, equivalent to --allow-missing. + (usage): Document name vs. descriptor differences. + Refer to manual for descriptions of --max-unchanged-stats=N + and --max-consecutive-size-changes=N. + (valid_file_spec): New function. + (recheck): Assert valid_file_spec. + Remove dead else-if block (suggestion from Eli Zaretskii). + Adjust stmts that set f->tailable -- unlike for `missing', tailable + doesn't depend on errno == ENOENT. + (parse_options): Give a warning if --retry is used when not following + by name. + + * tests/join/Test.pm: New test case (but commented out) for + Paul's 1999-06-01 fix. + +1999-07-09 Jim Meyering + + * configure.in (ALL_LINGUAS): Add Greek (el). + +1999-07-04 Jim Meyering + + * tests/join/Test.pm: New test case for Paul's 1999-06-03 fix. + +1999-07-03 Eli Zaretskii + + * src/tail.c (struct File_spec): New member, errnum. + (recheck): Record the new value of errno in f->errnum. Don't + output an error message unless the new value of errno differs from + the old one. Output a message if previously-inaccessible file + becomes accessible. + (tail_forever): Always recheck files whose fd is negative. If the + file cannot be fstat'ed, record the errno value in f[i].errnum. + (tail_file): If the file cannot be open, record the errno value in + f->errnum. If it can be opened, initialize f->errnum to zero. If + it's a non-regular non-fifo file, initialize f->errnum to -1. + +1999-06-21 Jim Meyering + + * doc/textutils.texi: Use lower case characters in sc{} context. + Reported by Eli Zaretskii. + +1999-06-03 Paul Eggert + + * src/join.c (xfields): Only s separate fields, not s. + +1999-06-01 Paul Eggert + + * lib/linebuffer.c (readline): Leave room for an extra byte + after the newline; comm needs this for memcoll. + +1999-06-01 Paul Eggert + + Add LC_COLLATE support to `join'. + + * doc/textutils.texi: Describe join and LC_COLLATE. + + * src/join.c: Add support for LC_COLLATE locale. + Include hard-locale.h, linebuffer.h, memcoll.h. + (struct line): New member `buf', replacing `beg' and `lim'. + All uses changed. + (hard_LC_COLLATE): New var. + (main): Initialize it. + (get_line): Use readline to read the line, + instead of doing it by hand. + That way, we get a buffer that we can pass to memcoll. + (keycmp): Use memcoll to compare lines if hard_LC_COLLATE is nonzero. + +1999-05-27 Volker Borchert + + * tests/Makefile.am: Qualify .env-warn with $(srcdir)/ prefix. + +1999-05-25 Paul Eggert + + Add LC_COLLATE support to `comm', so that `comm' is compatible + with `sort' in nontrivial locales. + + * doc/textutils.texi: Document locale-specific mode for comm. + + * lib/Makefile.am (libtu_a_SOURCES): Add hard-locale.c, memcoll.c. + (noinst_HEADERS): Add hard-locale.h, memcoll.h. + + * src/comm.c: Include hard-locale.h, memcoll.h. + (hard_LC_COLLATE): New variable. + (compare_files): Use memcoll to compare if hard_LC_COLLATE. + (main): Initialize hard_LC_COLLATE from locale. + + * src/sort.c: Include hard-locale.h, memcoll.h. + (hard_LC_COLLATE, hard_LC_CTYPE, hard_LC_TIME): New variables, + replacing `need_locale'. + (memcoll): Move to lib/memcoll.c. + (keycompare): No need to alloc (0), since our caller now does it. + (compare): alloca (0) before returning. + (my_setlocale): Remove; hard_locale now dows this. + (main): Invoke setlocale, bindtextdomain, and textdomain before + invoking anything that might print an error. + Use hard_locale to determine which locales are hard. + + * lib/hard-locale.c, lib/hard-locale.h, lib/memcoll.c, lib/memcoll.h: + New files. + +1999-05-25 Paul Eggert + + * lib/linebuffer.c (readline): + Append trailing newline to line. + * lib/linebuffer.h + [struct linebuffer] (size): Declare to be of type size_t, not long. + [struct linebuffer] (length): Likewise. + * src/comm.c, (writeline): Lines now contain trailing newline. + * src/uniq.c (find_field, different): Use size_t, not int, for lengths. + (writeline): Lines now contain trailing newline. + (check_file): Use size_t, not int, for lengths. + * src/nl.c (proc_text, check_section, main): More of the same. + + * lib/linebuffer.h (struct linebuffer): Use size_t for sizes. + src/nl.c (header_del_len, body_del_len, footer_del_len, main): + Likewise. + src/uniq.c (find_field, different, check_file): Likewise. + + * lib/linebuffer.c (readline): Silently append trailing + newline if needed. Do not bother setting buffer length to 0 + at EOF, since it's not part of the spec and nobody relies on + it. Do not compute the difference between unrelated pointers. + +1999-05-25 Paul Eggert + + * src/tac.c (memrchr): Ifdef out this unused function. + +1999-05-25 Jim Meyering + + * doc/textutils.texi (Squeezing): Remove misleading square brackets + from SET1 in the one-word-per-line example. + +1999-05-22 Jim Meyering + + * lib/Makefile.am (libtu_a_SOURCES): Remove memchr.c. + From Ulrich Drepper. + + * Version 1.22m. + +1999-05-22 Paul Eggert + + * doc/textutils.texi: Document locale-specific changes to `sort', + as well as the new, POSIX-compliant definition of line comparison, + and -g's more careful treatment of NaNs, infinities and zeros. + + * src/sort.c (general_numcompare): Put exceptional cases + first, not last, to be consistent with -M. + +1999-05-21 Paul Eggert + + * src/sort.c (strtod): Declare if STDC_HEADERS is not defined. + (general_numcompare): Use strtod, not xstrtod. + Do not consider partial conversions to be errors. + Put -infinity at the start, and +infinity at the end; + follow +infinity with NaNs (sorted by bit pattern), + and finally by conversion errors. + +1999-05-21 Jim Meyering + + * tests/sort/Test.pm (11d): Reverse lines in expected output + to reflect latest change. + (use-nl): New test from Paul Eggert. + +1999-05-20 Paul Eggert + + * src/sort.c: Treat the trailing newline as part of the line, + as required by POSIX.2. + + (struct line, findlines, compare, checkfp, mergefps, sort): + A line now includes its trailing newline. + (findlines): Do not replace newline with NUL. + (memcoll, keycompare): Work even if the data to be compared are + adjacent strings; this is possible now that lines contain the + trailing newline. + (fillbuf): Always have an unused byte at the end of the buffer, + since memcoll and keycompare want to modify a byte after the last line. + (sortalloc, mergealloc): Increase by 1, for trailing byte. + +1999-05-20 Jim Meyering + + * tests/sort/Test.pm: Add test case from Paul Eggert. + +1999-05-20 Paul Eggert + + * src/sort.c (keycompare): Ignore any length difference if the + localized comparison says the strings are equal. + + * src/sort.c (memcoll, keycompare, compare): Handle NUL + characters properly when comparing with LC_COLLATE semantics. + (NLS_MEMCMP): Remove. + (memcoll): Renamed from strncoll. + Take separate lengths for each string. + This function is now invoked only when need_locale. + (keycompare): Don't copy strings when ignore and translate + are both NULL. + +1999-05-18 Paul Eggert + + * src/sort.c (MONTHTAB_CONST): Renamed from NLS_CONST; the use + is also changed. Define to const also if !HAVE_NL_LANGINFO. + + (usage): `,' -> `;' (English typo). + +1999-05-17 Eli Zaretskii + + * src/cat.c (main): When stdout is in binary mode, make sure all + input files are also read in binary mode. + +1999-05-16 Jim Meyering + + * Version 1.22l. + +1999-05-11 Paul Eggert + + * src/sort.c: Don't autodetect the locale of numbers and + months, as this conflicts with POSIX.2 and is tricky to boot. + + (FLOATING_COMMA, NLS_STRNCMP, NLS_MAX_GROUPS, + NLS_ONE_CHARACTER_STRING): Remove macros no longer used. + + (nls_grouping, nls_fraction_found, nls_month_found, nos_monthtab, + nls_months_collide, nls_keyhead, us_monthtab): Remove variables no + longer used. + + (struct nls_keyfield): Remove types no longer used. + + (strncoll_s2_readonly, nls_set_fraction, look_for_fraction, + nls_month_is_either_locale, nls_numeric_format): Remove functions no + longer used. + + (monthtab): Now has the role that us_monthtab had, but it's const only + if ENABLE_NLS is not defined. + + (C_DECIMAL_POINT): Renamed from FLOATING_POINT. All uses changed. + (MONTHS_PER_YEAR): Renamed from NLS_NUM_MONTHS. All uses changed. + (struct_month_cmp): Renamed from nls_sort_month_comp. All uses changed. + Use strcmp, not strcoll, since the user doesn't care about collating + here. + + (inittables): Read locale data into monthtab, rather than modifying a + separate month table and futzing with indirection. Do not worry about + colliding months, since we no longer autodetect month locale. + + (fraccompare): Don't set no-longer-used variable nls_fraction_found. + + (getmonth): Use strncmp to compare months, since user doesn't care + about collating here. Fix bug where code incorrectly assumed that + strlen (monthtab[lo].name) == strlen (monthtab[ix].name). + + (keycompare, main): Don't autodetect month locale. + + (compare): Don't use NLS_MEMCP in code that can't be executed if + need_locale is false, as NLS_MEMCP is equivalent to memcmp in that + case. + + (sort, insertkey, main): Don't autodetect numeric locale. + +1999-05-15 Jim Meyering + + * tests/join/Test.pm (trailing-sp): New test for this fix. + * src/join.c (xfields): Don't interpret a trailing blank as a + delimiter when e.g. -t: was specified. From Tim Smithers. + +1999-05-12 Jim Meyering + + * tests/Makefile.am (envvar-check): Renamed from check-local. + (check): Depend on envvar-check so the envvar check is performed + before all other tests. Reported by Volker Borchert. + * tests/.env-warn: Use `%%' place-holder that Makefile.am rule expects, + so CDPATH is mentioned in the message. Reported by Volker Borchert. + +1999-05-11 Jim Meyering + + * src/sort.c (usage): Split the --help message into two pieces so that + neither is longer than 2048. For Irix4's cc. Reported by Kaveh Ghazi. + +1999-05-09 Jim Meyering + + * lib/regex.c: Update from libc. + + * Version 1.22k. + + * Makefile.maint (alpha): Put the announcement in + /tmp/announce-$(distdir) + + * tests/sort/Test.pm (neg-nls): New test. + +1999-05-08 Jim Meyering + + * src/system.h (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM, + and all the *_MIN and *_MAX symbols): Remove definitions. + * src/sys2.h: Put the definitions here instead (this file is shared + between all three *utils packages, while system.h is not). + +1999-05-06 Paul Eggert + + * src/sort.c (fraccompare, numcompare): Merge the NLS and + non-NLS versions into a single function. + + (decimal_point): Now char, since we no longer convert to unsigned + char. + (th_sep): Now int, since we use a value out of char range to denote + the absence of a thousands separator. + (IS_THOUSANDS_SEP): New macro. + (USE_NEW_FRAC_COMPARE): Remove. + (nls_set_fraction): Arg is now char, not unsigned char. + Set th_sep to CHAR_MAX + 1 if there is no thousands separator. + (numcompare): Don't convert to unsigned char unless necessary. + (main): Turn off decimal points and thousand separators if they + are multibyte characters, as we don't support that yet. + +1999-05-06 Paul Eggert + + * src/system.h (CHAR_MIN, CHAR_MAX): New macros. + (SCHAR_MIN, SCHAR_MAX): Don't assume that char is signed. + +1999-05-06 Paul Eggert + + * src/sort.c (numcompare): Handle comparison of two negative + numbers correctly in the ENABLE_NLS case. + +1999-05-04 Jim Meyering + + * src/pr.c (usage): Break the usage message into 3 pieces instead of + only 2. The strings had grown to be longer than 2048, which evokes + errors when compiling with Irix4's cc. Reported by Kaveh Ghazi. + + * src/tsort.c (search_item): Use `1' instead of `+1'. The latter + elicits a syntax error from SunOS4's cc. From Kaveh Ghazi. + +1999-05-03 Jim Meyering + + * src/ptx.c : Don't include. + [!STDC_HEADERS]: Remove definitions of ctype macros. + Convert e.g., isspace to ISSPACE to use definitions from sys2.h. + Reported by Kaveh Ghazi. + + * src/sys2.h (TOLOWER): Define. + (TOUPPER): Define. + * src/join.c (TOLOWER): Remove definition. + * src/md5sum.c (TOLOWER): Remove definition. + +1999-04-30 Jim Meyering + + * src/sort.c (usage): Document the differences between the + obsolescent, +POS1[-POS2] form, and the POSIX -k option. + +1999-04-24 Jim Meyering + + * configure.in: Use AC_CANONICAL_HOST. + + * lib/Makefile.am (libtu_a_SOURCES): Add xstrtoumax.c + (noinst_HEADERS): Remove xstrtoul.h. + + * src/csplit.c: Include new "xstrtol.h", not "xstrtoul.h". + (struct control) [repeat]: Declare as uintmax_t, not int. + (struct control) [lines_required]: Likewise. + (handle_line_error): Use human_readable to print lines_required. + (parse_repeat_count): Parse a uintmax_t. + (parse_patterns): Parse a uintmax_t. + + * src/tail.c: Include new "xstrtol.h", not "xstrtoul.h". + * src/od.c: Likewise. + + * src/head.c: Include new "xstrtol.h", not "xstrtoul.h". + Change all U_LONG_LONG to uintmax_t. + (head_lines): Move a couple dcls into an inner scope. + (string_to_integer): Rename from string_to_ull. + +1999-04-19 Jim Meyering + + * Makefile.maint (b_host): Remove /pub suffix. + +1999-04-18 Jim Meyering + + * Version 1.22j. + + * Makefile.maint (my-distcheck): Use AMTAR, not TAR. + + * src/sort.c (usage): s/DIRECT/DIRECTORY/g + Rename global: s/temp_file_prefix/temp_dir/. + (NAME_MAX_IN_DIR): Rename from PATH_MAX_IN_DIR. Use _POSIX_NAME_MAX, + not _POSIX_PATH_MAX. Guard with #if HAVE_PATHCONF rather than + #if HAVE_UNISTD_H. + (tempname): Wrap after 99999 only for length-impaired file systems. + +1999-04-17 Jim Meyering + + * src/tail.c (file_lines): Fix serious bug introduced with last changes. + From Andreas Schwab. + +1999-04-15 Jim Meyering + + * tests/Makefile.am (EXTRA_DIST): Rename .posix-warn to .env-warn. + (check-local): Warn about CDPATH in the same way + we warn about POSIXLY_CORRECT, since the cp/same-file test fails at + least when using bash with CDPATH set. Reported by Mark Hewitt. + + * src/pr.c Add comments. + (init_header): Tweak white space in Date/Time header. + * tests/pr/Test.pm: Updated all tests to reflect the big + 1999-02-13 change. From Roland Huebner. + +1999-04-12 Jim Meyering + + * src/cat.c (main): Declare out_dev to be of type dev_t, not `int'. + Declare out_ino to be of type ino_t, not `int'. + From John Bley. + + * src/od.c (MIN, MAX): Remove definitions. + * src/sys2.h (MIN, MAX): Define here instead. + Reported by John Bley. + +1999-04-11 Jim Meyering + + * Version 1.22i. + + * tests/pr/Test.pm (test_vector): Disable all tests while I wait for + an updated suite. + + Fix the problem whereby `yes > k & sleep 1; tail -2c k' would infloop. + * src/tail.c (COPY_TO_EOF): Define. + (dump_remainder): Add parameter, n_bytes, and rewrite to use it. + Update callers. + (file_lines): Rename parameter. + (tail_bytes): Remove obsolete comment. + + Fix the problem whereby `yes > k & sleep 1; tail -1 k' would infloop. + * src/tail.c (dump_remainder): Move this function to precede the + new use in file_lines. + (tail_lines): Don't call dump_remainder here. + (file_lines): Call dump_remainder here instead. + Reported by Lehti Rami. + + * lib/readtokens.c (readtoken, readtokens): Protoize. + +1999-04-10 Jim Meyering + + * src/tail.c (xwrite): Use STDOUT_FILENO instead of literal `1'. + +1999-04-04 Jim Meyering + + * src/cat.c: Standardize --help and --version processing. + * src/comm.c: Likewise. + * src/csplit.c: Likewise. + * src/cut.c: Likewise. + * src/expand.c: Likewise. + * src/fmt.c: Likewise. + * src/fold.c: Likewise. + * src/head.c: Likewise. + * src/join.c: Likewise. + * src/md5sum.c: Likewise. + * src/nl.c: Likewise. + * src/od.c: Likewise. + * src/paste.c: Likewise. + * src/pr.c: Likewise. + * src/ptx.c: Likewise. + * src/split.c: Likewise. + * src/sum.c: Likewise. + * src/tac.c: Likewise. + * src/tail.c: Likewise. + * src/tr.c: Likewise. + * src/unexpand.c: Likewise. + * src/uniq.c: Likewise. + * src/wc.c: Likewise. + +1999-03-29 Jim Meyering + + * configure.in (GNU_PACKAGE): Remove related code -- now it's in + the catch-all for shared autoconf code, m4/jm-macros.m4. + (jm_CHECK_ALL_TYPES): Remove explicit AC_TYPE_* macros and use + this instead. + +1999-03-26 Jim Meyering + + * lib/Makefile.am (libfu_a_SOURCES): Add version-etc.c. + (noinst_HEADERS): Add version-etc.h. + +1999-03-25 Jim Meyering + + * src/tail.c (recheck): Factor out a block of duplicated code. + Set f->size to 0 upon encountering a new file so we read it from + the beginning rather than from the end of the first line or + block. Otherwise, after a log rotation, tail would omit the first + line or block of the new file. Reported by Ed Avis. + +1999-03-20 Jim Meyering + + * tests/Makefile.am (SUBDIRS): Temporarily remove pr. + +1999-03-13 Jim Meyering + + * src/tac.c (tac_mem): `#if-0'-out this unused function. + (tac_stdin_to_mem): Likewise. + + * doc/textutils.texi (cut invocation): Describe --output-delimiter. + +1999-03-12 Jim Meyering + + * src/sys2.h (SETVBUF): Define new macro. + * src/tail.c (dump_remainder): Don't fflush stdout here. + (main) [if forever]: Make stdout unbuffered, instead. + Akim Demaille pointed out that when running `echo x>a; tail -f a>>a' , + the file `a' didn't grow longer than two lines. Now it grows + without bound. + +1999-03-07 Jim Meyering + + * tests/md5sum/newline-1: Test for the actual feature. + With help from Eli Zaretskii. + + * src/pr.c (usage): Add missing \n\. + + The newline test would always fail on MSDOS/Windows systems -- + so move it to a separate file where we can test for that. + * tests/md5sum/basic-1: Remove newline test. + * tests/md5sum/newline-1: New file. + * tests/md5sum/Makefile.am (TESTS): Add newline-1. + Pointed out by Eli Zaretskii. + + 1999-02-13 Roland Huebner + * src/pr.c + (main): Redefine options -s, -w to be POSIX compliant; introduce + new options -J, -S, -W to disentangle -s and -w when used together + with the three column options; + (add_line_number): Make POSIX compliant; use default number + separator TAB with single column output. + (add_line_number): Make POSIX compliant; with multicolumn output + now prefer `text columns of equal width' rather than a consequent + use of `default n-separator TAB'. + (add_line_number): Change line number cut-off from lower-oder to + higher-oder digit to avoid loss of information; no consequent + handling exists in different utilities and other UNIXes. + (char_to_clump): Expand input text tabs to 8 spaces, if + input_tab_char doesn't equal TAB (adapted to other UNIXes). + (usage): Update POSIX compliant options -s, -w; add new options -J, + -S, -W. + (main): Update the source internal documentation. + Some smaller BUGFIXES (print_sep_string, init_header, skip_to_page, + reset_status, print_header). + + * tests/md5sum/basic-1 (backslash): Use .\foo instead of \.foo so we + don't tramp on root directory in MSDOS/Windows. + Suggestion from Eli Zaretskii. + + 1999-02-15 Eli Zaretskii + + * tests/md5sum/Makefile.am (TESTS_ENVIRONMENT): Run md5sum with the + --text option (for MSDOS). + +1999-03-06 Jim Meyering + + * src/cut.c (getstr): Change type of `delim' parameter from char to int. + (cut_fields): Cast to `unsigned char' before comparing. + (main): Cast to `unsigned char' before assigning. + From Arne Juul. + * tests/cut/Test.pm: Add a test to exercise the bug. + + * src/ptx.c (swallow_file_in_memory): Use a `%s' format in error call, + in case the argument string contains a `%'. + (main): Likewise. + * src/fmt.c (main): Likewise. + * src/sort.c (main): Likewise. + + 1999-02-13 Eli Zaretskii + + * src/sys2.h [__DJGPP__]: Include and . + + * src/ptx.c (swallow_file_in_memory): Slurp up the whole file at + once on MSDOS as well, but we have to relax the test for whether + reading it succeeded. + +1999-03-03 Jim Meyering + + * src/cat.c: Include long-options.h + [long_options]: Remove the "help" and "version" entries. + Remove declarations of show_help and show_version. + (main): Use parse_long_options, including author name(s). + Remove the show_version and show_help blocks. + * src/cksum.c: Likewise. + * src/comm.c: Likewise. + * src/csplit.c: Likewise. + * src/cut.c: Likewise. + * src/expand.c: Likewise. + * src/fmt.c: Likewise. + * src/fold.c: Likewise. + * src/head.c: Likewise. + * src/nl.c: Likewise. + * src/od.c: Likewise. + * src/paste.c: Likewise. + * src/pr.c: Likewise. + * src/split.c: Likewise. + * src/sum.c: Likewise. + * src/tac.c: Likewise. + * src/tail.c: Likewise. + * src/tr.c: Likewise. + * src/unexpand.c: Likewise. + * src/uniq.c: Likewise. + * src/wc.c: Likewise. + + * src/ptx.c: Include long-options.h + [long_options]: Remove the "help" and "version" entries. + Remove declarations of show_help and show_version. + (main): Remove `const' attribute from dcl of argv parameter. + Call bindtextdomain and textdomain. + Use parse_long_options, including author name(s). + Remove the show_version and show_help blocks. + + * src/join.c (main): Include author name argument in call to + parse_long_options. + * src/md5sum.c (main): Likewise. + * src/sort.c (main): Likewise. + * src/tsort.c (main): Likewise. + +1999-02-07 Jim Meyering + + * Version 1.22h. + + * Makefile.maint (my-distcheck): Don't depend on dist, now that this + is hooked up to the distcheck rule. + * Makefile.am (distcheck-hook): New target and rule -- link to shared + rule, my-distcheck, in Makefile.maint. + +1999-01-31 Jim Meyering + + * doc/textutils.texi: Wrap the @top node in @ifnottex instead of + @ifinfo so `makeinfo --html ...' works. From Karl Berry. + +1999-01-30 Jim Meyering + + * acconfig.h: Remove lots of `#undef's, now that we use the + 3-argument forms of AC_DEFINE* macros. + + * configure.in: Require autoconf 2.13. + Use 3-argument form of AC_DEFINE*. + +1999-01-24 Jim Meyering + + * src/tac.c (DONT_UNLINK_WHILE_OPEN) [__MSDOS__ || _WIN32]: Define. + + * lib/quotearg.c (quotearg_n_options): Revert type of parameter `n' + (and hence that of the local `n1', too) to `int' at Paul's request. + +1999-01-18 Akim Demaille + + * doc/textutils.texi: Harmonization of @samp use for options. + +1999-01-17 Jim Meyering + + * Makefile.am (SUBDIRS): Add djgpp. + * configure.in (AC_OUTPUT): Add djgpp/Makefile. + * djgpp/: New directory. + + * man/Makefile.maint ($(man_MANS)): Don't remove the target (the + man page) until after we've created its replacement. + +1999-01-16 Eli Zaretskii + + * GNUmakefile: Add SHELL = /bin/sh. + * man/GNUmakefile: Likewise. + +1999-01-16 Jim Meyering + + * acconfig.h: Remove @BOTTOM@ section. + Instead, add the define and decl via m4/jm-macros.m4. + + * lib/argmatch.h (XARGMATCH): Define to return a value once again. + (XARGCASEMATCH): Likewise. + + * lib/argmatch.c (EXIT_FAILURE): Define. + (ARGMATCH_DIE): Provide default. + (__xargmatch_internal): New function. + s/rogram_name/program_name. + From Akim Demaille. + +1999-01-14 Jim Meyering + + * tests/md5sum/basic-1: Use `f', not `x' as temp. file name to avoid + warnings from perl5.004. + Reported by Volker Borchert. + + * lib/long-options.c (parse_long_options): Rename `usage' parameter + to avoid shadowing globally scoped function. + +1999-01-14 Akim Demaille + + * acconfig.h: Add a @BOTTOM@ section. + (ARGMATCH_DIE) [@BOTTOM@]: Define to usage(1). + Declare usage. + * src/*.c: Don't prototype usage as static. + +1999-01-10 Jim Meyering + + * Version 1.22g. + + All of the following new code is protected by + `#if DONT_UNLINK_WHILE_OPEN' + * src/tac.c (file_to_remove): New global. + (fp_to_close): New global. + (unlink_tempfile): New function. + (record_tempfile): New function. + (save_stdin): Call record_tempfile. + Use SET_BINARY. + (main): Use SET_BINARY and SET_BINARY2. + From Eli Zaretskii. + +1999-01-09 Jim Meyering + + * tests/uniq/Test.pm: Add tests from Jochen Hein. + * src/uniq.c: New option: --all-repeated (-D). + (output_all_repeated) [output_mode]: New enum value. + (usage): Describe it. + (writeline): Test for new mode. + (check_file): Likewise. + Based on patches from Jochen Hein and Florin Iucha. + (main): Diagnose `too many arguments'. + + * tests/head/Test.pm (null-1): Add test from Jochen Hein. + + * src/tail.c (parse_obsolescent_option): Interpret `number' as decimal. + (parse_options): Likewise. + Reported by Kamal Paul Nigam. + + * src/tail.c: New option: --max-unchanged-stats=N. + New option: --max-n-consecutive-size-changes=N. + +1999-01-03 Jim Meyering + + * src/md5sum.c (usage): Remove third program_name argument -- there + were only two `%s' in the format string. + +1999-01-02 Jim Meyering + + * src/tsort.c (tsort): Use a single call to error instead of two + to fprintf. + (main): Remove `%s: ' prefix on format string. + + * src/tail.c (parse_options): Use XARGMATCH in place of argmatch. + + * src/ptx.c (format_vals): New array. + (main): Use XARGMATCH in place of argmatch. + + * lib/argmatch.h (XARGMATCH): Don't return a value; instead, + modify a parameter. Add a `Die_stmt' parameter. + Add parentheses. + * lib/argmatch.c (__xargmatch_internal): Remove now-unused function. + (argmatch_to_argument): Add `const' attribute to first parameter. + +1999-01-01 Jim Meyering + + * src/tsort.c: Move inclusion of assert.h to follow that of stdio.h. + Some losing systems require this. + Use STREQ macro instead of strcmp in a few places. + + * po/POTFILES.in: Add tsort.c. + + * man/Makefile.maint ($(man_MANS)): `exit 1' if any of help2man, + chmod, or mv fails. Otherwise, the failure could go unnoticed. + + * man/Makefile.summ: Add entries for ptx and tsort. + + * src/tsort.c: Include readtokens.h. + (zeros): Rename global from `rr'. + (getstr): Remove function. + (tsort) Use readtoken instead of getstr. + + * lib/readtokens.c: New file. + * lib/readtokens.h: New file. + * lib/Makefile.am (libtu_a_SOURCES): Add readtokens.c. + (noinst_HEADERS): Add readtokens.h. + + * man/Makefile.am (man_MANS): Add ptx.1. + * man/ptx.x: New file. + + * src/tail.c (parse_options): Use XARGMATCH in place of argmatch. + + * man/Makefile.am (man_MANS): Add tsort.1. + * man/tsort.x: New (essentially empty) file. + + * src/tsort.c: Rename globals N and R so they don't shadow locals. + (tsort): Rename from `sort'. + + 1998-11-07 Mark Kettenis + * src/Makefile.am (bin_PROGRAMS): Add tsort. + * src/tsort.c: New program. + + * lib/Makefile.am (libtu_a_SOURCES): Add quotearg.c. + (noinst_HEADERS): Add quotearg.h. + + ============================ + All of the following are from: + 1998-04-17 Eli Zaretskii + + * src/system.h (SET_BINARY, SET_BINARY2, fileno, setmode): New + macros. + + * src/cat.c (usage) [O_BINARY]: Describe -B,--binary option. + (main) [O_BINARY]: binary_files, binary_output, file_open_mode: + new variables. Add --binary to long_options[]. Switch stdin and + stdout to binary mode unless file contents are not important + anyway. Open files in binary mode when required. + + * src/cksum.c (cksum) [O_BINARY]: Read redirected stdin in binary + mode. + + * src/expand.c (expand): Use binary I/O where appropriate. + + * src/head.c (head_bytes, head_lines) [O_BINARY]: Use binary I/O. + + * src/md5sum.c (OPENOPTS) [O_BINARY]: Use binary I/O when non-zero + argument. + (md5_file) [O_BINARY]: Switch redirected stdin to binary mode. + (main) [O_BINARY]: Use binary reads by default on those systems + which care about the difference. + + * src/od.c (skip, read_char, read_block) [O_BINARY]: Switch input + stream to binary mode. + + * src/sort.c (PATH_MAX_IN_DIR) [HAVE_UNISTD_H]: New macro, for max + file name characters in a given directory. + (tempname): Make sure the temp file name is unique even if long + file names aren't supported. + + * src/split.c (cwrite) [O_BINARY]: Write output in binary mode. + (main) [O_BINARY]: Read input in binary mode. + + * src/sum.c (bsd_sum_file, sysv_sum_file) [O_BINARY]: Read input + in binary mode. + + * src/tac.c (record_tempfile, unlink_tempfile) + [DONT_UNLINK_WHILE_OPEN]: New functions, for systems where a file + cannot be removed before it is closed. + (save_stdin) [DONT_UNLINK_WHILE_OPEN]: Record the temporary file, + to be removed before exit. + (tac_file, save_stdin, main): Use binary I/O when appropriate. + + * src/tail.c (tail_lines, tail_bytes) [O_BINARY]: Use binary I/O + when appropriate. + + * src/tr.c (main) [O_BINARY]: Use binary I/O when appropriate. + + * src/unexpand.c (unexpand): Use binary I/O where appropriate. + + * src/wc.c (wc): Use binary mode for input. + + * doc/textutil.texi: Add comments about peculiarities of Textutils + operation on MS-DOS/MS-Windows. + +1998-12-22 Jim Meyering + + * configure.in (ALL_LINGUAS): Add chinese (zh). + +1998-12-17 Jim Meyering + + New options for tail: + --follow=name, --follow=descriptor, --allow-missing + * src/tail.c (Follow_mode): New enum. + (n_live_files): New function. + (tail_forever): Avoid starvation with --follow=name and a + continually-growing unlinked or renamed file. + +1998-12-13 Jim Meyering + + * tests/uniq/Test.pm: New file. + * tests/uniq/Makefile.am: New file. + * tests/uniq: New directory. + * tests/Makefile.am (SUBDIRS): Add uniq. + * configure.in (AC_OUTPUT): Add tests/uniq/Makefile. + From Jochen Hein. + + * lib/Makefile.am (lstat.c): Add rule to generate this from xstat.in. + (stat.c): Likewise. + (EXTRA_DIST): Add xstat.in. + * lib/stat.c: Remove file. + * lib/lstat.c: Remove file. + * lib/xstat.in (xstat@): New file. + + * configure.in (ALL_LINGUAS): Add Russian (ru). + +1998-10-31 Jim Meyering + + * acconfig.h (stat): New #undef. + +1998-10-22 Jim Meyering + + * src/fold.c (usage): Add mention of --version and --help. + Reported by Matej Vela . + +1998-10-04 Jim Meyering + + * lib/fnmatch.h: New file. (unused) + * lib/fnmatch.c: New file. (unused) + * lib/Makefile.am (noinst_HEADERS): Add fnmatch.h. + +1998-10-03 Jim Meyering + + * man/Makefile.am: Switch to using help2man. + (EXTRA_DIST): Add Makefile.summ. + + * man/help2man: Invoke program with --manhelp option only if + --name=STRING not specified. Otherwise, this would fail with `yes'. + * man/Makefile.summ: New file. + * man/Makefile.maint: Include it. + * man/help2man: New file. + * man/GNUmakefile: New file. + * man/Makefile.maint: New file. + * man/*.x: New files. + * man/*.1: Remove files. + + * src/md5sum.c (split_3): Rename local variable, to `escaped_filename'. + (main): Output the leading backslash not just when there's a newline + in the file name, but also when there's a backslash. + Reported by Jim Dennis. + + * tests/md5sum/basic-1: Add tests with filenames containing newline + and backslash characters. (for the bug fixed above) + + * tests/Makefile.am (EXTRA_DIST): Add Fetish.pm. + * tests/Fetish.pm: New file. + + * tests/md5sum/basic-1: New file: rewrite of old tests to use Fetish.pm. + * tests/md5sum/Test.pm: Remove file. + * tests/md5sum/Makefile.am: Rewrite. + +1998-09-19 Jim Meyering + + * src/ptx.c (program_name): Declare *not* to be const. + +1998-08-29 Jim Meyering + + * src/cut.c: Don't assume ASCII. + * src/pr.c: Likewise. + * src/tail.c: Likewise. + +1998-08-15 Jim Meyering + + * src/pr.c (usage): Reformat. + + * src/ptx.c: Add braces to suppress warning about ambiguous `else'. + * lib/bumpalloc.h: Likewise. + +1998-08-13 François Pinard + + * src/ptx.c: New file. + * src/Makefile.am (bin_PROGRAMS): Add ptx. + * lib/bumpalloc.h, lib/diacrit.h, lib/diacrit.c: New files. + * lib/Makefile.am (libtu_a_SOURCES): Add diacrit.c. + (noinst_HEADERS): Add bumpalloc.h and diacrit.h. + +1998-08-09 Andreas Schwab + + * src/pr.c (long_options): Add long names for all options. + (usage): Update help string. + (main): Handle the special options --pages and --columns. + +1998-08-02 Jim Meyering + + * lib/linebuffer.c (readline): Return zero upon error as well as upon + end of file. From James Youngman. + Ansideclify. + +1998-08-01 Jim Meyering + + * src/sort.c (my_setlocale): Guard definition within #ifdef ENABLE_NLS. + From Manfred Hollstein. + +1998-07-30 Jim Meyering + + * tests/cut/Test.pm: Avoid broken pipe message for tests that fail + with usage errors. + + * src/sort.c (usage): Add angle brackets to make `Report bugs...' + message consistent with all the rest. + +1998-07-28 Andreas Schwab + + * tests/cut/Test.pm: Avoid broken pipe for 'y' and 'z' tests. + + * src/sort.c (NEGATION_SIGN): Renamed from NEGATIVE_SIGN to avoid + clash with . All uses changed. + +1998-07-26 Jim Meyering + + * intl/localealias.c (read_alias_file): Avoid mixing `char*' and + `unsigned char*' variables. Again for irix4. + Mostly from Kaveh Ghazi. + + * src/join.c: Convert some char* dcls to `unsigned char*' and remove + a cast -- to placate irix4's cc. + * src/fmt.c (check_punctuation): Add cast to placate irix4's cc. + Reported by Kaveh Ghazi. + + * src/md5sum.c (split_3): Add cast to placate irix4's cc. + From Kaveh Ghazi. + +1998-07-25 Jim Meyering + + * Version 1.22f. + + * tests/cut/Test.pm: Add tests for new --output-delimiter option, + as well as for NUL input delimiter (--delimiter=''). + * src/cut.c (cut_fields): Honor new --output-delimiter option. + (main): Fix handling of --delimiter='' (-d ''). Until now, it has + never worked as advertised. I guess no one tried it. + + * tests/sort/Test.pm: Add two tests relating to this. + * src/sort.c (main): Stat all non-`-' input file files (and fail if a + stat fails) when an output file is specified by `-o' but doesn't exist. + Reported by Will Edgington. + + * tests/sort/Test.pm: New tests of -o. + +1998-07-16 Jim Meyering + + * lib/Makefile.am (noinst_HEADERS): Add lchown.h. + * lib/lchown.h: New file, just to define ENOSYS on systems that lack it. + * lib/lchown.c: Include lchown.h. + +1998-07-04 Jim Meyering + + * configure.in (AM_WITH_REGEX): Remove. Now the replacement + macro, jm_WITH_REGEX, is bundled with the rest in jm_MACROS. + * acconfig.h (WITH_REGEX): Remove undef. + * src/csplit.c: Remove #ifdef around inclusion. + * src/nl.c: Likewise. + * src/tac.c: Likewise. + * src/csplit.c (extract_regexp): Remove #if !WITH_REGEX...#endif block. + * lib/Makefile.am (noinst_HEADERS): Remove rx.h. + * lib/rx.c: Remove file. + * lib/rx.h: Remove file. + +1998-06-29 Jim Meyering + + * src/wc.c: Update calls to human_readable -- now there's one fewer arg. + + * lib/Makefile.am (libtu_a_SOURCES): Add argmatch.c. + (noinst_HEADERS): Add argmatch.h. + +1998-06-28 Jim Meyering + + * src/sys2.h: Add macro definitions for GNU libc *_unlocked wrappers. + +1998-06-27 Jim Meyering + + * tests/pr/Test.pm: Add two tests for double spacing. + * src/pr.c (print_page): If cols_ready_to_print is zero, + break out of loop just before the double-space test. + Reported by Michael Stutz. + +1998-06-18 Jim Meyering + + * tests/Makefile.am.in (check): Depend on $(maint_gen) so + `make maintainer-clean; ./configure; make check' works. + +1998-05-25 Jim Meyering + + * configure.in (_GNU_SOURCE): AC_DEFINE it here. + * acconfig.h (_GNU_SOURCE): Remove definition from @TOP@ section. + [!_GNU_SOURCE]: Add #undef instead. + +1998-05-16 Jim Meyering + + * configure.in (jm_MACROS): New wrapper macro. + Remove uses of most jm_* macros. + + * src/tac.c (tac_seekable): Fix error in handling regex separators. + * tests/tac/Test.pm (opt-b, opt-s, opt_sb, opt_r): New tests. + (opt_br): New test -- exercises above-fixed bug. + + * lib/Makefile.am (EXTRA_DIST): Remove. Automake groks the `LIBOBJS=' + lines from the m4/*.m4 macros, so the hack of including some + custom-replaced C source file names here is no longer needed. + + * acconfig.h (chown): Add undef. + (D_INO_IN_DIRENT): Likewise. + (D_TYPE_IN_DIRENT): Likewise. + (ssize_t): Likewise. + +1998-05-09 Jim Meyering + + * src/tac.c (tac_seekable): Rename from tac_stream. + Change `FILE *in' parameter to `int input_fd'. Adjust callers. + +1998-05-03 Jim Meyering + + * po/: Update from gettext-0.10.35. + * intl/: Likewise. + * configure.in: Remove use of AC_LINK_FILES. + (AC_OUTPUT): Remove po/Makefile-generating sed command. + +1998-04-26 Jim Meyering + + * tests/tail/Test.pm: Disable test f-1, now that it fails. + + * src/sort.c (keycompare) (CMP_WITH_IGNORE): Don't return 0 from inside + the keyspec-iterating loop. With this change, test 22a passes. + Reported by Zvi Har'El. + (strncoll): Remove bogus assertion. + * tests/sort/Test.pm: Add tests for the above fix. + + * configure.in: Use jm_ASSERT. + * acconfig.h: Add NDEBUG. + + * src/cut.c: Don't define NDEBUG. + * src/csplit.c: Likewise. + * src/join.c: Likewise. + * src/sort.c: Likewise. + * src/tr.c: Likewise. + + * src/cut.c: Don't define _GNU_SOURCE (now it's in config.h). + * src/expand.c: Likewise. + * src/fold.c: Likewise. + * src/join.c: Likewise. + * src/sort.c: Likewise. + * src/tr.c: Likewise. + * src/unexpand.c: Likewise. + * src/uniq.c: Likewise. + + * src/tail.c (close_fd): New function -- converted from macro. + [struct File_spec] (n_stat_calls): New member. + [struct File_spec] (n_unchanged_stats): New member. + (max_n_unchanged_stats): New global. + Initialize new members. + (xwrite): New function -- converted from macro. + [struct File_spec] (pretty_name): Remove member. + (pretty_name): New function. + + * src/md5sum.c (md5_check): Declare local, `md5num' as _unsigned_ char*. + (hex_digits): Declare parameter `s' as _unsigned_ char*. + (split_3): Declare parameter `u' as _unsigned_ char**. + +1998-04-17 Jim Meyering + + * src/fmt.c (check_punctuation): Used unsigned char* pointers to avoid + new warning. + * src/join.c (xfields): Likewise. + +1998-04-12 Jim Meyering + + * src/cat.c: Use STREQ macro rather than strcmp. + * src/cksum.c: Likewise. + * src/comm.c: Likewise. + * src/csplit.c: Likewise. + * src/cut.c: Likewise. + * src/fmt.c: Likewise. + * src/fold.c: Likewise. + * src/head.c: Likewise. + * src/join.c: Likewise. + * src/md5sum.c: Likewise. + * src/nl.c: Likewise. + * src/paste.c: Likewise. + * src/pr.c: Likewise. + * src/split.c: Likewise. + * src/sum.c: Likewise. + * src/tac.c: Likewise. + * src/uniq.c: Likewise. + * src/wc.c: Likewise. + +1998-04-11 Jim Meyering + + * lib/safe-read.h: New file. + * lib/safe-read.c: Include it. + * src/cat.c: Include it instead of merely declaring safe_read. + * src/csplit.c: Likewise. + * src/head.c: Likewise. + * src/split.c: Likewise. + * src/sum.c: Likewise. + * src/tac.c: Likewise. + * src/tail.c: Likewise. + * src/tr.c: Likewise. + * src/wc.c: Likewise. + + * lib/Makefile.am (noinst_HEADERS): Add safe-read.h. + + * src/wc.c [HAVE_INTTYPES_H]: Include inttypes.h. + Declare counters to be of type uintmax_t. + (write_counts): Use human_readable to format potentially-long-long + numbers. Suggestion from Rogier Wolff. + (wc): Declare per-file counters to be of type uintmax_t. + Declare bytes_read to be ssize_t. + * lib/Makefile.am (libtu_a_SOURCES): Add human.c. + (noinst_HEADERS): Add human.h. + + * lib/human.c: New file. + * lib/human.h: New file. + +1998-04-04 Jim Meyering + + * configure.in (jm_AC_HEADER_INTTYPES_H): Use it. + (jm_AC_TYPE_UINTMAX_T): Use it. + (jm_PREREQ): Use it. + + * Makefile.am (ACLOCAL_AMFLAGS): Define this, so automake/aclocal + know about the m4/ subdirectory. + * Makefile.maint (aclocal-files): Remove now-unnecessary (with + automake-1.2h and the above change) aclocal-related rules and includes. + +1998-04-03 Jim Meyering + + * lib/closeout.c: New file. + * lib/closeout.h: New file. + * lib/Makefile.am (libtu_a_SOURCES): Add closeout.c. + (noinst_HEADERS): Add closeout.h. + +1998-03-31 Jim Meyering + + * lib/xstrtol.c: Merge with the version from fileutils. + +1998-03-27 Jim Meyering + + * Makefile.am (AUTOMAKE_OPTIONS): Require 1.2h. + +1998-03-23 Jim Meyering + + * acconfig.h: Remove HAVE_INTTYPES_H, now that m4/inttypes_h.m4 + automatically handles it. + +1998-03-19 Jim Meyering + + * src/system.h (SCHAR_MIN): Define. + (SHRT_MIN): Define. + od.c needs these when compiling with NCR's R2.0c C compiler. + (TYPE_MAXIMUM): Cast result to `(t)' so this macro works with + `unsigned char'. + From Greg Wooledge. + +1998-03-15 Jim Meyering + + * src/tail.c (tail_file): Merge largely-duplicated blocks of code. + +1998-03-03 Paul Eggert + + * src/sort.c (xtmpfopen): Open temporary file exclusively, to + foil a common denial-of-service attack. + * src/tac.c (save_stdin): Likewise. + +1998-02-16 Jim Meyering + + * configure.in (jm_FUNC_LSTAT): Use it. + (jm_FUNC_STAT): Use it. + * lib/Makefile.am (EXTRA_DIST): Add lstat.c and stat.c. + +1998-02-06 Jim Meyering + + * configure.in: Don't use AM_MAINTAINER_MODE or + AC_PATH_PROG(PERL, perl). + (jm_PERL): Use this. + +1998-02-04 Jim Meyering + + * tests/Makefile.am.in (EXTRA_DIST): Remove mk-script.pl. + (mk_script): Set to ../mk-script. + (x-tests): Use `$(PERL) -w -- $(mk_script)', not ./mk-script. + Remove @MAINT@ cruft. + (Makefile.am): Likewise. + Remove @MAINT@ cruft. Now `missing' will explain the failure + when people don't have Perl yet modify a file whose rebuilding + would lead to the use of Perl. + + * tests/Makefile.am (EXTRA_DIST): Add mk-script. + * tests/*/mk-script.pl: Remove files. + + * GNUmakefile: New file. + * Makefile.am (EXTRA_DIST): Add GNUmakefile. + Don't include Makefile.maint from here. It's included from GNUmakefile. + +1998-01-30 Paul Eggert + + * configure.in (AC_LFS): Put before anything that can affect or use + CPPFLAGS, LDFLAGS, or LIBS. + +1998-01-25 Jim Meyering + + * Makefile.maint: New file. + * Makefile.am: Move rules common to textutils, fileutils, sh-utils + into Makefile.maint. + Include Makefile.maint. + (EXTRA_DIST): Add Makefile.maint. + + * src/cat.c (cat): Convert comma-expressions to pairs of + semicolon-terminated stmts. + Add braces around compound if/else stmts. + +1998-01-24 Jim Meyering + + * src/tail.c (parse_obsolescent_option): Do not interpret `-f -n 1 ...' + as obsolescent options. + Accept new option: --sleep-interval=SECONDS (-s). + (parse_options): Recognize it. + (usage): Describe it. + (tail_forever): Use it. + (dump_remainder): Use it. + * tests/tail/Test.pm (f-1): Add test for option-processing of `-f -n 1'. + + * tests/cut/: Rename directory to remove `-test' suffix. + * tests/join/: Likewise. + * tests/md5sum/: Likewise. + * tests/pr/: Likewise. + * tests/sort/: Likewise. + * tests/tr/: Likewise. + * configure.in (AC_OUTPUT): Reflect renamings in tests/. + * tests/Makefile.am (SUBDIRS): Reflect renamings in tests/. + + * src/system.h (TYPE_MINIMUM): Add extra outer cast to work around + bug in Cray C 5.0.3.0 when T == time_t. + +1998-01-18 Jim Meyering + + * src/sort.c (strncoll, strncoll_s2_readonly, look_for_fraction, + numcompare): Remove the `unsigned' from some `unsigned char*' + parameter types. Add casts via UCHAR where necessary to avoid + problems with unwanted sign extension. Based on a patch from + Kaveh Ghazi to appease Irix4's cc compiler. + +1998-01-17 Jim Meyering + + * src/split.c (next_file_name): Rewrite. This removes an artificial + limit (albeit already high, at INT_MAX :-) on the number of files + split could create. Reported by Ralf W. Stephan. + +1998-01-16 Jim Meyering + + * src/sort.c (mergefps): Add braces to avoid ambiguous `else' stmt. + (nls_set_fraction): Likewise. + + * src/sort.c: Guard inclusion of langinfo.h also with HAVE_LANGINFO_H, + for Irix-4.0.5. From Kaveh Ghazi. + * configure.in: Check for langinfo.h. + + * lib/getline.c: Make PARAMS-defining conditionals consistent. + * lib/linebuffer.h: Likewise. + * lib/long-options.h: Likewise. + * lib/memcasecmp.h: Likewise. + * lib/xstrtod.h: Likewise. + * lib/xstrtol.h: Likewise. + Suggestion from Kaveh Ghazi. + + * tests/head/Test.pm (fail-0): Disable test. It depends on + sizeof(long) being 32 bits. Reported by Kaveh Ghazi. + +1998-01-10 Jim Meyering + + * Version 1.22d. + + * src/system.h [HAVE_LIMITS_H]: Include limits.h + (TYPE_SIGNED): Define. + (TYPE_MINIMUM): Define. + (TYPE_MAXIMUM): Define. + (CHAR_BIT): Define. + (SCHAR_MAX): Define. + (UCHAR_MAX): Define. + (SHRT_MAX): Define. + (INT_MAX): Define. + (UINT_MAX): Define. + (LONG_MAX): Define. + (ULONG_MAX): Define. + * src/*.c: Remove definitions of those symbols. + + * src/csplit.c: Move inclusion of regex.h/rx.h to follow system.h + since it now includes limit.h which defines RE_DUP_MAX. + * src/nl.c: Likewise. + * src/tac.c: Likewise. + + * lib/xstrtol.c (bkm_scale): Renamed from BKM_SCALE. + Rewrite macro as function. Return a value. Update caller. + Cast __ZLONG_MAX `__unsigned long int' before casting to double to + avoid SunOS /bin/cc compiler bug. + +1998-01-08 Jim Meyering + + * src/tac-pipe.c: New file. But not yet used. + * src/Makefile.am (EXTRA_DIST): Add tac-pipe.c. + + * src/tac.c (tac_stream): Don't perform arithmetic on now-void* pointer + result of xrealloc (until recently it was char*). + + * configure.in (AC_CHECK_FUNCS): Add nl_langinfo. + * src/sort.c (inittables): Add && HAVE_NL_LANGINFO to the #if-test + guarding the nls month-checking code. + (nls_numeric_format): Remove unnecessary (and error-evoking w/SunOS' cc) + `unsigned' from dcls of text and lim. + (main): Cast lconvp->grouping to `unsigned char*' to appease SunOS's cc. + +1998-01-03 Jim Meyering + + * lib/Makefile.am (AUTOMAKE_OPTIONS): Define to ../src/ansi2knr. + + * configure.in: Convert the .o suffix on files in LIBOBJS to $U.o so + those files will be built via the ANSI2KNR-filtering rules if necessary. + +1997-12-25 Jim Meyering + + * configure.in: Remove AC_DEFINE of _GNU_SOURCE. + * acconfig.h (_GNU_SOURCE): Define if not already defined. + Put this code in @TOP@ section. + (_GNU_SOURCE): Remove #undef. + +1997-12-22 Jim Meyering + + * configure.in: AC_DEFINE _GNU_SOURCE. + * acconfig.h: Add _GNU_SOURCE. + +1997-12-21 Jim Meyering + + * configure.in (AC_CHECK_HEADERS): Add stdlib.h. + + * src/system.h: Merge in things from fileutils' version of this file. + * src/csplit.c: s/__P/PARAMS/. + * src/fmt.c: s/__P/PARAMS/. + * src/od.c: s/__P/PARAMS/. + * src/pr.c: s/__P/PARAMS/. + +1997-12-14 Jim Meyering + + * src/sys2.h: s/HAVE_DECLARATION_/HAVE_DECL_/g. + +1997-12-13 Jim Meyering + + * src/fmt.c (main): Add some braces. + Check return code from fclose of each input file. + Close stdout and check for errors. + + * src/csplit.c (close_output_file): Check ferror before calling fclose. + (main): Close stdout and check for errors. + +1997-11-15 Jim Meyering + + * acconfig.h: Add mktime. + * configure.in (jm_FUNC_MKTIME): Use it. + * lib/mktime.c: New file. + * lib/Makefile.am (EXTRA_DIST): Add mktime.c + + * intl/Makefile.in (distclean): Don't remove libintl.h here. + * Makefile.am (DISTCLEANFILES): Remove it here instead. + +1997-11-13 Jim Meyering + + * lib/strftime.c: Update from FSF. + * m4/strftime.m4: Check for POSIX.2's %f format spec. + +1997-11-12 Jim Meyering + + * src/system.h [!HAVE_MEMPCPY] (mempcpy): Define. + * configure.in (AC_CHECK_FUNCS): Add mempcpy. + +1997-11-09 Jim Meyering + + * configure.in (jm_FUNC_STRFTIME): Use it. + * m4/jm-mktime.m4 (jm_FUNC_MKTIME): Check for localtime_r. + * m4/strftime.m4 (jm_STRFTIME_PREREQS): Check for localtime_r. + (jm_FUNC_GNU_STRFTIME): Use new macro. + (jm_FUNC_STRFTIME): New macro. Likewise. + Reported by Noel Cragg. + +1997-11-08 Jim Meyering + + * m4/lfs.m4 (AC_LFS): New file/macro. + * m4/Makefile.am (EXTRA_DIST): Add lfs.m4. + * configure.in (AC_LFS): Use it. + (AC_CHECK_FUNCS): Add fseeko. + * src/od.c (fseeko): Define a stub if ! HAVE_FSEEKO. + (skip): Use fseeko if available. Don't use lseek; it causes + the stdio stream to become out of sync with respect to the + underyling file descriptor. + From Paul Eggert. + +1997-10-16 Paul Eggert + + * configure.in (AC_CHECK_FUNCS): Add fseeko. + + * src/od.c (skip): Use fseeko. Don't use lseek; it causes + the stdio stream to become out of sync with respect to the + underyling file descriptor. + +1997-11-06 Jim Meyering + + * src/sort.c (getmonth): Remove HAVE_ALLOCA #ifdefs. + We always have alloca. + (keycompare): Don't use variable size arrays (it's a gcc-extension). + Rewrite code that increments new lengths when not `ignoring'. + +1997-11-02 Jim Meyering + + * acconfig.h: Add malloc and realloc. + + * src/wc.c (main): New option, --max-line-length (-L). + (wc, write_counts): Implement it. + From Bruno Haible. + +1997-10-26 Jim Meyering + + * lib/memcasecmp.c: Convert to upper case before comparing. + This makes join -i work with sort -f. + Reported by Arthur Pool. + +1997-10-25 Jim Meyering + + * lib/xmalloc.c (xalloc_fail): Renamed from fixup_null_alloc. + (xcalloc): #ifdef-out unused function. + (xrealloc): Remove code to work around deficient versions of realloc. + Now we have an autoconf-enabled replacement version. + (xmalloc): Remove code to work around deficient versions of malloc. + Now we have an autoconf-enabled replacement version. + + * lib/memcmp.c (rpl_memcmp): Rename from memcmp. + + * src/sort.c (NLS_STRNCMP) [!ENABLE_NLS]: s/strcmp/strncmp/. + + * lib/xmalloc.c (xalloc_fail_func): Initialize to 0, not NULL. + + * configure.in (jm_FUNC_MALLOC): Use it. + (jm_FUNC_REALLOC): Use it. + + * lib/Makefile.am (EXTRA_DIST): Add malloc.c. + * lib/malloc.c: New file. + * m4/malloc.m4: New file. + * m4/Makefile.am (EXTRA_DIST): Add malloc.m4. + + * lib/Makefile.am (noinst_HEADERS): Add xalloc.h. + (EXTRA_DIST): Add realloc.c. + (EXTRA_DIST): Add malloc.c. + + * src/system.h: Include xalloc.h. + Remove dcls of xmalloc, xcalloc and xrealloc. + + * lib/xalloc.h: New file. + + * lib/xmalloc.c: Include xalloc.h. + Change VOID to void. + (xalloc_exit_failure): Renamed extern. + (xalloc_msg_memory_exhausted): New extern. + (xalloc_fail_func): New extern. + (fixup_null_alloc): Use new variables. + +1997-10-24 Jim Meyering + + * src/unexpand.c: Remove old-style xmalloc and xrealloc decls. + (add_tabstop): Cast first arg of xrealloc to char*. + + * src/sort.c: Include xalloc.h. + (xmalloc): Remove function. + (xrealloc): Remove function. + (main): Set xalloc_fail_func to cleanup. + Set xalloc_exit_failure SORT_FAILURE. + + * src/paste.c: Remove old-style xmalloc and xrealloc decls. + (paste_parallel): Cast first arg of xrealloc to char*. + + * src/od.c: Remove old-style xmalloc and xrealloc decls. + (decode_format_string): Cast first arg of xrealloc to char*. + + * src/expand.c: Remove old-style xmalloc and xrealloc decls. + (add_tabstop): Cast first arg of xrealloc to char*. + + * lib/xalloc.h: New file. + + * src/cut.c (ADD_RANGE_PAIR): Cast first arg of xrealloc to char*. + (getstr): Cast xmalloc return value to char*. + + * src/csplit.c: Include xalloc.h. + (xmalloc): Remove function. + (xrealloc): Remove function. + (main): Set xalloc_fail_func to cleanup. + + * src/*.c: Remove old-style xmalloc and xrealloc decls. + * src/system.h: Add prototyped xcalloc, xmalloc and xrealloc decls. + Suggestion from Achim Blumensath. + +1997-10-23 Jim Meyering + + * Makefile.am (aclocal-files): Also depend on m4/Makefile.am. + + * src/system.h [!HAVE_DECLARATION_FREE]: Declare free. + [!HAVE_DECLARATION_MALLOC]: Declare malloc. + [!HAVE_DECLARATION_REALLOC]: Declare realloc. + [!HAVE_DECLARATION_STPCPY]: Declare stpcpy. + [!HAVE_DECLARATION_STRSTR]: Declare strstr. + * src/cat.c: Remove stpcpy dcl. + * src/csplit.c: Remove malloc and realloc dcls. + * src/sort.c: Remove free, malloc, and realloc dcls. + * src/tac.c: Remove malloc, and realloc dcls. + * src/tr.c: Remove stpcpy dcl. + On some systems, strstr and stpcpy are macros, so declaring them + unconditionally gets syntax errors. + Reported by Mark M. Kettenis. + + * configure.in: Use jm_CHECK_DECLS. + * m4/Makefile.am (EXTRA_DIST): Add decl.m4 and check-decl.m4. + +1997-10-22 Jim Meyering + + * m4/decl.m4: New file. + * m4/check-decl.m4: New file. New macro, jm_CHECK_DECLS. + +1997-10-16 Paul Eggert + + * src/od.c (LONG_MAX): Define if not defined. + +1997-10-16 Jim Meyering + + * src/sort.c (look_for_fraction): Patch from Ĝrn Hansen. + (getmonth): Compare the two month names only to the length of the + string in the month table. Patch from Ĝrn Hansen. + (NLS_STRNCMP): New macro. + (strncoll_s2_readonly): New function. + (inittables): Don't use temporary `comp' to hide type of + comparator function. + (nls_sort_month_comp): Declare parameters to be void* to match + comparator function type required for qsort. + (getmonth): Use NLS_STRNCMP rather than #ifdef. + Use do-while, rather than while-loop. + +1997-10-14 Jim Meyering + + * src/sort.c (_NL_ITEM) [!defined]: Define. + From from Ĝrn E. Hansen. + + * src/sort.c: Use STREQ in place of most uses of strcmp. + (NLS_STRCMP): Define. + (getmonth): Remove ifdef and use NLS_STRCMP instead. + Use HAVE_ALLOCA, not _HAVE_ALLOCA. + (zaptemp): Make parameter `const'. + + * tests/sort-test/Test.pm: Add tests to exercise new fraccompare. + + * src/sort.c (CHARS_IN_ABM): Remove definition + (inittables): Remove assumption that all abbreviated month names have + length 3. + (getmonth): Likewise. + (main): Add #if's for more efficient code when using the GNU C library. + From Ulrich Drepper. + + * src/sort.c (strncoll): Rename parameter to LEN. + (keycompare): Move assignment out of if-expression. + + * lib/xstrdup.c: New file. + * lib/Makefile.am (libtu_a_SOURCES): Add xstrdup.c + + * src/sort.c: Declare xstrdup. + (my_setlocale): New function. + (main): Guard against failure of strdup (use xstrdup) and setlocale. + + * src/system.h (STREQ): Define. + * src/od.c (STREQ): Remove definition. + + * src/sort.c (look_for_fraction): Eliminate arbitrary limit on + number of `groups'. Declare as void, not int. + Patch from Ĝrn E. Hansen. + (main): When determining whether we're in the C or POSIX locale, + don't rely on the form of the string returned by setlocale. + Suggestion from Ulrich Drepper. + +1997-10-12 Jim Meyering + + * src/sort.c: Apply big patch from Ĝrn E. Hansen. + Clean up, indent. + (NLS_MEMCMP): Define. + (keycompare): Use it instead of open-coded #ifdefs. + (compare): Likewise. + (NLS_MAP): Remove unused definitions. + Replace with uses of UCHAR. + (nls_locale_map): Remove dcl of unused file-scope array. + +1997-10-10 Jim Meyering + + * tests/sort-test/Test.pm: Add a test. + From William Lewis. + +1997-10-07 Jim Meyering + + * src/*.c: Update bug-reporting address. + * src/cat.c: Indent cpp directives to reflect nesting. + * src/cksum.c: Likewise. + * src/csplit.c: Likewise. + * src/fmt.c: Likewise. + * src/nl.c: Likewise. + * src/paste.c: Likewise. + +1997-09-27 Jim Meyering + + * m4/memcmp.m4: Integrate test to detect bug in memcmp from the + Next x86 OpenStep C library. Test program from William Lewis. + +1997-09-21 Jim Meyering + + * src/od.c [struct tspec] (hexl_mode_trailer): Rename from `trailer.' + (dump_hexl_mode_trailer): Rename from dump_string_trailer. + Use fputs and putchar instead of trivial or %-less printfs. + (decode_one_format): Parenthesize each field_width assignment in an + argument list to make the side effect a little more apparent. + (write_block): Use fputs and putchar instead of trivial or %-less + printfs. + (dump_strings): Cast string_min to off_t to avoid long-standing warning. + + * src/od.c: Implement new `z' (hexl-mode) modifier. + [struct tspec] (trailer): New field. + (field_width): Likewise. + (dump_string_trailer): New function. + (decode_one_format): Save each field_width in the tspec. + Patch from John Kodis. + +1997-09-14 Jim Meyering + + * src/od.c (main) [--traditional]: Don't give diagnostic about there + being more than three arguments if there are *no* arguments specified. + Reported by Jochen Hein. + +1997-09-13 Jim Meyering + + * tests/sort-test/Test.pm: Add tests 19a and 19b. + +1997-07-21 Jim Meyering + + * src/tail.c (parse_obsolescent_option): #ifdef-out portability warning. + +1997-07-19 Jim Meyering + + * src/sort.c (checkfp): Print the `disorder' message. Include both + the number and the contents of the first out-of-order line, in addition + to the file name. Change meaning of return value. + (check): Don't print disorder message here. + Adjust test of checkfp's return value. + Feature suggestion from Karl Heuer. + +1997-07-13 Jim Meyering + + * doc/Makefile.am (EXTRA_DIST): Remove explicit mention of texinfo.texi. + Now, automake includes it automatically. + + * src/head.c: Include xstrtoul.h. + Remove global variable, unit_size. + (atou): Remove now-unused function. + (parse_unit): Likewise. + (string_to_ull): New function. + (head): Take new parameter, count_lines. Use it instead of unit_size. + Update callers. + (head_file): Likewise. + (main): Use string_to_ull, not atou/parse_unit. + The problem was that overflow wasn't detected, so `head -c 4096m' + was treated just like `head -c 0'. + Reported by Jerome Abela. + + * tests/wc: New directory. + * tests/head: New directory. + * tests/Makefile.am (SUBDIRS): Add head and wc. + * configure.in (AC_OUTPUT): Add tests/head/Makefile and + tests/wc/Makefile. + +1997-07-05 Jim Meyering + + * src/tail.c (parse_obsolescent_option): If POSIXLY_CORRECT is set, give + a diagnostic and fail when there are two or more non-option arguments. + +1997-07-04 Jim Meyering + + * tests/tac/mk-script.pl: Redirect output of cmp to /dev/null. + + * configure.in (ALL_LINGUAS): Add Norwegian (no). + + * Makefile.am (aclocal-files): Look in source directory, not build dir. + From Andreas Schwab. + +Sun Jun 15 06:36:41 1997 Jim Meyering + + * src/pr.c (init_header) [T_BUF_FMT]: Output the 4-digit year (not the + 2-digit abbreviation) in each page header. Reported by Noah Friedman. + +Sat Jun 14 12:29:12 1997 Jim Meyering + + * src/cut.c (cut_fields): Detect when the input is empty and handle + that special case. Before `cut -f1 < /dev/null' would improperly + output a single newline. Reported by Phil Richards. + +Sun Apr 27 15:10:58 1997 Jim Meyering + + * man/Makefile.am (DISTFILES): Add $(man_MANS). + + * configure.in (ALL_LINGUAS): Add Czech (cs) and Swedish (sv). + +Thu Apr 3 21:14:02 1997 Jim Meyering + + * m4/Makefile.am (EXTRA_DIST): Update file list. + + * tests/cut-test/Test.pm: Add test from Phil Richards. + +Sat Mar 22 20:29:10 1997 Jim Meyering + + * missing: New file -- from the automake-1.1m distribution. + +Fri Mar 21 23:56:41 1997 Jim Meyering + + * Makefile.am (AUTOMAKE_OPTIONS): Require automake-1.1l. + (aclocal.m4): Use aclocal's new -I option. + +Thu Mar 13 21:46:04 1997 Jim Meyering + + * src/tr.c (main): Make sure c1 is not -1 before using it as an + array index. Patch from Greg McGary. Although this is truly a + bug, I believe it would not cause tr to misbehave on most systems. + I could not construct a test case with which this bug causes tr + to generate invalid output. + + * tests/pr-test/Test.pm: Add test that -o 0 works. + + * src/pr.c (main): Allow use of 0 (zero) as the margin offset + argument to the -o option. Patch from Gary Anderson. + +Fri Feb 28 22:32:51 1997 Jim Meyering + + * src/uniq.c (usage): Fix typo in --help output. From Andreas Schwab. + +Tue Feb 25 20:34:51 1997 Jim Meyering + + * lib/Makefile.am (noinst_HEADERS): Add obstack.h. + (libtu_a_SOURCES): Add obstack.c. + +Sun Feb 16 08:30:29 1997 Jim Meyering + + * tests/Makefile.am (SUBDIRS): Add tac. + * tests/tac: New directory. + * configure.in (AC_OUTPUT): Add tests/tac/Makefile. + + * tests/pr-test/{tt-0FF, tt-bl, tta3-0FF, ttb3-0FF, tt-FF, tt-t, + tta3-FF, ttb3-FF}: New files. Renamed (s/T/tt/) to avoid name clashes + on case-independent filesystems. + * tests/pr-test/Test.pm (Tests '7.*'): Reflect file-renaming. + + * src/tail.c (parse_obsolescent_option): Reverse order of args in + diagnostic. Remove `' quotes in diagnostic. + (parse_options): Remove `' quotes in diagnostic. + +Sat Feb 8 22:43:45 1997 Jim Meyering + + * src/tail.c (parse_obsolescent_option): Give warning diagnostic for + (but now accept) obsolescent usage with more than one file argument. + +Sun Feb 2 23:06:59 1997 Jim Meyering + + * src/join.c: Move alloca-related preprocessor code into system.h. + * src/od.c: Remove alloca-related preprocessor code. + * src/system.h: Add alloca-related preprocessor code. + +Sat Feb 1 07:21:43 1997 Jim Meyering + + * tests/pr-test/*: Rename files to avoid exceeding 14-character limit. + * tests/pr-test/Test.pm: Reflect renamings. + + * tests/pr-test/mk-script.pl (spec_to_list): Warn about all filenames + that exceed max-length before dying. + + * src/pr.c (init_parameters): For compatibility: use default + separator `TAB' with full length lines. From Roland Huebner. + +Fri Jan 31 19:53:54 1997 Jim Meyering + + * src/tac.c: Rename globals buffer and buffer_size to have G_ prefix + to avoid shadowing local variables. + + * lib/long-options.c (parse_long_options): Compare getopt_long return + value against -1, not EOF. Use NULL, not `(int *) 0' as last parameter + in getopt_long call. + + * src/pr.c (add_line_number): Rename from `number' to avoid shadowing + local variables. + + * src/*.c: Compare getopt_long return value against -1, not EOF. + Use NULL, not `(int *) 0' as last parameter in getopt_long call. + (usage): Bracket bug-reporting address with <> and append a period. + +Wed Jan 29 20:54:24 1997 Jim Meyering + + * tests/tr-test/Test.pm: Do each test twice: get input via REDIR + and PIPE. + + * tests/tail/Test.pm (test_vector): Do each (non-stdin-requiring) + test three times. + + * tests/pr-test/Test.pm: Remove common_option_prefix flag. + (test_vector): Prepend the common option here instead. + + * tests/md5sum-test/Test.pm: Remove input_via_stdin flag. + Do each test twice: get input via REDIR and PIPE. + + * tests/cut-test/Test.pm: Do each test three times. + + * tests/cut-test/mk-script.pl: Allow each test to be run any or all + of three different ways. Program input may be specified via a file + or files listed on the command line, via input redirection (if there's + only one file), or via a pipe. + +Tue Jan 28 20:54:06 1997 Jim Meyering + + * tests/cut-test/mk-script.pl: Remove `t' prefix on all generated + test file names. + Change suffixes from (.in, .exp, .out, .err) to (.I, .X, .O, .E). + Ensure that no test file (generated or maintainer-supplied) has a + name longer than 14 characters. + +Sun Jan 26 12:49:50 1997 Jim Meyering + + * Version 1.22. + + * src/tail.c (parse_options): Add quotes to make messages identical. + +Sat Jan 25 00:12:29 1997 Jim Meyering + + * src/tail.c (parse_obsolescent_option): Comment. + (parse_options): Remove unnecessary goto and label. + + * tests/sort-test/mk-script.pl: Interpret `input arg is a hash + reference' as meaning that the tested program will read no input. + Most of the tests for the date program use this feature. + Also for date, the generated script now reflects specification + (in Test.pm) of default and per-test environment settings. + + * src/csplit.c: Reflect changes to xstrtol and xstrtoul interfaces. + * src/fold.c: Likewise. + * src/head.c: Likewise. + * src/join.c: Likewise. + * src/nl.c: Likewise. + * src/od.c: Likewise. + * src/pr.c: Likewise. + * src/uniq.c: Likewise. + + * lib/xstrtoul.h (XSTRTOL_H): Undefine it. + + * lib/xstrtol.h [!_STRTOL_ERROR]: Define the type `enum strtol_error' + only if it hasn't already been defined. + (_STRTOL_ERROR): Undefine. + + * lib/xstrtol.c (__xstrtol): Change interpretation of + VALID_SUFFIXES == NULL vs VALID_SUFFIXES == "". Use the former + when any suffix is valid, the later when no suffix is allowed. + +Fri Jan 24 23:36:00 1997 Jim Meyering + + * lib/long-options.c (parse_long_options): Reset optind to zero + before just returning so that getopt internals get initialized from + the probably-new parameters when/if getopt is called later. + From Ulrich Drepper. + +Thu Jan 23 19:17:03 1997 Jim Meyering + + * src/tail.c (parse_obsolescent_option): Recognize and fail for + more malformed obsolescent options. Makes for better diagnostics. + +Wed Jan 22 21:34:50 1997 Jim Meyering + + * tests/Makefile.am (SUBDIRS): Add tail. + * tests/tail: New directory. + * configure.in (AC_OUTPUT): Add tests/tail/Makefile. + + * src/tail.c (parse_options): New function. + (parse_obsolescent_option): New function. + (main): Use the new functions instead of open-coding them. + This better fixes the bug in handling obsolescent `+Nc' options. + General cleanup. + +Tue Jan 21 22:49:00 1997 Jim Meyering + + * src/tail.c (main): Properly handle what the POSIX spec calls + the `obsolescent' usage (e.g., tail +2c). It didn't work. + Reported by Karl Heuer. + +Sun Jan 12 22:13:27 1997 Jim Meyering + + * tests/tr-test/Test.pm: Rename tests so that the associated files + have names that are distinct even on filesystems on which file + names are case insensitive. + Reported by Fred Fish. + * tests/cut-test/Test.pm: Likewise. + + * tests/tr-test/Makefile.am: Regenerated to reflect renamed tests. + * tests/cut-test/Makefile.am: Likewise. + +Wed Jan 8 16:38:24 1997 Jim Meyering + + * Version 1.21. + + * lib/getopt.c (_getopt_internal): Use `_', rather than the + (sometimes-)expansion `gettext'. + +Tue Jan 7 22:50:13 1997 Jim Meyering + + * lib/getopt.c: New (more POSIX compliant) version from GNU libc. + [_]: Define to gettext also if ENABLE_NLS is defined. + This is temporary. + +Thu Jan 2 21:17:50 1997 Jim Meyering + + * src/pr.c (init_fps): Initialize lines_stored field in three places. + This avoids uninitialized memory reads in close_file. + +Wed Jan 1 17:32:18 1997 Jim Meyering + + * configure.in (AC_ARG_PROGRAM): Remove explicit use. + It's implicit in AM_INIT_AUTOMAKE. From Wayne Stewart. + +Sun Dec 29 23:42:57 1996 Jim Meyering + + * src/pr.c (init_header): Plug a small memory leak by using stack + rather than heap for a 15-byte temporary buffer. + +Sat Dec 28 00:03:23 1996 Jim Meyering + + * src/pr.c (TAB_WIDTH): Parenthesize uses of parameters and renamed + from tab_width. + (POS_AFTER_TAB): Renamed from pos_after_tab. Define in terms of + TAB_WIDTH rather than duplicating the expression. + +Fri Dec 27 17:29:02 1996 Jim Meyering + + * tests/join-test/mk-script.pl: Fix a couple of thinkos and typos. + Now it works with pr's tests, too. + + * tests/pr-test/Makefile.am (explicit): Regenerate list of files, + this time with duplicates removed. + + * src/pr.c (usage): Break long string literal into two separate + printf statements to accomodate default maximum of 2048 characters + for Irix-4.0.5. Reported by Kaveh Ghazi. + + * Makefile.am (aclocal.m4): No longer depend on acinclude.m4. + + * tests/Makefile.am (SUBDIRS): Add pr-test. + + * configure.in: AC_REQUIRE version 2.12 of autoconf. + AC_OUTPUT: Add tests/pr-test/Makefile. + +Sun Dec 22 08:11:27 1996 Jim Meyering + + * acinclude.m4: Move macros to individual files in new directory, m4/. + See ChangeLog entries in sh-utils for the details. + + * configure.in: Increment version to 1.20a. + + * tests/md5sum-test/Makefile.am: Use same framework as other tests. + * tests/md5sum-test/Test.pm: New file. + +Sat Dec 21 20:32:58 1996 Jim Meyering + + * tests/Makefile.am (EXTRA_DIST): Add README and Makefile.am.in. + + * tests/Makefile.am.in: New file. + + * tests/sort-test/Makefile.am: Clone the Makefile.am from join-test. + Replace only the definition of $x and the auto-generated lists of + test files. + * tests/cut-test/Makefile.am: Likewise. + * tests/tr-test/Makefile.am: Likewise. + + * tests/join-test/Makefile.am: Add @MAINT@-protected rule for + verifying that Makefile.am is consistent with Test.pm. + +Fri Dec 20 00:08:36 1996 Jim Meyering + + * tests/join-test/Makefile.am (MAINTAINERCLEANFILES): Use $(in1) + and $(in2), not $(in). + + * tests/join-test/mk-script.pl: New option: --list. + Generate lists of files used/generated. + +Thu Dec 19 23:28:41 1996 Jim Meyering + + * tests/join-test/mk-script.pl: Rewrite to be more general -- so + it can be used for join, cut, sort, tr, and soon, pr test suites. + * tests/tr-test/mk-script.pl: Symlink through CVS repo to join's + mk-script.pl. + * tests/sort-test/mk-script.pl: Likewise. + * tests/cut-test/mk-script.pl: Likewise. + + * tests/tr-test/Test.pm: Adapted for new mk-script.pl. + * tests/join-test/Test.pm: Likewise. + +Tue Dec 17 16:48:51 1996 Jim Meyering + + * tests/join-test/Makefile.am (.pl): Make generated file read-only so + I don't accidentally modify it instead of the one with the .pl suffix. + + * acinclude.m4 (jm_SYS_PROC_UPTIME): Require AC_PROG_CC, rather than + now-obsolete AC_C_CROSS. + (jm_FUNC_MKTIME): When redefining, use rpl_ prefix, not gnu_ one + since there's nothing GNU-specific about the replacement. Contrast + with gnu_ prefix added to strftime. + (jm_FUNC_MEMCMP): New macro. + * configure.in: Use jm_FUNC_MEMCMP instead of AM_FUNC_MEMCMP. + * acconfig.h: Add memcmp. + * README: Remove warning about memcmp. The new macro handles it. + +Mon Dec 16 23:03:27 1996 Jim Meyering + + * tests/Makefile.am (pkgdata_DATA): Remove unnecessary assignment. + From Eric Backus. + (AUTOMAKE_OPTIONS): Likewise. + +Sat Dec 14 14:51:50 1996 Jim Meyering + + * acinclude.m4 (jm_SYS_PROC_UPTIME): Fix typo in cache variable + name for cross compiling. + Remove definitions of gettext-related macros. The gettext + installation procedure installs corresponding .m4 files so that + aclocal will use them. + +1996-12-12 Paul Eggert + + * system.h (ISDIGIT): Replace with smaller, faster edition + that yields nonzero only on ASCII digits. + (ISDIGIT_LOCALE): New macro, with same meaning that ISDIGIT + used to have. + + * tr.c (is_char_class_member): Use ISDIGIT_LOCALE instead of + ISDIGIT to test for characters in CC_DIGIT class. + + * sort.c (digits): Remove; subsumed by new ISDIGIT. + (inittables): Remove initialization of `digits'. + (fraccompare, numcompare, main): Use ISDIGIT (x) instead of digits[x]. + (fraccompare, numcompare): Avoid casts to unsigned char that are no + longer needed. + + * csplit.c (get_format_width, get_format_prec): Avoid + unnecessary comparison of digit to '\0'. + +Thu Dec 12 23:42:51 1996 Jim Meyering + + * src/sort.c (usage): Clarify description of -u option. + From Karl Berry. + +Wed Dec 11 19:32:18 1996 Jim Meyering + + * Version 1.20. + +Tue Dec 10 00:15:50 1996 Jim Meyering + + The file name, `build-script.pl' is longer than 14 characters. + Rename it. + * tests/cut-test/mk-script.pl: Rename from build-script.pl. + * tests/cut-test/Makefile.am: Reflect renaming. + * tests/tr-test/mk-script.pl: Rename from build-script.pl. + * tests/tr-test/Makefile.am: Reflect renaming. + * tests/sort-test/mk-script.pl: Rename from build-script.pl. + * tests/sort-test/Makefile.am: Reflect renaming. + * tests/join-test/mk-script.pl: Rename from build-script.pl. + * tests/join-test/Makefile.am: Reflect renaming. + Reported by Karl Heuer. + + * configure.in (VERSION): Bump to 1.19r. + (AC_ISC_POSIX): Remove kludgy macro. + Use this test instead: + (LIBS): Add -lcposix if it contains strerror. + Patch from Karl Heuer. + +Sun Dec 8 07:22:38 1996 Jim Meyering + + =========== Update for automake-1.1k. + * Makefile.am (AUTOMAKE_OPTIONS): Require 1.1k. + * configure.in (AM_CONFIG_HEADER): Use it. + (AC_OUTPUT): Remove stamp-h timestamping statement. + Now, AM_CONFIG_HEADER does it automatically. + * lib/Makefile.am (noinst_LIBRARIES): Rename to libtu.a as per + new automake requirement. + Rename tu_* variables to libtu_a_*. + +Wed Dec 4 21:03:18 1996 Jim Meyering + + * src/pr.c: Apply big patch from Roland Huebner. + + * src/tr.c (main) [!POSIXLY_CORRECT]: Allow the identity mappings: + [:upper:] to [:upper:] and [:lower:] to [:lower:]. + (main) [POSIXLY_CORRECT]: Give a more specific diagnostic for + the invalid identity mappings [:upper:] to [:upper:] and [:lower:] + to [:lower:]. + (class_ok): Update table to reflect that tr now allows these + identity mappings. Suggestion from Risto Kankkunen. + +Thu Nov 28 00:31:18 1996 Jim Meyering + + * configure.in (AM_GNU_GETTEXT): Renamed from ud_GNU_GETTEXT + for gettext-0.10.25. + +Tue Nov 26 23:05:14 1996 Jim Meyering + + * src/sort.c (fraccompare): Add explicit `int' in `register' dcls, + to avoid new warning from gcc. + +Sun Nov 24 21:02:15 1996 Jim Meyering + + * tests/sort-test/Makefile.am (t): Add names of those 5 tests. + + * tests/sort-test/Test.pm: Add 5 tests to exercize just-fixed code. + + * src/sort.c (set_ordering): Revert 1994-05-04 change to this function + so that blanks are not unconditionally ignored when computing start + and end positions for numeric keys with explicit character offsets. + Reported by Markus Demleitner. + +Sat Nov 23 16:07:08 1996 Jim Meyering + + * cat.c (usage): Alphabetize option descriptions the way sort -f would. + * fmt.c (usage): Likewise. + * join.c (usage): Likewise. + * md5sum.c (usage): Likewise. + * od.c (usage): Likewise. + * pr.c (usage): Likewise. + * sort.c (usage): Likewise. + * split.c (usage): Likewise. + * wc.c (usage): Likewise. + From Karl Berry. + +Fri Nov 22 20:20:37 1996 Jim Meyering + + * src/csplit.c (process_regexp): Update CURRENT_LINE only if + the new value would be larger. This avoids the infinite loop + otherwise provoked by situations like this: + printf "\na\n" | csplit - '/a/-1' '{*}' + From Jens Schmidt. + +Tue Nov 19 23:16:57 1996 Jim Meyering + + * configure.in (AM_SANITY_CHECK_CC): Remove it. Autoconf-2.11 + has this built-in. + +Sat Nov 2 08:50:01 1996 Jim Meyering + + * doc/Makefile.am (MAKEINFO): Set to makeinfo --no-split. + Otherwise, the generated info files have names longer than + the 14-byte max of some old systems. + Reported by Karl Heuer. + +Fri Nov 1 21:33:16 1996 Jim Meyering + + * lib/strtol.c: Update from GNU libc. + + * tests/sort-test/Test.pm: Add a test to exercize this fix. + + * src/sort.c [!ENABLE_ASSERTIONS]: Guard NDEBUG definition. + (checkfp): Fix off-by-one error that resulted in writing one byte + beyond the end of a malloc'd buffer. It caused `sort -c' to segfault + on Linux systems having a relatively recent libc. Before, running + the command, perl -e "print 'x' x 30, \"\n\";"|sort -c + would provoke the memory overrun (though not necessarily the failure). + Add an assertion. + Reported by Risto Kankkunen. + +Thu Oct 31 17:48:24 1996 Jim Meyering + + * src/sort.c (key_init): New function. + (main): Use key_init in the two places where it was open-coded. + This fixes a UMR of the general_numeric field. + + * src/join.c (decode_field_spec): Always give FIELD_INDEX a value. + This avoids a spurious UMR report from purify. + (prjoin): Add an assertion. + (add_field): Update assertion. + + * src/tr.c (es_free): New function. + (parse_str): Use it to plug a small memory leak. + +Wed Oct 23 22:02:24 1996 Jim Meyering + + * lib/md5.c: Update from GNU libc. + * lib/md5.h: Update from GNU libc. + +Mon Oct 21 16:48:12 1996 Jim Meyering + + * src/tr.c (validate): Remove TAB from diagnostic, for consistency. + +Sun Oct 20 13:44:07 1996 Jim Meyering + + * lib/Makefile.am (INCLUDES): Add -I../intl. Reported by Eric Backus. + + * Makefile.am (AUTOMAKE_OPTIONS): Set to `gnits' + (EXTRA_DIST): Remove. + + * configure.in: Remove README_ALPHA related code. Automake takes + care of it automatically now when in gnits mode. + + * lib/md5.c (md5_process_bytes): Cast void* pointer to char* before + doing arithmetic with it. + +Sat Oct 19 23:13:54 1996 Jim Meyering + + * lib/md5.c: Update from GNU libc. + * lib/md5.h: Update from GNU libc. + +Fri Oct 18 00:08:04 1996 Jim Meyering + + * configure.in (AC_OUTPUT): Add tests/join-test/Makefile. + + * tests/Makefile.am (SUBDIRS): Add join-test. + +Tue Oct 15 23:25:31 1996 Jim Meyering + + * src/tr.c (get_next): Rewrite to treat lower/upper mapping as a + special case. + (main): Write separate loops to initialize mapping for lower->upper + and upper->lower conversion. + Reported by Arne Henrik Juul. + +Sun Oct 13 12:52:42 1996 Jim Meyering + + * lib/xstrtol.c (__xstrtol): Return an error for invalid suffix. + Before, e.g., `split -b 1M' would be silently accepted and treated + like `split -b 1'. Reported by Franc,ois. + + * src/split.c (usage): Remove parameter, REASON. + (main): Update callers to use combination of error (0, 0, ... and + usage (EXIT_FAILURE). + (main): When a string operand cannot be converted to a number of + bytes or lines, include that string in the diagnostic. + +Sat Oct 12 00:05:11 1996 Jim Meyering + + * configure.in (AC_REPLACE_FUNCS): Add strpbrk and strtol. + + * lib/Makefile.am (EXTRA_DIST): Remove. + +Thu Oct 10 23:41:36 1996 Jim Meyering + + * lib/md5.c (md5_stream): Apply fix from Ralph Loader + via Ulrich Drepper. + +Wed Oct 9 07:26:40 1996 Jim Meyering + + * lib/Makefile.am (tu_DEPENDENCIES): Depend on $(tu_LIBADD). + +Tue Oct 8 21:32:17 1996 Jim Meyering + + * lib/error.c: Include error.h to align with libit -- + under protest, François :-). + +Sun Oct 6 08:02:28 1996 Jim Meyering + + * acinclude.m4 (AC_HEADER_SYS_TIME_H, AM_FUNC_MKTIME, + AM_FUNC_ERROR_AT_LINE, AM_FUNC_OBSTACK): Remove definitions. + They're included in automake-1.1f. + + * configure.in (AM_FUNC_ERROR_AT_LINE): Use it instead of + open-coding it. + +Sat Oct 5 12:40:22 1996 Jim Meyering + + * lib/memcpy.c [HAVE_CONFIG_H]: Include config.h. + From Karl Berry. + +Fri Oct 4 07:20:37 1996 Jim Meyering + + * configure.in (GNU_PACKAGE): New variable. + (PACKAGE_VERSION): Remove it. + + * acconfig.h (GNU_PACKAGE): New variable. + (PACKAGE_VERSION): Remove now-unused variable. + + * lib/long-options.c (parse_long_options): Separate package name + and version number to accomodate new --version output requirement. + * lib/long-options.h: Update prototype. + +Thu Oct 3 23:27:31 1996 Jim Meyering + + * src/md5sum.c (main): Remove dead code that used to print --version + output. + +Tue Oct 1 06:54:22 1996 Jim Meyering + + * configure.in: Use result of AM_FUNC_STRTOD to set POW_LIBM. + * src/Makefile.am (sort_LDADD): Use any library (-lm) that + gets substituted for @POW_LIBM@. + + * tests/md5sum-test/md5-rfc (md5sum): Use ../../src/md5sum. + +Mon Sep 30 23:35:46 1996 Jim Meyering + + * tests/md5sum-test/md5-rfc (md5sum): Set to $srcdir/md5sum. + + * acinclude.m4: Update definitions from gettext-0.24. + +Sun Sep 29 20:04:53 1996 Jim Meyering + + * tests/sort-test/build-script.pl: Die if close fails. + * tests/tr-test/build-script.pl: Likewise. + + * configure.in (AC_OUTPUT): Add tests/cut-test/Makefile. + * tests/Makefile.am (SUBDIRS): Add cut-test. + * tests/cut-test: New directory. + +Fri Sep 27 22:22:09 1996 Jim Meyering + + * configure.in (ALL_LINGUAS): Add spanish (es). + +Thu Sep 26 21:02:54 1996 Jim Meyering + + * src/md5sum.c (usage): Remove references in --help output to + the now-deprecated --string option. Support for it will be + removed soon. Using this option can provoke a memory access + violation on some systems because of (unavoidable in an efficient + implementation) alignment assumptions made by functions in md5.c. + md5sum.c could leave the option in and accomodate the alignment + restriction, but this option was intended solely for testing, and + the tests are now all file-oriented, so it's not necessary. + + * tests/md5sum-test/md5-rfc: Rewrite to avoid use of --string option. + +Wed Sep 25 21:43:10 1996 Jim Meyering + + * tests/sort-test/Makefile.am (t): Factor out .in suffix. + Include new test: t16a. + * tests/tr-test/Makefile.am (t): Likewise. + + * src/Makefile.am (EXTRA_DIST): Remove md5-test.rfc. + +Mon Sep 23 10:00:50 1996 Jim Meyering + + * tests/md5sum-test/Makefile.am (EXTRA_DIST): Distribute $(TESTS). + +Sun Sep 22 09:24:22 1996 Jim Meyering + + * src/sort.c (keycompare): Declare translate to be unsigned char *. + Otherwise, sign extension caused misordering when using e.g. -f. + Reported by Erick Branderhorst. + * tests/sort-test/Test.pm: Add Erick's test for that fix. + + * tests/Makefile.am (SUBDIRS): Add md5sum-test. + +Sat Sep 21 13:34:59 1996 Jim Meyering + + * src/Makefile.am (check): Remove tests for md5sum. + * tests/md5sum-test: New directory. Put them here instead. + * configure.in (AC_OUTPUT): Add tests/md5sum-test/Makefile. + +Thu Sep 19 08:54:05 1996 Jim Meyering + + * tests/: Rename from checks. + * Makefile.am (SUBDIRS): Change `checks' to `tests'. + * configure.in (AC_OUTPUT): Likewise. + + * configure.in ($PACKAGE, $VERSION): Don't AC_DEFINE_UNQUOTED these. + AM_INIT_AUTOMAKE now does it (as of automake-1.1e). + +Sun Sep 15 23:08:48 1996 Jim Meyering + + * Makefile.am (EXTRA_DIST): Remove acinclude.m4. + +Thu Sep 12 17:05:23 1996 Jim Meyering + + * lib/Makefile.am (EXTRA_DIST): Add getline.c. + (tu_SOURCES): Remove getline.c + From Kaveh Ghazi. + +Sun Sep 8 13:55:18 1996 Jim Meyering + + * checks/sort-test/build-script.pl: Prefix $in with \$srcdir/ + so make check works with VPATH build. From Uli Drepper. + +Sat Sep 7 12:25:42 1996 Jim Meyering + + * src/system.h: Add comments justifying IS* versions of ctype.h macros. + + * src/fmt.c (check_punctuation): Use ISPUNCT instead of ispunct. + (get_line): Use ISSPACE instead of isspace. From Bruno Haible. + +Mon Sep 2 10:34:46 1996 Jim Meyering + + * src/*.c (usage): Tell where to report bugs. + +Sun Aug 25 22:50:47 1996 Jim Meyering + + * checks/sort-test/Makefile.am (EXTRA_DIST): Add $x-tests. + ($x-tests): Guard dependencies with @MAINT@. + * checks/tr-test/Makefile.am: Likewise. + +Sat Aug 24 14:25:41 1996 Jim Meyering + + * src/cat.c (cat): Cast first arg to stpcpy to char* to avoid warnings. + +Wed Aug 21 22:28:26 1996 Jim Meyering + + * configure.in (ALL_LINGUAS): Add polish (pl). + +Sun Aug 18 09:34:42 1996 Jim Meyering + + * configure.in (AC_OUTPUT): Add checks/sort-test/Makefile. + * checks/Makefile.am (SUBDIRS): Add sort-test. + +Sat Aug 17 18:57:17 1996 Jim Meyering + + * Makefile.am (EXTRA_DIST): Add acinclude.m4. + +Tue Aug 13 21:47:23 1996 Jim Meyering + + * src/Makefile.am (EXTRA_DIST): Remove ansi2knr.1 and ansi2knr.c. + Automake includes them automatically. + + * configure.in (AM_INIT_AUTOMAKE): Use it. + (AM_PROG_INSTALL): Remove. AM_INIT_AUTOMAKE does this. + (AC_PROG_MAKE_SET): Likewise. + +Sun Aug 11 20:49:21 1996 Jim Meyering + + * configure.in: Rename a few macros for automake-1.1c. + (AC_REPLACE_GNU_GETOPT): Remove. + (AC_PATH_PROG): Find perl -- needed only for checks if you + change or remove things with e.g. make maintainerclean. + + + * lib/Makefile.am (tu_LIBADD): Remove @REGEXOBJ@. New AM_WITH_REGEX + adds .o files to @LIBOBJ@. + (tu_SOURCES): Add getopt.c and getopt1.c. + (EXTRA_DIST): Remove getopt.c and getopt1.c. + + * acinclude.m4: New file -- derived from aclocal.m4. + * aclocal.m4: This file is now generated by the aclocal program + (which comes with the automake package.) + +Sun Aug 4 10:50:46 1996 Jim Meyering + + * checks/: New directory. + * checks/Makefile.am: New file. + * configure.in (AC_OUTPUT): Add new directories: checks, + checks/tr-test. + * Makefile.am (SUBDIRS): Likewise. + +Sat Jul 27 17:22:14 1996 Jim Meyering + + * src/system.h (bindtextdomain) [!ENABLE_NLS]: Undefine to avoid + redefinition warnings on solaris. + (textdomain) [!ENABLE_NLS]: Likewise. + +Thu Jul 25 23:06:35 1996 Jim Meyering + + * src/unexpand.c (unexpand): Move EOF check to follow code that + processes and generates output for pending spaces. Before + `printf ' ' |unexpand -t 1,2' generated no output. + + * src/md5sum.c (md5_check): Remove parameter, BINARY. + Rename local TYPE_FLAG to BINARY, so md5_file uses the binary mode + from the input stream rather than the one from the command line. + (main): Fail with a diagnostic if --binary or --text is specified + when verifying checksums. + Reported by Eli Zaretskii . + +Sun Jul 21 11:58:48 1996 Jim Meyering + + * configure.in: Add check for error_at_line so systems with + GNU libc don't compile and link with distributed error.c. + * lib/Makefile.am (tu_SOURCES): Remove error.c. + (EXTRA_DIST): Add error.c. + + * configure.in (AC_REPLACE_FUNCS): Replace getline.c. + Add related check for the getdelim function. + From Ulrich Drepper -- as done in gettext. + +Sat Jul 20 15:59:36 1996 Jim Meyering + + * configure.in (PACKAGE_VERSION): Use space instead of hyphen to + separate PACKAGE and VERSION. + + * aclocal.m4 (AM_SANITY_CHECK_CC): New macro. Derived from + macros from Bruno Haible and from Cygnus. + * configure.in (AM_SANITY_CHECK_CC): Use it. + +Wed Jul 17 00:30:28 1996 Jim Meyering + + * install-sh: Get version with MIT copyright. + +Tue Jul 16 00:09:37 1996 Jim Meyering + + * aclocal.m4 (fp_C_PROTOTYPES): Improved version from + François Pinard. + Update all other macros to reference $fp_cv_prog_cc_stdc, rather + than $ac_cv_prog_cc_stdc. + + * src/od.c (OFF_T_MAX): Remove definition. + (main): Compare against LONG_MAX rather than OFF_T_MAX. + +Mon Jul 15 23:42:57 1996 Jim Meyering + + * Many files: Update FSF address. + +Sun Jul 14 16:53:50 1996 Jim Meyering + + * src/unexpand.c (unexpand): Fix bug that contributed to endless loop + when invoking `echo ' ' |unexpand -t 1,2': use print_tab_index, not + tab_index in inner flush_pend: while loop. From Keith Owens + . + + * src/unexpand.c [HAVE_LIMITS_H]: Include limits.h for INT_MAX. + [!INT_MAX]: Define it. + (main): Append INT_MAX to command-line-specified tab list to + ensure termination in unexpand's inner loop. + Derived from a patch from Keith Owens. + +Thu Jul 11 22:04:36 1996 Jim Meyering + + * Version 1.19. + + * configure.in (VERSION): Bump to 1.19. + +Wed Jul 10 22:57:29 1996 Jim Meyering + + * aclocal.m4 (fp_PROG_CC_STDC): Include sys/stat.h in test program + so that DYNIX/ptx V4.1.3 doesn't use `-Xc -D__EXTENSIONS__' -- with + those options on that system, sys/stat.h gets compile errors. + With help from Marcus Daniels. + + * getopt.c: Update from gettext-0.10.23. + * getopt1.c: Likewise. + * getopt.h: Likewise. + +Tue Jul 9 18:07:23 1996 Jim Meyering + + * src/fmt.c (MAXCOST): Use `(unsigned long)1' rather than `(COST)1' + so the left operand of the << isn't signed. + From Kjetil Torgrim Homme. + + * po/Makefile.in.in (install-data): Don't install NLS files when + they're not requested. From Ulrich Drepper. Reported by + Kjetil Torgrim Homme . + +Fri Jul 5 21:55:58 1996 Jim Meyering + + * po/Makefile.in.in ($(PACKAGE).pot): Merge from gettext-0.10.23. + * ABOUT-NLS: Likewise. + * intl/*: Likewise. + * aclocal.m4: Likewise. + +Thu Jul 4 07:24:54 1996 Jim Meyering + + * src/uniq.c (usage): Remove space before newline in usage message. + + * src/md5sum.c (MIN_DIGEST_LINE_LENGTH): New macro. + [NEWLINE_REPLACEMENT_STRING*]: Remove macros. + (main): Output a leading backslash for a line describing a file + whose name contains a newline. Then translate each NEWLINE byte + in the file name to the string, "\\n", and each backslash to "\\\\". + File names that don't contain NEWLINE aren't translated. + (split_3): Rewrite to handle file names with embedded newlines. + Miles Bader and Jim Blandy suggested this new encoding scheme. + + * src/md5sum.c (md5_file): Replace obsolete comment with a description + of the function. + (md5_check): Don't use "s"-adding trick to form the plural of + `checksum.' That doesn't work well with translation. + Suggestions from Ulrich Drepper. + (split_3): Add missing semicolon so it compiles. From Jim Blandy. + +Wed Jul 3 23:21:09 1996 Jim Meyering + + * src/md5sum.c (split_3): Correct test for 35-byte line to accomodate + fact that leading blanks may be stripped. + +Tue Jul 2 21:51:40 1996 Jim Meyering + + * configure.in (ALL_LINGUAS): Add dutch (nl). + +Mon Jul 1 23:50:19 1996 Jim Meyering + + * src/md5sum.c [NEWLINE_REPLACEMENT_STRING]: Define. + (split_3): Translate NL bytes not to NUL, but to + NEWLINE_REPLACEMENT_STRING. + Suggested by Ulrich Drepper. + (main): Translate back to NL-containing filename. + +Sun Jun 30 22:42:17 1996 Jim Meyering + + * src/md5sum.c (split_3): Take an additional parameter, S_LEN. + Adapt caller. + Map translated NEWLINE-containing filename back into the original + NEWLINE-containing name. + (md5_check): Translate NEWLINE bytes to NUL bytes in filename. + +Sat Jun 29 18:59:07 1996 Jim Meyering + + * configure.in (PACKAGE_VERSION): Add `GNU ' prefix so it + appears in the output of --version. Reported by RMS. + +Wed Jun 26 21:35:10 1996 Jim Meyering + + * src/Makefile.am (LDADD): Remove sort-specific hack to link + with -lm. + * aclocal.m4 (AM_FUNC_STRTOD): New macro. + * configure.in (AM_FUNC_STRTOD): Use it. + (AC_REPLACE_FUNCS): Remove strtod. + Suggested by Tom Tromey. + + * po/Makefile.in.in (install-data): Add `else true;' to avoid + letting failing if-condition cause make failure. + From Fred Fish (fnf@ninemoons.com). + +Tue Jun 25 21:55:18 1996 Jim Meyering + + * Version 1.18a. + +Tue Jun 18 20:43:20 1996 Jim Meyering + + * aclocal.m4: Update from gettext-0.10.20. + * ABOUT-NLS: Likewise. + * intl/*: Likewise. + +Thu Jun 13 22:31:39 1996 Jim Meyering + + * configure.in (VERSION): Bump to 1.18a. + + * po/Makefile.in.in ($(PACKAGE).pot): Reapply change of May 30. + Depend on POTFILES only when using maintainer mode. + + * intl/*: Update from gettext-0.10.18. + +Tue Jun 11 23:32:10 1996 Jim Meyering + + * Version 1.18. + + * po/Makefile.in.in: Update from gettext-0.10.17. + * intl/*: Likewise. + * ABOUT-NLS: Likewise. + +Mon Jun 10 18:22:29 1996 Jim Meyering + + * Makefile.am (cvs-dist): Use -c option in cvs tag command. + +Fri Jun 7 22:06:46 1996 Jim Meyering + + * configure.in (VERSION): Set to 1.18. + + * src/Makefile.am (sort_LDADD): Set this to -lm to get pow when using + the strtod supplied with this package. Otherwise, linking failed on + Solaris-2.4 systems. Reported by Wayne Stewart . + +Thu Jun 6 21:57:08 1996 Jim Meyering + + * po/Makefile.in.in: Update from gettext-0.10.16. + * intl/*: Likewise. + * ABOUT-NLS: Likewise. + * aclocal.m4 (AC_REPLACE_GNU_GETOPT): Move definition to precede + gettext-related ones. + Update from gettext-0.10.16. + +Fri May 31 22:04:51 1996 Jim Meyering + + * Version 1.17. + + * Makefile.am (EXTRA_DIST): Set to texinfo.tex so that file is + distributed. + +Thu May 30 00:07:48 1996 Jim Meyering + + * Version 1.16. + + * tail.c (main): Interpret the old-style +VALUE and -VALUE options + like -c VALUE and -c +VALUE (resp) when VALUE has one of the [bkm] + suffix multipliers. This makes the code consistent with --help + output. Reported by Karl Heuer. + + * sort.c (limfield): #ifdef-out a block of code that makes + GNU sort incompatible with Unix sort when a key-end spec refers + to the N'th character in a field that has fewer than N characters. + The POSIX spec doesn't appear to specify behavior for this case. + From Karl Heuer. + + * po/Makefile.in.in (stamp-cat-id): Avoid using temp filename + longer than 14 characters. + (mostlyclean): Likewise. + From Karl Heuer. + + * po/Makefile.in.in ($(PACKAGE).pot): Depend on POTFILES only + when using maintainer mode. Reported by Karl Heuer. + + * po/Makefile.in.in (.po.mo): Reenable dependency and rule. + It is required when using native NLS, e.g. on Solaris. + From Marcus Daniels. + + * od.c (decode_one_format): Use %lu (not %d) printf format + corresponding to unsigned long, SIZE. + + * Version 1.15. + + * intl/Makefile.in (installcheck): New target. + * po/Makefile.in.in (installcheck): New target. + + * od.c (decode_one_format): Take another parameter. + Give a specific diagnostic for invalid format spec here rather + than an overly general one from caller's caller. + (decode_format_string): Update caller. + (main): Don't give diagnostic here when decode_format_string fails. + Remove assertions that could fail on some Crays because they don't + have a two-byte type. + Johan Danielsson (joda@pdc.kth.se) reported the failed assertions. + +Mon May 27 17:43:31 1996 Jim Meyering + + * cat.c (main): Use STDIN_FILENO and STDOUT_FILENO instead of + less portable fileno (stdin) and fileno (stdout). + * sort.c (main): Use STDIN_FILENO instead of less portable + fileno (stdin). + +Mon May 20 21:50:23 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * Makefile.am (distcheck): Remove target and rule -- automake-0.33 + adds it automatically. + +Sun May 19 13:15:49 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * configure.in (LINGUAS): Add ko. + * Makefile.am (distcheck): Remove @MAINT@ prefix from first command. + +Thu May 16 22:18:41 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * Makefile.am (distcheck): New target. From Gord Matzigkeit. + +Fri May 10 20:46:13 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * po/Makefile.in.in (all-yes): Always depend on CATALOGS. Otherwise + they won't be built and install could fail. From Ulrich Drepper. + (.po.mo): Disable dependency and rule when not in maintainer mode. + + * aclocal.m4 (ud_WITH_NLS): Make DATADIRNAME and CATOBJEXT depend + on whether we're using GNU gettext. From Ulrich Drepper. + +Wed May 8 21:10:43 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * intl/Makefile.in (distdir): Renamed from dist. For compatibility + with automake-0.32. + * po/Makefile.in.in (distdir): Likewise. + + * po/Makefile.in.in (all-yes): Depend on GMOFILES. + Depend on CATALOGS and GMOFILES files only in maintainer mode. + +Tue May 7 22:10:20 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * configure.in: Require autoconf-2.10. + + * aclocal.m4 (jm_MAINTAINER_MODE): New macro. + * configure.in (jm_MAINTAINER_MODE): Use it. + +Sat May 4 20:40:01 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * configure.in (LINGUAS): Add de. + * po/de.po: New file. + + * memcasecmp.c [IN_CTYPE_DOMAIN]: Rename from ISASCII. + * regex.c [IN_CTYPE_DOMAIN]: Likewise. + * system.h [IN_CTYPE_DOMAIN]: Likewise. + +Sun Apr 28 17:10:03 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * fmt.c (copy_rest): Don't copy past end of prefix. Output + trailing spaces if the prefix had any. Before, fmt would + improperly output NUL bytes. The command + perl -e 'print "| S";' |fmt -p' | '|tr '\0' @ + output `|@S'. Reported by François Pinard. + + * sort.c (main): Give a better diagnostic for `sort -0'. + Reported by Karl Berry. + + * configure.in: Make fp_C_PROTOTYPES precede AC_C_INLINE. + Otherwise, some systems lose because the value AC_C_INLINE choses + with plain `cc' is different from that chosen when using the ANSI-mode + C compiler. From Kaveh Ghazi. + +Tue Apr 23 22:05:35 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * aclocal.m4 (AC_REPLACE_GNU_GETOPT): New macro. + * configure.in: Use it. + * lib/Makefile.am (tu_SOURCES): Remove getopt.c and getopt1.c. + (EXTRA_DIST): Add getopt.c and getopt1.c + + * src/*.c, src/*.h: Update Copyright years to include 1996. + +Sun Apr 21 08:04:51 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * getline.c: New version from gettext-0.10.12. + * getline.h: Likewise. + * configure.in (AC_CHECK_FUNCS): Add getdelim. + Suggested by Ulrich Drepper. + + * md5sum.c (md5_check): Remove spurious newline at end of error + format string. + + * od.c (decode_one_format): Use printf's L modifier for long doubles, + not `l'. From Eric Backus. + + * Makefile.am (LDADD): Put @INTLLIBS@ before package library. + + * od.c: Include . + [!BITSPERBYTE]: Define. + [OFF_T_MAX]: Use BITSPERBYTE, not 8, and cast the result to off_t. + * configure.in (AC_CHECK_HEADERS): Add values.h. + +Fri Apr 19 23:48:53 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * Makefile.am (cvs-dist): New rule. Based on the one from + Tom Tromey's automake. + +Thu Apr 18 22:13:14 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * tail.c (main): Make code clearer: use new variable `n_files' in + place of `argc - optind'. Use `file' instead of `argv + optind'. + +Sat Apr 13 13:08:29 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * lib/Makefile.am (noinst_HEADERS): Include memcasecmp.h, + not memcasecmp.c. + + * memcasecmp.c: Unprotoize. + [ISASCII]: Define. + [ISUPPER]: Define. + + * join.c (decode_field_spec): Rename local variable `valid' + to invalid (and reverse sense) to avoid conflict with the + macro definition in /usr/include/locale.h on SunOS 4.1.3. + +Tue Apr 9 22:43:57 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * uniq.c: Add new option --ignore-case (-i). + Include memcasecmp.h. + (different): Compare with memcasecmp if ignoring case. + (main): Handle 'i'. + + * join.c (memcasecmp): Remove static definition of function. + Include memcasecmp.h instead. + + * memcasecmp.c: New file. + * memcasecmp.h: New file. + * lib/Makefile.am (tu_SOURCES): Add memcasecmp.c. + (noinst_HEADERS): Add memcasecmp.h. + +Thu Apr 4 17:05:33 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * tr.c: The following commands all failed unnecessarily. + tr -cs '[:upper:]' '[X*]' + tr -dcs '[:lower:]' n-rs-z + tr -ds '[:xdigit:]' [:alnum:]' + tr -dcs '[:alnum:]' [:digit:]' + tr -dc '[:upper:]' + Reported by Ross Ridge (ross@worf.mks.com). + (validate): Add missing conjunct (translating) in test for + `translating and complementing character classes' error. Before, + valid uses of tr could fail. E.g. `tr -dcs '[:cntrl:]' '[:alnum:]''. + (homogeneous_spec_list): New function. + (validate): Use it to relax the old (overly restrictive) restriction + that prohibited use of complemented character classes when translating. + Now, that is allowed as long as the translation maps many to one. + (get_spec_stats): Rename and redefine global has_char_class from + has_upper_or_lower. + +Wed Apr 3 07:08:57 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * aclocal.m4: Update NLS macros from gettext-0.10.11. + + * src/Makefile.am (INCLUDES): Add -I$(srcdir) to get system.h + when srcdir != builddir. From Kaveh Ghazi. + +Wed Mar 27 23:33:36 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * cksum.c (cksum): Use format "%lu %ld" (instead of "%10lu %8ld") + to be POSIX compliant. From Stephen Gildea . + +Sun Mar 24 08:47:40 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * join.c (main): Use EXIT_FAILURE, not 2, as exit code in error call. + * od.c (skip, main): Likewise. + * tr.c (main): Likewise. + + * cat.c cksum.c comm.c csplit.c cut.c expand.c fmt.c fold.c head.c + join.c md5sum.c nl.c od.c paste.c pr.c split.c sum.c tac.c tail.c + tr.c unexpand.c uniq.c wc.c: Exit with status EXIT_SUCCESS or + EXIT_FAILURE, rather than 0 or 1. + +Sat Mar 23 23:14:40 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * system.h [EXIT_FAILURE]: Undefine and define to 1 also if it + is defined to zero. Suggested by Paul Eggert. + + * sort.c [SORT_FAILURE]: New macro. + Be careful to exit with 1 only when -c is used and the + input is not properly sorted. In all other cases, use + SORT_FAILURE as required by POSIX. + (main): Change some `error (1, ...' to use SORT_FAILURE. + Upon successful termination, exit with EXIT_SUCCESS instead of `0'. + Replace all uses of `2' (as exit code) with SORT_FAILURE. + +Thu Mar 21 22:47:50 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * csplit.c: Include assert.h, but disable assertions. + (process_line_count): Replace if-abort with a slightly relaxed + assertion. Before, `echo |csplit - 1 1' would abort. + Reported by Samuli.Karkkainen@hut.fi. + (parse_patterns): Disallow uses like `csplit FILE 0' with zero + line number, `csplit FILE 2 1' with decreasing line numbers, and + warn about uses like `csplit FILE 3 3' that have equal line numbers. + + * sort.c (main): Declare to be of type int, not void. + From Peter Seebach . + * cat.c cksum.c comm.c csplit.c cut.c expand.c fold.c head.c join.c + nl.c paste.c pr.c split.c sum.c tac.c tail.c tr.c unexpand.c uniq.c + wc.c (main): Likewise. + +Sat Mar 16 16:30:07 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * configure.in (PACKAGE_VERSION): New macro. + * acconfig.h (PACKAGE_VERSION): Add it. + * src/Makefile.am: Remove rules for generating version.c. + Remove references to version.o, version.h, and stamp-v. + * version.c: Remove file. + * version.h: Remove file. + * cat.c cksum.c comm.c csplit.c cut.c expand.c fmt.c fold.c + head.c join.c md5sum.c nl.c od.c paste.c pr.c sort.c split.c + sum.c tac.c tail.c tr.c unexpand.c uniq.c wc.c: Don't include + version.h. + (main): Use PACKAGE_VERSION instead of version_string. + +Mon Mar 11 16:07:08 CST 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * sort.c (write_bytes): Renamed from xfwrite. + Remove SIZE parameter. It was always 1. Update all callers. + Rename NELEM parameter to N_BYTES and change its type to size_t. + +Sat Mar 9 13:30:12 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * cat.c cksum.c comm.c csplit.c cut.c expand.c fmt.c + fold.c head.c join.c md5sum.c nl.c od.c paste.c pr.c sort.c + split.c sum.c tac.c tail.c tr.c unexpand.c uniq.c wc.c (main): + Initialize for internationalized message support: call setlocale, + bindtextdomain, and textdomain. + * system.h: Add definitions and includes for NLS. + * Makefile.am (SUBDIRS): Add intl and po. + * src/Makefile.am (datadir): Define. + (localedir): Define. + (DEFS): Add LOCALEDIR definition. + (LDADD): Add @INTLLIBS@. + * aclocal.m4: Add NLS-related macro definitions from + gettext distribution. + * acconfig.h (ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_LC_MESSAGES, + HAVE_STPCPY): New macros. + Add PACKAGE and VERSION. + * configure.in (PACKAGE): Define with AC_DEFINE_UNQUOTED. + (VERSION): Likewise. + (ALL_LINGUAS): Define. + (AC_CHECK_HEADERS): Add float.h. + (ud_GNU_GETTEXT): Use it. + Link an nls file. + (AC_OUTPUT): Reflect addition of two new directories, intl and po. + Create po/Makefile. + From François Pinard. + + * tr.c (star_digits_closebracket): Declare formal param, IDX, + and local I to be of type size_t (rather than int) to avoid + warnings from gcc -Wall. + +Wed Feb 28 20:32:48 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * src/Makefile.am: Adapt for automake-0.30. + (noinst_HEADERS): Rename from HEADERS. + (INCLUDES): Remove -I.. and -I$(srcdir). automake-0.30 adds these + to DEFS automatically. + * lib/Makefile.am (noinst_HEADERS): Rename from HEADERS. + +Wed Feb 21 18:56:27 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * join.c (xfields) [without -t]: Ignore leading blanks. + From David Dyck (dcd@tc.fluke.COM). + +Sun Feb 18 12:07:27 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * join.c [TOLOWER]: Define. + (usage): Briefly describe new --ignore-case (-i) option. + (memcasecmp): New function. + (main): Set IGNORE_CASE for -i. + (keycmp): Compare with memcasecmp if IGNORE_CASE is set. + Suggestion and an initial patch from Alberto Accomazzi + . + +Sat Feb 17 18:54:40 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * sort.c: Add -z option. Change all occurrences of '\n' to `eolchar'. + (usage): Describe it. + (main): Set eolchar to 0 for -z. + From Mark W. Eichin . + +Fri Feb 16 21:44:14 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * join.c (main): Mark two strings for translation. + * md5sum.c (md5_check): Mark a string for translation. + From François Pinard. + +Mon Feb 12 21:12:28 1996 Jim Meyering (meyering@na-net.ornl.gov) + + Update for automake-0.29. + * Makefile.am (CONFIG_HEADER): Don't define. Automake now does it. + * src/Makefile.am: Likewise. + * lib/Makefile.am: Likewise. + * doc/Makefile.am (info_TEXINFOS): Renamed from TEXINFOS. + * man/Makefile.am (man_MANS): Renamed from MANS. + + * fmt.c [TRUE]: Undefine before defining to avoid warning on NeXT. + [FALSE]: Likewise. + From Derek Clegg (dclegg@next.com). + +Sat Feb 3 16:20:40 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * Version 1.14. + +Wed Jan 31 23:26:13 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * tail.c (dump_remainder): Flush stdout when tailing-forever on + multiple files. From Carlos Canau . + +Fri Jan 5 18:30:28 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * aclocal.m4: For SVR4 systems, use -Xc -D_POSIX_C_SOURCE in CFLAGS, + not just -Xc. From François Pinard. + + * doc/Makefile.am (DIST_OTHER): Don't set to mdate-sh. mdate-sh is + distributed automatically. From Tom Tromey. + +Thu Jan 4 20:32:52 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * nl.c: Include rx.h after limit.h (not before) to avoid warning + about the redeclaration of RE_DUP_MAX in limit.h. rx.h protects + its definition. From Kaveh Ghazi. + + * src/Makefile.am (DIST_OTHER): Include md5-test.rfc so make check + works again. Reported by François Pinard and Kaveh Ghazi. + + * rx.c [SYNTAX]: Rename from SYNTAX_TABLE. + [SYNTAX_TABLE]: Remove extern dcl of re_syntax_table. + (RE_SEARCH_2_FN): Cast string1 and string2 to avoid pointer type + mismatch errors from e.g. SunOS's /bin/cc. + Reported by Kaveh Ghazi. + +Wed Jan 3 23:34:39 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * configure.in (VERSION): Set variable directly rather than from + a separate file. + * Makefile.am (DIST_OTHER): Remove VERSION. + * src/Makefile.am (version.c): Depend on Makefile, not ../VERSION. + (stamp-v): New target; depend on Makefile. + (DISTCLEANFILES): Add stamp-v, version.c. + +Tue Jan 2 00:08:08 1996 Jim Meyering (meyering@na-net.ornl.gov) + + * sort.c (keycompare): Rewrite cases handling ignored characters + so that they really are ignored. Reported by Carl Johnson + . + +Fri Dec 22 21:34:55 1995 Andreas Schwab + + * configure.in: Touch stamp-h only if config.h is remade. + + * csplit.c (extract_regexp) [!WITH_REGEX]: Intialize + syntax_parens field. + +Mon Dec 18 21:42:44 1995 Jim Meyering (meyering@comco.com) + + Use automake to generate Makefile.in files. + * Makefile.am: New file. + * doc/Makefile.am: New file. + * lib/Makefile.am: New file. + * man/Makefile.am: New file. + * src/Makefile.am: New file. + +Thu Dec 14 21:13:22 1995 Jim Meyering (meyering@comco.com) + + * fmt.c (main): Use xstrtol instead of atoi. + + * fold.c (main): Use xstrtol instead of atoi. + (fold_file): Make a couple locals `int', not size_t, and cast + fwrite's third parameter to size_t. + + * nl.c (main): Use xstrtol instead of atoi. + Rename misleading --first-page=N option to --starting-line-number=N. + (usage): Update. + + * uniq.c (main): Use xstrtol instead of atoi. + +Fri Dec 8 20:48:00 1995 Jim Meyering (meyering@comco.com) + + * aclocal.m4 (fp_C_PROTOTYPES): Set ANSI2KNR to ./ansi2knr. + +Thu Dec 7 19:55:03 1995 Jim Meyering (meyering@comco.com) + + * aclocal.m4 (ud_WITH_REGEX): New macro. + * configure.in: Use it. + * rx.c, rx.h: New files. + * lib/Makefile.in (REGEX): Set to @REGEXOBJ@, not regex.o. + (SOURCES, DISTFILES): Add rx.c, rx.h. + * acconfig.h (WITH_REGEX): Add it. + * csplit.c [!WITH_REGEX]: Include rx.h. + * nl.c [!WITH_REGEX]: Likewise. + * tac.c [!WITH_REGEX]: Likewise. + From Ulrich Drepper and François Pinard. + +Tue Dec 5 17:49:53 1995 Jim Meyering (meyering@comco.com) + + * sort.c (main): Diagnose invalid arguments to -k, then fail. + + * sort.c (numcompare): Properly handle all cases in which signs differ. + From Karl Heuer. + + * Makefile.in (mandir): @mandir@ is just $(prefix)/man. + Append `/man1'. Reported by Karl Heuer. + + * sum.c (bsd_sum_file): Remove misleading comment. From Karl Heuer. + + * src/Makefile.in [.c._o]: Don't create $<-tmp. From Kaveh Ghazi. + +Fri Dec 1 01:02:36 1995 Jim Meyering (meyering@comco.com) + + * lib/Makefile.in (default): New target. + + * sort.c (numcompare): Properly order `-' and valid integers; + treat `-' as if it were zero. Reported by Ross Alexander + . + + * Makefile.in (DISTFILES): Remove unused mkdep-Makefile. + (.PHONY): Depend on default. + +Wed Nov 29 21:50:53 1995 Jim Meyering (meyering@comco.com) + + * aclocal.m4 (jm_PROG_C_MKDEP): Remove, for now. + (jm_AUTODEPS): Likewise. + (jm_WITH_GNU_MAKE): Likewise. + * configure.in (jm_AUTODEPS): Remove. + + * sort.c (begfield): Replace loop with equivalent if-else. + (limfield): Fix bug that made field specs like -k1.5 return a + pointer into LINE beyond the first field. + Don't try to trim trailing blanks here; it's not + possible because we don't know where the field begins. + Replace loop with equivalent if-else. + (trim_trailing_blanks): New function. + (findlines): Call it. + (keycompare): Likewise. + (main): Don't decrement T2 corresponding to `x' in field + specs like -ku.v,w.x. + +Sun Nov 26 15:50:23 1995 Jim Meyering (meyering@comco.com) + + * csplit.c [!UINT_MAX]: Define. + [!INT_MAX]: Define. + Include xstrtoul.h. + (string_to_number): Remove function. + (check_for_offset): Use xstrtoul instead of string_to_number. + (parse_repeat_count): Likewise. + (parse_patterns): Likewise. + (main): Likewise. + +Wed Nov 22 23:12:47 1995 Jim Meyering (meyering@comco.com) + + * Makefile.in (all et. al.): If make was invoked with -k and a + sub-make fails, fail after the loop rather than exiting right away. + Otherwise, make's -k option could be ineffective. + +Sat Nov 18 12:04:30 1995 Jim Meyering (meyering@comco.com) + + * src/Makefile.in (version.c): Depend on ../VERSION, not Makefile. + + Update for autoconf-2.5: + * src/Makefile.in (libdir): Set to @libdir@. + (bindir): Set to @bindir@. + * doc/Makefile.in (infodir): Set to @infodir@. + * man/Makefile.in (exec_prefix): Remove it. + (mandir): Set to @mandir@. + (bindir): Remove it. + +Thu Nov 16 21:25:45 1995 Jim Meyering (meyering@comco.com) + + * Makefile.in (default): New default target. Depend on `all' to + work around bug in AIX-3.2.5's /bin/make. Reported by Andreas Luik + . + +Wed Nov 15 23:48:31 1995 Jim Meyering (meyering@comco.com) + + * mkdep-Makefile (.deps/empty.P): Depend on BUILT-HEADERS. + + * aclocal.m4 (jm_PROG_C_MKDEP): Rename from jm_PROG_MKDEP. + * src/Makefile.in (C_MKDEP): Rename from MKDEP. + * lib/Makefile.in (C_MKDEP): Likewise. + * mkdep-Makefile (C_MKDEP): Likewise. + Add comments. + + * csplit.c [__P]: Don't define it here. + * pr.c [__P]: Don't define it here. + * fmt.c [__P]: Don't define it here. + * system.h [__P]: Define it here. + + * aclocal.m4 (jm_AUTODEPS): Rename from jm_WITH_AUTODEPS. + Revamp, with suggestions from Franc,ois Pinard. + (jm_WITH_GNU_MAKE): New macro. + (jm_PROG_MKDEP): New macro. + * configure.in (jm_PROG_MKDEP): Use it. + * src/Makefile.in (MKDEP): Set it. + * lib/Makefile.in (MKDEP): Likewise. + * mkdep-Makefile: Use MKDEP, not DEP_CC. + (DEP_CFLAGS): Remove it. + +Tue Nov 14 23:10:54 1995 Jim Meyering (meyering@comco.com) + + * sort.c: Add support for sorting numbers in scientific notation. + Include xstrtod.h. + (struct keyfield): Add field: general_numeric. + (usage): Describe -g option. + (general_numcompare): New function. + (keycompare): Use new comparison function when general_numeric + flag is set. + (set_ordering): Honor `g' flag. + (main): Initialize and use new field. + From Marcus Daniels . + + * configure.in (AC_REPLACE_FUNCS): Add strtod. + * lib/Makefile.in (SOURCES): Add xstrtod.c. + (OBJECTS): Add xstrtod.o. + (DISTFILES): Add xstrtod.h. + + * csplit.c (cleanup): Don't exit. + (interrupt_handler): Rewrite to reset default signal handler + then repost caught signal. + (xmalloc, xrealloc, read_input, write_to_file, handle_line_error, + process_line_count, process_regexp, create_output_file, + close_output_file): Call cleanup_fatal, not cleanup. + Add const attribute to lots of parameters. + (cleanup_fatal): Renamed from cleanup. Call cleanup, then exit. + Update callers. + + * tac.c (cleanup): Don't exit. + (cleanup_fatal): New function. Call cleanup, then exit. + (sighandler): New function. + (cleanup_fatal): Renamed from cleanup. Call cleanup, then exit. + Update callers. + (tac_stdin): Set up sighandler as signal handler, not `cleanup'. + +Sat Nov 11 15:46:02 1995 Jim Meyering (meyering@comco.com) + + * od.c (skip): Cast fseek's offset argument to `long'. + Erik Bennett reported that this is + necessary on BSDI systems. And if offset doesn't fit in a long, + then try using lseek instead. + + * sort.c (xmalloc): Declare static. + (xrealloc): Likewise. + + * tac.c (cleanup): Add signal number parameter. + Update callers. + + * cat.c (main): Don't die when dev/ino of input and output are + the same and the file descriptors correspond to stdin and stdout. + This is necessary on at least Digital UNIX (aka OSF1) 3.2C. + Otherwise, running `cat << X > $$' would fail with `cat: -: input + file is output file'. From Jarkko Hietaniemi . + + * Makefile.in (DISTFILES): Add @README_ALPHA@. + (config.status) Depend on VERSION. + * configure.in: Set README_ALPHA if the version number ends in [a-z]. + +Fri Nov 10 21:13:42 1995 Jim Meyering (meyering@comco.com) + + * fold.c (usage): Clarify meaning of --spaces. From Karl Berry. + + src/Makefile.in (.c._c): Don't redirect directly to $@. + (._c._o, .c._o): Remove temporary src file. + +Tue Nov 7 23:55:24 1995 Jim Meyering (meyering@comco.com) + + * VERSION: New file. + * configure.in (VERSION): New variable. + (PACKAGE): New variable. + + * Makefile.in (DISTFILES): Add VERSION. + (distdir): Use @PACKAGE@-@VERSION@, not distname. + Remove all references to distname. + * src/Makefile.in (version.c): Generate it. + (SOURCES): Remove now-generated version.c. + (distclean): Delete version.c. + * doc/Makefile.in (version.texi): Use @PACKAGE@-@VERSION@, + not version.c + + * */Makefile.in (distdir): Use @PACKAGE@-@VERSION@, not distname. + Remove all references to distname. + + * split.c: New option: --verbose. + (main): Recognize it. + (usage): Document it. + From Marty Leisner . + +Sun Nov 5 06:59:27 1995 Jim Meyering (meyering@comco.com) + + * src/Makefile.in: Reflect protoization of csplit.c, fmt.c, pr.c, + and unexpand.c. + + * pr.c: Protoize. + (store_columns): Remove spurious 2nd argument in call to read_line. + [__P]: Define. Use it in prototyped forward decls. + + * csplit.c: Move prototypes after struct declarations. + Remove prototypes for xmalloc, xrealloc. + Protect prototypes with __P. + (new_control_record): Cast arg 1 to realloc. + + * fmt.c [__P]: Test PROTOTYPES, not __STDC__. + Protoize. + +Sat Nov 4 23:51:30 1995 Jim Meyering (meyering@comco.com) + + * csplit.c (close_output_file): Set output_stream to NULL so we + don't recurse endlessly between this function and cleanup. + + * unexpand.c: Reorder functions to obviate forward dcls. Remove + forward dcls. Protoize. Add `const' attribute to some parameters. + +Mon Oct 30 23:15:56 1995 Jim Meyering (meyering@comco.com) + + * wc.c: Reorder functions to obviate forward dcls. Remove + forward dcls. Protoize. Add `const' attribute to some parameters. + * uniq.c: Likewise. + * split.c: Likewise. + + * split.c (isdigits, convint): Remove these. + (main): Use xstrtol instead. + +Sun Oct 29 14:04:36 1995 Jim Meyering (meyering@comco.com) + + * paste.c (main): Move function body to end of file. + Remove forward dcls and protoize. + * sum.c (main): Likewise. + * nl.c: Protoize. Reorder functions to obviate forward dcls. + Remove forward dcls. + * tac.c: Likewise. + * src/Makefile.in (OBJECTS): Reflect that all of the above + now use prototypes. + + * sum.c (bsd_sum_file): Give file name parameter const attribute. + (sysv_sum_file): Likewise. + + * tac.c (xwrite): Give output buffer parameter const attribute. + (output): Likewise for both parameters. + (tac): Likewise for file name parameter. + (tac_file): Likewise. + +Sat Oct 28 16:02:39 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c (md5_check): Use the same message format when there is + a single file and it gets a read error or checksum mismatch as when + there are more. Write that warning to standard error, not standard + output. Suggestions from Greg Troxel (gdt@b-sgi.bbn.com). + +Thu Oct 26 00:11:35 1995 Jim Meyering (meyering@comco.com) + + * sort.c (xtmpfopen): New function to set proper permissions on + temporary files. Use it instead of xfopen. Reported by Erik Corry + (erik@kroete2.freinet.de). + +Mon Oct 23 23:17:04 1995 Jim Meyering (meyering@comco.com) + + * aclocal.m4 (jm_WITH_AUTODEPS): New directive. + * configure.in: Use it. + + * lib/Makefile.in (INCLUDE, COMPILE): New variables. + (.c.o): Rewrite to be more like src/Makefile.in. + + * src/Makefile.in (distclean): Remove .deps. + Include @top_srcdir@/mkdep-Makefile. + + * mkdep.Makefile: New file. + * Makefile.in (DISTFILES): Add mkdep-Makefile. + * doc/Makefile.in (mostlyclean): Also remove *.info. + +Thu Oct 19 17:38:28 1995 Jim Meyering (meyering@comco.com) + + * od.c: Indent cpp directives. + + * tr.c (BEGIN_STATE): Use INT_MAX - 1 so as not to interfere + with large repeat counts. + (struct E_string): New struct. + (find_closing_delim): Take E_string arg rather than char* and length. + (find_bracketed_repeat): Likewise. + (star_digits_closebracket): New function. + (append_char_class): No longer give diagnostic. + (append_equiv_class): Likewise. + (build_spec_list): Give them here instead, allowing string1 like + [:*][:upper:] that got errors before. + Take E_string arg rather than char*. + Convert switch stmts into if-then so as to use ES_MATCH. + +Tue Oct 17 22:48:00 1995 Jim Meyering (meyering@comco.com) + + * cat.c: Protoize. Reorder functions to obviate forward dcls. + Remove forward dcls. + * expand.c: Likewise. + * fold.c: Likewise. + * head.c: Likewise. + * od.c: Likewise. + * sort.c: Likewise. + * tail.c: Likewise. + + * src/Makefile.in (OBJECTS): Reflect that all of the above + now use prototypes. + + * head.c: Add `const' attribute to dcls of lots of formals. + + * sort.c: Add `const' attribute to dcls of lots of formals. + Move struct dcls to precede dcls of file-scope variables. + (monthtab, keyhead): Separate variable dcls from type dcls. + +Fri Oct 13 20:38:39 1995 Jim Meyering (meyering@comco.com) + + * join.c (add_field_list): Allow SPACE and TAB as well as `,' as + list item separators, per POSIX spec. + (prjoin): Rewrite loop that iterates over field specs. + Handle case in which file spec is 0. + +Sun Oct 8 22:41:15 1995 Jim Meyering (meyering@comco.com) + + * strpbrk.c: New file. + * lib/Makefile.in (SOURCES): Add strpbrk.c. + Remove bcopy.c. + +Sat Oct 7 22:27:01 1995 Jim Meyering (meyering@comco.com) + + * join.c (add_field): No longer return a value. + (decode_field_spec): New function. + (add_field_list): Rewrite to be more strict. + Before, `,1.2' was accepted as valid. + (main): Use xstrtol instead atoi. + Combine nearly identical -a and -v cases. + Close input files. + +Fri Oct 6 23:10:01 1995 Jim Meyering (meyering@comco.com) + + * join.c (main): Report `too few/many non-option arguments' + then print --help output rather than just the latter. + Properly interpret obsolescent usage like `join -o 2.1 2.1 2.2'. + (usage): Describe POSIX -1, -2 options and deprecate -j* ones + + * join.c (usage): Move to precede all other functions. + + * join.c: Protoize. + +Tue Oct 3 22:44:05 1995 Jim Meyering (meyering@comco.com) + + * csplit.c, sort.c, tac.c: Test SA_INTERRUPT, not _POSIX_VERSION, + to determine whether `sigaction' functions are available. + Reported by Paul Nevai . + Fix suggested by Karl Berry. + + * md5sum.c (main): Declare counter, N_STRINGS, to be an integral + type, not `char'. + + * cut.c: Convert many declarations using `int' to use `unsigned int' + to avoid warnings from `gcc -Wall' about comparing signed and + unsigned types. + (set_fields): Use memset (not open coded loop) to initialize array. + +Thu Sep 28 23:16:05 1995 Jim Meyering (meyering@comco.com) + + * Version 1.13. + + * Makefile.in (DISTFILES): Remove README.alpha for major release. + + * od.c (decode_one_format): Remove spurious semicolon. + From John Kodis. + +Tue Sep 26 23:05:01 1995 Jim Meyering (meyering@comco.com) + + * man/Makefile.in (install-data, uninstall): Use sed not basename. + The GNU Coding Standard suggests that only a select set of + relatively standard utilities be used in Makefiles. basename is + not among them. Suggested by Ulrich Drepper. + +Sun Sep 24 08:36:47 1995 Jim Meyering (meyering@comco.com) + + * cksum.c: Protoize. + * cut.c: Protoize. + + * src/Makefile.in (OBJECTS): Reflect that cksum.c and cut.c use + prototypes. + (cksum): Depend on cksum$O. + (cut): Depend on cut$O. + +Sat Sep 23 15:43:46 1995 Jim Meyering (meyering@comco.com) + + * Version 1.12.2. + + * Makefile.in (DISTFILES): Add README.alpha. + + * lib/Makfile.in (GETOPT, MEMCHR, REGEX): New variables. + (OBJECTS): Use them instead of hard-coding object file names. + Suggested by Ulrich Drepper. + + * md5sum.c (md5_check): Distinguish between open/read failure + and checksum mismatch. + +Mon Sep 18 23:15:05 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c: Protoize. + * src/Makefile.in (OBJECTS): Change md5sum.o to md5sum$O. + (join.o, md5sum$O, sort.o) Depend on ../lib/long-options.h. + (md5sum): Depend on md5sum$O. + + * md5sum.c (main, usage): Remove -h, -s, -v short options. + Rename --verbose to --warn, --quiet to --status. + (main): Handle --help and --version using parse_long_options. + (md5_check): Check ferror. + + * sort.c (tempname): Replace `16' with a more readable expansion. + Make sure that counter never exceeds 99999. + (checkfp): Rearrange loop to avoid duplicate test. + Move a couple dcls from function scope into inner block. + +Tue Aug 8 21:49:27 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c (main): Fail if either --verbose or --quiet is specified + when not verifying checksums. + + * md5sum.c (md5_check): Fail if no valid line is found. + Don't use the word `fail' unless there were failures -- + instead, say `all N tests passed.' + + * md5sum.c (main) [handling --string option]: Don't output + nonstandard `b' binary flag. From Greg Troxel (gdt@bbn.com). + * md5-test.rfc: Remove now-inconsistant `b' marker. + (usage): Clarify help message. With suggestions from Greg Troxel. + +Mon Aug 7 23:27:54 1995 Jim Meyering (meyering@comco.com) + + * sort.c (mergefps) [lint]: Initialize SAVEALLOC to avoid spurious + compiler warning. From Ulrich Drepper. + + * pr.c (read_line) [lint]: Initialize CHARS to avoid spurious + compiler warning. From Ulrich Drepper. + + * Makefile.in (DISTFILES): Don't distribute unneeded COPYING.LIB. + From Franc,ois. + +Mon Aug 7 00:02:59 1995 Jim Meyering (meyering@comco.com) + + * system.h (_): Define macro -- as empty for now. + * src/*.c: Annotate localizable strings with _(...). From Franc,ois. + +Sat Aug 5 23:51:25 1995 Jim Meyering (meyering@comco.com) + + * Version 1.12.1. + + * configure.in: Add fp_C_PROTOTYPES. + +Fri Aug 4 23:21:46 1995 Jim Meyering (meyering@comco.com) + + * src/Makefile.in (DISTFILES): Include ansi2knr.c and ansi2knr.1. + Add suffixes, dependencies, and rules to convert ANSI source to K&R + when required. Mark tr.o and comm.o as the only such files (for now). + + * tr.c: Protoize. + * comm.c: Protoize. + + * Makefile.in (DISTFILES): Add aclocal.m4 and acconfig.h. + (configure): Depend on aclocal.m4. + (stamp.h.in): Depend on aclocal.m4 and acconfig.h. + +Sun Jul 30 00:01:58 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c (md5_check): Use getline instead of fgets. + + * lib/Makefile.in (SOURCES): Add getline.c. + (OBJECTS): Add getline.o. + (DISTFILES): Add getline.h. + (getline.o): Depend on getline.h. + + * md5.c [memcpy]: Define to bcopy if needed. + (md5_buffer): Explicitely cast SWAP expressions to unsigned + to avoid warning. + + * lib/Makefile.in (strtoul.o): Depend on strtol.c. + + * sort.c (check): Print `disorder on...' message on standard error, + not stdout. This is a minor concession to POSIX which says + `no output shall be produced...'. + + * sort.c (main): Fix -k so it works. -k 2,3 was being treated + like -k 2. Reported by Marcus Daniels . + +Wed Jul 26 22:54:48 1995 Jim Meyering (meyering@comco.com) + + * man/Makefile.in (install, uninstall): Strip off `.1', not just `1' + before applying $(transform) to manual name. From Karl Berry. + + * md5sum.c (have_read_stdin): New global variable. + (md5_file, md5_check): Set it. + (main): Use it. + + * md5sum.c [OPENOPTS]: Depend explicitly on BINARY. + (md5_file): Take a new parameter, MD5_RESULT, and no longer + generate output. + (md5_check): Invoke md5_file instead of calling fopen directly. + When giving a diagnostic for a line with invalid format, also report + the line number. + (main): Generate output after a successful md5_file call. + [in many places]: Upon detection of an error, rather than exiting + immediately, issue a diagnostic, note that an error occurred and + exit later. + +Mon Jul 24 21:48:26 1995 Jim Meyering (meyering@comco.com) + + * tail.c (tail_bytes) [from_start]: For regular files, seek + relative to the initial input file pointer position, not + necessarily from the beginning of the file. + [!from_start]: Don't back up past the initial position of the + input file pointer. + (tail_lines): Call file_lines only if FD refers to a regular file + with its file pointer positioned at beginning of file. Otherwise, + call pipe_lines. This is a kludge. Once there's a decent test + suite, fix this properly. + Before, (echo 1; echo 2) > k; sh -c 'read x; tail' < k + would output both lines of the input file even though the first had + already been read. Reported by John Roll (john@panic.harvard.edu). + + * md5sum.c [_LIBC || STDC_HEADERS] (TOLOWER): Define to tolower. + + * csplit.c (main): When too few arguments are given, don't just + issue the usage message; also report why. + +Sat Jul 22 00:16:01 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c (md5_check): New function -- extracted from main. + +Fri Jul 21 01:21:49 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c (md5_file): New function -- extracted from main. + (main): Call the new function instead of doing all that in an + if-stmt. Always use "%s" format rather than raw filename as + format argument in printf-style functions like error. Otherwise, + filenames containing `%' are likely to lose. + Remove all mention of `old format'. + (split_3): No longer parse the `new format.' There is only one + valid format now: the compatible one. + + * lib/Makefile.in (SOURCES): Add md5.c. + (OBJECTS): Add md5.o. + (DISTFILES): Add md5.h. + (md5.o): Depend on md5.h. + + * system.h [!EXIT_FAILURE, !EXIT_SUCCESS]: Define them. + * lib/md5.c (md5_stream): Check for read failure and return + indication of success rather than second argument. + * lib/md5.h (md5_stream): Update prototype. + [__P]: Define macro. + * md5sum.c: Use EXIT_FAILURE and EXIT_SUCCESS. + (main): Report an error if md5_stream fails. Otherwise, running + `md5sum dir-on-mounted-filesystem' always reported the checksum + for an empty file. Now it gets the `is a directory' error. + Greg McGary (gkm@magilla.cichlid.com) reported that the released + version got stuck in an infinite loop with such arguments. + + * lib/md5.c: New file. + * lib/md5.h: New file. + * md5sum.c: Rewritten to use library interface. + From Ulrich Drepper. + +Sun Jul 16 18:42:34 1995 Jim Meyering (meyering@comco.com) + + * configure.in: Add AC_C_INLINE: md5sum.c uses inline keyword. + +Tue Jul 11 21:56:02 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c Add #else block after #ifdef VMS. + (main): Rename local variable. + Detect and report failed fclose calls on stdout and checkfile_stream. + + * tr.c (unqote): Comment out unreachable break stmts. + (append_range): Declare FIRST and LAST parameters to be unsigned int, + not size_t. + (find_closing_delim): Clean up interface, separating boolean success + indicator and index. + (find_bracketed_repeat): Likewise. + (build_spec_list): Adapt to use new interfaces. + Declare CLOSING_DELIM_IDX and CLOSING_BRACKET_IDX to be of + type size_t, not int. + (main): Declare NR and CHARS_READ to be of type long, not int. + + * sort.c (main): Comment out unreachable break stmt. + + * tail.c (tail): Explicitly cast to long the N_UNITS argumennt in + call to tail_lines. Otherwise, NetBSD lost because N_UNITS (of type + off_t, a 64-bit type on NetBSD) wasn't converted to the target type, + long. Reported by Dan Hagerty (hag@gnu.ai.it.edu). + + * comm.c: Reorder functions so main is last, so no forward dcls + are needed. + +Sun Jul 9 11:41:15 1995 Jim Meyering (meyering@comco.com) + + * sort.c (main): When using obsolescent +pos -pos syntax, allow + omission of field spec only when character offset is specified. + Otherwise, -. +. would be accepted. + +Sat Jul 8 13:48:06 1995 Jim Meyering (meyering@comco.com) + + * sort.c (main): Allow field spec, M, to be omitted in +M.N or -M.N + position specification. For compatibility with existing practice + (what vendors?), omitting M is now equivalent to specifying `0' for M, + but only when using the +pos -pos syntax, not with the -k option. + From Rick Sladkey (jrs@world.std.com). + +Thu Jul 6 23:44:20 1995 Jim Meyering (meyering@comco.com) + + * od.c (dump): Correct loop-termination criterion. + Before, running `printf 1234| ./od --width=4 --read-bytes=4' + printed output for 8 bytes -- the last four were garbage. + This happened only when the dump limit, N, was specified (with + --read-bytes=N) and N was a multiple of bytes_per_block + (usually 16, but 4 in this example). From Andreas Schwab. + +Sun Jul 2 22:12:40 1995 Jim Meyering (meyering@comco.com) + + * lib/Makefile.in (check): Depend on libtu.a. + + * md5sum.c (split_3): Rewrite to parse Plumb/Lankester format as well. + (main): Print each sum line in (de facto) standard Plumb/Lankester + format. + New option: --quiet. + Check option no longer takes an argument. + When checking, exit status reflects success. + +Sat Jun 24 16:18:01 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c [__GNUC__]: Don't conditionalize use of "inline". + Autoconf (via config.h) defines it away for compilers that don't + grok it. + + * cat.c, comm.c, join.c, sort.c, uniq.c: Undefine min/max before + defining to avoid redefinition warning on some systems. + + * csplit.c (read_input): Rename paramater MAX to MAX_N_BYTES. + This avoids potential conflict with max macro from some system's + header files when using bad pre-ANSI compilers. + + * uniq.c (usage): Fix typo in text of --help output. + From Steve McConnel + + * md5sum.c [uint32]: When testing for 32-bit arithmetic type, + also check `unsigned long', as a concession to systems with + int's smaller than 32 bits. + + * configure.in (AC_REPLACE_FUNCS): Remove memcmp (again!) since + AC_FUNC_MEMCMP already handles it. This avoids warnings from + ranlib on nextstep systems. From Kaveh Ghazi. + + * csplit.c (interrupt_handler): Declare to have a single integer + parameter. Otherwise, some compilers fail with a type mismatch + error in sa_handler assignment. + + * fmt.c [word]: Redefine. Otherwise, systems (Unicos for one) with + headers that typedef `word' get syntax errors because of the + variable by the same name. + + * join.c [join]: Redefine to avoid conflict with prototype in some + system header file. Also for Unicos. + + * md5sum.c (main): Remove spurious colon in getopt spec string. + From Ken Pizzini . + +Tue Jun 20 06:59:16 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c (md5_file): Initialize two elements of LEN portably, + rather than with ANSI aggregate initialization. Reported by + Edzer Pebesma . + +Sun Jun 18 09:15:57 1995 Jim Meyering (meyering@comco.com) + + * Version 1.12. + + * md5sum.c (process_buffer): Copy values from struct into + individual local variables before performing computation on them, + then copy results back into returned struct. Solely for better + optimization by compilers that can't keep struct members in + registers. From Ulrich Drepper. + +Thu Jun 15 22:09:14 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c: Remove unnecessary uses of `defined' in #if* tests. + Don't use #elif. Some older compilers don't grok it. + (split_3): New function to parse out sum, flag, and filename + when reading check file. + (hex_digits): Remove length parameter since string parameter is + now nul-terminated. + (main): Don't allocate separate arrays for filename and sum + when checking. Get pointers into line buffer with split_3 instead + of using sscanf. + (main): Treat `no file args' just like `-' when not checking + or using strings. + (hex_digits): Unprotoize. + + * md5sum.c (main): Don't use a separate loop to convert to lower + case. Suggested by Ulrich Drepper. + (CLOSE): New macro. + (md5_file): Use it. + From Ulrich Drepper. + + * md5sum.c: Don't include values.h. + [__P]: Undefine it. + + * md5sum.c: [UNIX || unix]: Also test __UNIX__, __unix__, + and _POSIX_VERSION. Reported by Arne H. Juul. + +Tue Jun 13 21:20:10 1995 Jim Meyering (meyering@comco.com) + + * tr.c [NDEBUG]: Define it to disable assertions. Some systems + have a broken header. + (is_char_class_member): Set a variable in each branch of switch + stmt and return that value after the switch (rather than returning + directly from every branch). + (unquote): More int->size_t changes. + (build_spec_list): More int->size_t changes. + Be very careful about comparison now that variables are unsigned: + Use i + 2 < len rather than i < len - 2. The latter didn't work + for len < 2. Caught early thanks to a thorough regression test + suite. + +Mon Jun 12 23:07:59 1995 Jim Meyering (meyering@comco.com) + + * sort.c (xfclose): Don't try to flush stdin, only stdout. + Otherwise, at least Ultrix-4.3's fflush would return EOF. + Reported by Jim Blandy (jimb@cyclic.com). + + * tr.c (non_neg_strtol): Don't compare signed and unsigned. + [struct Spec_list] (indefinite_repeat_element): New member. + Use size_t rather than int or unsigned long where reasonable. + (get_spec_status): Make interface cleaner. + (get_s1_spec_status): New function. + (get_s2_spec_status): New function. + (validate): Use new functions instead of get_spec_status. + +Sun Jun 11 00:39:50 1995 Jim Meyering (meyering@comco.com) + + * md5sum.c: New file. From Ulrich Drepper. + * md5-test.rfc: New file. + * Makefile.in (PROGS): Add md5sum. + (check): Run a recursive make in each subdirectory. + * man/Makefile.in (MANFILES): Add md5sum.1. + * src/Makefile.in (SOURCES): Add md5sum.c. + (OBJECTS): Add md5sum.o. + (PROGS): Add md5sum. + (check): Add basic checks for md5sum. + (md5sum): Add dependency and link rule. + (DISTFILES): Add md5-test.rfc. + + * tr.c (look_up_char_class, append_char_class, append_equiv_class): + Use const attribute when appropriate. + +Sun May 28 14:48:58 1995 Jim Meyering (meyering@comco.com) + + * join.c: Overhauled to make -a1 and -a2 options work. + Passed all tests in a fairly thorough test suite. + Reported by Michael Hasselberg (mikelh@zonta.ping.de). + +Sat May 27 00:35:47 1995 Jim Meyering (meyering@comco.com) + + * tail.c (main): Remove dcl of and statements that set now-unused + variable. + + * system.h [!STDC_HEADERS && HAVE_MEMORY_H]: Include memory.h. + Without this, SunOS doesn't get type for memchr. + Reported by Kaveh Ghazi. + +Thu May 25 00:06:50 1995 Jim Meyering (meyering@comco.com) + + * tail.c (tail_lines): Change one more `long' to `off_t'. + Otherwise, tail didn't work on NetBSD. From Arne H. Juul. + + * csplit.c [struct control]: Change type of `repeat' to unsigned + long to avoid conversion warning. + +Sun May 21 07:50:00 1995 Jim Meyering (meyering@comco.com) + + * Makefile.in (.PHONY): TAGS is not a phony target. From Franc,ois. + + * xstrtol.c (__strtol): Remove prototype altogether. + Move inclusion of xstrtol.h back so that it follows system headers. + + * Version 1.11.2. + +Sat May 20 06:44:14 1995 Jim Meyering (meyering@comco.com) + + * join.c (ADD_FIELD): Declare in K&R style, not ANSI. + From Kaveh Ghazi. + + * xstrtol.c: Define NDEBUG for systems with losing assert.h. + (__strtol): Add __unsigned to prototype and use __P. + Move inclusion of xstrtol.h to precede prototype. + From Kaveh Ghazi. + + * memmove.c: Include config.h for definition of const. + From Kaveh Ghazi. + + * All Makefile.in (install-exec, install-exec): New targets. + From Karl Berry. + + * tr.c (look_up_char_class): Take a string length argument -- required + because the argument is a string that is *not* NUL-terminated. + Use strncmp, not strcmp and add string lengths comparison. + (append_char_class): Update caller. Before this change, + tr '[:upper:]' '[:lower:]' read one uninitialized byte. + From Andreas Schwab. + + * split.c (next_file_name): Move dcls of file-scope variables into + this function. Don't rely on arithmetic being two's complement. + + * paste.c [CLOSED, ENDLIST]: Don't cast constants to FILE pointers. + Instead, declare two FILE structs and use their addresses. + + * csplit.c (record_line_starts): Remove set-but-not-used, + file-scope variable. + +Sat May 13 08:57:20 1995 Jim Meyering (meyering@comco.com) + + * all source files (usage): Include one- or two-line synopsis + in --help output. From Karl Berry. + + * lib/Makefile.in [.c.o]: Remove -I. since safe-l?stat.h are no + longer used. + +Wed May 10 22:26:35 1995 Jim Meyering (meyering@comco.com) + + * Version 1.11.1 + +Sun May 7 13:35:49 1995 Jim Meyering (meyering@comco.com) + + * all Makefile.in (maintainer-clean): Renamed from realclean + per GNU Standards. + +Thu May 4 23:15:58 1995 Jim Meyering (meyering@comco.com) + + * sort.c (main): Use stat, not safe_stat. The latter was unnecessary. + Don't include safe-stat.h. + + * lib/Makefile.in (DISTFILES): Remove safe-xstat.hin. + Remove all associated rules. safe-l?stat.h are no longer used. + + * sort.c Don't hard-code /tmp. + [DEFAULT_TMPDIR]: Use this instead. + * tac.c (save_stdin): Likewise. + + * sort.c (set_ordering): Properly parse arguments like `+x.yn'. + Reported by John Salmon (johns@mullet.anu.edu.au). + Patch from Mike Haertel. + +Wed Apr 26 23:48:13 1995 Jim Meyering (meyering@comco.com) + + * sort.c (tempname): AND-off high bits of pid so that its decimal + string representation is no longer than five digits. + From Hans Verkuil (hans@wyst.hobby.nl). + +Thu Apr 20 23:09:33 1995 Jim Meyering (meyering@comco.com) + + * expand.c (add_tabstop): Give correct size when reallocating + tab_list buffer. From Geoff Odhner (geoff@franklin.com). + Reproduce with expand --t=`perl -e "print join (',', (1..300));"`. + +Tue Apr 18 22:57:43 1995 Jim Meyering (meyering@comco.com) + + * configure.in (AC_OUTPUT): Use echo, not date, to avoid creating + unnecessary conflicts for people using version control software + like RCS and CVS. + (AC_ARG_PROGRAM): Use it. + +Thu Apr 13 23:22:57 1995 Jim Meyering (meyering@comco.com) + + * head.c: Remove block of redundant comments describing options. + (usage): Remove reference to -l option. It's not valid. + + * od.c (write_block): Declare index I as unsigned int, not int. + (get_lcm): Likewise. + (dump_strings): Likewise. + (main): Likewise. + (dump): Cast BYTES_PER_BLOCK to off_t in MIN expression. + (dump_strings): Declare bufsize to be of type size_t, not int. + + * split.c (next_file_name): Don't reuse X as an index. + Declare new variable I instead. + +Sat Mar 25 15:07:23 1995 Jim Meyering (meyering@comco.com) + + * csplit.c: Declare as `unsigned int' all variables that were + just `unsigned'. + (make_filename): Change type of arg to unsigned int. + (split_file): Change type of indices to unsigned int. + +Thu Mar 16 22:05:05 1995 Jim Meyering (meyering@comco.com) + + * od.c (main): Detect and fail when argument to -N is too large + to fit in an off_t. + +Sun Mar 12 12:02:39 1995 Jim Meyering (meyering@comco.com) + + * configure.in (AC_REPLACE_FUNCS): Add memcmp.c. + Remove check for sizeof long. + + * linebuffer.h: Undefine __P before defining it. + * long-options.h: Likewise. + * xstrtol.h: Likewise. + + * memcpy.c: New file. + * lib/Makefile.in (SOURCES): Add memcpy.c. + +Fri Mar 10 21:14:11 1995 Jim Meyering (meyering@comco.com) + + * src/*.c: Update Copyright dates. + +Sat Feb 11 07:31:08 1995 Jim Meyering (meyering@comco.com) + + * system.h: Remove index/rindex and bcmp/bcopy/bzero references. + Separate errno declaration from STDC_HEADERS. + + * wc.c (wc): For efficiency, handle separately the cases in which + words need not be counted. Suggested by Karl Heuer. + + * wc.c (wc): Don't overcount the number of bytes when reading + from a regular file on stdin with file pointer not at BOF. + From Karl Heuer . Before, the command + `(dd ibs=99k skip=1; wc -c) < /etc/group' made wc wrongly output + the size of the file. Now it outputs `0'. + +Sat Jan 28 07:07:23 1995 Jim Meyering (meyering@comco.com) + + * cat.c (cat): Use memmove rather than bcopy. + * csplit.c (load_buffer): Use memcpy rather than bcopy. + (extract_regexp): Use strrchr, not rindex. + * fmt.c (isopen, isclose, isperiod): Use strchr, not index. + (flush_paragraph): Use memmove instead of bcopy. + * fold.c (fold_file): Use memmove instead of bcopy. + * od.c (decode_format_string): Use memmove instead of bcopy. + [EQUAL_BLOCKS]: Use memcmp, not bcmp. + (parse_old_offset): Use strchr, not index. + (dump): Use memset, not bzero. + * sort.c (checkfp, mergefps): Use memcpy instead of bcopy. + (fillbuf): Use memmove instead of bcopy. + * split.c (main): Use memset, not bzero. + (line_bytes_split): Use memmove instead of bcopy. + * tac.c (tac): Use memmove instead of bcopy. + (output): Use memcpy instead of bcopy. + * tail.c (pipe_lines, pipe_bytes): Use memcpy instead of bcopy. + * tr.c (substr): Use memcpy instead of bcopy. + (card_of_complement, set_initialize): Use memset, not bzero. + + * tr.c (substr): Don't allocate a byte for trailing NUL in result + since the result needn't be NUL-terminated. Don't NUL terminate it. + + * configure.in (AC_REPLACE_FUNCS): Check for memmove and memcpy, + not bcopy. + (AC_CHECK_FUNCS): Add strchr and strrchr. + + * lib/Makefile.in (SOURCES): Add memmove.c and memcpy.c. + * memmove.c: New file. + * memcpy.c: New file. + +Tue Jan 24 22:18:19 1995 Jim Meyering (meyering@comco.com) + + * fmt.c (copy_rest): Replace `||' with `&&'. Before, a paragraph + not followed by a newline would be followed by data copied from + uninitialized storage. Repeat by `printf abc|fmt|od -ac'. + Reported by Franc,ois Pinard. + + * od.c: Rename macros with FP_ prefix. Use FLOAT_ instead. + AIX-2.2.1 declares a typedef, FP_DOUBLE, that conflicted. + Be careful to use off_t instead of explicit `unsigned long'. + Otherwise, systems like 4.4BSD lose on calls to fseek that + expect off_t (which is long long on that system). + (parse_old_offset): Use xstrtoul + (main): Likewise. + + * src/Makefile.in (od.o, tail.o): Depend on ../lib/strtol.h. + +Mon Dec 19 22:13:55 1994 Jim Meyering (meyering@comco.com) + + * tail.c (numerous functions): Give char* filename arguments the + const attribute. + + * lib/Makefile.in (SOURCES): Remove xwrite.c. It was no longer used. + Add xstrtol.c and xstrtoul.c. + (OBJECTS): Likewise for .o files. + (DISTFILES): Add error.h and xstrtol.h and xstrtoul.h. + + * lib/Makefile.in (DISTFILES): Remove safe-xstat.cin. + (distclean): Remove references to safe-l?stat.c. + Remove all related rules and dependencies. + + * src/Makefile.in: $(OBJECTS): Depend on ../lib/error.h. + +Thu Dec 15 23:14:04 1994 Jim Meyering (meyering@comco.com) + + * tail.c (tail_file): Fix call to error with %s in format, but + no corresponding argument. + + * src/*.c: Include "error.h" instead of simply declaring + `void error ();'. + * od.c (main): Use %lu, not %d for unsigned long. + (my_strtoul, uint_fatal_error): Remove functions. Use xstrtoul + and STRTOL_FATAL_ERROR instead. + +Sun Dec 11 17:24:09 1994 Jim Meyering (meyering@comco.com) + + * sort.c (main): Fix interpretation of field offsets when specified + via -k option. They were being interpreted as zero-indexed. POSIX + says they are 1-based indices. From Rik Faith . + (keycompare): Don't ignore characters at the end of words when + otherwise they would compare equal. From Rik Faith. + + * tail.c (): Change the type of n_units/n_lines/n_bytes + to off_t because n_bytes is used as the option to fseek and off_t may + be long long (e.g. on BSD4.4). The only place where a 32-bit limit is + imposed is in the string-to-integer converstion of xstrtol. + (main): Use xstrtol instead of manual string to integer conversion. + + * csplit.c (get_format_width, get_format_prec): Use ISDIGIT instead of + comparisons against '0' and '9'. + + * tr.c [!ULONGMAX]: Define it. + [!LONGMAX]: Define in terms of ULONGMAX instead of as a 32-bit constant. + + * full-write.c: Declare (or not) errno based on definedness or + errno, not STDC_HEADERS. + * safe-read.c: Likewise. + * xwrite.c: Likewise. + +Thu Nov 17 06:37:33 1994 Jim Meyering (meyering@comco.com) + + * tail.c (dump_remainder): Flush standard output just before + sleeping so that `tail -f' will output partial lines sooner. + This applies only when following the end of a single file. + From Leonard N. Zubkoff . + + * tail.c (file_lines, pipe_lines, pipe_bytes, start_bytes, + start_lines, dump_remainder): Use STDOUT_FILENO instead of `1' in + XWRITE calls. + * tac.c (output): Use STDOUT_FILENO instead of `1' in xwrite call. + * system.h (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO): Define if + not already defined. + +Wed Nov 16 07:01:38 1994 Jim Meyering (meyering@comco.com) + + * tr.c: Include instead of "getopt.h". + + * sort.c (tempname): Merge two very similar sprintf stmts into one. + + * tail.c: Use BUFSIZ instead of BUFSIZE. + + * cut.c: Declare DELIM to be `int' rather than unsigned char. + + * fmt.c: Use index, not strchr -- per GNU Standards. + Reported by Kaveh Ghazi. + Always include . + (main): Include program name in --version output. + +Sun Nov 06 00:17:21 1994 Jim Meyering (meyering@comco.com) + + * Version 1.11. + +Sat Nov 05 15:14:44 1994 Jim Meyering (meyering@comco.com) + + * memcmp.c, srtoul.c: Use up-to-date versions. + Reported by Franc,ois Pinard. + + * src/Makefile.in (DEFS): Remove -Dlint... again. + + * src/Makefile.in (PROGS): Add fmt! + Reported by Andreas Stolcke (stolcke@ICSI.Berkeley.EDU). + +Fri Nov 04 17:26:16 1994 Jim Meyering (meyering@comco.com) + + * Version 1.10. + +Thu Nov 03 23:23:08 1994 Jim Meyering (meyering@comco.com) + + * linebuffer.h: Use __P instead of _P since the latter conflicts + with a definition in some . From Kaveh Ghazi. + +Wed Nov 02 17:36:34 1994 Jim Meyering (meyering@comco.com) + + * tr.c: Add const attribute where appropriate. + + * tail.c (BUFSIZ): Use definition from . + +Tue Nov 01 23:54:09 1994 Jim Meyering (meyering@comco.com) + + * tail.c (XWRITE): Allow n_bytes == 0 but call fwrite only if + n_bytes is positive. Turn off assertions. `tail /dev/null' was + getting a failed assertion. Reported by Doug McLaren + (dougmc@comco.com). + + * cut.c (cut_bytes): Print at least a newline for every line of input. + (cut_fields): Print a newline even for lines whose only selected + field is empty. But print nothing when using -s without -f1. + And print nothing for empty input. Reported by + Richard_Sharman@software.mitel.com. + +Tue Nov 01 06:05:23 1994 Jim Meyering (meyering@comco.com) + + * fmt.c: Change #ifdef __STDC__ to #if defined (__STDC__) && __STDC__. + * linebuffer.h: Likewise. + +Mon Oct 31 06:53:32 1994 Jim Meyering (meyering@comco.com) + + * configure.in (AC_REPLACE_FUNCS): Remove memcmp since AC_FUNC_MEMCMP + already handles it. From Kaveh Ghazi. + + * {lib,src}/Makefile.in (DEFS): Don't use -Dlint. Some systems + get failures when it's defined. From Kaveh Ghazi. + + * cat.c (cat): Conditionalize test for errno == ENOSYS. It's not + defined on some Next and Alliant systems. From Kaveh Ghazi. + + * sort.c join.c (main): Include version.h and call parse_long_options + with the proper number of arguments. Reported by Franc,ois Pinard. + +Sun Oct 30 01:30:41 1994 Jim Meyering (meyering@comco.com) + + * (configure.in): Add AC_OFF_T and rearrange by type along the + same lines as autoscan. + + * fmt.c, fmt.1: New files. + Both from Ross Paterson (rap@doc.ic.ac.uk). + + * Makefile.in (PROGS): Add fmt. + * src/Makefile.in (SOURCES, OBJECTS): Add fmt.c and fmt.o respectively. + (fmt): Add a link rule. + * man/Makefile.in (MANFILES): Add fmt.1. + +Sat Oct 08 10:44:30 1994 Jim Meyering (meyering@comco.com) + + * Makefile.in (All of them): Update from the ones in sh-utils. + From now on, rules and definitions that are comon to the fileutils, + textutils, and sh-utils will get ChangeLog entries only in the + sh-utils. + +Tue Oct 04 20:42:46 1994 Jim Meyering (meyering@comco.com) + + * od.c (my_strtoul): Set errno to zero before calling strtoul. + Otherwise, od can fail complaining about a valid integer argument. + From Andreas Schwab. + +Sun Oct 02 17:57:09 1994 Jim Meyering (meyering@comco.com) + + * tr.c (main): Give an error and fail when squeezing repeats + and no non-options are given. Reported by Tony Robinson + (ajr@eng.cam.ac.uk). + + * sort.c (main): Temporarily copy each input file that might be + another name for the output file. When in doubt (e.g. a pipe), + copy. This allows the dangerous (historical -- in cnews) idiom + `cat file | sort -o file' to work properly. Don't rely on this + behavior in new shell scripts. From Paul Eggert (eggert@twinsun.com). + +Mon Sep 26 18:01:47 1994 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu) + + * lib/xwrite.c safe-read.c memchr.c linebuffer.c full-write.c: + Remove CONFIG_BROKETS ifdef. + * src/Makefile.in lib/Makefile.in: Don't define it. + +Sat Sep 24 21:26:27 1994 Jim Meyering (meyering@comco.com) + + * full-write.c (full_write): Declare argument LEN to be size_t. + +Mon Sep 12 13:35:27 1994 Jim Meyering (meyering@comco.com) + + * tail.c (tail_file): [For multiple files only]: Report truncation + of monitored file and reset current file size. From Franc,ois Pinard. + +Sat Aug 27 16:57:20 1994 Jim Meyering (meyering@comco.com) + + * system.h [BROKEN_STAT_MACROS]: Remove unnecessary #ifdef's. + From Franc,ois Pinard. + +Tue Jul 26 11:33:53 1994 Jim Meyering (meyering@comco.com) + + * system.h: Remove `|| defined(_POSIX_VERSION)' from test that + decides whether to include . From Francois Pinard. + +Wed Jul 13 12:33:34 1994 Jim Meyering (meyering@comco.com) + + * tr.c (substr): Fix off-by-one allocation error. + +Wed Jun 22 01:02:50 1994 Jim Meyering (meyering@comco.com) + + * tac.c (tac_file): Use O_RDONLY instead of zero in call to open. + (tac): Fix typo that had `1' as arg #2 of error after failed read. + Use errno instead. From Michael I Bushnell . + +Thu May 26 08:46:32 1994 Jim Meyering (meyering@comco.com) + + * configure.in [INSTALL]: Revert change of March 25. autoconf + has been fixed. + +Mon Apr 11 17:25:43 1994 Jim Meyering (meyering@comco.com) + + * join.c (prline): Remove unused function. Indent. + +Fri May 6 05:44:24 1994 Jim Meyering (meyering@comco.com) + + * tail.c (tail_forever): Don't print headers when asked not to. + From Karsten Thygesen . + + * wc.c (wc): Optimize for the case when only bytes are being counted + and the input is not a regular file. From Jeff Moore . + +Sun Apr 24 10:54:08 1994 Jim Meyering (meyering@comco.com) + + * configure.in [AC_SIZEOF_TYPE]: Update for autoconf-1.9. + * memchr.c: Test SIZEOF_LONG instead of LONG_64_BITS. + +Mon Apr 11 17:55:52 1994 Jim Meyering (meyering@comco.com) + + * csplit.c (struct control): Add new field, repeat_forever. + Remove now-unneeded definition of INT_MAX. + (process_regexp): Test repeat_forever instead of comparing `repeat' + to INT_MAX. + (split_file): Don't even reference `repeat' count if repeat_forever + is set. + (new_control_record): Initialize repeat_forever field. + (parse_repeat_count): Set it instead of setting repeat count to + INT_MAX. + (process_line_count): Abort for internal error instead of calling + handle_line_error. + + * long-options.c (parse_long_options): Take a new argument indicating + the utility name (e.g. "join", not "gjoin") for version output. + Print both the utility and the package names, e.g. `join - GNU + textutils-1.9.1' instead of just the package name. + + * join.c (main): Call parse_long_options with program name arg. + * sort.c (main): Ditto. + + * All source except sort.c and join.c (main): Change --version output + to include utility name as well as package name and version info. + +Wed Mar 30 08:53:21 1994 Jim Meyering (meyering@comco.com) + + * configure.in: Use AC_SET_MAKE. + * Makefile.in: Edit MAKE assignments into @SET_MAKE@. + +Mon Mar 28 09:55:05 1994 Jim Meyering (meyering@comco.com) + + * tr.c (main): In addition to the --help usage pointer, give an + explicit error message for too many arguments. + +Fri Mar 25 18:11:19 1994 Jim Meyering (meyering@comco.com) + + * configure.in: Use AC_VERBOSE, AC_CHECKING, and AC_WARN instead + of explicit echo commands. + [INSTALL]: When AC_PROG_INSTALL resorts to setting this to + `./install.sh', make it `../install.sh' instead since that + script will be invoked only from subdirectories. + [AC_SIZEOF_TYPE]: Use this instead of deprecated AC_LONG_64_BITS. + + * cat.c (cat): The command `:|cat -s' failed on Irix5 because + ioctl (d, FIONREAD,... now returns ENOSYS for pipes -- under Irix4 + it returned EINVAL. Detect this. + (main) [lint]: Initialize variables to suppress `used before + initialized' warnings. + + * csplit.c: Change long option name from --suffix to --suffix-format. + + * od.c (skip): Correct a comment. + (main): Don't output anything to stdout if the sole input file + doesn't exist. Reported by Bauke Jan Douma . + + * od.c (dump) [lint]: Initialize a variable to suppress `used before + initialized' warning. + (main) [lint]: Ditto. + * paste.c (paste_parallel) [lint]: Ditto. + +Fri Jan 28 11:02:21 1994 Jim Meyering (meyering@comco.com) + + * configure.in: Don't set LDFLAGS since linking now uses both + LDFLAGS and CFLAGS. + +Wed Jan 18 16:14:00 1994 Jim Meyering (meyering@comco.com) + + * unexpand.c (unexpand): Don't segfault when given a name of a + nonexistent file. + * expand.c (expand): Ditto. + Both from Bauke Jan Douma . + +Thu Jan 13 17:27:38 1994 Jim Meyering (meyering@comco.com) + + * src/Makefile.in: Change all link commands to use both $(CFLAGS) + and $(LDFLAGS). + + * csplit.c (load_buffer): Rather than incrementing buffer size, + double it each time we fail to find a newline. Otherwise, csplit + would run out of memory when processing files with very long lines. + +Mon Jan 10 01:20:38 1994 Jim Meyering (meyering@comco.com) + + * man/Makefile.in (manprefix): Use binprefix as the default. + +Sat Jan 08 22:22:45 1994 Jim Meyering (meyering@comco.com) + + * cat.c: Use full_write and safe_read instead of write and read resp. + * csplit.c: Ditto. + * head.c: Ditto. + * split.c: Ditto. + * tac.c: Ditto. + + * sum.c: Use safe_read instead of read. + * tr.c: Ditto. + * wc.c: Ditto. + + * tail.c: Replace calls to xwrite with calls to fwrite. + Use fopen/fclose instead of open/close. + (write_header): Use a single call to printf instead of four to xwrite. + Use safe_read instead of read. + * head.c: Ditto. + +Tue Dec 28 15:49:32 1993 Jim Meyering (meyering@comco.com) + + * install.sh: New file. + Makefile.in [DISTFILES]: Add it. + +Wed Dec 22 18:52:44 1993 Jim Meyering (meyering@comco.com) + + * memcmp.c: Use the latest version from the GNU C library. + + * cut.c [ADD_RANGE_PAIR]: New macro. + (set_fields): Collect the list of all selected ranges before + allocating and initializing the boolean lookup table. + (cut_bytes, cut_fields): Complete rewrite. Avoid copying + into buffer whenever possible. Properly handle input without + trailing newline. + (getstr): New function. Copied from getline.c, but with minor changes. + + * sort.c (main): Properly handle -Tdir. + Before, `sort -T/var/tmp' gave `sort: unrecognized option `-v''. + Reported by Kristoffer Rose (kris@diku.dk). + + * cut.c (main): Give separate errors for `-s without -f' + and `-d without -f'. + (main): Now -d '' means `use the NUL byte as the delimiter'. + Before, it got an error. + +Mon Dec 20 23:29:30 1993 Jim Meyering (meyering@comco.com) + + * configure.in [test for 8-bit clean memcmp]: Add a test to detect + losing memcmp from SunOS4.1.x. From Robert H. de Vries + . + +Sat Dec 18 01:12:24 1993 Jim Meyering (meyering@comco.com) + + * configure.in (AC_OUTPUT): Put `touch stamp-config' in second arg + so it goes in config.status. This eliminates unnecessary second run + of configure. + +Thu Dec 02 23:53:03 1993 Jim Meyering (meyering@comco.com) + + * configure.in (AC_HAVE_FUNCS): Add isascii. + * system.h [!defined (isascii) || defined (STDC_HEADERS)]: This failed + on AIX PS/2 1.3 systems because isascii is a function and it is used + in definitions (with the necessary side effect of assigning to a + global variable) of the is* macros. Also test HAVE_ISASCII and + redefine ISASCII(c) instead of isascii. + Reported by Minh Tran-Le (tranle@intellicorp.com). + +Fri Nov 19 22:41:48 1993 Jim Meyering (meyering@comco.com) + + * configure.in: Don't run the test for 8-bit clean memcmp if we + already know we'll be using our replacement. + +Fri Nov 12 00:44:49 1993 Jim Meyering (meyering@comco.com) + + * Version 1.9.1. + + * tac.c (usage): Fix typo in long usage. + * sort.c (usage): Likewise. + From Philippe.Schnoebelen@imag.fr. + + * cut.c [FATAL_ERROR]: New macro. + (main): Call both error and usage (2) through FATAL_ERROR in + many places. Before, only `error (2...' was called. + (invalid_list): Removed. This function is subsumed by FATAL_ERROR. + + * cut.c (cut_fields): Properly handle input lacking a terminating + newline. Before, the command `printf "a\tb" |cut -f 1' generated + no output. + +Tue Nov 09 17:26:25 1993 Jim Meyering (meyering@comco.com) + + od.c (usage): Change --backward-compatible to --traditional in + the long usage message. + +Sun Nov 07 00:50:05 1993 Jim Meyering (meyering@comco.com) + + * Version 1.9. + +Sat Nov 06 22:51:31 1993 Jim Meyering (meyering@comco.com) + + * cut.c (cut_fields): Revert July 27 change. Instead, strip off + trailing delimiter unless given a range of fields like `3-' that + extends to end of line. + (set_fields): Moved local `eol_range_start' to file-scope. + Reported by Arne H. Juul (arnej@solan.unit.no). + +Tue Nov 02 00:53:41 1993 Jim Meyering (meyering@comco.com) + + * fold.c (fold_file): Don't get stuck in an endless loop when + width is smaller than 8 and there are TABs in the input. + +Sat Oct 30 15:31:28 1993 Jim Meyering (meyering@comco.com) + + * join.c: Remove now-unused dcls of show_help and show_version. + +Fri Oct 29 13:58:50 1993 Jim Meyering (meyering@comco.com) + + * csplit.c [INT_MAX]: Make sure it's defined. + [not HAVE_LIMITS_H]: Don't include limits.h. + From Kaveh R. Ghazi (ghazi@noc.rutgers.edu). + +Wed Oct 27 01:13:52 1993 Jim Meyering (meyering@comco.com) + + * Version 1.8.1. + +Mon Oct 25 20:16:33 1993 Jim Meyering (meyering@comco.com) + + * sort.c: Accept but ignore -y0 for compatibility with Solaris 2. + From Chuck Hedrick (hedrick@klinzhai.rutgers.edu). + + * sort.c (main): Handle --help and --version options. + * Makefile.in (sort.o): Depend on long-options.h. + +Sun Oct 24 00:31:02 1993 Jim Meyering (meyering@comco.com) + + * csplit.c, cut.c, expand.c, fold.c, head.c, nl.c, od.c, paste.c, + split.c, tac.c, tail.c, unexpand.c, uniq.c: Use the preferred + `--longopt=arg' syntax in --help message rather than `--longopt arg'. + From Francois Pinard. + + * tail.c: Don't include . It hasn't been necessary + since the Dec 12, 1992 change. + + * join.c (main): Accept `-v 1' again. Adding the --version + long option had broken it, although -v1 still worked. Call + parse_long_options instead of adding "help" and "version" + to join's longopt strct. + * Makefile.in [SOURCES, OBJECTS, DISTFILES]: Add long-options.c + and long-options.h. + * (join): Depend on and link with long-options.o. + * (join.o): Depend on long-options.h. + + * od.c: Change --compatible (-C) to --backward-compatible (-B). + + * csplit.c: Change --abandon-null-files to --elide-empty-files. + +Sat Oct 23 01:00:12 1993 Jim Meyering (meyering@comco.com) + + * tr.c (get_next, string2_extend): Add default: label to switch stmt. + + * cat.c, cksum.c, comm.c, csplit.c, cut.c, expand.c, fold.c, head.c, + join.c, nl.c, od.c, paste.c, pr.c, split.c, sum.c, tac.c, tail.c, + tr.c, unexpand.c, uniq.c, wc.c (usage): Add long --help. + Exit successfully for --help, non-zero for usage error. + From Francois Pinard. + + * configure.in: Add AC_STAT_MACROS_BROKEN. + * system.h [AC_STAT_MACROS_BROKEN]: Test it. + +Fri Oct 22 23:26:17 1993 Jim Meyering (meyering@comco.com) + + * linebuffer.c, memchr.c [HAVE_CONFIG_H, CONFIG_BROKETS]: Include + or "config.h". + * cat.c, cksum.c, comm.c, csplit.c, cut.c, expand.c, fold.c, head.c, + join.c, nl.c, od.c, paste.c, pr.c, sort.c, split.c, sum.c, tac.c, + tail.c, tr.c, unexpand.c, uniq.c, version.c, wc.c: Ditto. + + * configure.in: Use AC_CONFIG_HEADER. + * Makefile.in [DIST]: Add config.h.in. + + * Makefile.in: Convert so make may be run from subdirectories. + Add dependencies on config.h. + * src/Makefile.in: Ditto. + * lib/Makefile.in: Ditto. + * man/Makefile.in: Ditto. + +Wed Oct 20 20:05:48 1993 Jim Meyering (meyering@comco.com) + + * memchr.c (memchr): Do the 32-bit assignment only if !LONG_64_BITS. + In the 64-bit assignment, be careful to cast the shift operand to + long. + Abort if sizeof (unsigned long) > 8. + +Tue Oct 19 22:37:58 1993 Jim Meyering (meyering@comco.com) + + * csplit.c: Allow repeat counts to be specified via `{*}'. + New option --suffix=format. Supercedes --digits option. + New option --abandon-null-files. + From Ronald F. Guilmette (rfg@netcom.com). + + * csplit.1: Updated. + From Ronald F. Guilmette. + + * csplit.c: Remove register keyword (replace with `int' in two cases). + + * csplit.c: [MAX]: Macro renamed from max and moved to top of file. + (bytes_to_octal_digits): New static array. + (get_format_flags): Combine '+' and ' ' cases of switch stmt. + Return count if for loop terminates. + (get_format_width): Use `bytes_to_octal_digits' instead of just 11. + (get_format_prec): Make sure is_negative is defined before used. + (get_format_conv_type): Give a different error message if there + is no conversion specifier. + Test ISPRINT (ch) instead of `ch < '~' && ch > ' ''. + (max_out): Use `%%' rather than `%' in format string. + +Sat Oct 16 10:45:17 1993 Jim Meyering (meyering@comco.com) + + * pr.c (main): When argc == 1, don't try to xmalloc (0). + +Tue Oct 12 00:53:26 1993 Jim Meyering (meyering@comco.com) + + * xwrite.c [HAVE_CONFIG_H, CONFIG_BROKETS]: Include + or "config.h". + +Sat Oct 09 23:37:43 1993 Jim Meyering (meyering@comco.com) + + * configure.in: Remove AC_UNISTD_H; add unistd.h to AC_HAVE_HEADERS. + +Thu Sep 9 21:52:10 1993 Jim Meyering (meyering@comco.com) + + * src/*.c: Print version on standard output, not stderr. + + * configure.in: Add AC_LONG_64_BITS. + * memchr.c: Use #ifdef LONG_64_BITS instead of + `if (sizeof(longword) > 4)'. + +Tue Jul 27 22:19:39 1993 Jim Meyering (meyering@comco.com) + + * cat.c (cat): Don't fail just because ioctl (d, FIONREAD,... can't + always handle devices. Ignore errno == EINVAL and errno == ENODEV. + `cat -v /dev/null' was failing on many systems. + + * cut.c (cut_fields): Don't strip off trailing delimiter e.g. + `echo 'a:b:c:' | cut -d: -f3-' should print `c:', not just `c'. + From William Dowling . + +Thu May 27 01:37:51 1993 Jim Meyering (meyering@comco.com) + + * Version 1.8. + + * memchr.c: De-ansify the fixed version from glibc. + It is supposed to work on systems with 64-bit long ints. + +Mon May 24 00:32:43 1993 Jim Meyering (meyering@comco.com) + + * Version 1.7. + +Sat May 22 02:13:12 1993 Jim Meyering (meyering@comco.com) + + * Version 1.6. + +Fri May 21 22:57:53 1993 Jim Meyering (meyering@comco.com) + + * pr.c (cols_ready_to_print): New function. It replaces a global + variable by the same name and computes on the fly the value that + was supposed to be maintained through that variable. This should + put to rest the `pr -2a' bug. + (main): Don't let getopt_long reorder arguments so we can + distinguish between `pr -1 -2' and `pr -12'. Rework handling of + -n and +n options. + + * fold.c: Declare xmalloc. + +Wed May 19 19:12:18 1993 Karl Berry (karl@owl.hq.ileaf.com) + + * sort.c (main): fflush before exit, so a closed stdout doesn't lose. + +Tue May 18 23:49:26 1993 Jim Meyering (meyering@comco.com) + + * mkinstalldirs: New file. + * Makefile.in (installdirs): Use it to create installation directories. + +Fri May 14 23:45:52 1993 Jim Meyering (meyering@comco.com) + + * all source: With --version, print version and exit immediately. + +Thu May 13 01:03:16 1993 Jim Meyering (meyering@comco.com) + + * Makefile.in (installdirs): New rules for creating installation + directories. (install): depend on it. + + * tail.c (main): Remove --compatible since `+1f' may be used + to get the BSD `-0f' behavior portably. + + * fold.c (main): Turn -N arguments, where N is a digit, into -wN. + From Ian Lance Taylor (ian@cygnus.com). + +Mon May 10 22:33:44 1993 Jim Meyering (meyering@comco.com) + + * tail.c (main): New option -C, --compatible to make `tail -0f' + work like `tail +1f' for compatibility with BSD tail. + +Thu May 6 23:28:56 1993 Jim Meyering (meyering@comco.com) + + * pr.c (print_page): Decrement cols_ready_to_print even when + lines_to_print == 0. The command `echo |pr -2ta' *still* didn't + terminate. Add parentheses for clarity. + +Mon May 3 23:57:47 1993 Jim Meyering (meyering@comco.com) + + * Version 1.5. + + * od.c (main): Remove set-but-not-used variable, `usage_error'. + + * split.c (main): Call usage with an argument. + +Sun May 2 16:05:04 1993 Jim Meyering (meyering@comco.com) + + * configure.in: Reverse if-else branches in AC_TEST_PROGRAM test + for 8-bit clean memcmp. + + * cat.c (usage, main): Remove unused argument. + + * csplit.c (remove_line): Remove set-but-not-used variable, `line_got.' + (check_for_offset): Remove unused argument `argnum.' + + * configure.in: Add AC_SIZE_T. + +Sat May 1 09:03:19 1993 Jim Meyering (meyering@comco.com) + + * uniq.c (main): Interpret non-option arguments with a leading `+' + only if we haven't seen `--'. + + * tr.c (main): Change variable name to avoid shadowed dcl. + * wc.c (write_counts): Ditto. + + * sum.1: Make documentation agree with the code. + + * od.c: Depend only on HAVE_LONG_DOUBLE for long double support. + +Fri Apr 30 20:16:03 1993 Jim Meyering (meyering@comco.com) + + * configure.in [AC_HAVE_HEADERS]: Add limits.h. + + * configure.in [CFLAGS, LDFLAGS]: Assign reasonable defaults. + + * od.c (parse_old_offset): Don't use prototype in function + definition. Remove unnecessary conjunct from test for hexadecimal + prefix. + + * od.c: Depend on __GNUC__ || HAVE_LONG_DOUBLE rather than __STDC__ + for long double support; there are compilers (Stardent Vistra svr4) + without long double but still define __STDC__. + +Thu Apr 29 02:01:27 1993 Jim Meyering (meyering@comco.com) + + * src/*.c and man/*.c except for sort: Add --help and --version + options. + + * pr.c: Convert to use getopt_long. + + * lib/memcmp.c: Use version from glibc. + [WORDS_BIGENDIAN]: Test this instead of the using glibc's + __BYTE_ORDER macro. + * configure.in: Use AC_WORDS_BIGENDIAN to set it. + + * od.c (parse_old_offset): Allow `0X' as well as `0x' prefix to + indicate hex. + + * Makefile.in (dist): Depend on Makefile so that changes to + Makefile.in (like adding new files to DISTRIB) are reflected + in the new distribution. + +Fri Apr 23 21:53:47 1993 Jim Meyering (meyering@comco.com) + + * {lib,src}/Makefile.in [.c.o]: Make CPPFLAGS and CFLAGS follow + other options so users can use them to override DEFS. + * src/Makefile.in [.c.o]: Add -I$(srcdir) for version.h. + + * Makefile.in [CFLAGS, LDFLAGS]: Don't set to -g explicitely; + configure's AC_SUBST will set these. + + * Makefile.in [Makefile]: Add dependencies and a rule to remake it. + [targets that cd then run make in subdirectories]: Don't depend + on `cd ..'; use a subshell instead. + + * Makefile.in [info, install-info, dvi, check, installcheck]: + New targets but no rules; comply with standards. + + * configure.in [CFLAGS]: Default to -g -O if CC is gcc and the user + hasn't specified CFLAGS. + [LDFLAGS]: Substitute into Makefile. + +Tue Mar 30 21:36:11 1993 Jim Meyering (meyering@comco.com) + + * od.c: New option --compatible, -C. + (parse_old_offset): New function. + * od.1: Document new option. + +Mon Mar 29 21:27:56 1993 Jim Meyering (meyering@comco.com) + + * cut.c, expand.c, join.c, nl.c: Always call error with errno + (not zero) after failed fclose or non-zero ferror. + +Sun Mar 28 16:59:31 1993 Mike Haertel (mike@cs.uoregon.edu) + + * configure.in: Add check for working memcmp; use GNU's if + the system's doesn't grok the 8th bit. + * memcmp.c: Fix it so it groks the 8th bit. + TODO: We really need to provide a fast memcmp, since most + machines will have a broken memcmp. Probably should get + the one from glibc. + * sort.c (mergefps): Maintain keybeg and keylim when copying + the current line to `saved'. + (numcompare): Skip white space here since -n no longer implies -b. + (getmonth): Skip white space here since -M no longer implies -b. + (compare): Completely overhauled to make the 8th bit work right, + also to properly handle the global reverse option. + (set_ordering): -n no longer implies -b, according to Posix. + For consistency, -M also no longer implies -b. + (main): Correct treatment of -r and global keys. + (findlines): Clear keybeg and keylim if no keys are used. + (sort): Avoid overwriting tempfiles[] array bounds. + +Sun Mar 21 22:29:29 1993 Jim Meyering (meyering@comco.com) + + * pr.c (close_file): Reverse May 13, '92 change, but add the condition + that cols_ready_to_print not be decremented when printing across. + The command `echo |pr -2ta' didn't terminate. + (print_page): Rewrite conditional (that had side effects in second + conjunct) using nested if statements to make it clear that we do + indeed want those semantics. + +Tue Jan 19 13:35:24 1993 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) + + * Version 1.4. + + * system.h: Try BBSIZE if BSIZE isn't defined. + From Tony Robinson . + +Sat Dec 12 12:37:00 1992 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) + + * tail.c (tail_forever): Use an array of file descriptors + instead of forking processes. + (dump_remainder): Return number of bytes read. + (tail_file): Fill in the new array. + From Ian Lance Taylor. + +Fri Dec 11 17:18:16 1992 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) + + * system.h: Only define index, bcmp, etc. if not already defined. + +Tue Dec 8 10:31:14 1992 Jim Meyering (meyering@idefix.comco.com) + + * tr.c (is_char_class_member): Remove unreached return after abort. + +Sun Dec 6 22:34:52 1992 Jim Meyering (meyering@idefix.comco.com) + + * csplit, cut.c, expand.c, fold.c, head.c, join.c, od.c, pr.c, + sort.c, split.c, tail.c, tr.c, unexpand.c, uniq.c: Remove inclusion + of and definitions of is* ctype macros to system.h. + Change a few more uses of is* ctype macros to (protected) upper + case versions. + + * system.h: Add isascii-protected ctype IS* macros. + +Wed Dec 2 12:28:10 1992 Jim Meyering (meyering@idefix.comco.com) + + * all files using getopt.h: Convert static declarations of + struct option to use new macros from getopt.h: no_argument, + required_argument, and optional_argument. + +Tue Dec 01 10:57:24 1992 Jim Meyering (meyering@idefix.comco.com) + + * od.c, pr.c, sort.c: Make uses of ctype.h macros consistent. + + * tr.c (main): Close stdin and stdout and check return status. + +Tue Nov 24 09:26:08 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * system.h, csplit.c: Use HAVE_FCNTL_H and HAVE_STRING_H + instead of USG. + +Tue Nov 24 08:42:30 1992 Jim Meyering (meyering@idefix.comco.com) + + * tr.c: Define new macros ISPRINT, ISALNUM, ISXDIGIT, ... that + use isascii if it is defined. + (is_char_class_member, make_printable_char, make_printable_str, + non_neg_strtol): Use new macros instead of lower case ones + from . + + * od.c (print_ascii, dump_strings): Use ISDIGIT and ISPRINT + macros like pr.c. Suggested by David J. MacKenzie. + + * od.c (print_ascii, dump_strings): Check for isascii before isprint. + (dump_strings): Free malloc'd buffer before returning. + (skip): Return non-zero if an error occurred, zero otherwise. + Exit only if asked to skip beyond end of combined input. + (check_and_close): New function. + (skip, read_block, read_char): Call check_and_close when done + processing the file associated with in_stream. + (skip, read_block, read_char): Set have_read_stdin. + (main): Close stdin (if it was ever read) and check for errors + just before exiting. + (write_block, dump_strings, dump): Don't test return value from + functions that operate on streams. Rely on later ferror tests. + +Sat Nov 21 12:41:49 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * sort.c (main, usage): Add -T option. + +Thu Nov 19 14:33:40 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * tail.c (tail_forever, sigusr1, kill_kids): New functions to + do -f on multiple files. + (main): Call tail_forever. + From Ian Lance Taylor. + +Tue Nov 10 14:29:11 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * cut.c (cut_fields): Add cast. + + * od.c (decode_one_format): Remove '#' from pre_fmt_string; + many systems don't support it. + Conditionalize long double support on __STDC__, not __GNUC__. + From Ian Lance Taylor. + +Mon Nov 9 00:24:41 1992 Jim Meyering (meyering@idefix.comco.com) + + * sort.c (numcompare, keycompare): Add parentheses suggested + by gcc -Wall. Put braces around individual monthtab initializers. + + * cksum.c: Declare error. Make checksum table `const.' + + * pr.c: Remove comment and dcl of unused variable, `print_a_number'. + + * split.c (main): Add `default: abort();' to enumeration switch. + + * All files: Make all functions and extern variables static. + Make all longopts arrays const as well as static. + Make a couple statically initialized aggregates `const.' + +Sun Nov 8 19:46:59 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * od.c (main): Make old-style format options accumulate. + From Jim Meyering. + +Sat Nov 7 00:26:14 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * tr.c (look_up_char_class): Add cast. + + * nl.c (build_type_arg), csplit.c (extract_regexp), tac.c (main): + Add `const' to variable receiving value from re_compile_pattern. + + * wc.c (wc): If doing only -c, use st_size for regular files. + + * fold.c (fold_file): Was folding 1 column too early. + From Eric Backus . + + * memset.c: New file. + +Fri Nov 6 20:14:51 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * cksum.c: New file. + +Tue Oct 13 16:24:06 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * tac.c (tac_stdin): Handle SIGPIPE. + * sort.c (main): Handle SIGTERM. + + * od.c: New file. + + * system.h [USG || STDC_HEADERS]: Define bcmp. + +Sat Oct 3 20:41:24 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * sort.c (main): Handle SIGPIPE. From trq@dionysos.thphys.ox.ac.uk. + +Tue Sep 29 01:10:05 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * paste.c (main): Don't write on a string constant. + +Mon Aug 24 00:02:45 1992 Jim Meyering (meyering@churchy.gnu.ai.mit.edu) + + * tr.c: Minor cleanup. Replaced some assert(0) with abort(). + +Tue Jul 7 02:14:19 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * cmp.c, cmp.1: Move to diff distribution. + +Fri Jul 3 16:37:59 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * system.h: Change FOO_MISSING to HAVE_FOO. + +Wed May 13 20:05:41 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu) + + * pr.c (COLUMN): Add structure member to remember filename. + (main, init_fps, open_file, close_file): Use it. + + (close_file): Don't decrement cols_ready_to_print when closing + a file. From cdl@mpl.UCSD.EDU (Carl Lowenstein). + +Mon May 11 19:17:33 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu) + + * cmp.c: --show-chars -> --print-chars. + + * pr.c: Rename some variables. + +Sat May 9 18:39:47 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * system.h: Define DEV_BSIZE if not defined. + +Wed Apr 22 02:15:09 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu) + + * system.h, tac.c: SIGTYPE -> RETSIGTYPE. + +Fri Apr 17 10:42:23 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * sort.c (main): Don't stop processing args when we hit "-"; + treat it like a regular filename. + From ian@airs.com (Ian Lance Taylor). + + * pr.c (print_page): Fix off by one line count when ^L is in input. + From Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de). + +Mon Apr 6 20:52:29 1992 Jim Meyering (meyering@churchy.gnu.ai.mit.edu) + + * tr.c (validate): Change error message so it doesn't mention + actual name of --truncate-set1 option. From David MacKenzie. + +Sun Apr 5 14:22:42 1992 Jim Meyering (meyering@hal.gnu.ai.mit.edu) + + * tr.c (string2_extend, validate): Give an error message when + translating without --truncate-set1, with empty string2, and + with non-empty string1. "tr 1 ''" produced a failed assertion. + +Mon Mar 30 02:20:56 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * system.h: Change how ST_BLKSIZE is calculated to allow for + non-POSIX systems that don't define BSIZE in sys/param.h. + +Sat Mar 28 11:18:01 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * sum.c (main, bsd_sum_file): Don't print filename if BSD + algorithm is used and only one file was given. + +Wed Mar 25 11:34:41 1992 Jim Meyering (meyering@wombat.gnu.ai.mit.edu) + + * tr.c (get_spec_stats): Fix assertion to allow ranges like a-a + with starting character equal to ending character. This is + contrary to the POSIX spec, but what is already implemented + in find_closing_delim. + +Mon Mar 16 00:15:11 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * Version 1.3. + + * sort.c (numcompare, checkfp): Add parens to placate gcc2. + + * sort.c (mergefps): For -u, output the first, not last, of + the lines that compare equal. From Mike Haertel. + +Tue Mar 10 10:51:38 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * tr.c: Remove initial capitals and periods from error messages. + +Sun Mar 8 22:03:45 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * sum.c (main): Add -r option for SYSV compat. + +Thu Feb 27 22:26:25 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * sort.c (compare): If -s given, leave lines in their original order. + (main): Recognize -s. + (usage): Document -s. + From Mike Haertel. + +Tue Feb 18 20:29:45 1992 Randall Smith (randy at geech.gnu.ai.mit.edu) + + * sort.c (sort): Check for complete parsing of buffer into + lines before nixing temp files. + +Mon Feb 17 10:35:58 1992 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * sum.c (sysv_sum_file): Use %lu instead of %u to print a + long. Not that it matters for GNU . . . + + * tr.c (unquote, make_printable_str): Use \007 instead of ANSI \a. + (append_normal_char, append_range, append_char_class, + append_repeated_char, append_equiv_class, spec_init): + Initialize `next' field of new `struct List_element'. + From rommel@informatik.tu-muenchen.de (Kai-Uwe Rommel). + +Sat Feb 8 17:16:49 1992 David J. MacKenzie (djm at apple-gunkies.gnu.ai.mit.edu) + + * join.c (get_line): Renamed from getline to avoid GNU libc conflict. + +Sun Feb 2 21:22:01 1992 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * Version 1.2. + + * nl.c: Support multiple files and "-" for stdin. + (main): Check for read and write errors. + (nl_file): New function. + +Wed Jan 29 10:09:10 1992 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * tr.c (main): -t option was called -b in getopt spec. + (validate): Don't warn that set1 is longer than set2. + + * tr.c: Rename --sysv-string2-truncate to --truncate-string1. + +Fri Jan 17 16:29:05 1992 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * nl.c: New program from bin-src. + + * nl.c (main): Use a struct linebuffer for line_buf. + (process_file): Use readline instead of fgets, to preserve NULs. + (check_section): Use memcmp instead of strncmp. + (proc_text): Print line_buf with fwrite instead of printf. + + * nl.c (main): Usage message if too many args given. Check + for error in closing input file. Lengths of section delimiter + strings were 1 too large. Take separator_str into account in + length of print_no_line_fmt. + (build_print_fmt): Allocate space for print_fmt, in case + separator_str is long. + (proc_text): A blank line is one that contains nothing, not + even nonprinting characters. + +Fri Jan 17 01:04:22 1992 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * All programs: Document `--' instead of `+' to introduce + long-named options, in usage messages. + + * sum.c (bsd_sum_file): Renamed from sum_file. + (sysv_sum_file): New function. + (main): Recognize an option to select between the algorithms. + +Sun Jan 5 17:41:18 1992 Jim Meyering (meyering at churchy.gnu.ai.mit.edu) + + * pr.c (close_file, print_page): Fixed bug that had the command + yes |head |pr -t printing "yyyyyyyyyy". + * (print_page): Fixed bug that had pr -3 -a printing two too few + trailer lines per page. + * (main): Added restriction that -a and -m are incompatible. + Although the POSIX spec doesn't explicitly say they shouldn't + be used together, it says -a modifies the -column option and + that -column shouldn't be used with -m. + +Thu Jan 2 15:23:59 1992 David J. MacKenzie (djm at albert.gnu.ai.mit.edu) + + * nl.c: Include regex.h after, not before, sys/types.h. + +Thu Jan 2 12:18:10 1992 Tom Lord (lord at geech.gnu.ai.mit.edu) + + * sort.c (fillbuf) return bytes buffered instead of bytes read. + +Fri Dec 27 22:53:36 1991 Jim Kingdon (kingdon at geech.gnu.ai.mit.edu) + + * sort.c (LINEALLOC): New #define. + (struct lines): New field ``limit''. + (initlines): Set it from new arg ``limit''. + (sort, mergefps, checkfp): Pass new arg to initlines(). + (findlines): Don't realloc past lines->limit. + +Tue Dec 24 01:24:03 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * tac.c, sort.c, csplit.c, system.h: Change POSIX ifdefs to + HAVE_UNISTD_H and _POSIX_VERSION. + + * xwrite.c: Change POSIX ifdef to HAVE_UNISTD_H. + +Sat 14 Dec 1991 11:46:42 Jim Meyering (meyering at wombat) + + * tr.c: Fixed an inaccurate comment on posix_pedantic. + +Thu 12 Dec 1991 21:15:20 Jim Meyering (meyering at hal) + + * tr.c: Changed underscores to hyphens in long option name + "sysv_string2_truncate". + +Wed Dec 11 13:33:34 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * tac.c (main): Set obscure_syntax to tell re_search to + allocate memory for the group registers. + +Fri Dec 6 18:26:27 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * tac.c, sort.c, csplit.c [POSIX]: Use sigaction instead of + signal, which POSIX doesn't have. + * sort.c: Replace inthandler and huphandler with sighandler. + * csplit.c (main): Only handle signals if they were not being + ignored. + + * tr.c: POSIX_ME_HARDER -> POSIXLY_CORRECT. + +Wed Dec 4 00:47:47 1991 Jim Meyering (meyering at wombat) + + * tr.c (unquote): Reformat code so it doesn't go beyond column 80. + * tr.c (squeeze_filter): Comment a little on why it's better + to step through the input by two. + * tr.c (set_initialize): Write a comment describing the function. + * tr.c: Eliminated the variable `portability_warnings' and replaced + references to it by references to `!posix_pedantic'. One of the + uses of portability_warnings had been wrong. + +Tue Dec 3 14:03:35 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * tr.c: New program. + +Sun Dec 1 15:07:35 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * linebuffer.[ch] (freebuffer): New function (used by cron). + +Thu Oct 17 22:30:22 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * system.h, configure, Makefile.in: Don't include memory.h if + STDC_HEADERS, removing need for MEMORY_H_MISSING. + +Thu 17 Oct 1991 16:53:07 Jim Meyering (meyering at wombat) + + * pr.c (print_page): REALLY fixed `extra newline at EOF' problem. + Somehow, part of my patch didn't make it last time. + +Sat Oct 12 12:04:47 1991 David J. MacKenzie (djm at churchy.gnu.ai.mit.edu) + + * tail.c (pipe_lines, pipe_bytes): Initialize `first->next'. + + * cmp.c (cmp): Print EOF message to stderr, not stdout, for + POSIX 1003.2.11.2. + + * sort.c (xfwrite): fwrite never returns < 0, so check if + number written is number we asked to write. + (fillbuf, main): fread never returns < 0, so check ferror instead. + From Rainer Orth. + +Tue Oct 8 18:07:08 1991 Jim Meyering (meyering at churchy) + + * pr.c (print_page): Really fixed `extra newline at EOF' problem. + * (store_columns): Fixed bug that caused `pr -b -2' to coredump + on files of certain lengths. + +Fri Oct 4 22:30:25 1991 Jim Meyering (meyering at churchy) + + * pr.c (print_page): Fixed to not add single spurious newline + at EOF when using -t. + +Wed Oct 2 01:02:05 1991 David J. MacKenzie (djm at apple-gunkies) + + * pr.c (print_page): Don't pad the page if -t given. + + * csplit.c (load_buffer), sort.c (mergefps): Use bcopy, not memcpy. + +Thu Sep 26 12:35:00 1991 David J. MacKenzie (djm at churchy.gnu.ai.mit.edu) + + * Version 1.1. + + * configure, system.h: Include memory.h if it works. + + * split.c: Allow `b' unit as well as `k' and `m'. + + * head.c, tail.c: Replace -b +blocks option with specifying + units (b, k, or m) after the number. + (parse_unit): New function. + + * fold.c (main): Check that -w arg is a number. + + * cut.c: +delimiter takes an arg. + +Mon Sep 16 14:52:38 1991 David J. MacKenzie (djm at churchy.gnu.ai.mit.edu) + + * pr.c (close_file): Don't close an already closed file. + +Thu Sep 12 00:14:43 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * memchr.c: New file. + * configure: Check if it's needed. + + * csplit.c, gcsplit.1: New program. + + * pr.c (cleanup): Only free buffers if they were allocated. + + * sort.c [!USG && !STDC_HEADERS]: Declare memchr. + +Wed Sep 11 20:54:16 1991 Jim Meyering (meyering at churchy) + + * pr.c: The following 3 bugs appeared (at least) when printing + a single file with the options `-3 -f'. + * (print_white_space): Single spaces were being replaced + with tabs. + * (print_page): Some lines were getting too much white space + at the beginning because spaces_not_printed wasn't being reset + to 0. + * (read_line): The single space between a truncated column + on its left and the column on its right was omitted. Fixed + so that previous value of input_position is restored before + returning FALSE. + +Sat Sep 7 03:22:18 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * configure: Only remove /etc from PATH when it's not part of + a larger name. + +Wed Sep 4 17:09:24 1991 David J. MacKenzie (djm at apple-gunkies) + + * linebuffer.c (readline): Fix incorrect recalculation of `end'. + + * head.c, tail.c: Replace `mode' variables and bitmasks with + separate variables for each option. + +Mon Sep 2 04:00:37 1991 David J. MacKenzie (djm at apple-gunkies) + + * wc.c: New program. + +Sun Sep 1 01:18:38 1991 David J. MacKenzie (djm at apple-gunkies) + + * fold.c (fold_file): Read in an int, not a char, for EOF + comparison. + + * configure: Check whether st_blksize is missing. + + * tac.c (save_stdin): Put copy of pipe input in TMPDIR if + defined, instead of /tmp. + +Thu Aug 29 14:48:15 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * xwrite.c [POSIX]: unistd.h might require sys/types.h. + +Wed Aug 28 11:57:39 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * paste.c (main): Consider -d "" to be like -d "\0", + for POSIX (if I read it right). + + * sort.c, join.c: New programs. + + * cut.c (set_field): Allow blanks as well as commas to + separate numbers in ranges. + +Sun Aug 25 19:57:40 1991 Jim Meyering (meyering at apple-gunkies) + + * pr.c: Failure to open an input file is no longer a fatal error. + A message is printed for each failed open. When printing + in parallel, each failed open results in one fewer output column. + Added POSIX -r option to suppress the message. + * pr.c: Added variables: failed_opens, ignore_failed_opens. + These changes were based in part on work by David MacKenzie. + +Sat Aug 24 15:27:39 1991 Jim Meyering (meyering at pogo) + + * pr.c: Complain if user gives both -m and -[0-9]+ options. + +Wed Aug 21 22:04:57 1991 David J. MacKenzie (djm at apple-gunkies) + + * Version 1.0. + +Mon Aug 19 00:16:51 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * expand.c: Rename some variables. + (expand): Don't access value off end of array. + * unexpand.c: Rename some variables. + (unexpand): Don't access value off end of array. + Instead of copying tabs verbatim and flushing pending spaces + when one is reached, count them as the proper number of + pending spaces. Instead of changing tabs to single spaces if + the tabstop list is exhausted, print the rest of the line + unchanged (for POSIX). + +Sat Aug 17 01:49:41 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * cut.c (cut_file), paste.c (paste_parallel, paste_serial): + Clear EOF and error conditions on stdin so it can be reused. + + * expand.c, unexpand.c (parse_tabstops): Allow blanks as well + as commas to separate tabstops, for POSIX. + * expand.c (expand), unexpand.c (unexpand): Don't line-buffer + the output; send it directly to stdout. + * unexpand.c (main): Make -t stupidly imply -a for POSIX. + (unexpand): If a tab stop list was given and we move past its end, + copy the rest of the line verbatim. + + * split.c (convint): New function to allow 'm' and 'k' after + byte counts. + (main): Use it. Change -c option to -b for POSIX. + +Fri Aug 9 02:47:02 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * pr.c: Protect isdigit with isascii, if required. + +Tue Aug 6 21:42:25 1991 David J. MacKenzie (djm at wheat-chex) + + Most of the following is from Paul Eggert: + * cat.c (main): If stdin is read, check close at end. + * cmp.c (main): Check for stdin being closed. + Check for close errors on stdin and stdout. + (cmp): Return a value instead of exiting. + * cut.c (cut_file): New function, from code in main. + Check for read errors. + (main): Check for close errors. + * expand.c, unexpand.c (main): Check for close errors. + (next_file): Go to next file if one can't be opened. + Check for close errors. + * head.c (main), tail.c (main): If stdin was read, check for + close errors. + * head.c (head_file), tail.c (tail_file): Check for close errors. + * paste.c (main, paste_parallel, paste_serial), tac.c (main): + Check for close errors. Close stdin if it was read. + * split.c (main): Check for close errors. + + * configure, Makefile.in's: Support +srcdir option. + Make config.status. Fix up clean targets. + +Wed Jul 31 01:32:59 1991 David J. MacKenzie (djm at hal) + + * linebuffer.h (struct linebuffer): Add a field to indicate + the number of valid chars in the line. + * linebuffer.c (initbuffer, readline): Fill it in. + * uniq.c, comm.c: Use it. + + * pr.c (main): Check stdin and stdout fclose for errors. + (init_parameters): If there's no room for header and footer, + omit them rather than dying (for POSIX). + (init_header): Take a file descriptor as additional arg. + (init_fps): Change callers. Note when stdin is read. + (open_file): For filename "-" use stdin. + (close_file): Don't close stdin. Check close for errors. + (print_char, char_to_clump): Use isprint instead of explicit + comparisons. + + * memcmp.c: New file (needed for comm). + * bcopy.c: New file (needed for fold). + * system.h: Don't define bcopy as memcpy. + * configure: Check for bcopy and memcmp. + + * uniq.c (main): Use "-" instead of NULL to mean stdin or + stdout. + (check_file): Use "-" instead of NULL to mean stdin or stdout. + Check readline return instead of for NUL character to + detect eof. + Check fclose for errors. + (find_field): Use linebuffer length, not NULs, to detect end + of line. + (different): New function, replaces compare. Uses memcmp + instead of strncmp. + (writeline): Use fwrite instead of fputs so NULs are preserved. + + * comm.c (compare_files): Return an error indication. + Don't take a filename of NULL to mean stdin. + Use memcmp instead of strcmp to allow for NULs. + Check fclose for errors. + (writeline): Use fwrite instead of fputs so NULs are preserved. + + * sum.c (sum_file): Take an arg indicating whether to print + the filename, and don't take NULL meaning stdin. Set a flag + when we read stdin. Check fclose return for errors. + (main): If stdin was read, check fclose return for errors. + Use filename of "-" if no args given. + +Thu Jul 25 15:17:10 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * fold.c: Rewritten from scratch for POSIX. + +Wed Jul 24 01:55:41 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * split.c (line_bytes_split): Use xmalloc instead of alloca. + * system.h: Don't declare alloca. + + * tac.c, tail.c: Use SEEK_ instead of L_ for lseek. + * system.h: Define SEEK_ macros if not defined. + + * pr.c: Rename variable `truncate' to avoid library function conflict. + +Tue Jul 23 13:21:48 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * linebuffer.c, linebuffer.h: New files. + * comm.c, uniq.c (initbuffer, readline): Functions + removed (use versions in linebuffer.c). + +Mon Jul 22 13:23:53 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * sum.c (sumfile): Always print 5 digits for second number, too. + Interpret "-" to mean stdin. + +Sat Jul 20 14:24:40 1991 David J. MacKenzie (djm at bleen) + + * uniq.c: Use isblank instead of isspace, to support POSIX.2. + * comm.c, pr.c, uniq.c (concat, fatal, error, + pfatal_with_name, xmalloc, xrealloc): Functions removed. + +Sat Jul 13 02:04:53 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) + + * nl.c: Add long-named options. Doc fixes. + +Sat Jul 6 02:19:09 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) + + * expand.c, unexpand.c [STDC_HEADERS]: Include stdlib.h. + + * xwrite.c [POSIX]: Include unistd.h. + [STDC_HEADERS]: Don't declare errno. + +Sun Jun 30 23:35:16 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) + + * uniq.c: Add long-named options. Remove marginally useful -z + option (zero padded repeat counts). + +Thu Jun 27 16:31:45 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) + + * tail.c (tail_file), tac.c (save_stdin, tac_file), split.c + (cwrite), head.c (head_file), cat.c (main): Check close return + value for delayed error report due to NFS. + +Tue Jun 11 00:12:15 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) + + * cat.c: Replace "uchar" with "unsigned char", to avoid + problems with various systems' typedefs. + +Thu Jun 6 12:54:26 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu) + + * cat.c (cat): Interpret ENOTTY return from FIONREAD ioctl to mean + operation is unsupported, for HP-UX 7.0. + +Sun Apr 14 21:49:17 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu) + + * sum.c: Always print five digits for first number. + +Fri Mar 15 16:16:54 1991 David J. MacKenzie (djm at geech.ai.mit.edu) + + * cat.c, cmp.c: Don't use fileno(); not needed. + +Thu Jan 10 02:16:55 1991 David J. MacKenzie (djm at albert.ai.mit.edu) + + * tac.c, tail.c: Change _POSIX_SOURCE to POSIX. + +Thu Dec 27 00:06:45 1990 David J. MacKenzie (djm at egypt) + + * cut.c (cut_file_bytes, cut_file_fields): Make inbufp and + outbufp global. + (enlarge_line): Adjust inbufp and outbufp. + +Sun Sep 9 16:54:19 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cat.c: Declare free returning void, not int, so it + doesn't bomb on Xenix. + +Mon Sep 3 22:23:57 1990 David J. MacKenzie (djm at coke) + + * tac.c: Print error messages before calling cleanup, not after. + +Tue Aug 28 18:05:24 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * tac.c (cleanup): Return SIGTYPE, not int. + +Tue Aug 7 12:51:18 1990 David J. MacKenzie (djm at apple-gunkies) + + * cut.c (main, usage): Add -b and -n options for POSIX. + (set_fields): Don't allow SPC or TAB as number separators. + + * paste.c (paste_parallel): If open of any file fails, quit + (for POSIX). + +Mon Aug 6 22:14:13 1990 David J. MacKenzie (djm at apple-gunkies) + + * pr.c: Add POSIX -F option (same as -f). + + * uniq.c (check_file): Allow '-' to mean stdin or stdout. + +Mon Aug 6 14:43:30 1990 David J. MacKenzie (djm at pogo.ai.mit.edu) + + * head.c, tail.c: Change `chars' to `bytes' globally. + (main, usage): Use POSIX.2 draft 10 option syntax. + +Sun Aug 5 11:51:12 1990 David J. MacKenzie (djm at pogo.ai.mit.edu) + + * cat.c (main): Don't delay error messages, so they appear + where expected. + (main, simple_cat, cat): Make errors in input files nonfatal. + +Sat Aug 4 10:11:30 1990 David J. MacKenzie (djm at pogo.ai.mit.edu) + + * cat.c: Remove -c option added for POSIX draft 9, since POSIX + draft 10 removed it. + + * tac.c (tac_stdin): Use fstat instead of lseek to determine + whether stdin is seekable, because lseek silently fails on + some special files, like tty's. + tail.c (tail_chars, tail_lines): Use fstat instead of lseek; + don't turn off -f for non-regular files (assume the user knows + what he's doing; it might work for fifo's and sockets). + + * paste.c (main): If no files given, use stdin. + Don't let collapse_escapes write on string constant (delim default). + (paste_parallel): Don't close stdin. + + * cut.c (main): Use standard input for filename of "-". + + * comm.c (compare_files): Allow '-' to mean stdin. + +Fri Aug 3 13:38:28 1990 David J. MacKenzie (djm at pogo.ai.mit.edu) + + * cut.c (enlarge_line): Take an arg giving the required amount + of space. Change callers. + (main): Don't allow -t'' without -f. + Make `delim' unsigned to fix sign extension problem in comparison. + +Tue Jul 17 12:36:11 EDT 1990 Jay Fenlason (hack@ai.mit.edu) + + * pr.c Deleted excess whitespace from ends of lines. + Modified to work with current version of getopt, which + returns 1 instead of 0 for non-options. + Reversed the meaning of the -f option, to be compatable + with real pr. + +Sun Jul 8 00:39:31 1990 David J. MacKenzie (djm at apple-gunkies) + + * cmp.c (main, usage): Rename -L option to -c and don't have + it imply -l. + (printc): Take an arg to specify number of chars to pad to, + for column alignment. + (cmp): Respect flag_print_chars in default output format. + Align columns for cmp -cl. + +Sat Jul 7 17:23:30 1990 David J. MacKenzie (djm at apple-gunkies) + + * cmp.c: For +show-chars, have getopt return 'L' so + `flag_print_chars' gets set. + +Fri Jun 29 01:04:19 1990 David J. MacKenzie (djm at apple-gunkies) + + * tac.c (main): Initialize fastmap and translate fields of + regex before compiling it. + +Fri Jun 22 00:38:20 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * tac.c: Change +regexp to +regex for consistency with GNU find. + +Wed Jun 20 01:46:09 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cat.c (cat): If FIONREAD is available, only use it if it is + supported by the filesystem that the file is on. + +Sun Jun 3 20:26:19 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cat.c (main): Add a variable to control whether the check + for input file == output file is made, because no values of + st_dev and st_ino should be assumed to be available for this + purpose. Only do the check for regular files. + + * tac.c: Use bcopy instead of memcpy. + +Thu May 31 00:55:36 1990 David J. MacKenzie (djm at apple-gunkies) + + * head.c: Use longs instead of ints for file offsets, for 16 + bit machines. + +Tue May 22 00:56:51 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cmp.c: Change some ints to longs for 16 bit machines. + (bcmp_cnt): Make char-pointer counting slightly simpler. + +Sat May 12 01:16:42 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cat.c (main): Allow input file to be output file for devices + (ttys, etc.). Check whether input file is output file when + reading standard input. Print any error messages for standard + input. + + * cmp.c (bcmp_cnt): Handle int comparisons correctly on 16 bit + machines as well as 32 bit ones. + * cmp.c, tail.c: Use longs instead of ints for file offsets. + +Fri May 11 02:11:03 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cmp.c: Fix some exit statuses for POSIX. + +Tue May 8 03:41:42 1990 David J. MacKenzie (djm at abyss) + + * tac.c: Use regular expressions as the record boundaries. + Give better error messages. + Reformat code and make it more readable. + (main): Use getopt_long to parse options. + (tac_stdin): Do not make a temporary file if standard input + is a file. + (tac_file): New function. + (tac): Take an open file desc as an arg. + (output): Rewrite to use its own efficient buffering. + (xmalloc, xrealloc, xwrite): New functions. + +Sun Apr 8 20:33:20 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * head.c, tail.c: Use `error' instead of `fatal_perror' and + `nonfatal_perror'. Remove some unnecessary info from messages. + +Wed Mar 21 09:30:18 1990 David J. MacKenzie (djm at pogo.ai.mit.edu) + + * comm.c (main): Pass the list of files to compare_files as a + char ** instead of a char *. + (compare_files): Make arg a char **. + + * uniq.c: Declare some functions as void. + Change global vars `countmode' and `mode' from ints to enums. + (main): Use getopt to parse options and support POSIX options. + Don't use integer_arg to parse numbers, since `-#' can't be + parsed that way using getopt. + (find_field): Use isspace for finding fields boundaries. + +Tue Mar 20 14:28:25 1990 David J. MacKenzie (djm at pogo.ai.mit.edu) + + * comm.c (main): Call usage if given bad option or wrong + number of args. Exit with 0 status normally. + (usage): New function. + Declare some other functions as void. + +Wed Mar 14 10:48:40 1990 David J. MacKenzie (djm at rice-chex) + + * cmp.c (main, cmp, usage): Replace -q +quick option with -L + +show-chars option to add ASCII representation of bytes to -l format. + +Tue Mar 13 00:50:14 1990 David J. MacKenzie (djm at rice-chex) + + * cmp.c (cmp): Change EOF message for POSIX compatibility. + For -l format, clear bits > FF. + +Mon Mar 5 17:21:00 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * tail.c: Move global `errors' into main instead of having + nonfatal_perror set it. + (tail, tail_chars, tail_file, tail_lines, pipe_chars, pipe_lines): + Return an error status. + (file_lines, start_chars, start_lines): Reverse the meaning of + the return value. + (tail_lines, tail_chars): Account for that reversal. + +Mon Mar 5 00:34:36 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * head.c: Move global `errors' into main and have the various + functions return an error status instead of setting it in + nonfatal_perror. + +Sat Mar 3 11:27:27 1990 Torbj|rn Granlund (tege at echnaton) + + * cmp.c (cmp): Call function bcmp_cnt for flag == 0 (i.e. no + options specified), to compare the two blocks and count + newlines simultaneously. + * cmp.c New function: bcmp_cnt. + + * cmp.c (main): Test if output is redirected to /dev/null, and + assume `-s' if this is so. + +Tue Feb 20 17:09:19 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cat.c: Change `argbad' from a char to a short, so it will + work on machines with unsigned chars. + +Sat Feb 10 02:16:40 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * cmp.c (cmp): Rename `r' to `first_diff', and `x' to `smaller'. + Remove unneccessary variable `c1'. If -l was given, increase + `char_number' by the number of bytes read, after producing output, + rather than by the offset of the first differing bytes, before + producing output. + Replace if-else-if constructions with case statements for clarity. + (bcmp2): Rename `n' to `nread'. + +Wed Dec 20 01:32:06 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) + + * nl.c (proc_text): Use re_search instead of re_match. + +Tue Dec 19 01:26:34 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) + + * nl.c: Indent. Un-nest statements. Use GNU regexp functions + instead of System V ones. Move function declarations together. + (quit): Remove useless function. + (program_name): New variable for error messages. + (main): Use perror in error message. + (xmalloc): New function to replace myalloc. + (myalloc): Function removed. + Global: use program_name and xmalloc. + +Sun Dec 17 00:36:36 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) + + * uniq.c: Declare some functions. + (main): Initialize infile and outfile. Call usage if given + invalid args. Normally exit with 0 status instead of garbage. + (usage): New function to print usage message and exit. + (check_file): Remove unused variable. + (readline): Compare against EOF, not < 0. + (xmalloc, xrealloc): Return char *, not int. + Ok to return 0 if 0 bytes requested. + (lb1, lb2): Remove unused global vars. + (concat): Remove unused function. + +Sat Dec 16 15:15:50 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) + + * comm.c: Remove unused global variables lb1, lb2. + (main): Remove unneeded variable. + (compare_files): Remove unused arg. + (readline): un-nest assignment. Test against EOF instead of < 0. + (error): Print to stderr, not stdout. + (xmalloc, xrealloc): Return char * instead of int. + Returning 0 is ok if 0 bytes requested (ANSI C). + + +Local Variables: +version-control: never +End: diff --git a/contrib/gnu-sort/INSTALL b/contrib/gnu-sort/INSTALL new file mode 100644 index 0000000..62ea076 --- /dev/null +++ b/contrib/gnu-sort/INSTALL @@ -0,0 +1,231 @@ +Copyright 1994, 1995, 1996, 1999, 2000, 2001 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 host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it cannot guess the host 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 host 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'. In this case, you should also specify the +build platform with `--build=TYPE', because, in this case, it may not +be possible to guess the build platform (it sometimes involves +compiling and running simple test programs, and this can't be done if +the compiler is a cross compiler). + +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/contrib/gnu-sort/NEWS b/contrib/gnu-sort/NEWS new file mode 100644 index 0000000..fab6754 --- /dev/null +++ b/contrib/gnu-sort/NEWS @@ -0,0 +1,452 @@ +Changes in release 2.1 +[2.0.21] +* split accepts new option -a or --suffix-length. +* split no longer generates longer suffixes than requested; instead, it reports + an error when suffixes are exhausted. POSIX requires this behavior. +* The _POSIX2_VERSION environment variable lets you select which version + of POSIX the utilities should conform to. Its default value is system + dependent. Set _POSIX2_VERSION=199209 to cause the utilities to support + obsolete usage like "sort +1". +* The following obsolete usages are no longer supported when conforming + to POSIX 1003.1-2001, which prohibits most digit-string options: + expand -N (instead, use expand -t N) + head -N (instead, use head -c N or head -n N) + fold -N (instead, use fold -w N) + split -N (instead, use split -l N) + tail -N (instead, use tail -c N or tail -n N) + unexpand -N (instead, use unexpand --first-only -t N) + uniq -N (instead, use uniq -f N) + The following obsolete usages (options without arguments) are no + longer supported when conforming to POSIX 1003.1-2001, which + prohibits most options with optional arguments: + od -s (instead, use od --strings) + od -w (instead, use od --width) + pr -S (instead, use pr --sep-string) +[2.0.20] +* tr no longer gets failed a assertion for [==] or [::] +* The following obsolete usages are no longer supported when conforming + to POSIX 1003.1-2001, which prohibits most options with leading "+": + sort +POS1 -POS2 (instead, use sort -k) + tail +N (instead, use tail -c +N or tail -n +N) + uniq +N (instead, use uniq -s N) +* Warnings are issued for obsolete usages on older hosts, + unless POSIXLY_CORRECT is set in the environment. +* sort -m no longer segfaults when given an empty file +* sort -S now accepts 'K' as a synonym for 'k'. +* wc recognizes all locale-defined white-space characters, not just those + in the "C" locale. +[2.0.19] +* portability tweak to make lib/regex.c compile +* split translatable strings only in the middle of sentences +[2.0.18] +* sort could segfault on systems without a working mkstemp function and + with a gettimeofday function that clobbers the static buffer that + localtime uses for it's return value -- introduced in 2.0.17 +[2.0.17] +* csplit no longer gets a failed assertion for this: + printf 'a\n\n'|csplit - '/^$/' 2 +* sort detects physical memory attributes more portably +* tail no longer gets a segfault on Linux's /proc/ksyms +* sum -s produces the proper 16-bit checksum for large files + (this fixes a bug that was introduced in 2.0f) +* uniq is now about 3 times faster than the version from 2.0 on Linux systems; + the code uses lock-avoiding variants of common I/O functions +[2.0.16] +* tail -F no longer segfaults +[2.0.15] +* `head -c N' and `od -N N' now read no more than N bytes of input +* tail accepts new option: -F, equivalent to `--follow=name --retry', + for compatibility with the FreeBSD and NetBSD versions of tail. +* fmt no longer segfaults when using a maximum line width larger than 32767 +* uniq's --all-repeated option has new modes to delimit groups + of duplicate lines: --all-repeated={precede,separate,none(default)} +[2.0.14] +* sort now accepts long options like "--reverse" and "--". +* sort now checks option syntax as POSIX requires, except that (as usual + for GNU) options can follow file names unless POSIXLY_CORRECT is set. + For example, invalid positional combinations like "sort +1 -r -2" are + now rejected as per POSIX. +* The next POSIX standard will require that obsolescent 'sort' + positional options like +1 be treated as file names, not options. + Please use 'sort -k' instead. +[2.0.13] +* pr accepts new -D or --date option, to specify date format. +* The following changes are required by POSIX: + - If POSIXLY_CORRECT is set, dates in pr headers now look something like + 'Dec 4 23:59 2001', with the exact appearance affected by LC_TIME. + - pr -h now affects only the center header string, not the entire header. + - pr no longer truncates headers. +* Spacing in pr headers has been adjusted slightly. +* `fmt --prefix=S' now works when S contains a byte with the high bit set +[2.0.12] +* sort has improved performance when using very little main memory +* sort has improved memory management +* sort is no longer susceptible to certain denial of service attacks +* sort no longer suffers from a race condition whereby an interrupt received + during cleanup could cause it to fail to remove temporary files. + This problem could arise only on hosts without sigaction. +[2.0.11] +* sort accepts new -S SIZE option, to specify main-memory usage. +[2.0.10] +* od is faster and more portable than it was in 2.0.9 +* tail avoids an uninitialized memory reference +[2.0.9] +* od now prints valid addresses for offsets of 2^32 and larger, and allows + the byte offset (-j) and byte count (-N) arguments to be 2^32 and larger. +* tail now works with line and byte counts of 2^32 and larger, on systems + with large file support +* join now works with an 8-bit delimiter +* fix a compilation failure on some Solaris systems with wc.c +[2.0.8] +* od now supports 8-byte integers, assuming they're printable with e.g., %lld +* new program: sha1sum +* wc accepts new -m option: count (potentially multi-byte) characters +* wc's `--chars' option is now equivalent to -m, not --bytes as it used to be +* `cat -n' works properly when processing 2^31 or more lines +[2.0g] +* sort's --help output now warns that it is locale-aware +* tail: fix a buffer underrun error that occurred on an empty pipe, + also thanks to bounded pointers +* pr: fix a bounds violation found by Greg McGary's bounded-pointers-enabled gcc + It could have caused (with low probability) the columns on the last page of + output *not* to be `balanced' when they should have been. +* sort: if the -T tmpdir option is given multiple times, all the given + directories are used; this can improve performance for huge sort/merges. +[2.0f] +* all programs fail when printing --help or --version output to a full device +* cut no longer gets a segfault under some circumstances +* unexpand accepts new option: --first-only +[2.0e] +* `tail -f directory' no longer gets a failed assertion +* sort: big performance improvement when sorting many small files; + from Charles Randall +* configure and portability changes in m4/ and lib/ +[2.0d] +* preliminary sort performance improvements +* tsort now works more like the traditional UNIX tsort. Before it would + exit when it found a loop. Now it continues and outputs all items. +* unexpand no longer infloops on certain sequences of white space +* unified lib/: now that directory and most of the configuration framework + is common between fileutils, textutils, and sh-utils +[2.0c] +* include lib/nanosleep.h. +[2.0b] +* portability tweaks for error.c vs. systems with deficient strerror_r +[2.0a] +* `tail --follow=name' no longer gets a failed assertion for a + dev,inode-reusing race condition +* sort and comm no longer consider newlines to be part of the line, + as this requirement will likely be removed from POSIX.2. + This undoes some changes made for textutils 1.22m and 1.22n. +* tail's (short only) -f option no longer accepts an optional argument, + so e.g., `tail -fn 2 file' works again. +* tail no longer refuses to operate on certain types of files +* fixed bug in tsort's handling of cycles +Changes in release 2.0 +[1.22q] +* HPUX portability fix: md5sum would dump core due to use of libc's getline +[1.22p] +* portability fixes from Paul Eggert based largely on tar-1.13 reports +* `tail --pid=PID' now works even when PID belongs to some other user +[1.22o] +* tail accepts new option: --pid=PID +[1.22n] +* tail accepts the following new options (some of which were added in 1.22g): + --retry + --follow[={name|descriptor}] + --max-unchanged-stats=N + --max-consecutive-size-changes=N + --sleep-interval=S +* wc uses the POSIX-mandated output format when POSIXLY_CORRECT is set +* To maintain compatibility with sort, comm and join now obey the LC_COLLATE + locale, and comm now considers newlines to be part of the lines. +* use lib/memchr.c only if it's not provided by the system -- this means + that on systems with a fast library memchr function you may notice an + improvement. If you use a system with a buggy or signifcantly slower + memchr, please report it. +[1.22m] +* sort now considers newlines to be part of the line, as required by POSIX.2. + E.g. a line starting with a tab now sorts before an empty line, + since tab precedes newline in the ASCII collating sequence. +* sort handles NUL bytes correctly when configured/compiled with --enable-nls +* fix typos in my version of AC_SEARCH_LIBS. +* fix dates on config files so builders don't need autoconf/automake +[1.22l] +* sort no longer autodetects the locale of numbers and months, + as that conflicts with POSIX.2 +* `join -tC' now works when input contains trailing spaces +* portability tweaks for Irix's cc +[1.22k] +* `sort -n' works with negative numbers when configured/compiled + with --enable-nls +* head accepts byte and line counts of type uintmax_t (so up to 2^64 - 1) +[1.22j] +* tail: fix bug introduced in 1.22i +[1.22i] +* tail now terminates in `yes > k & sleep 1; tail -2c k' +* `tail -f' now ensures that stdout is unbuffered +* fix a bug in cut to allow use of 8-bit delimiters +* pr accepts POSIX compliant options -s and -w, + the new capital letter options -J, -S and _W turn off the + unexpected interferences of the small letter options -s and -w + if used together with the column options. +* pr output has been adapted to other UNIXes in some cases. +[1.22h] +* portability tweaks +* Window/NT/DOS support +[1.22g] +* uniq accepts new option: --all-repeated (-D). +* Windows/DOS portability fixes +* new program: tsort +* tail has several new options +* md5sum can handle file names with embedded backslash characters +* pr accepts long option names (see `pr --help') +* new program: ptx (moved to this package from being its own distribution) +[1.22f] +* cut accepts new --output-delimiter=STR option +* `sort -o no-such-file no-such-file' now fails, as it should +* fix pr bug: pr -td didn't double space +* fix tac bug when using -b, -r, and -s SEPARATOR +* fix sort bug whereby using key-local `d' option would cause following + key specs to be ignored when any two keys (in the `d'-modified test) + compared equal. +[1.22e] +* remove maintainer mode +[1.22d] +* wc accepts new option: --max-line-length (-L) +* sort can sort according to your locale if your C library supports that +[1.22c] +[1.22b] +* od supports a new trailing `z' character in a type specification: + $ od -tx1z . + 0000000 be ef c6 0f fd f9 d7 e0 ec cb f3 c6 00 db e8 00 >................< + 0000020 00 00 d2 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< + 0000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< + * + 0000600 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 cc >..............5.< + 0000620 05 63 76 74 2e 6f 00 00 29 ac 08 70 72 6f 6a 65 >.cvt.o..)..proje< + 0000640 63 74 73 00 00 00 18 9a 05 63 76 74 2e 63 00 00 >cts......cvt.c..< + 0000660 18 d9 03 52 43 53 00 00 18 c0 05 78 2e 64 61 74 >...RCS.....x.dat< + +[1.22a] +* sort -c reports both the number and the contents of the first out-of-order + line, in addition to the file name. +* `head -c 4096m' is no longer treated just like `head -c 0' + now it gets a diagnostic about 4096m being too large. +* pr: For compatibility (also more POSIX compliant): Include default + separator `TAB' when merging lines of full length. +* When POSIXLY_CORRECT is not set, tail -N now accepts more than one file + argument, to be consistent with the way head -N works. If POSIXLY_CORRECT + is set, using two or more file arguments with the obsolescent form (-N) + evokes an error. To avoid the warning or failure, use the POSIX -n N option + or the GNU --lines=N option. + +Changes in release 1.22 +[1.21a] +* Fix a bug in tail when invoked with an argument like `+NUMBERc' +* Add test suite for tail + +Changes in release 1.21 +* Using --program-prefix no longer applies the prefix twice + +Changes in release 1.20 +* fix pr: -l now uses total number of lines per page also with -f +* fix pr: use left-hand-side truncation of header string to avoid line + overflow +* fix pr: it now accepts `form feeds set in input files', also with -m + and multiple form feeds at different pages in each file +* pr now accepts: -h "", print a blank line header +* pr: when skipping pages (+FIRST_PAGE option) line counting (-n option) + starts with 1st line of input file (not of 1st page printed) by default +* pr accepts new option: -N, start printing with an optional line number +* pr -t retains `form feeds set in input files' (`don't destroy page layout') +* pr accepts new option: -T, equivalent to -t, but eliminate also form feeds + (`clear file') +* pr accepts the extension: +FIRST_PAGE[:LAST_PAGE] +* pr -w and -s option disentangled (`use a separator' no longer destroys + column alignment) +* pr accepts new option: -j, merge lines of full length +* pr accepts the extension: -s[STRING], use separator string instead of + character only +* pr -b is no longer an independent option, balancing is always used + with -COLUMN (a requirement of unrestricted use of form feeds) +* pr accepts new option: --test, to run the pr tests with a constant + header string +* join passes all of its tests on Alpha OSF 4.0. +* sort no longer improperly ignores blanks in determining starting and ending + positions for keys with explicit character offsets +* fix bug in csplit with regexp and negative offset that led to infinite loop + Changes in test release 1.19q +* fix bug in sort -c that sometimes resulted in a segfault + Changes in test release 1.19p +* md5sum's --string option is being deprecated and is no longer documented. + It is still accepted, but will be removed altogether in 1.22. +* tr '[:lower:]' '[:upper:]' no longer fails when LC_CTYPE is set to + iso_8859_1 on Solaris -- or any other character set with differing + numbers of uppercase and lowercase characters +* split and tail diagnose unrecognized multiplier suffixes, in e.g., + `split --bytes=1M' (should be `-b 1m' or `--bytes=1m') +* fix bug in md5sum's handling of partial reads +* fix bug in treatment by sort -f of bytes with high-bit set +* update configuration system to use automake's aclocal program +* configure performs sanity check on CC and CFLAGS to avoid a misleading + failure that suggested cross-compiling was the cause +* distribute test suites for cut, join, sort, and tr +* unexpand no longer gets in endless loop +* when verifying checksums, md5sum uses the binary mode flag from the + input stream rather than the one from the command line + +Changes in release 1.19 +* md5sum can verify digests of files with names containing newline characters +* update from gettext-0.10.20. + +Changes in release 1.18 +* when building sort, link with -lm on systems that use the replacement strtod +* update from gettext-0.10.17. + +Changes in release 1.17 +* include texinfo.tex in the distribution + +Changes in release 1.16 +* sort is compatible with Unix sort when a key-end spec refers to the N'th + character in a field that has fewer than N characters +* tail with old-style options like -20k and +31m operates on units of bytes, + as the --help usage message says. Before, it used units of lines. + +Changes in release 1.15 +* od gives better diagnostics for invalid format specs +* uses automake-generated Makefile templates +* configure takes a new option: --enable-maintainer-mode +* fix a bug in fmt when prefix has trailing white space +* internationalized diagnostic messages +* fix a couple bugs in tr involving use of -c and/or -d flags -- see ChangeLog +* diagnose some improper or questionable invocations of csplit +* properly handle `echo |csplit - 1 1', rather than aborting +* fix join: without -t it now ignores leading blanks +* sort accepts new option: -z for NUL terminated records +* join accepts new option: --ignore-case, -i +* uniq accepts new option: --ignore-case, -i + +User-visible changes in release 1.14 +* sort -i and sort -d properly order strings containing ignored characters +* nl: rename misleading --first-page=N option to --starting-line-number=N. +* sort diagnoses invalid arguments to -k, then fails +* sort -n properly orders invalid integers with respect to valid integers +* sorting works with character offsets larger than corresponding field width +* sort's -b option and `b' modifier work +* sort -k2,2 works. +* csplit detects integer overflow when converting command line arguments +* sort accepts new option/flag, -g, for sorting numbers in scientific notation +* join accepts POSIX `-o 0' field specifier. +* tr 'a[b*512]' '[a*]' < /dev/null terminates +* tr '[:*3][:digit:]' 'a-m' and tr 'a[=*2][=c=]' 'xyyz' no longer fail +* special characters in tr's string1 and string2 may be escaped with backslash + +User-visible changes in release 1.13 +* md5sum: with --check, distinguish between open/read failure and bad checksum +* md5sum: remove -h, -s, -v short options +* md5sum: rename --verbose to --warn, --quiet to --status +* md5sum --check fails if it finds no properly formatted checksum lines +* sort -c prints `disorder on...' message on standard error, not stdout +* sort -k works as described in the texinfo documentation +* tail works on NetBSD +* md5sum reads and writes (de facto) standard Plumb/Lankester format +* sort accepts -.1 +.2 options for compatibility +* od works properly when dump limit is specified and is a multiple of + bytes_per_block (set by --width, 16 by default). + +User-visible changes in release 1.12 +* sort no longer reports spurious errors on Ultrix systems +* new program: md5sum +* all --help messages have been improved +* join's -a1 and -a2 options work +* tr '[:upper:]' '[:lower:]' no longer reads uninitialized memory +* sort properly handles command line arguments like `+7.2n' +* fmt properly formats paragraphs not terminated by a newline +* tail -f flushes stdout before sleeping so that it will output partial + lines sooner +* sort properly orders fields where one field is a proper prefix of the other +* sort properly interprets field offsets specified via the -k option +* dd, od, and tail work on systems for which off_t is long long (e.g. BSD4.4) +* wc is faster when not counting words +* wc now works even when file pointer isn't at beginning of file +* expand no longer seg faults with very long tab lists + +User-visible changes in release 1.11 +* fmt is built + +User-visible changes in release 1.10 +* skeletal texinfo documentation (mainly just the `invoking' nodes) +* new program: fmt +* tail -f on multiple files reports file truncation +* tail -q has been fixed so it never prints headers +* wc -c is much faster when operating on non-regular files +* unexpand gives a diagnostic (rather than a segfault) when given a name of + a nonexistent file. +* cat, csplit, head, split, sum, tac, tail, tr, and wc no longer fail + gratuitously when continued after a suspended read or write system call. +* cut interprets -d '' to mean `use the NUL byte as the delimiter' rather + than reporting that no delimiter was specified and failing. +* `echo a:b:c: | cut -d: -f3,4' prints `c:'. Before it printed just `c'. +* cut has been rewritten, is markedly faster for large inputs, and passes a + fairly large test suite. +* sort properly handles the argument to the -T option. + +Major changes in release 1.9.1: +* cut no longer ignores the last line of input when that line lacks a + trailing newline character + +Major changes in release 1.9: +* `echo a:b:c: | cut -d: -f3-' prints `c:' and + `echo a:b | cut -d: -f1' prints `a'. +* the command `printf '\t\n' |fold -w n' now terminates. + Before, it wouldn't stop for n less than 8. +* sort accepts and ignores -y[string] options for compatibilty with Solaris. +* cat -v /dev/null works on more systems +* od's --compatible (-C) flag renamed to --traditional (no short option) +* --help and --version exit successfully +* --help gives a one-line description of each option and shows the + correspondence between short and long-named options. +* fix bug in cut. Now `echo 'a:b:c:' | cut -d: -f3-' works. + Before it printed `c' instead of `c:' +* csplit allows repeat counts to be specified via `{*}'. +* csplit accepts a new option, --suffix=format that supercedes the + --digits option. The --digits option will continue to work. +* csplit accepts a new option, --elide-empty-files. +* configure uses config.h, so DEFS won't exceed preprocessor limits of + some compilers on the number of symbols defined via -D. +* work around problem where $(srcdir)/config.h was used instead of + ../config.h -- this happened only when building in a subdirectory + and when config.h remained in $(srcdir) from a previous ./configure. + +Major changes in release 1.8: +* added non-ANSIfied version of memchr.c from GNU libc. + +Major changes in release 1.7: +* none +Major changes in release 1.6: +* with the --version option programs print the version and exit immediately +* pr -2a really terminates +* pr -n produces multi-column output + +Major changes in release 1.5: +* sort is 8-bit clean +* sort's -n and -M options no longer imply -b +* several bugs in sort have been fixed +* all programs accept --help and --version options +* od --compatible accepts pre-POSIX arguments +* pr -2a terminates + +Major changes in release 1.4: +* add od and cksum programs +* move cmp to GNU diff distribution +* tail -f works for multiple files +* pr prints the file name in error messages +* fix some off by 1 errors in pr and fold +* optimize wc -c on regular files +* sort handles `-' argument correctly +* sort supports -T option +* tr ranges like a-a work +* tr x '' fails gracefully +* default sum output format is BSD compatible +* paste -d '' works diff --git a/contrib/gnu-sort/README b/contrib/gnu-sort/README new file mode 100644 index 0000000..48e7bec --- /dev/null +++ b/contrib/gnu-sort/README @@ -0,0 +1,41 @@ +These are the GNU text file (actually, file contents) processing +utilities. Most of these programs have significant advantages over +their Unix counterparts, such as greater speed, additional options, +and fewer arbitrary limits. + +The programs that can be built with this package are: cat, cksum, comm, +csplit, cut, expand, fmt, fold, head, join, md5sum, nl, od, paste, pr, +ptx, sort, split, sum, tac, tail, tr, tsort, unexpand, uniq, and wc. + +See the file NEWS for a list of major changes in the current release. + +See the file INSTALL for compilation and installation instructions. + +I M P O R T A N T: + + Some Cray C compilers lack support for a 32-bit arithmetic type. + Since gettext requires such a type, you should use the --disable-nls + option when invoking configure on such systems. + +The textutils are intended to be POSIX.2 compliant (with BSD and other +extensions), like the rest of the GNU system. They are almost there, +but a few incompatibilities remain. + +Note that the man pages are now automatically generated from templates +and from the --help usage message. Patches to the template files (man/*.x) +are welcome. However, the authoritative documentation is in texinfo form +in the doc directory. + +These programs all recognize the `--version' option. When reporting +bugs, please include in the subject line both the package name/version +and the name of the program for which you found a problem. + +For general documentation on the coding and usage standards +this distribution follows, see the GNU standards document +http://www.gnu.org/prep/standards.html, and the documentation +for automake and autoconf: +http://www.gnu.org/software/autoconf/autoconf.html, +http://www.gnu.org/software/automake/automake.html. + +Mail suggestions and bug reports for these programs to +bug-textutils@gnu.org. diff --git a/contrib/gnu-sort/README-alpha b/contrib/gnu-sort/README-alpha new file mode 100644 index 0000000..e57d649 --- /dev/null +++ b/contrib/gnu-sort/README-alpha @@ -0,0 +1,3 @@ +This is a test release of this package. + +Please send comments and problem reports to bug-textutils@gnu.org. diff --git a/contrib/gnu-sort/THANKS b/contrib/gnu-sort/THANKS new file mode 100644 index 0000000..08e0186 --- /dev/null +++ b/contrib/gnu-sort/THANKS @@ -0,0 +1,340 @@ +These people have contributed to the GNU fileutils, textutils, +and/or sh-utils packages. Some have reported problems, others have +contributed improvements to the documentation, actual code, and even +complete programs. Those contributions are described in the ChangeLog +files. If your name has been left out, if you'd rather not be listed, +or if you'd prefer a different address be used, please let me know. +Some old names and addresses are still in the ChangeLog. + +Achim Blumensath blume@corona.oche.de +Adam Klein aklein@debian.org +Akim Demaille demaille@inf.enst.fr +Alain Magloire alain@qnx.com +Alan Iwi iwi@atm.ox.ac.uk +Albert Hopkins ahopkins@dynacare.com +Alberto Accomazzi alberto@cfa0.harvard.edu +aldomel aldomel@ix.netcom.com +Alen Muzinic zveki@fly.cc.fer.hr +Alexandre Duret-Lutz duret_g@epita.fr +Alexey Solovyov alekso@math.uu.se +Andre Novaes Cunha Andre.Cunha@br.global-one.net +Andreas Gruenbacher ag@bestbits.at +Andreas Jaeger jaeger@gnu.org +Andreas Luik luik@isa.de +Andreas Schwab schwab@suse.de +Andreas Stolcke stolcke@ICSI.Berkeley.EDU +Andres Soolo andres@soolo.matti.ee +Andrew Burgess aab@cichlid.com +Andrew Dalke dalke@bioreason.com +Andrew Pham andpha@us.ibm.com +Andrew Tridgell tridge@samba.org +Andries Brouwer Andries.Brouwer@cwi.nl +Andy Longton alongton@metamark.com +Antonio Rendas ajrendas@yahoo.com +Ariel Faigon ariel@cthulhu.engr.sgi.com +Arne H. Juul arnej@solan.unit.no +Arne Henrik Juul arnej@imf.unit.no +Arthur Pool pool@commerce.uq.edu.au +Austin Donnelly Austin.Donnelly@cl.cam.ac.uk +Axel Kittenberger Anshil@gmx.net +Bauke Jan Douma bjdouma@xs4all.nl +Bengt Martensson bengt@mathematik.uni-Bremen.de +Bernd Leibing bernd.leibing@rz.uni-ulm.de +Bernhard Baehr bernhard.baehr@gmx.de +Bernhard Rosenkraenzer bero@redhat.de +Bill Peters peters@gaffel.as.arizona.edu +Bjorn Helgaas helgaas@rsn.hp.com +Bob McCracken kerouac@ravenet.com +Bob Proulx rwp@fc.hp.com +Branden Robinson branden@necrotic.deadbeast.net +Brendan O'Dea bod@compusol.com.au +Brian Kimball bfk@footbag.org +Brian Youmans 3diff@gnu.org +Bruno Haible haible@clisp.cons.org +Carl Johnson carlj@cjlinux.home.org +Carl Lowenstein cdl@mpl.UCSD.EDU +Carlos Canau Carlos.Canau@relay.puug.pt +Charles Karney karney@pppl.gov +Charles Randall crandall@matchlogic.com +Chip Salzenberg chip@valinux.com +Chris Faylor cgf@cygnus.com +Chris J. Bednar cjb@AdvancedDataSolutions.com +Chris Sylvain csylvain@umm.edu +Chris Yeo cyeo@biking.org +Christi Alice Scarborough christi@chiark.greenend.org.uk +Christian Harkort christian.harkort@web.de +Christian Krackowizer ckrackowiz@std.schuler-ag.com +Christian Rose menthos@menthos.com +Christian von Roques roques@pond.sub.org +Chuck Hedrick hedrick@klinzhai.rutgers.edu +Clark Morgan cmorgan@aracnet.com +Colin Plumb colin@nyx.net +Colin Watson cjw44@riva.ucam.org +Collin Rogowski collin@rogowski.de +Dale Scheetz dwarf@polaris.net +Dan Hagerty hag@gnu.ai.it.edu +Dan Pascu dan@services.iiruc.ro +Daniel Bergstrom noa@melody.se +Darren Salt ds@youmustbejoking.demon.co.uk +David Dyck dcd@tc.fluke.COM +David Godfrey dave@delta.demon.co.uk +David Luyer david_luyer@pacific.net.au +Dennis Henriksen opus@flamingo.osrl.dk +Derek Clegg dclegg@next.com +Dick Streefland dick_streefland@tasking.com +Dirk Lattermann dlatt@t-online.de +Dirk-Jan Faber djfaber@snow.nl +Dan Jacobson http://www.geocities.com/jidani +Don Parsons dparsons@synapse.kent.edu +Donni Erpel donald@appc11.gsi.de +Doug McLaren dougmc@comco.com +Dragos Harabor dharabor@us.oracle.com +Ed Avis epa98@doc.ic.ac.uk +Edzer Pebesma Edzer.Pebesma@rivm.nl +Eirik Fuller eirik@hackrat.com +Eivind eivindt@multinet.no +Eli Zaretskii eliz@is.elta.co.il +Emile LeBlanc leblanc@math.toronto.edu +Eric Backus ericb@lsid.hp.com +Eric G. Miller egm2@jps.net +Eric Pemente pemente@northpark.edu +Eric S. Raymond esr@snark.thyrsus.com +Erik Bennett bennett@cvo.oneworld.com +Erik Corry erik@kroete2.freinet.de +Felix Lee flee@teleport.com +Fletcher Mattox fletcher@cs.utexas.edu +Florin Iucha fiucha@hsys.mic.ro +Frank Adler fadler@allesklar.de +Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU +François Pinard pinard@iro.umontreal.ca +Fred Fish fnf@ninemoons.com +Frederik Eaton frederik@caltech.edu +Frédéric L. W. Meunier 0@pervalidus.net +Gabor Z. Papp gzp@gzp.org.hu +Galen Hazelwood galenh@micron.net +Gary Anderson ganderson@clark.net +Gaël Quéri gqueri@mail.dotcom.fr +Geoff Kuenning geoff@cs.hmc.edu +Geoff Odhner geoff@franklin.com +Geoff Whale geoffw@cse.unsw.EDU.AU +Gerhard Poul gpoul@gnu.org +Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp +GOTO Masanori gotom@debian.or.jp +Greg Louis glouis@dynamicro.on.ca +Greg McGary gkm@gnu.org +Greg Troxel gdt@bbn.com +Greg Wooledge gawooledge@sherwin.com +Gregory Leblanc gleblanc@cu-portland.edu +Göran Uddeborg goeran@uddeborg.pp.se +H. J. Lu hjl@valinux.com +Hans Verkuil hans@wyst.hobby.nl +Harry Liu rliu@lek.ugcs.caltech.edu +Herbert Xu herbert@gondor.apana.org.au +Holger Berger hberger@ess.nec.de +Hon-Yin Kok hkok@yoda.unl.edu +Hugh Daniel hugh@xanadu.com +Ian Bruce ian.bruce@myrealbox.com +Ian Jackson ijackson@chiark.greenend.org.uk +Ian Lance Taylor ian@cygnus.com +Ian Turner vectro@pipeline.com +James james@albion.glarp.com +James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk +James Sneeringer jvs@ocslink.com +James Tanis jtt@soscorp.com +James Youngman james+usenet@free-lunch.demon.co.uk +Jamie Lokier jamie@imbolc.ucc.ie +Jan Fedak J.Fedak@sh.cvut.cz +Jan Nieuwenhuizen janneke@gnu.org +Janos Farkas chexum@shadow.banki.hu +Jarkko Hietaniemi jhi@epsilon.hut.fi +Jeff Moore jbm@mordor.com +Jeff Sheinberg jeffsh@erols.com +Jens Schmidt jms@jsds.hamburg.com +Jerome Abela abela@hsc.fr +Jesse Thilo jgt2@eecs.lehigh.edu +Jie Xu xuj@iag.net +Jim Blandy jimb@cyclic.com +Jim Dennis jimd@starshine.org +Joakim Rosqvist dvljrt@cs.umu.se +Jochen Hein jochen@jochen.org +Joe Orton joe@orton.demon.co.uk +Johan Danielsson joda@pdc.kth.se +John Bley jbb6@acpub.duke.edu +John David Anglin dave.anglin@nrc.ca +John Gatewood Ham zappaman@alphabox.compsci.buu.ac.th +John Gotts jgotts@umich.edu +John Kendall kendall@capps.com +John Kodis kodis@acm.org +John Murphy jam@philabs.research.philips.com +John Roll john@panic.harvard.edu +John Salmon johns@mullet.anu.edu.au +John Summerfield summer@OS2.ami.com.au +Joost van Baal joostvb@xs4all.nl +Jorge Stolfi stolfi@ic.unicamp.br +Joseph S. Myers jsm28@cam.ac.uk +Juan F. Codagnone juam@arnet.com.ar +Jungshik Shin jshin@pantheon.yale.edu +Jürgen Fluk louis@dachau.marco.de +jvogel jvogel@linkny.com +Kai-Uwe Rommel rommel@informatik.tu-muenchen.de +Kai Henningsen kai@debian.org +Kalle Olavi Niemitalo tosi@stekt.oulu.fi +Kamal Paul Nigam Kamal_Paul_Nigam@gs35.sp.cs.cmu.edu +Karl Eichwalder keichwa@gmx.net +Karl Heuer kwzh@gnu.org +Karl-Michael Schneider schneide@phil.uni-passau.de +Karsten Thygesen karthy@kom.auc.dk +Kaveh R. Ghazi ghazi@caip.rutgers.edu +Keith Owens kaos@audio.apana.org.au +Keith Thompson kst@sdsc.edu +Ken Pizzini kenp@halcyon.com +Kjetil Torgrim Homme kjetilho@ifi.uio.no +Kristoffer Rose kris@diku.dk +??? kytek@cybercomm.net +Larry McVoy lm@sgi.com +Lars Hecking lhecking@nmrc.ucc.ie +Lehti Rami rammer@cs.tut.fi +Leonard N. Zubkoff lnz@dandelion.com +Lorne Baker lbaker@nitro.avint.net +M. P. Suzuki mpsuzuki@hiroshima-u.ac.jp +Maciej Kwapulinski pikpok@univ.gda.pl +Manas Garg manas@cygsoft.com +Manfred Hollstein manfred@s-direktnet.de +Marc Boucher marc@mbsi.ca +Marc Olzheim marcolz@stack.nl +Marco Franzen Marco.Franzen@Thyron.com +Marcus Daniels marcus@ee.pdx.edu +Mark A. Thomas thommark@access.digex.net +Mark D. Roth roth@uiuc.edu +Mark Harris mark@monitor.designacc.com +Mark Hewitt mhewitt@armature.com +Mark Hounschell markh@compro.net +Mark Kettenis kettenis@phys.uva.nl +Mark Nudelman marknu@flash.net +Mark W. Eichin eichin@cygnus.com +Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de +Martin martin@dresden.nacamar.de +Martin Gallant martyg@goodbit.net +Martin Hippe martin.hippe@schlund.de +Martin Mitchell martin@debian.org +Martin P.J. Zinser zinser@decus.de +Marty Leisner leisner@sdsp.mc.xerox.com +Masami Takikawa takikawm@CS.ORST.EDU +Mate Wierdl mw@moni.msci.memphis.edu +Matej Vela mvela@public.srce.hr +Matt Perry matt@primefactor.com +Matt Schalit mschalit@pacbell.net +Matthew Braun matthew@ans.net +Matthew Clarke Matthew_Clarke@mindlink.bc.ca +Matthew S. Levine mslevine@theory.lcs.mit.edu +Matthew Smith matts@bluesguitar.org +Matthew Swift swift@alum.mit.edu +Mattias Wadenstein maswan@acc.umu.se +Matthias Urlichs smurf@noris.de +Meelis Roos mroos@tartu.cyber.ee +Michael ??? michael@roka.net +Michael Deutschmann michael@talamasca.ocis.net +Michael Gaughen mgaughen@polyserve.com +Michael Hasselberg mikelh@zonta.ping.de +Michael Hohn hohn@math.utah.edu +Michael J. Croghan mcroghan@usatoday.com +Michael Steffens michael.steffens@s.netic.de +Michael Stone mstone@debian.org +Michael Stutz stutz@dsl.org +Michael Veksler mveksler@techunix.technion.ac.il +Michel Robitaille robitail@IRO.UMontreal.CA +Michiel Bacchiani bacchian@raven.bu.edu +Miles Bader miles@gnu.ai.mit.edu +Minh Tran-Le tranle@intellicorp.com +Morten Welinder terra@diku.dk +Neal H Walfield neal@cs.uml.edu +Nelson H. F. Beebe beebe@math.utah.edu +Nick Lawes nlawes@silverplatter.com +Niklas Edmundsson nikke@acc.umu.se +Noah Friedman friedman@splode.com +Noel Cragg noel@red-bean.com +Olav Morkrid olav@funcom.com +Ole Laursen olau@hardworking.dk +Oskar Liljeblad osk@hem.passagen.se +Ĝrn E. Hansen oehansen@daimi.aau.dk +Paul Eggert eggert@twinsun.com +Paul Nevai nevai@ops.mps.ohio-state.edu +Paul Sauer paul@alexa.com +Paul Slootman paul@debian.org +Pawel Prokop pablo@wizard.ae.krakow.pl +Per Cederqvist ceder@lysator.liu.se +Per Kristian Hove perhov@math.ntnu.no +Peter Eriksson peter@ifm.liu.se +Peter Moulder reiter@netspace.net.au +Peter Samuelson psamuels@sampo.creighton.edu +Peter Seebach seebs@taniemarie.solon.com +Petter Reinholdtsen pere@hungry.com +Phelippe Neveu pneveu@pcigeomatics.com +Phil Richards phil.richards@vf.vodafone.co.uk +Philippe De Muyter phdm@macqel.be +Philippe Schnoebelen Philippe.Schnoebelen@imag.fr +Piergiorgio Sartor sartor@sony.de +Piotr Kwapulinski kwap@univ.gda.pl +Prashant TR tr@eth.net +Rainer Orth ro@TechFak.Uni-Bielefeld.DE +Ralf W. Stephan stephan@tmt.de +Ralph Loader loader@maths.ox.ac.uk +Raul Miller moth@magenta.com +Richard Braakman dark@xs4all.nl +Richard Dawe richdawe@bigfoot.com +Richard J. Rauenzahn rrauenza@hairball.cup.hp.com +Richard Sharman rsharman@magmacom.com +Rick Sladkey jrs@world.std.com +Rik Faith faith@cs.unc.edu +Risto Kankkunen kankkune@lingsoft.fi +Robert H. de Vries robert@and.nl +Rogier Wolff R.E.Wolff@BitWizard.nl +Roland Huebner ro-huebner@gmx.de +Ronald F. Guilmette rfg@netcom.com +Ross Alexander r.alexander@auckland.ac.nz +Ross Paterson rap@doc.ic.ac.uk +Ross Ridge rridge@calum.csclub.uwaterloo.ca +Sami Farin sfarin@ratol.fi +Samuli Karkkainen Samuli.Karkkainen@hut.fi +Sander van Malssen svm@kozmix.ow.nl +Santiago Vila Doncel sanvila@unex.es +Savochkin Andrey Vladimirovich saw@msu.ru +Scott Lurndal slurn@griffin.engr.sgi.com +Soeren Sonnenburg sonnenburg@informatik.hu-berlin.de +Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr +Stephen Eglen eglen@pcg.wustl.edu +Stephen Gildea gildea@stop.mail-abuse.org +Stephen Smoogen ?????????? +Steve McConnel steve@acadcomp.sil.org +Stuart Kemp skemp@peter.bmc.com +Tadayoshi Funaba tadf@kt.rim.or.jp +Theodore Ts'o tytso@rsts-11.mit.edu +Thomas Bushnell thomas@gnu.ai.mit.edu +Thomas Quinot thomas@Cuivre.FR.EU.ORG +Tim Smithers mouse@dmouse.com.au +Tim Waugh twaugh@redhat +Todd A. Jacobs tjacobs@codegnome.org +Tom Quinn trq@dionysos.thphys.ox.ac.uk +Ton Hospel thospel@mail.dma.be +Tony Leneis tony@plaza.ds.adp.com +Tony Robinson ajr@eng.cam.ac.uk +Torbjorn Granlund tege@nada.kth.se +Torbjorn Lindgren tl@funcom.no +Torsten Landschoff torsten@pclab.ifg.uni-kiel.de +Ulrich Drepper drepper@gnu.org +Urs Thuermann urs@isnogud.escape.de +Uwe H. Steinfeld usteinfeld@gmx.net +Vesselin Atanasov vesselin@bgnet.bg +Vin Shelton acs@alumni.princeton.edu +Volker Borchert bt@teknon.de +Wayne Stewart wstewa@atl.com +Wenjun Zheng zwj@yahoo.com +Werner Almesberger Werner.Almesberger@epfl.ch +Wichert Akkerman wichert@cistron.nl +Will Edgington wedgingt@acm.org +William Bader william@nscs.fast.net +William Dowling will@franklin.com +William Lewis wiml@omnigroup.com +Wolfram Kleff kleff@cs.uni-bonn.de +Won-kyu Park wkpark@chem.skku.ac.kr +Zvi Har'El rl@math.technion.ac.il diff --git a/contrib/gnu-sort/TODO b/contrib/gnu-sort/TODO new file mode 100644 index 0000000..a102576 --- /dev/null +++ b/contrib/gnu-sort/TODO @@ -0,0 +1,93 @@ +Tasks for GNU textutils (listed in no particular order): + + write texinfo documentation for sha1sum + + Something that I would really appreciate is if someone would run the + Open Group's VSC-lite test suite against the fileutils and textutils + and report the failures. + + http://www.opengroup.org/testing/downloads/vsclite.html + + I've been meaning to do it myself for months, but haven't found the time. + There's a bit of set-up required, some of which requires root access, e.g., + to create a few test user accounts and some test groups. + ------------------ + + uniq: remove support for obsolescent +N syntax + + add tests for od + add some endian-aware tests for od + + tac: Set DONT_UNLINK_WHILE_OPEN when necessary. + + tail: add an option so that using -f on N files doesn't monopolize + N file descriptors + + tac: add options to help handle boundary cases + E.g., options to distinguish DELIM_STRING is + - starter (see existing --before option) + - terminator (this is what most people expect wrt NEWLINE + - separator (this would make `echo -n a:b:c|tac -s:' print `c:b:a') + + tail: support -r option by librarifying tac and using that + + cut: maybe add an option to say `fields are separated by whitespace'. + Of course, that isn't really necessary because you can preprocess + cut's input with tr to get the same effect: + + echo 'a b c' |tr -s '[:blank:]' | cut -d ' ' -f 2 + +------------ + + From: kwzh@gnu.ai.mit.edu (Karl Heuer) + Subject: [textutils-1.22] [sort] feature requests + To: textutils-bugs@gnu.ai.mit.edu + Date: Thu, 5 Jun 97 13:06:51 -0400 + + [...] + Another feature that I would sometimes find useful: change -c so that + it will report up to N instances of disorder before bailing out, where + N defaults to 1 but can be set to infinity or to some finite value by + another option. (An "instance of disorder" is two adjacent lines that + are malsorted; this does not imply that swapping them or removing one + or both would cause the list to be sorted. (1 3 5 7 9 0 2 4 6 8) has + just one instance of disorder.) + +------------ + + Date: Fri, 1 May 1998 20:27:39 -0700 (PDT) + From: Paul Rubin + To: gnu@gnu.org + Subject: small project suggestion + + Someone should rewrite the "sum" utility to give a choice of + different checksum algorithms (it's poorly organized for that now). + An experienced programmer could probably do it in a day or so, + or it might be a good, self-contained project for someone who is + just getting started. + + Algorithms that it should include are: + -- the POSIX algorithm + -- the BSD algorithm + -- CRC32 algorithm (used by pkzip) + -- CRC16 (used in TCP/IP) + -- possibly other CRC's (like the different CCITT polynomials) + -- SHA-1 and MD5 cryptographic hashes (replacing "md5sum"). + and possibly: + -- DSA digital signature based on secret key generated from + a passphrase (prompt the user, or read an environment variable). + + +--------------------- + +comm: add an option-enable check for sortedness of input files + +--------------------- + +uniq: add a more flexible key selection mechanism + +--------------------- + +Charles Randall +is working on making sort more suitable and efficient for very +large sets of input data. diff --git a/contrib/gnu-sort/lib/argmatch.c b/contrib/gnu-sort/lib/argmatch.c new file mode 100644 index 0000000..005be88 --- /dev/null +++ b/contrib/gnu-sort/lib/argmatch.c @@ -0,0 +1,309 @@ +/* argmatch.c -- find a match for a string in an array + 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 */ + +#include "argmatch.h" + +#include +#ifdef STDC_HEADERS +# 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/contrib/gnu-sort/lib/argmatch.h b/contrib/gnu-sort/lib/argmatch.h new file mode 100644 index 0000000..b719300 --- /dev/null +++ b/contrib/gnu-sort/lib/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/contrib/gnu-sort/lib/closeout.h b/contrib/gnu-sort/lib/closeout.h new file mode 100644 index 0000000..80f24e4 --- /dev/null +++ b/contrib/gnu-sort/lib/closeout.h @@ -0,0 +1,17 @@ +#ifndef CLOSEOUT_H +# define CLOSEOUT_H 1 + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +void close_stdout_set_status PARAMS ((int status)); +void close_stdout_set_file_name PARAMS ((const char *file)); +void close_stdout PARAMS ((void)); +void close_stdout_status PARAMS ((int status)); + +#endif diff --git a/contrib/gnu-sort/lib/dup-safer.c b/contrib/gnu-sort/lib/dup-safer.c new file mode 100644 index 0000000..f72fd84 --- /dev/null +++ b/contrib/gnu-sort/lib/dup-safer.c @@ -0,0 +1,62 @@ +/* Invoke dup, but avoid some glitches. + 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 Paul Eggert. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#if HAVE_FCNTL_H +# include +#endif + +#if HAVE_UNISTD_H +# include +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +#include + +/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ + +int +dup_safer (int fd) +{ +#ifdef F_DUPFD + return fcntl (fd, F_DUPFD, STDERR_FILENO + 1); +#else + int f = dup (fd); + if (0 <= f && f <= STDERR_FILENO) + { + int f1 = dup_safer (f); + int e = errno; + close (f); + errno = e; + f = f1; + } + return f; +#endif +} diff --git a/contrib/gnu-sort/lib/error.c b/contrib/gnu-sort/lib/error.c new file mode 100644 index 0000000..c02abce --- /dev/null +++ b/contrib/gnu-sort/lib/error.c @@ -0,0 +1,401 @@ +/* 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. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; 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/contrib/gnu-sort/lib/error.h b/contrib/gnu-sort/lib/error.h new file mode 100644 index 0000000..177b2dc --- /dev/null +++ b/contrib/gnu-sort/lib/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/contrib/gnu-sort/lib/fopen-safer.c b/contrib/gnu-sort/lib/fopen-safer.c new file mode 100644 index 0000000..6825f9b --- /dev/null +++ b/contrib/gnu-sort/lib/fopen-safer.c @@ -0,0 +1,76 @@ +/* Invoke fopen, but avoid some glitches. + 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 Paul Eggert. */ + +#if HAVE_CONFIG_H +# include +#endif + +#if HAVE_UNISTD_H +# include +#endif +#include + +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#include +#include + +/* Like fopen, but do not return stdin, stdout, or stderr. */ + +FILE * +fopen_safer (char const *file, char const *mode) +{ + FILE *fp = fopen (file, mode); + + if (fp) + { + int fd = fileno (fp); + + if (0 <= fd && fd <= STDERR_FILENO) + { + int f = dup_safer (fd); + + if (f < 0) + { + int e = errno; + fclose (fp); + errno = e; + return NULL; + } + + if (fclose (fp) != 0 + || ! (fp = fdopen (f, mode))) + { + int e = errno; + close (f); + errno = e; + return NULL; + } + } + } + + return fp; +} diff --git a/contrib/gnu-sort/lib/getopt.c b/contrib/gnu-sort/lib/getopt.c new file mode 100644 index 0000000..fa46c85 --- /dev/null +++ b/contrib/gnu-sort/lib/getopt.c @@ -0,0 +1,772 @@ +/* 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 roland@gnu.ai.mit.edu + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 + 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* $FreeBSD$ */ + +/* 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. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* 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 +#endif /* GNU C library. */ + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. + When compiling libc, the _ macro is predefined. */ +#ifdef HAVE_LIBINTL_H +# include +# define _(msgid) gettext (msgid) +#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 = NULL; + +/* 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 EOF, 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. */ + +/* XXX 1003.2 says this must be 1 before any call. */ +int optind = 0; + +/* 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 EOF 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 + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +char *getenv (); + +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__ +/* 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; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void +exchange (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. */ + + 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; + } + /* 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; + } + /* 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. */ + +static const char * +_getopt_initialize (optstring) + 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 = 1; + + 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; + + 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 `EOF'. + 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; +{ + optarg = NULL; + + if (optind == 0) + { + optstring = _getopt_initialize (optstring); + optind = 1; /* Don't scan ARGV[0], the program name. */ + } + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + 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 + && (argv[optind][0] != '-' || argv[optind][1] == '\0')) + 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 EOF; + } + + /* 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 ((argv[optind][0] != '-' || argv[optind][1] == '\0')) + { + if (ordering == REQUIRE_ORDER) + return EOF; + 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; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + +#ifdef lint + indfound = 0; /* Avoid spurious compiler warning. */ +#endif + + /* 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 (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 (opterr) + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + 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 (opterr) + 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); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + 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; + } + + /* 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 (opterr) + { + 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++; + 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 (opterr) + { + 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 '?'; + } + 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 (opterr) + { + /* 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 /* _LIBC or not __GNU_LIBRARY__. */ + +#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 == EOF) + 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/contrib/gnu-sort/lib/getopt.h b/contrib/gnu-sort/lib/getopt.h new file mode 100644 index 0000000..89bc731 --- /dev/null +++ b/contrib/gnu-sort/lib/getopt.h @@ -0,0 +1,131 @@ +/* Declarations for getopt. + Copyright (C) 1989, 90, 91, 92, 93, 94 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* $FreeBSD$ */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#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 EOF, 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; + +/* 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__ + 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 + +#if defined (__STDC__) && __STDC__ +#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__ */ +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); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GETOPT_H */ diff --git a/contrib/gnu-sort/lib/getopt1.c b/contrib/gnu-sort/lib/getopt1.c new file mode 100644 index 0000000..3d068e9 --- /dev/null +++ b/contrib/gnu-sort/lib/getopt1.c @@ -0,0 +1,182 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* $FreeBSD$ */ + +#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. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#else +char *getenv (); +#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 /* _LIBC or not __GNU_LIBRARY__. */ + +#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 == EOF) + 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/contrib/gnu-sort/lib/hard-locale.c b/contrib/gnu-sort/lib/hard-locale.c new file mode 100644 index 0000000..01e0ebd --- /dev/null +++ b/contrib/gnu-sort/lib/hard-locale.c @@ -0,0 +1,87 @@ +/* hard-locale.c -- Determine whether a locale is hard. + Copyright 1997, 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 + +#if __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + # pragma alloca +# else +# ifdef _WIN32 +# include +# include +# else +# ifndef alloca +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +#if HAVE_LOCALE_H +# include +#endif + +#if HAVE_STRING_H +# include +#endif + +/* Return nonzero if the current CATEGORY locale is hard, i.e. if you + can't get away with assuming traditional C or POSIX behavior. */ +int +hard_locale (int category) +{ +#if ! (defined ENABLE_NLS && HAVE_SETLOCALE) + return 0; +#else + + int hard = 1; + char const *p = setlocale (category, 0); + + if (p) + { +# if defined __GLIBC__ && __GLIBC__ >= 2 + if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0) + hard = 0; +# else + char *locale = alloca (strlen (p) + 1); + strcpy (locale, p); + + /* Temporarily set the locale to the "C" and "POSIX" locales to + find their names, so that we can determine whether one or the + other is the caller's locale. */ + if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0) + || ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0)) + hard = 0; + + /* Restore the caller's locale. */ + setlocale (category, locale); +# endif + } + + return hard; + +#endif +} diff --git a/contrib/gnu-sort/lib/hard-locale.h b/contrib/gnu-sort/lib/hard-locale.h new file mode 100644 index 0000000..5b054d9 --- /dev/null +++ b/contrib/gnu-sort/lib/hard-locale.h @@ -0,0 +1,18 @@ +#ifndef HARD_LOCALE_H_ +# define HARD_LOCALE_H_ 1 + +# if HAVE_CONFIG_H +# include +# endif + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +int hard_locale PARAMS ((int)); + +#endif /* HARD_LOCALE_H_ */ diff --git a/contrib/gnu-sort/lib/human.c b/contrib/gnu-sort/lib/human.c new file mode 100644 index 0000000..a9ccf38 --- /dev/null +++ b/contrib/gnu-sort/lib/human.c @@ -0,0 +1,366 @@ +/* human.c -- print human readable file size + + Copyright (C) 1996, 1997, 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. */ + +/* Originally contributed by lm@sgi.com; + --si, output block size selection, and large file support + added by eggert@twinsun.com. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +#if HAVE_LIMITS_H +# include +#endif + +#if HAVE_STRING_H +# include +#else +# include +#endif + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#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 + +#if ENABLE_NLS +# include +# define _(Text) gettext (Text) +#else +# define _(Text) Text +#endif + +#include +#include +#include + +#include "human.h" + +static const char suffixes[] = +{ + 0, /* not used */ + 'K', /* kibi ('k' for kilo is a special case) */ + 'M', /* mega or mebi */ + 'G', /* giga or gibi */ + 'T', /* tera or tebi */ + 'P', /* peta or pebi */ + 'E', /* exa or exbi */ + 'Z', /* zetta or 2**70 */ + 'Y' /* yotta or 2**80 */ +}; + +/* Generate into P[-1] (and possibly P[-2]) the proper suffix for + POWER and BASE. Return the address of the generated suffix. */ +static char * +generate_suffix_backwards (char *p, int power, int base) +{ + char letter = suffixes[power]; + + if (base == 1000) + { + *--p = 'B'; + if (power == 1) + letter = 'k'; + } + + *--p = letter; + return p; +} + +/* If INEXACT_STYLE is not human_round_to_even, and if easily + possible, adjust VALUE according to the style. */ +static double +adjust_value (enum human_inexact_style inexact_style, double value) +{ + /* Do not use the floor or ceil functions, as that would mean + linking with the standard math library, which is a porting pain. + So leave the value alone if it is too large to easily round. */ + if (inexact_style != human_round_to_even && value < (uintmax_t) -1) + { + uintmax_t u = value; + value = u + (inexact_style == human_ceiling && u != value); + } + + return value; +} + +/* Like human_readable_inexact, except always round to even. */ +char * +human_readable (uintmax_t n, char *buf, + int from_block_size, int output_block_size) +{ + return human_readable_inexact (n, buf, from_block_size, output_block_size, + human_round_to_even); +} + +/* Convert N to a human readable format in BUF. + + N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must + be nonnegative. + + OUTPUT_BLOCK_SIZE must be nonzero. If it is positive, use units of + OUTPUT_BLOCK_SIZE in the output number. + + Use INEXACT_STYLE to determine whether to take the ceiling or floor + of any result that cannot be expressed exactly. + + If OUTPUT_BLOCK_SIZE is negative, use a format like "127K" if + possible, using powers of -OUTPUT_BLOCK_SIZE; otherwise, use + ordinary decimal format. Normally -OUTPUT_BLOCK_SIZE is either + 1000 or 1024; it must be at least 2. Most people visually process + strings of 3-4 digits effectively, but longer strings of digits are + more prone to misinterpretation. Hence, converting to an + abbreviated form usually improves readability. Use a suffix + indicating which power is being used. For example, assuming + -OUTPUT_BLOCK_SIZE is 1024, 8500 would be converted to 8.3K, + 133456345 to 127M, 56990456345 to 53G, and so on. Numbers smaller + than -OUTPUT_BLOCK_SIZE aren't modified. If -OUTPUT_BLOCK_SIZE is + 1024, append a "B" after any size letter. */ + +char * +human_readable_inexact (uintmax_t n, char *buf, + int from_block_size, int output_block_size, + enum human_inexact_style inexact_style) +{ + uintmax_t amt; + int base; + int to_block_size; + int tenths = 0; + int power; + char *p; + + /* 0 means adjusted N == AMT.TENTHS; + 1 means AMT.TENTHS < adjusted N < AMT.TENTHS + 0.05; + 2 means adjusted N == AMT.TENTHS + 0.05; + 3 means AMT.TENTHS + 0.05 < adjusted N < AMT.TENTHS + 0.1. */ + int rounding = 0; + + if (output_block_size < 0) + { + base = -output_block_size; + to_block_size = 1; + } + else + { + base = 0; + to_block_size = output_block_size; + } + + p = buf + LONGEST_HUMAN_READABLE; + *p = '\0'; + +#ifdef lint + /* Suppress `used before initialized' warning. */ + power = 0; +#endif + + /* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. */ + + { + int multiplier; + int divisor; + int r2; + int r10; + if (to_block_size <= from_block_size + ? (from_block_size % to_block_size != 0 + || (multiplier = from_block_size / to_block_size, + (amt = n * multiplier) / multiplier != n)) + : (from_block_size == 0 + || to_block_size % from_block_size != 0 + || (divisor = to_block_size / from_block_size, + r10 = (n % divisor) * 10, + r2 = (r10 % divisor) * 2, + amt = n / divisor, + tenths = r10 / divisor, + rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2), + 0))) + { + /* Either the result cannot be computed easily using uintmax_t, + or from_block_size is zero. Fall back on floating point. + FIXME: This can yield answers that are slightly off. */ + + double damt = n * (from_block_size / (double) to_block_size); + + if (! base) + sprintf (buf, "%.0f", adjust_value (inexact_style, damt)); + else + { + char suffix[3]; + char const *psuffix; + double e = 1; + power = 0; + + do + { + e *= base; + power++; + } + while (e * base <= damt && power < sizeof suffixes - 1); + + damt /= e; + + suffix[2] = '\0'; + psuffix = generate_suffix_backwards (suffix + 2, power, base); + sprintf (buf, "%.1f%s", + adjust_value (inexact_style, damt), psuffix); + if (4 + (base == 1000) < strlen (buf)) + sprintf (buf, "%.0f%s", + adjust_value (inexact_style, damt * 10) / 10, psuffix); + } + + return buf; + } + } + + /* Use power of BASE notation if adjusted AMT is large enough. */ + + if (base && base <= amt) + { + power = 0; + + do + { + int r10 = (amt % base) * 10 + tenths; + int r2 = (r10 % base) * 2 + (rounding >> 1); + amt /= base; + tenths = r10 / base; + rounding = (r2 < base + ? 0 < r2 + rounding + : 2 + (base < r2 + rounding)); + power++; + } + while (base <= amt && power < sizeof suffixes - 1); + + p = generate_suffix_backwards (p, power, base); + + if (amt < 10) + { + if (2 * (1 - (int) inexact_style) + < rounding + (tenths & (inexact_style == human_round_to_even))) + { + tenths++; + rounding = 0; + + if (tenths == 10) + { + amt++; + tenths = 0; + } + } + + if (amt < 10) + { + *--p = '0' + tenths; + *--p = '.'; + tenths = rounding = 0; + } + } + } + + if (inexact_style == human_ceiling + ? 0 < tenths + rounding + : inexact_style == human_round_to_even + ? 5 < tenths + (2 < rounding + (amt & 1)) + : /* inexact_style == human_floor */ 0) + { + amt++; + + if (amt == base && power < sizeof suffixes - 1) + { + *p = suffixes[power + 1]; + *--p = '0'; + *--p = '.'; + amt = 1; + } + } + + do + *--p = '0' + (int) (amt % 10); + while ((amt /= 10) != 0); + + return p; +} + + +/* The default block size used for output. This number may change in + the future as disks get larger. */ +#ifndef DEFAULT_BLOCK_SIZE +# define DEFAULT_BLOCK_SIZE 1024 +#endif + +static char const *const block_size_args[] = { "human-readable", "si", 0 }; +static int const block_size_types[] = { -1024, -1000 }; + +static int +default_block_size (void) +{ + return getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE; +} + +static strtol_error +humblock (char const *spec, int *block_size) +{ + int i; + + if (! spec && ! (spec = getenv ("BLOCK_SIZE"))) + *block_size = default_block_size (); + else if (0 <= (i = ARGMATCH (spec, block_size_args, block_size_types))) + *block_size = block_size_types[i]; + else + { + char *ptr; + unsigned long val; + strtol_error e = xstrtoul (spec, &ptr, 0, &val, "eEgGkKmMpPtTyYzZ0"); + if (e != LONGINT_OK) + return e; + if (*ptr) + return LONGINT_INVALID_SUFFIX_CHAR; + if ((int) val < 0 || val != (int) val) + return LONGINT_OVERFLOW; + *block_size = (int) val; + } + + return LONGINT_OK; +} + +void +human_block_size (char const *spec, int report_errors, int *block_size) +{ + strtol_error e = humblock (spec, block_size); + if (*block_size == 0) + { + *block_size = default_block_size (); + e = LONGINT_INVALID; + } + if (e != LONGINT_OK && report_errors) + STRTOL_FATAL_ERROR (spec, _("block size"), e); +} diff --git a/contrib/gnu-sort/lib/human.h b/contrib/gnu-sort/lib/human.h new file mode 100644 index 0000000..4ec9f0d --- /dev/null +++ b/contrib/gnu-sort/lib/human.h @@ -0,0 +1,39 @@ +#ifndef HUMAN_H_ +# define HUMAN_H_ 1 + +# if HAVE_CONFIG_H +# include +# endif + +# if HAVE_INTTYPES_H +# include +# endif + +/* A conservative bound on the maximum length of a human-readable string. + The output can be the product of the largest uintmax_t and the largest int, + so add their sizes before converting to a bound on digits. */ +# define LONGEST_HUMAN_READABLE ((sizeof (uintmax_t) + sizeof (int)) \ + * CHAR_BIT / 3) + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +enum human_inexact_style +{ + human_floor = -1, + human_round_to_even = 0, + human_ceiling = 1 +}; + +char *human_readable PARAMS ((uintmax_t, char *, int, int)); +char *human_readable_inexact PARAMS ((uintmax_t, char *, int, int, + enum human_inexact_style)); + +void human_block_size PARAMS ((char const *, int, int *)); + +#endif /* HUMAN_H_ */ diff --git a/contrib/gnu-sort/lib/long-options.c b/contrib/gnu-sort/lib/long-options.c new file mode 100644 index 0000000..e36685f --- /dev/null +++ b/contrib/gnu-sort/lib/long-options.c @@ -0,0 +1,91 @@ +/* Utility to accept --help and --version options as unobtrusively as possible. + Copyright (C) 1993, 1994, 1998, 1999, 2000 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 + +#include +#include +#if HAVE_STDLIB_H +# include +#endif + +#include "long-options.h" +#include "version-etc.h" + +#if ENABLE_NLS +# include +# define _(Text) gettext (Text) +#else +# define _(Text) Text +#endif + +static struct option const long_options[] = +{ + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'v'}, + {0, 0, 0, 0} +}; + +/* Process long options --help and --version, but only if argc == 2. + Be careful not to gobble up `--'. */ + +void +parse_long_options (int argc, + char **argv, + const char *command_name, + const char *package, + const char *version, + const char *authors, + void (*usage_func)()) +{ + int c; + int saved_opterr; + + saved_opterr = opterr; + + /* Don't print an error message for unrecognized options. */ + opterr = 0; + + if (argc == 2 + && (c = getopt_long (argc, argv, "+", long_options, NULL)) != -1) + { + switch (c) + { + case 'h': + (*usage_func) (0); + + case 'v': + version_etc (stdout, command_name, package, version, authors); + exit (0); + + default: + /* Don't process any other long-named options. */ + break; + } + } + + /* Restore previous value. */ + opterr = saved_opterr; + + /* Reset this to zero so that getopt internals get initialized from + the probably-new parameters when/if getopt is called later. */ + optind = 0; +} diff --git a/contrib/gnu-sort/lib/long-options.h b/contrib/gnu-sort/lib/long-options.h new file mode 100644 index 0000000..f82ff04 --- /dev/null +++ b/contrib/gnu-sort/lib/long-options.h @@ -0,0 +1,35 @@ +/* long-options.h -- declaration for --help- and --version-handling function. + Copyright (C) 1993, 1994, 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. */ + +/* Written by Jim Meyering. */ + +#ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +void + parse_long_options PARAMS ((int _argc, + char **_argv, + const char *_command_name, + const char *_package, + const char *_version, + const char *_authors, + void (*_usage) (int))); diff --git a/contrib/gnu-sort/lib/memcoll.c b/contrib/gnu-sort/lib/memcoll.c new file mode 100644 index 0000000..a2decfe --- /dev/null +++ b/contrib/gnu-sort/lib/memcoll.c @@ -0,0 +1,79 @@ +/* Locale-specific memory comparison. + Copyright 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. */ + +/* Contributed by Paul Eggert . */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#include + +#if HAVE_STRING_H +# include +#endif + +/* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according + to the LC_COLLATE locale. S1 and S2 do not overlap, and are not + adjacent. Temporarily modify the bytes after S1 and S2, but + restore their original contents before returning. Set errno to an + error number if there is an error, and to zero otherwise. */ +int +memcoll (char *s1, size_t s1len, char *s2, size_t s2len) +{ + int diff; + char n1 = s1[s1len]; + char n2 = s2[s2len]; + + s1[s1len++] = '\0'; + s2[s2len++] = '\0'; + + while (! (errno = 0, (diff = strcoll (s1, s2)) || errno)) + { + /* strcoll found no difference, but perhaps it was fooled by NUL + characters in the data. Work around this problem by advancing + past the NUL chars. */ + size_t size1 = strlen (s1) + 1; + size_t size2 = strlen (s2) + 1; + s1 += size1; + s2 += size2; + s1len -= size1; + s2len -= size2; + + if (s1len == 0) + { + if (s2len != 0) + diff = -1; + break; + } + else if (s2len == 0) + { + diff = 1; + break; + } + } + + s1[s1len - 1] = n1; + s2[s2len - 1] = n2; + + return diff; +} diff --git a/contrib/gnu-sort/lib/memcoll.h b/contrib/gnu-sort/lib/memcoll.h new file mode 100644 index 0000000..4909bdd --- /dev/null +++ b/contrib/gnu-sort/lib/memcoll.h @@ -0,0 +1,18 @@ +#ifndef MEMCOLL_H_ +# define MEMCOLL_H_ 1 + +# if HAVE_CONFIG_H +# include +# endif + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +int memcoll PARAMS ((char *, size_t, char *, size_t)); + +#endif /* MEMCOLL_H_ */ diff --git a/contrib/gnu-sort/lib/pathmax.h b/contrib/gnu-sort/lib/pathmax.h new file mode 100644 index 0000000..de9313b --- /dev/null +++ b/contrib/gnu-sort/lib/pathmax.h @@ -0,0 +1,54 @@ +/* Define PATH_MAX somehow. Requires sys/types.h. + Copyright (C) 1992, 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. */ + +#ifndef _PATHMAX_H +# define _PATHMAX_H + +# if HAVE_UNISTD_H +# include +# endif + +/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define + PATH_MAX but might cause redefinition warnings when sys/param.h is + later included (as on MORE/BSD 4.3). */ +# if defined _POSIX_VERSION || (defined HAVE_LIMITS_H && !defined __GNUC__) +# include +# endif + +# ifndef _POSIX_PATH_MAX +# define _POSIX_PATH_MAX 255 +# endif + +# if !defined PATH_MAX && defined _PC_PATH_MAX +# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \ + : pathconf ("/", _PC_PATH_MAX)) +# endif + +/* Don't include sys/param.h if it already has been. */ +# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN +# include +# endif + +# if !defined PATH_MAX && defined MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# endif + +# ifndef PATH_MAX +# define PATH_MAX _POSIX_PATH_MAX +# endif + +#endif /* _PATHMAX_H */ diff --git a/contrib/gnu-sort/lib/physmem.c b/contrib/gnu-sort/lib/physmem.c new file mode 100644 index 0000000..4219c70 --- /dev/null +++ b/contrib/gnu-sort/lib/physmem.c @@ -0,0 +1,94 @@ +/* Calculate the size of physical memory. + Copyright 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. */ + +/* Written by Paul Eggert. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include "physmem.h" + +#if HAVE_UNISTD_H +# include +#endif + +#if HAVE_SYS_PSTAT_H +# include +#endif + +/* Return the total amount of physical memory. */ +double +physmem_total (void) +{ +#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE + { + double pages = sysconf (_SC_PHYS_PAGES); + double pagesize = sysconf (_SC_PAGESIZE); + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } +#endif + +#if HAVE_PSTAT_GETSTATIC + { + struct pst_static pss; + if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0)) + { + double pages = pss.physical_memory; + double pagesize = pss.page_size; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } + } +#endif + + /* Guess 64 MB. It's probably an older host, so guess small. */ + return 64 * 1024 * 1024; +} + +/* Return the amount of physical memory available. */ +double +physmem_available (void) +{ +#if defined _SC_AVPHYS_PAGES && defined _SC_PAGESIZE + { + double pages = sysconf (_SC_AVPHYS_PAGES); + double pagesize = sysconf (_SC_PAGESIZE); + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } +#endif + +#if HAVE_PSTAT_GETSTATIC && HAVE_PSTAT_GETDYNAMIC + { + struct pst_static pss; + struct pst_dynamic psd; + if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0) + && 0 <= pstat_getdynamic (&psd, sizeof psd, 1, 0)) + { + double pages = psd.psd_free; + double pagesize = pss.page_size; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } + } +#endif + + /* Guess 25% of physical memory. */ + return physmem_total () / 4; +} diff --git a/contrib/gnu-sort/lib/physmem.h b/contrib/gnu-sort/lib/physmem.h new file mode 100644 index 0000000..d9a9809 --- /dev/null +++ b/contrib/gnu-sort/lib/physmem.h @@ -0,0 +1,19 @@ +#ifndef PHYSMEM_H_ +# define PHYSMEM_H_ 1 + +# if HAVE_CONFIG_H +# include +# endif + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +double physmem_total PARAMS ((void)); +double physmem_available PARAMS ((void)); + +#endif /* PHYSMEM_H_ */ diff --git a/contrib/gnu-sort/lib/posixver.c b/contrib/gnu-sort/lib/posixver.c new file mode 100644 index 0000000..c45ac31 --- /dev/null +++ b/contrib/gnu-sort/lib/posixver.c @@ -0,0 +1,58 @@ +/* Which POSIX version to conform to, for utilities. + + 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 Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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 + +#include + +#include +#if !HAVE_DECL_GETENV && !defined getenv +char *getenv (); +#endif + +#if HAVE_UNISTD_H +# include +#endif +#ifndef _POSIX2_VERSION +# define _POSIX2_VERSION 0 +#endif + +/* The POSIX version that utilities should conform to. The default is + specified by the system. */ + +int +posix2_version (void) +{ + long int v = _POSIX2_VERSION; + char const *s = getenv ("_POSIX2_VERSION"); + + if (s && *s) + { + char *e; + long int i = strtol (s, &e, 10); + if (! *e) + v = i; + } + + return v < INT_MIN ? INT_MIN : v < INT_MAX ? v : INT_MAX; +} diff --git a/contrib/gnu-sort/lib/posixver.h b/contrib/gnu-sort/lib/posixver.h new file mode 100644 index 0000000..b64f6a2 --- /dev/null +++ b/contrib/gnu-sort/lib/posixver.h @@ -0,0 +1 @@ +int posix2_version (void); diff --git a/contrib/gnu-sort/lib/quote.c b/contrib/gnu-sort/lib/quote.c new file mode 100644 index 0000000..0ce935c --- /dev/null +++ b/contrib/gnu-sort/lib/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/contrib/gnu-sort/lib/quote.h b/contrib/gnu-sort/lib/quote.h new file mode 100644 index 0000000..5de896b --- /dev/null +++ b/contrib/gnu-sort/lib/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/contrib/gnu-sort/lib/quotearg.c b/contrib/gnu-sort/lib/quotearg.c new file mode 100644 index 0000000..9d43956 --- /dev/null +++ b/contrib/gnu-sort/lib/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/contrib/gnu-sort/lib/quotearg.h b/contrib/gnu-sort/lib/quotearg.h new file mode 100644 index 0000000..1134a51 --- /dev/null +++ b/contrib/gnu-sort/lib/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/contrib/gnu-sort/lib/stdio-safer.h b/contrib/gnu-sort/lib/stdio-safer.h new file mode 100644 index 0000000..bd5cbd8 --- /dev/null +++ b/contrib/gnu-sort/lib/stdio-safer.h @@ -0,0 +1,9 @@ +#ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +FILE *fopen_safer PARAMS ((char const *, char const *)); diff --git a/contrib/gnu-sort/lib/unistd-safer.h b/contrib/gnu-sort/lib/unistd-safer.h new file mode 100644 index 0000000..1b6a0f7 --- /dev/null +++ b/contrib/gnu-sort/lib/unistd-safer.h @@ -0,0 +1,9 @@ +#ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +int dup_safer PARAMS ((int)); diff --git a/contrib/gnu-sort/lib/version-etc.c b/contrib/gnu-sort/lib/version-etc.c new file mode 100644 index 0000000..4d4facf --- /dev/null +++ b/contrib/gnu-sort/lib/version-etc.c @@ -0,0 +1,71 @@ +/* Utility to help print --version output in a consistent format. + Copyright (C) 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 Jim Meyering. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include "unlocked-io.h" +#include "version-etc.h" + +#if ENABLE_NLS +# include +# define _(Text) gettext (Text) +#else +# define _(Text) Text +#endif + +/* Default copyright goes to the FSF. */ + +char* version_etc_copyright = + /* Do *not* mark this string for translation. */ + "Copyright (C) 2002 Free Software Foundation, Inc."; + + +/* Display the --version information the standard way. + + If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of + the program. The formats are therefore: + + PACKAGE VERSION + + or + + COMMAND_NAME (PACKAGE) VERSION. */ +void +version_etc (FILE *stream, + const char *command_name, const char *package, + const char *version, const char *authors) +{ + if (command_name) + fprintf (stream, "%s (%s) %s\n", command_name, package, version); + else + fprintf (stream, "%s %s\n", package, version); + fprintf (stream, _("Written by %s.\n"), authors); + putc ('\n', stream); + + fputs (version_etc_copyright, stream); + putc ('\n', stream); + + fputs (_("\ +This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"), + stream); +} diff --git a/contrib/gnu-sort/lib/version-etc.h b/contrib/gnu-sort/lib/version-etc.h new file mode 100644 index 0000000..ae223d4 --- /dev/null +++ b/contrib/gnu-sort/lib/version-etc.h @@ -0,0 +1,38 @@ +/* Utility to help print --version output in a consistent format. + Copyright (C) 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. */ + +/* Written by Jim Meyering. */ + +#ifndef VERSION_ETC_H +# define VERSION_ETC_H 1 + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +extern char *version_etc_copyright; + +void +version_etc PARAMS ((FILE *stream, + const char *command_name, const char *package, + const char *version, const char *authors)); + +#endif /* VERSION_ETC_H */ diff --git a/contrib/gnu-sort/lib/xalloc.h b/contrib/gnu-sort/lib/xalloc.h new file mode 100644 index 0000000..098a6c2 --- /dev/null +++ b/contrib/gnu-sort/lib/xalloc.h @@ -0,0 +1,87 @@ +/* xalloc.h -- malloc with out-of-memory checking + Copyright (C) 1990-1998, 1999, 2000 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 + +/* Exit value when the requested amount of memory is not available. + It is initialized to EXIT_FAILURE, but the caller may set it to + some other value. */ +extern int xalloc_exit_failure; + +/* 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/contrib/gnu-sort/lib/xmalloc.c b/contrib/gnu-sort/lib/xmalloc.c new file mode 100644 index 0000000..2f103d6 --- /dev/null +++ b/contrib/gnu-sort/lib/xmalloc.c @@ -0,0 +1,116 @@ +/* xmalloc.c -- malloc with out of memory checking + Copyright (C) 1990-1999, 2000 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 "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 + +/* Exit value when the requested amount of memory is not available. + The caller may set it to some other value. */ +int xalloc_exit_failure = EXIT_FAILURE; + +/* 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 (xalloc_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/contrib/gnu-sort/lib/xmemcoll.c b/contrib/gnu-sort/lib/xmemcoll.c new file mode 100644 index 0000000..0e35cb6 --- /dev/null +++ b/contrib/gnu-sort/lib/xmemcoll.c @@ -0,0 +1,70 @@ +/* Locale-specific memory comparison. + 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; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Contributed by Paul Eggert . */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#include + +#if ENABLE_NLS +# include +# define _(Text) gettext (Text) +#else +# define _(Text) Text +#endif + +#include "error.h" +#include "memcoll.h" +#include "quotearg.h" +#include "xmemcoll.h" + +/* Exit value when xmemcoll fails. + The caller may set it to some other value. */ +int xmemcoll_exit_failure = EXIT_FAILURE; + +/* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according + to the LC_COLLATE locale. S1 and S2 do not overlap, and are not + adjacent. Temporarily modify the bytes after S1 and S2, but + restore their original contents before returning. Report an error + and exit if there is an error. */ + +int +xmemcoll (char *s1, size_t s1len, char *s2, size_t s2len) +{ + int diff = memcoll (s1, s1len, s2, s2len); + int collation_errno = errno; + + if (collation_errno) + { + error (0, collation_errno, _("string comparison failed")); + error (0, 0, _("Set LC_ALL='C' to work around the problem.")); + error (xmemcoll_exit_failure, 0, + _("The strings compared were %s and %s."), + quotearg_n_style_mem (0, locale_quoting_style, s1, s1len), + quotearg_n_style_mem (1, locale_quoting_style, s2, s2len)); + } + + return diff; +} diff --git a/contrib/gnu-sort/lib/xmemcoll.h b/contrib/gnu-sort/lib/xmemcoll.h new file mode 100644 index 0000000..dfda0fc --- /dev/null +++ b/contrib/gnu-sort/lib/xmemcoll.h @@ -0,0 +1,2 @@ +extern int xmemcoll_exit_failure; +int xmemcoll (char *, size_t, char *, size_t); diff --git a/contrib/gnu-sort/lib/xstrtol.c b/contrib/gnu-sort/lib/xstrtol.c new file mode 100644 index 0000000..446d62e --- /dev/null +++ b/contrib/gnu-sort/lib/xstrtol.c @@ -0,0 +1,302 @@ +/* A more useful interface to strtol. + Copyright (C) 1995, 1996, 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. */ + +/* Written by Jim Meyering. */ + +#if HAVE_CONFIG_H +# include +#endif + +#ifndef __strtol +# define __strtol strtol +# define __strtol_t long int +# define __xstrtol xstrtol +#endif + +/* Some pre-ANSI implementations (e.g. SunOS 4) + need stderr defined if assertion checking is enabled. */ +#include + +#if STDC_HEADERS +# include +#endif + +#if HAVE_STRING_H +# include +#else +# include +# ifndef strchr +# define strchr index +# endif +#endif + +#include +#include + +#include +#ifndef errno +extern int errno; +#endif + +#if HAVE_LIMITS_H +# include +#endif + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +/* The extra casts work around common compiler bugs. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. + It is necessary at least when t == time_t. */ +#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) +#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t)) + +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) + +#include "xstrtol.h" + +#if !HAVE_DECL_STRTOL && !defined strtol +long int strtol (); +#endif + +#if !HAVE_DECL_STRTOUL && !defined strtoul +unsigned long int strtoul (); +#endif + +#if !HAVE_DECL_STRTOIMAX && !defined strtoimax +intmax_t strtoimax (); +#endif + +#if !HAVE_DECL_STRTOUMAX && !defined strtoumax +uintmax_t strtoumax (); +#endif + +static int +bkm_scale (__strtol_t *x, int scale_factor) +{ + __strtol_t product = *x * scale_factor; + if (*x != product / scale_factor) + return 1; + *x = product; + return 0; +} + +static int +bkm_scale_by_power (__strtol_t *x, int base, int power) +{ + while (power--) + if (bkm_scale (x, base)) + return 1; + + return 0; +} + +/* FIXME: comment. */ + +strtol_error +__xstrtol (const char *s, char **ptr, int strtol_base, + __strtol_t *val, const char *valid_suffixes) +{ + char *t_ptr; + char **p; + __strtol_t tmp; + + assert (0 <= strtol_base && strtol_base <= 36); + + p = (ptr ? ptr : &t_ptr); + + if (! TYPE_SIGNED (__strtol_t)) + { + const char *q = s; + while (ISSPACE ((unsigned char) *q)) + ++q; + if (*q == '-') + return LONGINT_INVALID; + } + + errno = 0; + tmp = __strtol (s, p, strtol_base); + if (errno != 0) + return LONGINT_OVERFLOW; + + if (*p == s) + { + /* If there is no number but there is a valid suffix, assume the + number is 1. The string is invalid otherwise. */ + if (valid_suffixes && **p && strchr (valid_suffixes, **p)) + tmp = 1; + else + return LONGINT_INVALID; + } + + /* Let valid_suffixes == NULL mean `allow any suffix'. */ + /* FIXME: update all callers except the ones that allow suffixes + after the number, changing last parameter NULL to `""'. */ + if (!valid_suffixes) + { + *val = tmp; + return LONGINT_OK; + } + + if (**p != '\0') + { + int base = 1024; + int suffixes = 1; + int overflow; + + if (!strchr (valid_suffixes, **p)) + { + *val = tmp; + return LONGINT_INVALID_SUFFIX_CHAR; + } + + if (strchr (valid_suffixes, '0')) + { + /* The ``valid suffix'' '0' is a special flag meaning that + an optional second suffix is allowed, which can change + the base. A suffix "B" (e.g. "100MB") stands for a power + of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for + a power of 1024. If no suffix (e.g. "100M"), assume + power-of-1024. */ + + switch (p[0][1]) + { + case 'i': + if (p[0][2] == 'B') + suffixes += 2; + break; + + case 'B': + case 'D': /* 'D' is obsolescent */ + base = 1000; + suffixes++; + break; + } + } + + switch (**p) + { + case 'b': + overflow = bkm_scale (&tmp, 512); + break; + + case 'B': + overflow = bkm_scale (&tmp, 1024); + break; + + case 'c': + overflow = 0; + break; + + case 'E': /* exa or exbi */ + overflow = bkm_scale_by_power (&tmp, base, 6); + break; + + case 'G': /* giga or gibi */ + case 'g': /* 'g' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 3); + break; + + case 'k': /* kilo */ + case 'K': /* kibi */ + overflow = bkm_scale_by_power (&tmp, base, 1); + break; + + case 'M': /* mega or mebi */ + case 'm': /* 'm' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 2); + break; + + case 'P': /* peta or pebi */ + overflow = bkm_scale_by_power (&tmp, base, 5); + break; + + case 'T': /* tera or tebi */ + case 't': /* 't' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 4); + break; + + case 'w': + overflow = bkm_scale (&tmp, 2); + break; + + case 'Y': /* yotta or 2**80 */ + overflow = bkm_scale_by_power (&tmp, base, 8); + break; + + case 'Z': /* zetta or 2**70 */ + overflow = bkm_scale_by_power (&tmp, base, 7); + break; + + default: + *val = tmp; + return LONGINT_INVALID_SUFFIX_CHAR; + break; + } + + if (overflow) + return LONGINT_OVERFLOW; + + (*p) += suffixes; + } + + *val = tmp; + return LONGINT_OK; +} + +#ifdef TESTING_XSTRTO + +# include +# include "error.h" + +char *program_name; + +int +main (int argc, char** argv) +{ + strtol_error s_err; + int i; + + program_name = argv[0]; + for (i=1; i%lu (%s)\n", argv[i], val, p); + } + else + { + STRTOL_FATAL_ERROR (argv[i], "arg", s_err); + } + } + exit (0); +} + +#endif /* TESTING_XSTRTO */ diff --git a/contrib/gnu-sort/lib/xstrtol.h b/contrib/gnu-sort/lib/xstrtol.h new file mode 100644 index 0000000..513855f --- /dev/null +++ b/contrib/gnu-sort/lib/xstrtol.h @@ -0,0 +1,82 @@ +/* A more useful interface to strtol. + Copyright 1995, 1996, 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. */ + +#ifndef XSTRTOL_H_ +# define XSTRTOL_H_ 1 + +# if HAVE_INTTYPES_H +# include /* for uintmax_t */ +# endif + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +# ifndef _STRTOL_ERROR +enum strtol_error + { + LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW + }; +typedef enum strtol_error strtol_error; +# endif + +# define _DECLARE_XSTRTOL(name, type) \ + strtol_error \ + name PARAMS ((const char *s, char **ptr, int base, \ + type *val, const char *valid_suffixes)); +_DECLARE_XSTRTOL (xstrtol, long int) +_DECLARE_XSTRTOL (xstrtoul, unsigned long int) +_DECLARE_XSTRTOL (xstrtoimax, intmax_t) +_DECLARE_XSTRTOL (xstrtoumax, uintmax_t) + +# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \ + do \ + { \ + switch ((Err)) \ + { \ + case LONGINT_OK: \ + abort (); \ + \ + case LONGINT_INVALID: \ + error ((Exit_code), 0, "invalid %s `%s'", \ + (Argument_type_string), (Str)); \ + break; \ + \ + case LONGINT_INVALID_SUFFIX_CHAR: \ + error ((Exit_code), 0, "invalid character following %s in `%s'", \ + (Argument_type_string), (Str)); \ + break; \ + \ + case LONGINT_OVERFLOW: \ + error ((Exit_code), 0, "%s `%s' too large", \ + (Argument_type_string), (Str)); \ + break; \ + } \ + } \ + while (0) + +# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \ + _STRTOL_ERROR (2, Str, Argument_type_string, Err) + +# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \ + _STRTOL_ERROR (0, Str, Argument_type_string, Err) + +#endif /* not XSTRTOL_H_ */ diff --git a/contrib/gnu-sort/lib/xstrtoul.c b/contrib/gnu-sort/lib/xstrtoul.c new file mode 100644 index 0000000..6140bbe --- /dev/null +++ b/contrib/gnu-sort/lib/xstrtoul.c @@ -0,0 +1,4 @@ +#define __strtol strtoul +#define __strtol_t unsigned long int +#define __xstrtol xstrtoul +#include "xstrtol.c" diff --git a/contrib/gnu-sort/lib/xstrtoumax.c b/contrib/gnu-sort/lib/xstrtoumax.c new file mode 100644 index 0000000..04d7cf9 --- /dev/null +++ b/contrib/gnu-sort/lib/xstrtoumax.c @@ -0,0 +1,31 @@ +/* xstrtoumax.c -- A more useful interface to strtoumax. + Copyright 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. */ + +/* Written by Paul Eggert. */ + +#if HAVE_CONFIG_H +# include +#endif + +#if HAVE_INTTYPES_H +# include +#endif + +#define __strtol strtoumax +#define __strtol_t uintmax_t +#define __xstrtol xstrtoumax +#include "xstrtol.c" diff --git a/contrib/gnu-sort/man/sort.1 b/contrib/gnu-sort/man/sort.1 new file mode 100644 index 0000000..919d355 --- /dev/null +++ b/contrib/gnu-sort/man/sort.1 @@ -0,0 +1,113 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.25. +.TH SORT "1" "February 2002" "sort (textutils) 2.0.21" "User Commands" +.SH NAME +sort \- sort lines of text files +.SH SYNOPSIS +.B sort +[\fIOPTION\fR]... [\fIFILE\fR]... +.SH DESCRIPTION +.\" Add any additional description here +.PP +Write sorted concatenation of all FILE(s) to standard output. +.PP +Ordering options: +.PP +Mandatory arguments to long options are mandatory for short options too. +.HP +\fB\-b\fR, \fB\-\-ignore\-leading\-blanks\fR ignore leading blanks +.TP +\fB\-d\fR, \fB\-\-dictionary\-order\fR +consider only blanks and alphanumeric characters +.TP +\fB\-f\fR, \fB\-\-ignore\-case\fR +fold lower case to upper case characters +.TP +\fB\-g\fR, \fB\-\-general\-numeric\-sort\fR +compare according to general numerical value +.TP +\fB\-i\fR, \fB\-\-ignore\-nonprinting\fR +consider only printable characters +.TP +\fB\-M\fR, \fB\-\-month\-sort\fR +compare (unknown) < `JAN' < ... < `DEC' +.TP +\fB\-n\fR, \fB\-\-numeric\-sort\fR +compare according to string numerical value +.TP +\fB\-r\fR, \fB\-\-reverse\fR +reverse the result of comparisons +.PP +Other options: +.TP +\fB\-c\fR, \fB\-\-check\fR +check whether input is sorted; do not sort +.TP +\fB\-k\fR, \fB\-\-key\fR=\fIPOS1[\fR,POS2] +start a key at POS1, end it at POS 2 (origin 1) +.TP +\fB\-m\fR, \fB\-\-merge\fR +merge already sorted files; do not sort +.TP +\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR +write result to FILE instead of standard output +.TP +\fB\-s\fR, \fB\-\-stable\fR +stabilize sort by disabling last-resort comparison +.TP +\fB\-S\fR, \fB\-\-buffer\-size\fR=\fISIZE\fR +use SIZE for main memory buffer +.HP +\fB\-t\fR, \fB\-\-field\-separator\fR=\fISEP\fR use SEP instead of non- to whitespace transition +.TP +\fB\-T\fR, \fB\-\-temporary\-directory\fR=\fIDIR\fR +use DIR for temporaries, not $TMPDIR or /tmp +multiple options specify multiple directories +.TP +\fB\-u\fR, \fB\-\-unique\fR +with \fB\-c\fR: check for strict ordering +otherwise: output only the first of an equal run +.TP +\fB\-z\fR, \fB\-\-zero\-terminated\fR +end lines with 0 byte, not newline +.TP +\fB\-\-help\fR +display this help and exit +.TP +\fB\-\-version\fR +output version information and exit +.PP +POS is F[.C][OPTS], where F is the field number and C the character position +in the field. OPTS is one or more single-letter ordering options, which +override global ordering options for that key. If no key is given, use the +entire line as the key. +.PP +SIZE may be followed by the following multiplicative suffixes: +% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y. +.PP +With no FILE, or when FILE is -, read standard input. +.PP +*** WARNING *** +The locale specified by the environment affects sort order. +Set LC_ALL=C to get the traditional sort order that uses +native byte values. +.SH AUTHOR +Written by Mike Haertel and Paul Eggert. +.SH "REPORTING BUGS" +Report bugs to . +.SH COPYRIGHT +Copyright \(co 2002 Free Software Foundation, Inc. +.br +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +.SH "SEE ALSO" +The full documentation for +.B sort +is maintained as a Texinfo manual. If the +.B info +and +.B sort +programs are properly installed at your site, the command +.IP +.B info sort +.PP +should give you access to the complete manual. diff --git a/contrib/gnu-sort/src/sort.c b/contrib/gnu-sort/src/sort.c new file mode 100644 index 0000000..a2b0ef16 --- /dev/null +++ b/contrib/gnu-sort/src/sort.c @@ -0,0 +1,2502 @@ +/* sort - sort lines of text (with all kinds of options). + Copyright (C) 88, 1991-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 December 1988 by Mike Haertel. + The author may be reached (Email) at the address mike@gnu.ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. + + Ĝrn E. Hansen added NLS support in 1997. */ + +#include + +#include +#include +#include +#include +#include +#include "system.h" +#include "long-options.h" +#include "error.h" +#include "hard-locale.h" +#include "human.h" +#include "physmem.h" +#include "posixver.h" +#include "stdio-safer.h" +#include "xmemcoll.h" +#include "xstrtol.h" + +#if HAVE_SYS_RESOURCE_H +# include +#endif +#ifndef RLIMIT_DATA +struct rlimit { size_t rlim_cur; }; +# define getrlimit(Resource, Rlp) (-1) +#endif + +/* The official name of this program (e.g., no `g' prefix). */ +#define PROGRAM_NAME "sort" + +#define AUTHORS N_ ("Mike Haertel and Paul Eggert") + +#if defined ENABLE_NLS && HAVE_LANGINFO_H +# include +#endif + +#ifndef SA_NOCLDSTOP +# define sigprocmask(How, Set, Oset) /* empty */ +# define sigset_t int +#endif + +#ifndef STDC_HEADERS +double strtod (); +#endif + +/* Undefine, to avoid warning about redefinition on some systems. */ +/* FIXME: Remove these: use MIN/MAX from sys2.h. */ +#undef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#undef max +#define max(a, b) ((a) > (b) ? (a) : (b)) + +#define UCHAR_LIM (UCHAR_MAX + 1) +#define UCHAR(c) ((unsigned char) (c)) + +#ifndef DEFAULT_TMPDIR +# define DEFAULT_TMPDIR "/tmp" +#endif + +/* Use this as exit status in case of error, not EXIT_FAILURE. This + is necessary because EXIT_FAILURE is usually 1 and POSIX requires + that sort exit with status 1 IFF invoked with -c and the input is + not properly sorted. Any other irregular exit must exit with a + status code greater than 1. */ +#define SORT_FAILURE 2 +#define SORT_OUT_OF_ORDER 1 + +#define C_DECIMAL_POINT '.' +#define NEGATION_SIGN '-' +#define NUMERIC_ZERO '0' + +#ifdef ENABLE_NLS + +static char decimal_point; +static int th_sep; /* if CHAR_MAX + 1, then there is no thousands separator */ + +/* Nonzero if the corresponding locales are hard. */ +static int hard_LC_COLLATE; +# if HAVE_NL_LANGINFO +static int hard_LC_TIME; +# endif + +# define IS_THOUSANDS_SEP(x) ((x) == th_sep) + +#else + +# define decimal_point C_DECIMAL_POINT +# define IS_THOUSANDS_SEP(x) 0 + +#endif + +#define NONZERO(x) (x != 0) + +/* The kind of blanks for '-b' to skip in various options. */ +enum blanktype { bl_start, bl_end, bl_both }; + +/* The character marking end of line. Default to \n. */ +static int eolchar = '\n'; + +/* Lines are held in core as counted strings. */ +struct line +{ + char *text; /* Text of the line. */ + size_t length; /* Length including final newline. */ + char *keybeg; /* Start of first key. */ + char *keylim; /* Limit of first key. */ +}; + +/* Input buffers. */ +struct buffer +{ + char *buf; /* Dynamically allocated buffer, + partitioned into 3 regions: + - input data; + - unused area; + - an array of lines, in reverse order. */ + size_t used; /* Number of bytes used for input data. */ + size_t nlines; /* Number of lines in the line array. */ + size_t alloc; /* Number of bytes allocated. */ + size_t left; /* Number of bytes left from previous reads. */ + size_t line_bytes; /* Number of bytes to reserve for each line. */ + int eof; /* An EOF has been read. */ +}; + +struct keyfield +{ + size_t sword; /* Zero-origin 'word' to start at. */ + size_t schar; /* Additional characters to skip. */ + int skipsblanks; /* Skip leading white space at start. */ + size_t eword; /* Zero-origin first word after field. */ + size_t echar; /* Additional characters in field. */ + int skipeblanks; /* Skip trailing white space at finish. */ + int *ignore; /* Boolean array of characters to ignore. */ + char *translate; /* Translation applied to characters. */ + int numeric; /* Flag for numeric comparison. Handle + strings of digits with optional decimal + point, but no exponential notation. */ + int general_numeric; /* Flag for general, numeric comparison. + Handle numbers in exponential notation. */ + int month; /* Flag for comparison by month name. */ + int reverse; /* Reverse the sense of comparison. */ + struct keyfield *next; /* Next keyfield to try. */ +}; + +struct month +{ + char *name; + int val; +}; + +/* The name this program was run with. */ +char *program_name; + +/* FIXME: None of these tables work with multibyte character sets. + Also, there are many other bugs when handling multibyte characters, + or even unibyte encodings where line boundaries are not in the + initial shift state. One way to fix this is to rewrite `sort' to + use wide characters internally, but doing this with good + performance is a bit tricky. */ + +/* Table of white space. */ +static int blanks[UCHAR_LIM]; + +/* Table of non-printing characters. */ +static int nonprinting[UCHAR_LIM]; + +/* Table of non-dictionary characters (not letters, digits, or blanks). */ +static int nondictionary[UCHAR_LIM]; + +/* Translation table folding lower case to upper. */ +static char fold_toupper[UCHAR_LIM]; + +#define MONTHS_PER_YEAR 12 + +#if defined ENABLE_NLS && HAVE_NL_LANGINFO +# define MONTHTAB_CONST /* empty */ +#else +# define MONTHTAB_CONST const +#endif + +/* Table mapping month names to integers. + Alphabetic order allows binary search. */ +static MONTHTAB_CONST struct month monthtab[] = +{ + {"APR", 4}, + {"AUG", 8}, + {"DEC", 12}, + {"FEB", 2}, + {"JAN", 1}, + {"JUL", 7}, + {"JUN", 6}, + {"MAR", 3}, + {"MAY", 5}, + {"NOV", 11}, + {"OCT", 10}, + {"SEP", 9} +}; + +/* During the merge phase, the number of files to merge at once. */ +#define NMERGE 16 + +/* Minimum size for a merge or check buffer. */ +#define MIN_MERGE_BUFFER_SIZE (2 + sizeof (struct line)) + +/* Minimum sort size; the code might not work with smaller sizes. */ +#define MIN_SORT_SIZE (NMERGE * MIN_MERGE_BUFFER_SIZE) + +/* The number of bytes needed for a merge or check buffer, which can + function relatively efficiently even if it holds only one line. If + a longer line is seen, this value is increased. */ +static size_t merge_buffer_size = MAX (MIN_MERGE_BUFFER_SIZE, 256 * 1024); + +/* The approximate maximum number of bytes of main memory to use, as + specified by the user. Zero if the user has not specified a size. */ +static size_t sort_size; + +/* The guessed size for non-regular files. */ +#define INPUT_FILE_SIZE_GUESS (1024 * 1024) + +/* Array of directory names in which any temporary files are to be created. */ +static char const **temp_dirs; + +/* Number of temporary directory names used. */ +static size_t temp_dir_count; + +/* Number of allocated slots in temp_dirs. */ +static size_t temp_dir_alloc; + +/* Our process ID. */ +static pid_t process_id; + +/* Flag to reverse the order of all comparisons. */ +static int reverse; + +/* Flag for stable sort. This turns off the last ditch bytewise + comparison of lines, and instead leaves lines in the same order + they were read if all keys compare equal. */ +static int stable; + +/* Tab character separating fields. If NUL, then fields are separated + by the empty string between a non-whitespace character and a whitespace + character. */ +static char tab; + +/* Flag to remove consecutive duplicate lines from the output. + Only the last of a sequence of equal lines will be output. */ +static int unique; + +/* Nonzero if any of the input files are the standard input. */ +static int have_read_stdin; + +/* List of key field comparisons to be tried. */ +static struct keyfield *keylist; + +void +usage (int status) +{ + if (status != 0) + fprintf (stderr, _("Try `%s --help' for more information.\n"), + program_name); + else + { + printf (_("\ +Usage: %s [OPTION]... [FILE]...\n\ +"), + program_name); + fputs (_("\ +Write sorted concatenation of all FILE(s) to standard output.\n\ +\n\ +Ordering options:\n\ +\n\ +"), stdout); + fputs (_("\ +Mandatory arguments to long options are mandatory for short options too.\n\ +"), stdout); + fputs (_("\ + -b, --ignore-leading-blanks ignore leading blanks\n\ + -d, --dictionary-order consider only blanks and alphanumeric characters\n\ + -f, --ignore-case fold lower case to upper case characters\n\ +"), stdout); + fputs (_("\ + -g, --general-numeric-sort compare according to general numerical value\n\ + -i, --ignore-nonprinting consider only printable characters\n\ + -M, --month-sort compare (unknown) < `JAN' < ... < `DEC'\n\ + -n, --numeric-sort compare according to string numerical value\n\ + -r, --reverse reverse the result of comparisons\n\ +\n\ +"), stdout); + fputs (_("\ +Other options:\n\ +\n\ + -c, --check check whether input is sorted; do not sort\n\ + -k, --key=POS1[,POS2] start a key at POS1, end it at POS 2 (origin 1)\n\ + -m, --merge merge already sorted files; do not sort\n\ + -o, --output=FILE write result to FILE instead of standard output\n\ + -s, --stable stabilize sort by disabling last-resort comparison\n\ + -S, --buffer-size=SIZE use SIZE for main memory buffer\n\ +"), stdout); + printf (_("\ + -t, --field-separator=SEP use SEP instead of non- to whitespace transition\n\ + -T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or %s\n\ + multiple options specify multiple directories\n\ + -u, --unique with -c: check for strict ordering\n\ + otherwise: output only the first of an equal run\n\ +"), DEFAULT_TMPDIR); + fputs (_("\ + -z, --zero-terminated end lines with 0 byte, not newline\n\ +"), stdout); + fputs (HELP_OPTION_DESCRIPTION, stdout); + fputs (VERSION_OPTION_DESCRIPTION, stdout); + fputs (_("\ +\n\ +POS is F[.C][OPTS], where F is the field number and C the character position\n\ +in the field. OPTS is one or more single-letter ordering options, which\n\ +override global ordering options for that key. If no key is given, use the\n\ +entire line as the key.\n\ +\n\ +SIZE may be followed by the following multiplicative suffixes:\n\ +"), stdout); + fputs (_("\ +% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y.\n\ +\n\ +With no FILE, or when FILE is -, read standard input.\n\ +\n\ +*** WARNING ***\n\ +The locale specified by the environment affects sort order.\n\ +Set LC_ALL=C to get the traditional sort order that uses\n\ +native byte values.\n\ +"), stdout ); + puts (_("\nReport bugs to .")); + } + /* Don't use EXIT_FAILURE here in case it is defined to be 1. + POSIX requires that sort return 1 IFF invoked with -c and + the input is not properly sorted. */ + assert (status == 0 || status == SORT_FAILURE); + exit (status); +} + +#define COMMON_SHORT_OPTIONS "-bcdfgik:mMno:rsS:t:T:uz" + +static struct option const long_options[] = +{ + {"ignore-leading-blanks", no_argument, NULL, 'b'}, + {"check", no_argument, NULL, 'c'}, + {"dictionary-order", no_argument, NULL, 'd'}, + {"ignore-case", no_argument, NULL, 'f'}, + {"general-numeric-sort", no_argument, NULL, 'g'}, + {"ignore-nonprinting", no_argument, NULL, 'i'}, + {"key", required_argument, NULL, 'k'}, + {"merge", no_argument, NULL, 'm'}, + {"month-sort", no_argument, NULL, 'M'}, + {"numeric-sort", no_argument, NULL, 'n'}, + {"output", required_argument, NULL, 'o'}, + {"reverse", no_argument, NULL, 'r'}, + {"stable", no_argument, NULL, 's'}, + {"buffer-size", required_argument, NULL, 'S'}, + {"field-separator", required_argument, NULL, 't'}, + {"temporary-directory", required_argument, NULL, 'T'}, + {"unique", no_argument, NULL, 'u'}, + {"zero-terminated", no_argument, NULL, 'z'}, + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {0, 0, 0, 0}, +}; + +/* The set of signals that are caught. */ +static sigset_t caught_signals; + +/* The list of temporary files. */ +struct tempnode +{ + struct tempnode *volatile next; + char name[1]; /* Actual size is 1 + file name length. */ +}; +static struct tempnode *volatile temphead; + +/* Clean up any remaining temporary files. */ + +static void +cleanup (void) +{ + struct tempnode *node; + + for (node = temphead; node; node = node->next) + unlink (node->name); +} + +/* Report MESSAGE for FILE, then clean up and exit. */ + +static void die PARAMS ((char const *, char const *)) ATTRIBUTE_NORETURN; +static void +die (char const *message, char const *file) +{ + error (0, errno, "%s: %s", message, file); + exit (SORT_FAILURE); +} + +/* Create a new temporary file, returning its newly allocated name. + Store into *PFP a stream open for writing. */ + +static char * +create_temp_file (FILE **pfp) +{ + static char const slashbase[] = "/sortXXXXXX"; + static size_t temp_dir_index; + sigset_t oldset; + int fd; + int saved_errno; + char const *temp_dir = temp_dirs[temp_dir_index]; + size_t len = strlen (temp_dir); + struct tempnode *node = + (struct tempnode *) xmalloc (sizeof node->next + len + sizeof slashbase); + char *file = node->name; + + memcpy (file, temp_dir, len); + memcpy (file + len, slashbase, sizeof slashbase); + node->next = temphead; + if (++temp_dir_index == temp_dir_count) + temp_dir_index = 0; + + /* Create the temporary file in a critical section, to avoid races. */ + sigprocmask (SIG_BLOCK, &caught_signals, &oldset); + fd = mkstemp (file); + if (0 <= fd) + temphead = node; + saved_errno = errno; + sigprocmask (SIG_SETMASK, &oldset, NULL); + errno = saved_errno; + + if (fd < 0 || (*pfp = fdopen (fd, "w")) == NULL) + die (_("cannot create temporary file"), file); + + return file; +} + +static FILE * +xfopen (const char *file, const char *how) +{ + FILE *fp; + + if (STREQ (file, "-")) + { + if (*how == 'r') + { + have_read_stdin = 1; + fp = stdin; + } + else + fp = stdout; + } + else + { + if ((fp = fopen_safer (file, how)) == NULL) + die (_("open failed"), file); + } + + return fp; +} + +/* Close FP, whose name is FILE, and report any errors. */ + +static void +xfclose (FILE *fp, char const *file) +{ + if (fp == stdin) + { + /* Allow reading stdin from tty more than once. */ + if (feof (fp)) + clearerr (fp); + } + else + { + if (fclose (fp) != 0) + die (_("close failed"), file); + } +} + +static void +write_bytes (const char *buf, size_t n_bytes, FILE *fp, const char *output_file) +{ + if (fwrite (buf, 1, n_bytes, fp) != n_bytes) + die (_("write failed"), output_file); +} + +/* Append DIR to the array of temporary directory names. */ +static void +add_temp_dir (char const *dir) +{ + if (temp_dir_count == temp_dir_alloc) + { + temp_dir_alloc = temp_dir_alloc ? temp_dir_alloc * 2 : 16; + temp_dirs = xrealloc (temp_dirs, sizeof (temp_dirs) * temp_dir_alloc); + } + + temp_dirs[temp_dir_count++] = dir; +} + +/* Search through the list of temporary files for NAME; + remove it if it is found on the list. */ + +static void +zaptemp (const char *name) +{ + struct tempnode *volatile *pnode; + struct tempnode *node; + + for (pnode = &temphead; (node = *pnode); pnode = &node->next) + if (node->name == name) + { + unlink (name); + *pnode = node->next; + free ((char *) node); + break; + } +} + +#if defined ENABLE_NLS && HAVE_NL_LANGINFO + +static int +struct_month_cmp (const void *m1, const void *m2) +{ + return strcmp (((const struct month *) m1)->name, + ((const struct month *) m2)->name); +} + +#endif + +/* Initialize the character class tables. */ + +static void +inittables (void) +{ + int i; + + for (i = 0; i < UCHAR_LIM; ++i) + { + if (ISBLANK (i)) + blanks[i] = 1; + if (!ISPRINT (i)) + nonprinting[i] = 1; + if (!ISALNUM (i) && !ISBLANK (i)) + nondictionary[i] = 1; + if (ISLOWER (i)) + fold_toupper[i] = toupper (i); + else + fold_toupper[i] = i; + } + +#if defined ENABLE_NLS && HAVE_NL_LANGINFO + /* If we're not in the "C" locale, read different names for months. */ + if (hard_LC_TIME) + { + for (i = 0; i < MONTHS_PER_YEAR; i++) + { + char *s; + size_t s_len; + size_t j; + char *name; + + s = (char *) nl_langinfo (ABMON_1 + i); + s_len = strlen (s); + monthtab[i].name = name = (char *) xmalloc (s_len + 1); + monthtab[i].val = i + 1; + + for (j = 0; j < s_len; j++) + name[j] = fold_toupper[UCHAR (s[j])]; + name[j] = '\0'; + } + qsort ((void *) monthtab, MONTHS_PER_YEAR, + sizeof (struct month), struct_month_cmp); + } +#endif /* NLS */ +} + +/* Specify the amount of main memory to use when sorting. */ +static void +specify_sort_size (char const *s) +{ + uintmax_t n; + char *suffix; + enum strtol_error e = xstrtoumax (s, &suffix, 10, &n, "EgGkKmMPtTYZ"); + + /* The default unit is KiB. */ + if (e == LONGINT_OK && ISDIGIT (suffix[-1])) + { + if (n <= UINTMAX_MAX / 1024) + n *= 1024; + else + e = LONGINT_OVERFLOW; + } + + /* A 'b' suffix means bytes; a '%' suffix means percent of memory. */ + if (e == LONGINT_INVALID_SUFFIX_CHAR && ISDIGIT (suffix[-1]) && ! suffix[1]) + switch (suffix[0]) + { + case 'b': + e = LONGINT_OK; + break; + + case '%': + { + double mem = physmem_total () * n / 100; + + /* Use "<", not "<=", to avoid problems with rounding. */ + if (mem < UINTMAX_MAX) + { + n = mem; + e = LONGINT_OK; + } + else + e = LONGINT_OVERFLOW; + } + break; + } + + if (e == LONGINT_OK) + { + sort_size = n; + if (sort_size == n) + { + sort_size = MAX (sort_size, MIN_SORT_SIZE); + return; + } + + e = LONGINT_OVERFLOW; + } + + STRTOL_FATAL_ERROR (s, _("sort size"), e); +} + +/* Return the default sort size. */ +static size_t +default_sort_size (void) +{ + /* Let MEM be available memory or 1/8 of total memory, whichever + is greater. */ + double avail = physmem_available (); + double total = physmem_total (); + double mem = MAX (avail, total / 8); + struct rlimit rlimit; + + /* Let SIZE be MEM, but no more than the maximum object size or + system resource limits. Avoid the MIN macro here, as it is not + quite right when only one argument is floating point. Don't + bother to check for values like RLIM_INFINITY since in practice + they are not much less than SIZE_MAX. */ + size_t size = SIZE_MAX; + if (mem < size) + size = mem; + if (getrlimit (RLIMIT_DATA, &rlimit) == 0 && rlimit.rlim_cur < size) + size = rlimit.rlim_cur; +#ifdef RLIMIT_AS + if (getrlimit (RLIMIT_AS, &rlimit) == 0 && rlimit.rlim_cur < size) + size = rlimit.rlim_cur; +#endif + + /* Leave a large safety margin for the above limits, as failure can + occur when they are exceeded. */ + size /= 2; + +#ifdef RLIMIT_RSS + /* Leave a 1/16 margin for RSS to leave room for code, stack, etc. + Exceeding RSS is not fatal, but can be quite slow. */ + if (getrlimit (RLIMIT_RSS, &rlimit) == 0 && rlimit.rlim_cur / 16 * 15 < size) + size = rlimit.rlim_cur / 16 * 15; +#endif + + /* Use no less than the minimum. */ + return MAX (size, MIN_SORT_SIZE); +} + +/* Return the sort buffer size to use with the input files identified + by FPS and FILES, which are alternate paths to the same files. + NFILES gives the number of input files; NFPS may be less. Assume + that each input line requires LINE_BYTES extra bytes' worth of line + information. Return at most SIZE_BOUND. */ + +static size_t +sort_buffer_size (FILE *const *fps, int nfps, + char *const *files, int nfiles, + size_t line_bytes, size_t size_bound) +{ + /* In the worst case, each input byte is a newline. */ + size_t worst_case_per_input_byte = line_bytes + 1; + + /* Keep enough room for one extra input line and an extra byte. + This extra room might be needed when preparing to read EOF. */ + size_t size = worst_case_per_input_byte + 1; + + int i; + + for (i = 0; i < nfiles; i++) + { + struct stat st; + off_t file_size; + size_t worst_case; + + if ((i < nfps ? fstat (fileno (fps[i]), &st) + : strcmp (files[i], "-") == 0 ? fstat (STDIN_FILENO, &st) + : stat (files[i], &st)) + != 0) + die (_("stat failed"), files[i]); + + file_size = S_ISREG (st.st_mode) ? st.st_size : INPUT_FILE_SIZE_GUESS; + + /* Add the amount of memory needed to represent the worst case + where the input consists entirely of newlines followed by a + single non-newline. Check for overflow. */ + worst_case = file_size * worst_case_per_input_byte + 1; + if (file_size != worst_case / worst_case_per_input_byte + || size_bound - size <= worst_case) + return size_bound; + size += worst_case; + } + + return size; +} + +/* Initialize BUF. Reserve LINE_BYTES bytes for each line; LINE_BYTES + must be at least sizeof (struct line). Allocate ALLOC bytes + initially. */ + +static void +initbuf (struct buffer *buf, size_t line_bytes, size_t alloc) +{ + /* Ensure that the line array is properly aligned. If the desired + size cannot be allocated, repeatedly halve it until allocation + succeeds. The smaller allocation may hurt overall performance, + but that's better than failing. */ + for (;;) + { + alloc += sizeof (struct line) - alloc % sizeof (struct line); + buf->buf = malloc (alloc); + if (buf->buf) + break; + alloc /= 2; + if (alloc <= line_bytes + 1) + xalloc_die (); + } + + buf->line_bytes = line_bytes; + buf->alloc = alloc; + buf->used = buf->left = buf->nlines = 0; + buf->eof = 0; +} + +/* Return one past the limit of the line array. */ + +static inline struct line * +buffer_linelim (struct buffer const *buf) +{ + return (struct line *) (buf->buf + buf->alloc); +} + +/* Return a pointer to the first character of the field specified + by KEY in LINE. */ + +static char * +begfield (const struct line *line, const struct keyfield *key) +{ + register char *ptr = line->text, *lim = ptr + line->length - 1; + register size_t sword = key->sword; + register size_t schar = key->schar; + + if (tab) + while (ptr < lim && sword--) + { + while (ptr < lim && *ptr != tab) + ++ptr; + if (ptr < lim) + ++ptr; + } + else + while (ptr < lim && sword--) + { + while (ptr < lim && blanks[UCHAR (*ptr)]) + ++ptr; + while (ptr < lim && !blanks[UCHAR (*ptr)]) + ++ptr; + } + + if (key->skipsblanks) + while (ptr < lim && blanks[UCHAR (*ptr)]) + ++ptr; + + if (schar < lim - ptr) + ptr += schar; + else + ptr = lim; + + return ptr; +} + +/* Return the limit of (a pointer to the first character after) the field + in LINE specified by KEY. */ + +static char * +limfield (const struct line *line, const struct keyfield *key) +{ + register char *ptr = line->text, *lim = ptr + line->length - 1; + register size_t eword = key->eword, echar = key->echar; + + /* Note: from the POSIX spec: + The leading field separator itself is included in + a field when -t is not used. FIXME: move this comment up... */ + + /* Move PTR past EWORD fields or to one past the last byte on LINE, + whichever comes first. If there are more than EWORD fields, leave + PTR pointing at the beginning of the field having zero-based index, + EWORD. If a delimiter character was specified (via -t), then that + `beginning' is the first character following the delimiting TAB. + Otherwise, leave PTR pointing at the first `blank' character after + the preceding field. */ + if (tab) + while (ptr < lim && eword--) + { + while (ptr < lim && *ptr != tab) + ++ptr; + if (ptr < lim && (eword | echar)) + ++ptr; + } + else + while (ptr < lim && eword--) + { + while (ptr < lim && blanks[UCHAR (*ptr)]) + ++ptr; + while (ptr < lim && !blanks[UCHAR (*ptr)]) + ++ptr; + } + +#ifdef POSIX_UNSPECIFIED + /* The following block of code makes GNU sort incompatible with + standard Unix sort, so it's ifdef'd out for now. + The POSIX spec isn't clear on how to interpret this. + FIXME: request clarification. + + From: kwzh@gnu.ai.mit.edu (Karl Heuer) + Date: Thu, 30 May 96 12:20:41 -0400 + + [...]I believe I've found another bug in `sort'. + + $ cat /tmp/sort.in + a b c 2 d + pq rs 1 t + $ textutils-1.15/src/sort +0.6 -0.7 skipsblanks) + while (ptr < lim && blanks[UCHAR (*ptr)]) + ++ptr; + + /* Advance PTR by ECHAR (if possible), but no further than LIM. */ + if (echar < lim - ptr) + ptr += echar; + else + ptr = lim; + + return ptr; +} + +/* FIXME */ + +static void +trim_trailing_blanks (const char *a_start, char **a_end) +{ + while (*a_end > a_start && blanks[UCHAR (*(*a_end - 1))]) + --(*a_end); +} + +/* Fill BUF reading from FP, moving buf->left bytes from the end + of buf->buf to the beginning first. If EOF is reached and the + file wasn't terminated by a newline, supply one. Set up BUF's line + table too. FILE is the name of the file corresponding to FP. + Return nonzero if some input was read. */ + +static int +fillbuf (struct buffer *buf, register FILE *fp, char const *file) +{ + struct keyfield const *key = keylist; + char eol = eolchar; + size_t line_bytes = buf->line_bytes; + size_t mergesize = merge_buffer_size - MIN_MERGE_BUFFER_SIZE; + + if (buf->eof) + return 0; + + if (buf->used != buf->left) + { + memmove (buf->buf, buf->buf + buf->used - buf->left, buf->left); + buf->used = buf->left; + buf->nlines = 0; + } + + for (;;) + { + char *ptr = buf->buf + buf->used; + struct line *linelim = buffer_linelim (buf); + struct line *line = linelim - buf->nlines; + size_t avail = (char *) linelim - buf->nlines * line_bytes - ptr; + char *line_start = buf->nlines ? line->text + line->length : buf->buf; + + while (line_bytes + 1 < avail) + { + /* Read as many bytes as possible, but do not read so many + bytes that there might not be enough room for the + corresponding line array. The worst case is when the + rest of the input file consists entirely of newlines, + except that the last byte is not a newline. */ + size_t readsize = (avail - 1) / (line_bytes + 1); + size_t bytes_read = fread (ptr, 1, readsize, fp); + char *ptrlim = ptr + bytes_read; + char *p; + avail -= bytes_read; + + if (bytes_read != readsize) + { + if (ferror (fp)) + die (_("read failed"), file); + if (feof (fp)) + { + buf->eof = 1; + if (buf->buf == ptrlim) + return 0; + if (ptrlim[-1] != eol) + *ptrlim++ = eol; + } + } + + /* Find and record each line in the just-read input. */ + while ((p = memchr (ptr, eol, ptrlim - ptr))) + { + ptr = p + 1; + line--; + line->text = line_start; + line->length = ptr - line_start; + mergesize = MAX (mergesize, line->length); + avail -= line_bytes; + + if (key) + { + /* Precompute the position of the first key for + efficiency. */ + line->keylim = key->eword == -1 ? p : limfield (line, key); + + if (key->sword != -1) + line->keybeg = begfield (line, key); + else + { + if (key->skipsblanks) + while (blanks[UCHAR (*line_start)]) + line_start++; + line->keybeg = line_start; + } + if (key->skipeblanks) + trim_trailing_blanks (line->keybeg, &line->keylim); + } + + line_start = ptr; + } + + ptr = ptrlim; + if (buf->eof) + break; + } + + buf->used = ptr - buf->buf; + buf->nlines = buffer_linelim (buf) - line; + if (buf->nlines != 0) + { + buf->left = ptr - line_start; + merge_buffer_size = mergesize + MIN_MERGE_BUFFER_SIZE; + return 1; + } + + /* The current input line is too long to fit in the buffer. + Double the buffer size and try again. */ + if (2 * buf->alloc < buf->alloc) + xalloc_die (); + buf->alloc *= 2; + buf->buf = xrealloc (buf->buf, buf->alloc); + } +} + +/* Compare strings A and B containing decimal fractions < 1. Each string + should begin with a decimal point followed immediately by the digits + of the fraction. Strings not of this form are considered to be zero. */ + +/* The goal here, is to take two numbers a and b... compare these + in parallel. Instead of converting each, and then comparing the + outcome. Most likely stopping the comparison before the conversion + is complete. The algorithm used, in the old sort: + + Algorithm: fraccompare + Action : compare two decimal fractions + accepts : char *a, char *b + returns : -1 if ab. + implement: + + if *a == decimal_point AND *b == decimal_point + find first character different in a and b. + if both are digits, return the difference *a - *b. + if *a is a digit + skip past zeros + if digit return 1, else 0 + if *b is a digit + skip past zeros + if digit return -1, else 0 + if *a is a decimal_point + skip past decimal_point and zeros + if digit return 1, else 0 + if *b is a decimal_point + skip past decimal_point and zeros + if digit return -1, else 0 + return 0 */ + +static int +fraccompare (register const char *a, register const char *b) +{ + if (*a == decimal_point && *b == decimal_point) + { + while (*++a == *++b) + if (! ISDIGIT (*a)) + return 0; + if (ISDIGIT (*a) && ISDIGIT (*b)) + return *a - *b; + if (ISDIGIT (*a)) + goto a_trailing_nonzero; + if (ISDIGIT (*b)) + goto b_trailing_nonzero; + return 0; + } + else if (*a++ == decimal_point) + { + a_trailing_nonzero: + while (*a == NUMERIC_ZERO) + a++; + return ISDIGIT (*a); + } + else if (*b++ == decimal_point) + { + b_trailing_nonzero: + while (*b == NUMERIC_ZERO) + b++; + return - ISDIGIT (*b); + } + return 0; +} + +/* Compare strings A and B as numbers without explicitly converting them to + machine numbers. Comparatively slow for short strings, but asymptotically + hideously fast. */ + +static int +numcompare (register const char *a, register const char *b) +{ + register int tmpa, tmpb, tmp; + register size_t loga, logb; + + tmpa = *a; + tmpb = *b; + + while (blanks[UCHAR (tmpa)]) + tmpa = *++a; + while (blanks[UCHAR (tmpb)]) + tmpb = *++b; + + if (tmpa == NEGATION_SIGN) + { + do + tmpa = *++a; + while (tmpa == NUMERIC_ZERO || IS_THOUSANDS_SEP (tmpa)); + if (tmpb != NEGATION_SIGN) + { + if (tmpa == decimal_point) + do + tmpa = *++a; + while (tmpa == NUMERIC_ZERO); + if (ISDIGIT (tmpa)) + return -1; + while (tmpb == NUMERIC_ZERO || IS_THOUSANDS_SEP (tmpb)) + tmpb = *++b; + if (tmpb == decimal_point) + do + tmpb = *++b; + while (tmpb == NUMERIC_ZERO); + if (ISDIGIT (tmpb)) + return -1; + return 0; + } + do + tmpb = *++b; + while (tmpb == NUMERIC_ZERO || IS_THOUSANDS_SEP (tmpb)); + + while (tmpa == tmpb && ISDIGIT (tmpa)) + { + do + tmpa = *++a; + while (IS_THOUSANDS_SEP (tmpa)); + do + tmpb = *++b; + while (IS_THOUSANDS_SEP (tmpb)); + } + + if ((tmpa == decimal_point && !ISDIGIT (tmpb)) + || (tmpb == decimal_point && !ISDIGIT (tmpa))) + return -fraccompare (a, b); + + tmp = tmpb - tmpa; + + for (loga = 0; ISDIGIT (tmpa); ++loga) + do + tmpa = *++a; + while (IS_THOUSANDS_SEP (tmpa)); + + for (logb = 0; ISDIGIT (tmpb); ++logb) + do + tmpb = *++b; + while (IS_THOUSANDS_SEP (tmpb)); + + if (loga != logb) + return loga < logb ? 1 : -1; + + if (!loga) + return 0; + + return tmp; + } + else if (tmpb == NEGATION_SIGN) + { + do + tmpb = *++b; + while (tmpb == NUMERIC_ZERO || IS_THOUSANDS_SEP (tmpb)); + if (tmpb == decimal_point) + do + tmpb = *++b; + while (tmpb == NUMERIC_ZERO); + if (ISDIGIT (tmpb)) + return 1; + while (tmpa == NUMERIC_ZERO || IS_THOUSANDS_SEP (tmpa)) + tmpa = *++a; + if (tmpa == decimal_point) + do + tmpa = *++a; + while (tmpa == NUMERIC_ZERO); + if (ISDIGIT (tmpa)) + return 1; + return 0; + } + else + { + while (tmpa == NUMERIC_ZERO || IS_THOUSANDS_SEP (tmpa)) + tmpa = *++a; + while (tmpb == NUMERIC_ZERO || IS_THOUSANDS_SEP (tmpb)) + tmpb = *++b; + + while (tmpa == tmpb && ISDIGIT (tmpa)) + { + do + tmpa = *++a; + while (IS_THOUSANDS_SEP (tmpa)); + do + tmpb = *++b; + while (IS_THOUSANDS_SEP (tmpb)); + } + + if ((tmpa == decimal_point && !ISDIGIT (tmpb)) + || (tmpb == decimal_point && !ISDIGIT (tmpa))) + return fraccompare (a, b); + + tmp = tmpa - tmpb; + + for (loga = 0; ISDIGIT (tmpa); ++loga) + do + tmpa = *++a; + while (IS_THOUSANDS_SEP (tmpa)); + + for (logb = 0; ISDIGIT (tmpb); ++logb) + do + tmpb = *++b; + while (IS_THOUSANDS_SEP (tmpb)); + + if (loga != logb) + return loga < logb ? -1 : 1; + + if (!loga) + return 0; + + return tmp; + } +} + +static int +general_numcompare (const char *sa, const char *sb) +{ + /* FIXME: add option to warn about failed conversions. */ + /* FIXME: maybe add option to try expensive FP conversion + only if A and B can't be compared more cheaply/accurately. */ + + char *ea; + char *eb; + double a = strtod (sa, &ea); + double b = strtod (sb, &eb); + + /* Put conversion errors at the start of the collating sequence. */ + if (sa == ea) + return sb == eb ? 0 : -1; + if (sb == eb) + return 1; + + /* Sort numbers in the usual way, where -0 == +0. Put NaNs after + conversion errors but before numbers; sort them by internal + bit-pattern, for lack of a more portable alternative. */ + return (a < b ? -1 + : a > b ? 1 + : a == b ? 0 + : b == b ? -1 + : a == a ? 1 + : memcmp ((char *) &a, (char *) &b, sizeof a)); +} + +/* Return an integer in 1..12 of the month name S with length LEN. + Return 0 if the name in S is not recognized. */ + +static int +getmonth (const char *s, size_t len) +{ + char *month; + register size_t i; + register int lo = 0, hi = MONTHS_PER_YEAR, result; + + while (len > 0 && blanks[UCHAR (*s)]) + { + ++s; + --len; + } + + if (len == 0) + return 0; + + month = (char *) alloca (len + 1); + for (i = 0; i < len; ++i) + month[i] = fold_toupper[UCHAR (s[i])]; + while (blanks[UCHAR (month[i - 1])]) + --i; + month[i] = '\0'; + + do + { + int ix = (lo + hi) / 2; + + if (strncmp (month, monthtab[ix].name, strlen (monthtab[ix].name)) < 0) + hi = ix; + else + lo = ix; + } + while (hi - lo > 1); + + result = (!strncmp (month, monthtab[lo].name, strlen (monthtab[lo].name)) + ? monthtab[lo].val : 0); + + return result; +} + +/* Compare two lines A and B trying every key in sequence until there + are no more keys or a difference is found. */ + +static int +keycompare (const struct line *a, const struct line *b) +{ + struct keyfield *key = keylist; + + /* For the first iteration only, the key positions have been + precomputed for us. */ + register char *texta = a->keybeg; + register char *textb = b->keybeg; + register char *lima = a->keylim; + register char *limb = b->keylim; + + int diff; + + for (;;) + { + register unsigned char *translate = (unsigned char *) key->translate; + register int *ignore = key->ignore; + + /* Find the lengths. */ + size_t lena = lima <= texta ? 0 : lima - texta; + size_t lenb = limb <= textb ? 0 : limb - textb; + + if (key->skipeblanks) + { + char *a_end = texta + lena; + char *b_end = textb + lenb; + trim_trailing_blanks (texta, &a_end); + trim_trailing_blanks (textb, &b_end); + lena = a_end - texta; + lenb = b_end - textb; + } + + /* Actually compare the fields. */ + if (key->numeric | key->general_numeric) + { + char savea = *lima, saveb = *limb; + + *lima = *limb = '\0'; + diff = ((key->numeric ? numcompare : general_numcompare) + (texta, textb)); + *lima = savea, *limb = saveb; + } + else if (key->month) + diff = getmonth (texta, lena) - getmonth (textb, lenb); +#ifdef ENABLE_NLS + /* Sorting like this may become slow, so in a simple locale the user + can select a faster sort that is similar to ascii sort */ + else if (hard_LC_COLLATE) + { + if (ignore || translate) + { + char *copy_a = (char *) alloca (lena + 1 + lenb + 1); + char *copy_b = copy_a + lena + 1; + size_t new_len_a, new_len_b, i; + + /* Ignore and/or translate chars before comparing. */ + for (new_len_a = new_len_b = i = 0; i < max (lena, lenb); i++) + { + if (i < lena) + { + copy_a[new_len_a] = (translate + ? translate[UCHAR (texta[i])] + : texta[i]); + if (!ignore || !ignore[UCHAR (texta[i])]) + ++new_len_a; + } + if (i < lenb) + { + copy_b[new_len_b] = (translate + ? translate[UCHAR (textb[i])] + : textb [i]); + if (!ignore || !ignore[UCHAR (textb[i])]) + ++new_len_b; + } + } + + diff = xmemcoll (copy_a, new_len_a, copy_b, new_len_b); + } + else if (lena == 0) + diff = - NONZERO (lenb); + else if (lenb == 0) + goto greater; + else + diff = xmemcoll (texta, lena, textb, lenb); + } +#endif + else if (ignore) + { +#define CMP_WITH_IGNORE(A, B) \ + do \ + { \ + for (;;) \ + { \ + while (texta < lima && ignore[UCHAR (*texta)]) \ + ++texta; \ + while (textb < limb && ignore[UCHAR (*textb)]) \ + ++textb; \ + if (! (texta < lima && textb < limb)) \ + break; \ + diff = UCHAR (A) - UCHAR (B); \ + if (diff) \ + goto not_equal; \ + ++texta; \ + ++textb; \ + } \ + \ + diff = (texta < lima) - (textb < limb); \ + } \ + while (0) + + if (translate) + CMP_WITH_IGNORE (translate[UCHAR (*texta)], + translate[UCHAR (*textb)]); + else + CMP_WITH_IGNORE (UCHAR (*texta), UCHAR (*textb)); + } + else if (lena == 0) + diff = - NONZERO (lenb); + else if (lenb == 0) + goto greater; + else + { + if (translate) + { + while (texta < lima && textb < limb) + { + diff = (UCHAR (translate[UCHAR (*texta++)]) + - UCHAR (translate[UCHAR (*textb++)])); + if (diff) + goto not_equal; + } + } + else + { + diff = memcmp (texta, textb, min (lena, lenb)); + if (diff) + goto not_equal; + } + diff = lena < lenb ? -1 : lena != lenb; + } + + if (diff) + goto not_equal; + + key = key->next; + if (! key) + break; + + /* Find the beginning and limit of the next field. */ + if (key->eword != -1) + lima = limfield (a, key), limb = limfield (b, key); + else + lima = a->text + a->length - 1, limb = b->text + b->length - 1; + + if (key->sword != -1) + texta = begfield (a, key), textb = begfield (b, key); + else + { + texta = a->text, textb = b->text; + if (key->skipsblanks) + { + while (texta < lima && blanks[UCHAR (*texta)]) + ++texta; + while (textb < limb && blanks[UCHAR (*textb)]) + ++textb; + } + } + } + + return 0; + + greater: + diff = 1; + not_equal: + return key->reverse ? -diff : diff; +} + +/* Compare two lines A and B, returning negative, zero, or positive + depending on whether A compares less than, equal to, or greater than B. */ + +static int +compare (register const struct line *a, register const struct line *b) +{ + int diff; + size_t alen, blen; + + /* First try to compare on the specified keys (if any). + The only two cases with no key at all are unadorned sort, + and unadorned sort -r. */ + if (keylist) + { + diff = keycompare (a, b); + alloca (0); + if (diff != 0 || unique || stable) + return diff; + } + + /* If the keys all compare equal (or no keys were specified) + fall through to the default comparison. */ + alen = a->length - 1, blen = b->length - 1; + + if (alen == 0) + diff = - NONZERO (blen); + else if (blen == 0) + diff = NONZERO (alen); +#ifdef ENABLE_NLS + else if (hard_LC_COLLATE) + diff = xmemcoll (a->text, alen, b->text, blen); +#endif + else if (! (diff = memcmp (a->text, b->text, min (alen, blen)))) + diff = alen < blen ? -1 : alen != blen; + + return reverse ? -diff : diff; +} + +/* Check that the lines read from the given FP come in order. Print a + diagnostic (FILE_NAME, line number, contents of line) to stderr and return + one if they are not in order. Otherwise, print no diagnostic + and return zero. */ + +static int +checkfp (FILE *fp, char *file_name) +{ + struct buffer buf; /* Input buffer. */ + struct line temp; /* Copy of previous line. */ + size_t alloc = 0; + uintmax_t line_number = 0; + struct keyfield *key = keylist; + int nonunique = 1 - unique; + int disordered = 0; + + initbuf (&buf, sizeof (struct line), + MAX (merge_buffer_size, sort_size)); + temp.text = NULL; + + while (fillbuf (&buf, fp, file_name)) + { + struct line const *line = buffer_linelim (&buf); + struct line const *linebase = line - buf.nlines; + + /* Make sure the line saved from the old buffer contents is + less than or equal to the first line of the new buffer. */ + if (alloc && nonunique <= compare (&temp, line - 1)) + { + found_disorder: + { + char hr_buf[LONGEST_HUMAN_READABLE + 1]; + struct line const *disorder_line = line - 1; + uintmax_t disorder_line_number = + buffer_linelim (&buf) - disorder_line + line_number; + fprintf (stderr, _("%s: %s:%s: disorder: "), + program_name, file_name, + human_readable (disorder_line_number, hr_buf, 1, 1)); + write_bytes (disorder_line->text, disorder_line->length, stderr, + _("standard error")); + disordered = 1; + break; + } + } + + /* Compare each line in the buffer with its successor. */ + while (linebase < --line) + if (nonunique <= compare (line, line - 1)) + goto found_disorder; + + line_number += buf.nlines; + + /* Save the last line of the buffer. */ + if (alloc < line->length) + { + do + { + alloc *= 2; + if (! alloc) + { + alloc = line->length; + break; + } + } + while (alloc < line->length); + + temp.text = xrealloc (temp.text, alloc); + } + memcpy (temp.text, line->text, line->length); + temp.length = line->length; + if (key) + { + temp.keybeg = temp.text + (line->keybeg - line->text); + temp.keylim = temp.text + (line->keylim - line->text); + } + } + + xfclose (fp, file_name); + free (buf.buf); + if (temp.text) + free (temp.text); + return disordered; +} + +/* Merge lines from FILES onto OFP. NFILES cannot be greater than + NMERGE. Close input and output files before returning. + OUTPUT_FILE gives the name of the output file; if OFP is NULL, the + output file has not been opened yet. */ + +static void +mergefps (char **files, register int nfiles, + FILE *ofp, const char *output_file) +{ + FILE *fps[NMERGE]; /* Input streams for each file. */ + struct buffer buffer[NMERGE]; /* Input buffers for each file. */ + struct line saved; /* Saved line storage for unique check. */ + struct line const *savedline = NULL; + /* &saved if there is a saved line. */ + size_t savealloc = 0; /* Size allocated for the saved line. */ + struct line const *cur[NMERGE]; /* Current line in each line table. */ + struct line const *base[NMERGE]; /* Base of each line table. */ + int ord[NMERGE]; /* Table representing a permutation of fps, + such that cur[ord[0]] is the smallest line + and will be next output. */ + register int i, j, t; + struct keyfield *key = keylist; + saved.text = NULL; + + /* Read initial lines from each input file. */ + for (i = 0; i < nfiles; ) + { + fps[i] = xfopen (files[i], "r"); + initbuf (&buffer[i], sizeof (struct line), + MAX (merge_buffer_size, sort_size / nfiles)); + if (fillbuf (&buffer[i], fps[i], files[i])) + { + struct line const *linelim = buffer_linelim (&buffer[i]); + cur[i] = linelim - 1; + base[i] = linelim - buffer[i].nlines; + i++; + } + else + { + /* fps[i] is empty; eliminate it from future consideration. */ + xfclose (fps[i], files[i]); + zaptemp (files[i]); + free (buffer[i].buf); + --nfiles; + for (j = i; j < nfiles; ++j) + files[j] = files[j + 1]; + } + } + + if (! ofp) + ofp = xfopen (output_file, "w"); + + /* Set up the ord table according to comparisons among input lines. + Since this only reorders two items if one is strictly greater than + the other, it is stable. */ + for (i = 0; i < nfiles; ++i) + ord[i] = i; + for (i = 1; i < nfiles; ++i) + if (0 < compare (cur[ord[i - 1]], cur[ord[i]])) + t = ord[i - 1], ord[i - 1] = ord[i], ord[i] = t, i = 0; + + /* Repeatedly output the smallest line until no input remains. */ + while (nfiles) + { + struct line const *smallest = cur[ord[0]]; + + /* If uniquified output is turned on, output only the first of + an identical series of lines. */ + if (unique) + { + if (savedline && compare (savedline, smallest)) + { + savedline = 0; + write_bytes (saved.text, saved.length, ofp, output_file); + } + if (!savedline) + { + savedline = &saved; + if (savealloc < smallest->length) + { + do + if (! savealloc) + { + savealloc = smallest->length; + break; + } + while ((savealloc *= 2) < smallest->length); + + saved.text = xrealloc (saved.text, savealloc); + } + saved.length = smallest->length; + memcpy (saved.text, smallest->text, saved.length); + if (key) + { + saved.keybeg = + saved.text + (smallest->keybeg - smallest->text); + saved.keylim = + saved.text + (smallest->keylim - smallest->text); + } + } + } + else + write_bytes (smallest->text, smallest->length, ofp, output_file); + + /* Check if we need to read more lines into core. */ + if (base[ord[0]] < smallest) + cur[ord[0]] = smallest - 1; + else + { + if (fillbuf (&buffer[ord[0]], fps[ord[0]], files[ord[0]])) + { + struct line const *linelim = buffer_linelim (&buffer[ord[0]]); + cur[ord[0]] = linelim - 1; + base[ord[0]] = linelim - buffer[ord[0]].nlines; + } + else + { + /* We reached EOF on fps[ord[0]]. */ + for (i = 1; i < nfiles; ++i) + if (ord[i] > ord[0]) + --ord[i]; + --nfiles; + xfclose (fps[ord[0]], files[ord[0]]); + zaptemp (files[ord[0]]); + free (buffer[ord[0]].buf); + for (i = ord[0]; i < nfiles; ++i) + { + fps[i] = fps[i + 1]; + files[i] = files[i + 1]; + buffer[i] = buffer[i + 1]; + cur[i] = cur[i + 1]; + base[i] = base[i + 1]; + } + for (i = 0; i < nfiles; ++i) + ord[i] = ord[i + 1]; + continue; + } + } + + /* The new line just read in may be larger than other lines + already in core; push it back in the queue until we encounter + a line larger than it. */ + for (i = 1; i < nfiles; ++i) + { + t = compare (cur[ord[0]], cur[ord[i]]); + if (!t) + t = ord[0] - ord[i]; + if (t < 0) + break; + } + t = ord[0]; + for (j = 1; j < i; ++j) + ord[j - 1] = ord[j]; + ord[i - 1] = t; + } + + if (unique && savedline) + { + write_bytes (saved.text, saved.length, ofp, output_file); + free (saved.text); + } + + xfclose (ofp, output_file); +} + +/* Sort the array LINES with NLINES members, using TEMP for temporary space. + The input and output arrays are in reverse order, and LINES and + TEMP point just past the end of their respective arrays. */ + +static void +sortlines (struct line *lines, size_t nlines, struct line *temp) +{ + register struct line *lo, *hi, *t; + register size_t nlo, nhi; + + if (nlines == 2) + { + if (0 < compare (&lines[-1], &lines[-2])) + { + struct line tmp = lines[-1]; + lines[-1] = lines[-2]; + lines[-2] = tmp; + } + return; + } + + nlo = nlines / 2; + lo = lines; + nhi = nlines - nlo; + hi = lines - nlo; + + if (nlo > 1) + sortlines (lo, nlo, temp); + + if (nhi > 1) + sortlines (hi, nhi, temp); + + t = temp; + + while (nlo && nhi) + if (compare (lo - 1, hi - 1) <= 0) + *--t = *--lo, --nlo; + else + *--t = *--hi, --nhi; + while (nlo--) + *--t = *--lo; + + for (lo = lines, nlo = nlines - nhi, t = temp; nlo; --nlo) + *--lo = *--t; +} + +/* Return the index of the first of NFILES FILES that is the same file + as OUTFILE. If none can be the same, return NFILES. Consider an + input pipe to be the same as OUTFILE, since the pipe might be the + output of a command like "cat OUTFILE". */ + +static int +first_same_file (char **files, int nfiles, char const *outfile) +{ + int i; + int got_outstat = 0; + struct stat instat, outstat; + + for (i = 0; i < nfiles; i++) + { + int standard_input = STREQ (files[i], "-"); + + if (STREQ (outfile, files[i]) && ! standard_input) + return i; + + if (! got_outstat) + { + got_outstat = 1; + if ((STREQ (outfile, "-") + ? fstat (STDOUT_FILENO, &outstat) + : stat (outfile, &outstat)) + != 0) + return nfiles; + } + + if (((standard_input + ? fstat (STDIN_FILENO, &instat) + : stat (files[i], &instat)) + == 0) + && (S_ISFIFO (instat.st_mode) || SAME_INODE (instat, outstat))) + return i; + } + + return nfiles; +} + +/* Check that each of the NFILES FILES is ordered. + Return a count of disordered files. */ + +static int +check (char **files, int nfiles) +{ + int i, disorders = 0; + FILE *fp; + + for (i = 0; i < nfiles; ++i) + { + fp = xfopen (files[i], "r"); + disorders += checkfp (fp, files[i]); + } + return disorders; +} + +/* Merge NFILES FILES onto OUTPUT_FILE. However, merge at most + MAX_MERGE input files directly onto OUTPUT_FILE. MAX_MERGE cannot + exceed NMERGE. */ + +static void +merge (char **files, int nfiles, int max_merge, char const *output_file) +{ + while (max_merge < nfiles) + { + FILE *tfp; + int i, t = 0; + char *temp; + for (i = 0; i < nfiles / NMERGE; ++i) + { + temp = create_temp_file (&tfp); + mergefps (&files[i * NMERGE], NMERGE, tfp, temp); + files[t++] = temp; + } + temp = create_temp_file (&tfp); + mergefps (&files[i * NMERGE], nfiles % NMERGE, tfp, temp); + files[t++] = temp; + nfiles = t; + if (nfiles == 1) + break; + } + + mergefps (files, nfiles, NULL, output_file); +} + +/* Sort NFILES FILES onto OUTPUT_FILE. */ + +static void +sort (char **files, int nfiles, char const *output_file) +{ + struct buffer buf; + int n_temp_files = 0; + int output_file_created = 0; + + static size_t size; + if (! size && ! (size = sort_size)) + size = default_sort_size (); + + buf.alloc = 0; + + while (nfiles) + { + char const *temp_output; + char const *file = *files; + FILE *fp = xfopen (file, "r"); + FILE *tfp; + + if (! buf.alloc) + initbuf (&buf, 2 * sizeof (struct line), + sort_buffer_size (&fp, 1, files, nfiles, + 2 * sizeof (struct line), size)); + buf.eof = 0; + files++; + nfiles--; + + while (fillbuf (&buf, fp, file)) + { + struct line *line; + struct line *linebase; + + if (buf.eof && nfiles + && (2 * sizeof (struct line) + 1 + < (buf.alloc - buf.used + - 2 * sizeof (struct line) * buf.nlines))) + { + /* End of file, but there is more input and buffer room. + Concatenate the next input file; this is faster in + the usual case. */ + buf.left = buf.used; + break; + } + + line = buffer_linelim (&buf); + linebase = line - buf.nlines; + sortlines (line, buf.nlines, linebase); + if (buf.eof && !nfiles && !n_temp_files && !buf.left) + { + xfclose (fp, file); + tfp = xfopen (output_file, "w"); + temp_output = output_file; + output_file_created = 1; + } + else + { + ++n_temp_files; + temp_output = create_temp_file (&tfp); + } + + do + { + line--; + write_bytes (line->text, line->length, tfp, temp_output); + if (unique) + while (linebase < line && compare (line, line - 1) == 0) + line--; + } + while (linebase < line); + + xfclose (tfp, temp_output); + + if (output_file_created) + goto finish; + } + xfclose (fp, file); + } + + finish: + free (buf.buf); + + if (! output_file_created) + { + int i = n_temp_files; + struct tempnode *node; + char **tempfiles = (char **) xmalloc (n_temp_files * sizeof (char *)); + for (node = temphead; i > 0; node = node->next) + tempfiles[--i] = node->name; + merge (tempfiles, n_temp_files, NMERGE, output_file); + free ((char *) tempfiles); + } +} + +/* Insert key KEY at the end of the key list. */ + +static void +insertkey (struct keyfield *key) +{ + struct keyfield **p; + + for (p = &keylist; *p; p = &(*p)->next) + continue; + *p = key; + key->next = NULL; +} + +/* Report a bad field specification SPEC, with extra info MSGID. */ + +static void badfieldspec PARAMS ((char const *, char const *)) + ATTRIBUTE_NORETURN; +static void +badfieldspec (char const *spec, char const *msgid) +{ + error (SORT_FAILURE, 0, _("%s: invalid field specification `%s'"), + _(msgid), spec); + abort (); +} + +/* Parse the leading integer in STRING and store the resulting value + (which must fit into size_t) into *VAL. Return the address of the + suffix after the integer. If MSGID is NULL, return NULL after + failure; otherwise, report MSGID and exit on failure. */ + +static char const * +parse_field_count (char const *string, size_t *val, char const *msgid) +{ + char *suffix; + uintmax_t n; + + switch (xstrtoumax (string, &suffix, 10, &n, "")) + { + case LONGINT_OK: + case LONGINT_INVALID_SUFFIX_CHAR: + *val = n; + if (*val == n) + break; + /* Fall through. */ + case LONGINT_OVERFLOW: + if (msgid) + error (SORT_FAILURE, 0, _("%s: count `%.*s' too large"), + _(msgid), (int) (suffix - string), string); + return NULL; + + case LONGINT_INVALID: + if (msgid) + error (SORT_FAILURE, 0, _("%s: invalid count at start of `%s'"), + _(msgid), string); + return NULL; + } + + return suffix; +} + +/* Handle interrupts and hangups. */ + +static void +sighandler (int sig) +{ +#ifndef SA_NOCLDSTOP + signal (sig, SIG_IGN); +#endif + + cleanup (); + +#ifdef SA_NOCLDSTOP + { + struct sigaction sigact; + + sigact.sa_handler = SIG_DFL; + sigemptyset (&sigact.sa_mask); + sigact.sa_flags = 0; + sigaction (sig, &sigact, NULL); + } +#else + signal (sig, SIG_DFL); +#endif + + kill (process_id, sig); +} + +/* Set the ordering options for KEY specified in S. + Return the address of the first character in S that + is not a valid ordering option. + BLANKTYPE is the kind of blanks that 'b' should skip. */ + +static char * +set_ordering (register const char *s, struct keyfield *key, + enum blanktype blanktype) +{ + while (*s) + { + switch (*s) + { + case 'b': + if (blanktype == bl_start || blanktype == bl_both) + key->skipsblanks = 1; + if (blanktype == bl_end || blanktype == bl_both) + key->skipeblanks = 1; + break; + case 'd': + key->ignore = nondictionary; + break; + case 'f': + key->translate = fold_toupper; + break; + case 'g': + key->general_numeric = 1; + break; + case 'i': + key->ignore = nonprinting; + break; + case 'M': + key->month = 1; + break; + case 'n': + key->numeric = 1; + break; + case 'r': + key->reverse = 1; + break; + default: + return (char *) s; + } + ++s; + } + return (char *) s; +} + +static struct keyfield * +new_key (void) +{ + struct keyfield *key = (struct keyfield *) xcalloc (1, sizeof *key); + key->eword = -1; + return key; +} + +int +main (int argc, char **argv) +{ + struct keyfield *key; + struct keyfield gkey; + char const *s; + int i; + int c = 0; + int checkonly = 0, mergeonly = 0, nfiles = 0; + int posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL); + bool obsolete_usage = (posix2_version () < 200112); + char const *short_options = (obsolete_usage + ? COMMON_SHORT_OPTIONS "y::" + : COMMON_SHORT_OPTIONS "y:"); + char *minus = "-", **files; + char const *outfile = minus; + static int const sigs[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM }; + int nsigs = sizeof sigs / sizeof *sigs; +#ifdef SA_NOCLDSTOP + struct sigaction oldact, newact; +#endif + + program_name = argv[0]; + process_id = getpid (); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + atexit (cleanup); + +#ifdef ENABLE_NLS + + hard_LC_COLLATE = hard_locale (LC_COLLATE); +# if HAVE_NL_LANGINFO + hard_LC_TIME = hard_locale (LC_TIME); +# endif + + /* Let's get locale's representation of the decimal point */ + { + struct lconv *lconvp = localeconv (); + + /* If the locale doesn't define a decimal point, or if the decimal + point is multibyte, use the C decimal point. We don't support + multibyte decimal points yet. */ + decimal_point = *lconvp->decimal_point; + if (! decimal_point || lconvp->decimal_point[1]) + decimal_point = C_DECIMAL_POINT; + + /* We don't support multibyte thousands separators yet. */ + th_sep = *lconvp->thousands_sep; + if (! th_sep || lconvp->thousands_sep[1]) + th_sep = CHAR_MAX + 1; + } + +#endif /* NLS */ + + have_read_stdin = 0; + inittables (); + + /* Change the way library functions fail. */ + xalloc_exit_failure = SORT_FAILURE; + xmemcoll_exit_failure = SORT_FAILURE; + +#ifdef SA_NOCLDSTOP + sigemptyset (&caught_signals); + for (i = 0; i < nsigs; i++) + sigaddset (&caught_signals, sigs[i]); + newact.sa_handler = sighandler; + newact.sa_mask = caught_signals; + newact.sa_flags = 0; +#endif + + for (i = 0; i < nsigs; i++) + { + int sig = sigs[i]; +#ifdef SA_NOCLDSTOP + sigaction (sig, NULL, &oldact); + if (oldact.sa_handler != SIG_IGN) + sigaction (sig, &newact, NULL); +#else + if (signal (sig, SIG_IGN) != SIG_IGN) + signal (sig, sighandler); +#endif + } + + gkey.sword = gkey.eword = -1; + gkey.ignore = NULL; + gkey.translate = NULL; + gkey.numeric = gkey.general_numeric = gkey.month = gkey.reverse = 0; + gkey.skipsblanks = gkey.skipeblanks = 0; + + files = (char **) xmalloc (sizeof (char *) * argc); + + for (;;) + { + /* Parse an operand as a file after "--" was seen; or if + pedantic and a file was seen, unless the POSIX version + predates 1003.1-2001 and -c was not seen and the operand is + "-o FILE" or "-oFILE". */ + + if (c == -1 + || (posix_pedantic && nfiles != 0 + && ! (obsolete_usage + && ! checkonly + && optind != argc + && argv[optind][0] == '-' && argv[optind][1] == 'o' + && (argv[optind][2] || optind + 1 != argc))) + || ((c = getopt_long (argc, argv, short_options, + long_options, NULL)) + == -1)) + { + if (optind == argc) + break; + files[nfiles++] = argv[optind++]; + } + else switch (c) + { + case 1: + key = NULL; + if (obsolete_usage && optarg[0] == '+') + { + /* Treat +POS1 [-POS2] as a key if possible; but silently + treat an operand as a file if it is not a valid +POS1. */ + key = new_key (); + s = parse_field_count (optarg + 1, &key->sword, NULL); + if (s && *s == '.') + s = parse_field_count (s + 1, &key->schar, NULL); + if (! (key->sword | key->schar)) + key->sword = -1; + if (! s || *set_ordering (s, key, bl_start)) + { + free (key); + key = NULL; + } + else + { + if (optind != argc && argv[optind][0] == '-' + && ISDIGIT (argv[optind][1])) + { + char const *optarg1 = argv[optind++]; + s = parse_field_count (optarg1 + 1, &key->eword, + N_("invalid number after `-'")); + if (*s == '.') + s = parse_field_count (s + 1, &key->echar, + N_("invalid number after `.'")); + if (*set_ordering (s, key, bl_end)) + badfieldspec (optarg1, + N_("stray character in field spec")); + } + insertkey (key); + } + } + if (! key) + files[nfiles++] = optarg; + break; + + case 'b': + case 'd': + case 'f': + case 'g': + case 'i': + case 'M': + case 'n': + case 'r': + { + char str[2]; + str[0] = c; + str[1] = '\0'; + set_ordering (str, &gkey, bl_both); + } + break; + + case 'c': + checkonly = 1; + break; + + case 'k': + key = new_key (); + + /* Get POS1. */ + s = parse_field_count (optarg, &key->sword, + N_("invalid number at field start")); + if (! key->sword--) + { + /* Provoke with `sort -k0' */ + badfieldspec (optarg, N_("field number is zero")); + } + if (*s == '.') + { + s = parse_field_count (s + 1, &key->schar, + N_("invalid number after `.'")); + if (! key->schar--) + { + /* Provoke with `sort -k1.0' */ + badfieldspec (optarg, N_("character offset is zero")); + } + } + if (! (key->sword | key->schar)) + key->sword = -1; + s = set_ordering (s, key, bl_start); + if (*s != ',') + { + key->eword = -1; + key->echar = 0; + } + else + { + /* Get POS2. */ + s = parse_field_count (s + 1, &key->eword, + N_("invalid number after `,'")); + if (! key->eword--) + { + /* Provoke with `sort -k1,0' */ + badfieldspec (optarg, N_("field number is zero")); + } + if (*s == '.') + s = parse_field_count (s + 1, &key->echar, + N_("invalid number after `.'")); + else + { + /* `-k 2,3' is equivalent to `+1 -3'. */ + key->eword++; + } + s = set_ordering (s, key, bl_end); + } + if (*s) + badfieldspec (optarg, N_("stray character in field spec")); + insertkey (key); + break; + + case 'm': + mergeonly = 1; + break; + + case 'o': + outfile = optarg; + break; + + case 's': + stable = 1; + break; + + case 'S': + specify_sort_size (optarg); + break; + + case 't': + tab = optarg[0]; + if (tab && optarg[1]) + { + /* Provoke with `sort -txx'. Complain about + "multi-character tab" instead of "multibyte tab", so + that the diagnostic's wording does not need to be + changed once multibyte characters are supported. */ + error (SORT_FAILURE, 0, _("multi-character tab `%s'"), optarg); + } + break; + + case 'T': + add_temp_dir (optarg); + break; + + case 'u': + unique = 1; + break; + + case 'y': + /* Accept and ignore e.g. -y0 for compatibility with Solaris + 2.x through Solaris 7. -y is marked as obsolete starting + with Solaris 8. */ + break; + + case 'z': + eolchar = 0; + break; + + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + + default: + usage (SORT_FAILURE); + } + } + + /* Inheritance of global options to individual keys. */ + for (key = keylist; key; key = key->next) + if (!key->ignore && !key->translate && !key->skipsblanks && !key->reverse + && !key->skipeblanks && !key->month && !key->numeric + && !key->general_numeric) + { + key->ignore = gkey.ignore; + key->translate = gkey.translate; + key->skipsblanks = gkey.skipsblanks; + key->skipeblanks = gkey.skipeblanks; + key->month = gkey.month; + key->numeric = gkey.numeric; + key->general_numeric = gkey.general_numeric; + key->reverse = gkey.reverse; + } + + if (!keylist && (gkey.ignore || gkey.translate || gkey.skipsblanks + || gkey.skipeblanks || gkey.month || gkey.numeric + || gkey.general_numeric)) + insertkey (&gkey); + reverse = gkey.reverse; + + if (temp_dir_count == 0) + { + char const *tmp_dir = getenv ("TMPDIR"); + add_temp_dir (tmp_dir ? tmp_dir : DEFAULT_TMPDIR); + } + + if (nfiles == 0) + { + nfiles = 1; + files = − + } + + if (checkonly) + { + if (nfiles > 1) + error (SORT_FAILURE, 0, _("extra operand `%s' not allowed with -c"), + files[1]); + + /* POSIX requires that sort return 1 IFF invoked with -c and the + input is not properly sorted. */ + exit (check (files, nfiles) == 0 ? EXIT_SUCCESS : SORT_OUT_OF_ORDER); + } + + if (mergeonly) + { + int max_merge = first_same_file (files, MIN (nfiles, NMERGE), outfile); + merge (files, nfiles, max_merge, outfile); + } + else + sort (files, nfiles, outfile); + + if (have_read_stdin && fclose (stdin) == EOF) + die (_("close failed"), "-"); + + exit (EXIT_SUCCESS); +} diff --git a/contrib/gnu-sort/src/sys2.h b/contrib/gnu-sort/src/sys2.h new file mode 100644 index 0000000..610c1fd --- /dev/null +++ b/contrib/gnu-sort/src/sys2.h @@ -0,0 +1,565 @@ +/* WARNING -- this file is temporary. It is shared between the + sh-utils, fileutils, and textutils packages. Once I find a little + more time, I'll merge the remaining things in system.h and everything + in this file will go back there. */ + +#if STAT_MACROS_BROKEN +# undef S_ISBLK +# undef S_ISCHR +# undef S_ISDIR +# undef S_ISDOOR +# undef S_ISFIFO +# undef S_ISLNK +# undef S_ISMPB +# undef S_ISMPC +# undef S_ISNWK +# undef S_ISREG +# undef S_ISSOCK +#endif /* STAT_MACROS_BROKEN. */ + +#ifndef S_IFMT +# define S_IFMT 0170000 +#endif +#if !defined(S_ISBLK) && defined(S_IFBLK) +# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#endif +#if !defined(S_ISCHR) && defined(S_IFCHR) +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#endif +#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 +#if !defined(S_ISFIFO) && defined(S_IFIFO) +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#endif +#if !defined(S_ISLNK) && defined(S_IFLNK) +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#endif +#if !defined(S_ISSOCK) && defined(S_IFSOCK) +# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +#endif +#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */ +# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) +# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) +#endif +#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ +# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) +#endif +#if !defined(S_ISDOOR) && defined(S_IFDOOR) /* Solaris 2.5 and up */ +# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) +#endif + +#if !S_ISUID +# define S_ISUID 04000 +#endif +#if !S_ISGID +# define S_ISGID 02000 +#endif + +/* S_ISVTX is a common extension to POSIX. */ +#ifndef S_ISVTX +# define S_ISVTX 01000 +#endif + +#if !S_IRUSR && S_IREAD +# define S_IRUSR S_IREAD +#endif +#if !S_IRUSR +# define S_IRUSR 00400 +#endif +#if !S_IRGRP +# define S_IRGRP (S_IRUSR >> 3) +#endif +#if !S_IROTH +# define S_IROTH (S_IRUSR >> 6) +#endif + +#if !S_IWUSR && S_IWRITE +# define S_IWUSR S_IWRITE +#endif +#if !S_IWUSR +# define S_IWUSR 00200 +#endif +#if !S_IWGRP +# define S_IWGRP (S_IWUSR >> 3) +#endif +#if !S_IWOTH +# define S_IWOTH (S_IWUSR >> 6) +#endif + +#if !S_IXUSR && S_IEXEC +# define S_IXUSR S_IEXEC +#endif +#if !S_IXUSR +# define S_IXUSR 00100 +#endif +#if !S_IXGRP +# define S_IXGRP (S_IXUSR >> 3) +#endif +#if !S_IXOTH +# define S_IXOTH (S_IXUSR >> 6) +#endif + +#if !S_IRWXU +# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +#endif +#if !S_IRWXG +# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +#endif +#if !S_IRWXO +# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +#endif + +/* S_IXUGO is a common extension to POSIX. */ +#if !S_IXUGO +# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) +#endif + +#ifndef S_IRWXUGO +# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +#endif + +/* All the mode bits that can be affected by chmod. */ +#define CHMOD_MODE_BITS \ + (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) + +#ifdef ST_MTIM_NSEC +# define ST_TIME_CMP_NS(a, b, ns) ((a).ns < (b).ns ? -1 : (a).ns > (b).ns) +#else +# define ST_TIME_CMP_NS(a, b, ns) 0 +#endif +#define ST_TIME_CMP(a, b, s, ns) \ + ((a).s < (b).s ? -1 : (a).s > (b).s ? 1 : ST_TIME_CMP_NS(a, b, ns)) +#define ATIME_CMP(a, b) ST_TIME_CMP (a, b, st_atime, st_atim.ST_MTIM_NSEC) +#define CTIME_CMP(a, b) ST_TIME_CMP (a, b, st_ctime, st_ctim.ST_MTIM_NSEC) +#define MTIME_CMP(a, b) ST_TIME_CMP (a, b, st_mtime, st_mtim.ST_MTIM_NSEC) + +#ifndef RETSIGTYPE +# define RETSIGTYPE void +#endif + +#if __GNUC__ +# ifndef alloca +# define alloca __builtin_alloca +# endif +#else +# if HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + # pragma alloca +# else +# ifdef _WIN32 +# include +# include +# else +# ifndef alloca +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +#ifdef __DJGPP__ + /* We need the declaration of setmode. */ +# include + /* We need the declaration of __djgpp_set_ctrl_c. */ +# include +#endif + +#if HAVE_STDINT_H +# include +#endif + +#if HAVE_INTTYPES_H +# include /* for the definition of UINTMAX_MAX */ +#endif + +#include + +/* Jim Meyering writes: + + "... Some ctype macros are valid only for character codes that + isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when + using /bin/cc or gcc but without giving an ansi option). So, all + ctype uses should be through macros like ISPRINT... If + STDC_HEADERS is defined, then autoconf has verified that the ctype + macros don't need to be guarded with references to isascii. ... + Defining isascii to 1 should let any compiler worth its salt + eliminate the && through constant folding." + + Bruno Haible adds: + + "... Furthermore, isupper(c) etc. have an undefined result if c is + outside the range -1 <= c <= 255. One is tempted to write isupper(c) + with c being of type `char', but this is wrong if c is an 8-bit + character >= 128 which gets sign-extended to a negative value. + The macro ISUPPER protects against this as well." */ + +#if STDC_HEADERS || (!defined (isascii) && !HAVE_ISASCII) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +#ifdef isblank +# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c)) +#else +# define ISBLANK(c) ((c) == ' ' || (c) == '\t') +#endif +#ifdef isgraph +# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c)) +#else +# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c)) +#endif + +/* This is defined in on at least Solaris2.6 systems. */ +#undef ISPRINT + +#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) +#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c)) +#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) +#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c)) +#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c)) +#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c)) +#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) +#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) +#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c)) +#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) + +#if STDC_HEADERS +# define TOLOWER(Ch) tolower (Ch) +# define TOUPPER(Ch) toupper (Ch) +#else +# define TOLOWER(Ch) (ISUPPER (Ch) ? tolower (Ch) : (Ch)) +# define TOUPPER(Ch) (ISLOWER (Ch) ? toupper (Ch) : (Ch)) +#endif + +/* ISDIGIT differs from ISDIGIT_LOCALE, 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) + +#ifndef PARAMS +# if PROTOTYPES +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +/* Take care of NLS matters. */ + +#if HAVE_LOCALE_H +# include +#endif +#if !HAVE_SETLOCALE +# define setlocale(Category, Locale) /* empty */ +#endif + +#if ENABLE_NLS +# include +# if HAVE_GETTEXT && !HAVE_DCGETTEXT && !defined dcgettext +# define dcgettext(Domain, Text, Category) Text +# endif +# define _(Text) gettext (Text) +#else +# undef bindtextdomain +# define bindtextdomain(Domain, Directory) /* empty */ +# undef textdomain +# define textdomain(Domain) /* empty */ +# undef dcgettext +# define dcgettext(Domainname, Text, Category) Text +# define _(Text) Text +#endif +#define N_(Text) Text + +#define STREQ(a, b) (strcmp ((a), (b)) == 0) + +#if !HAVE_DECL_FREE +void free (); +#endif + +#if !HAVE_DECL_MALLOC +char *malloc (); +#endif + +#if !HAVE_DECL_MEMCHR +char *memchr (); +#endif + +#if !HAVE_DECL_REALLOC +char *realloc (); +#endif + +#if !HAVE_DECL_STPCPY +# ifndef stpcpy +char *stpcpy (); +# endif +#endif + +#if !HAVE_DECL_STRNDUP +char *strndup (); +#endif + +#if !HAVE_DECL_STRSTR +char *strstr (); +#endif + +#if !HAVE_DECL_GETENV +char *getenv (); +#endif + +#if !HAVE_DECL_LSEEK +off_t lseek (); +#endif + +/* This is needed on some AIX systems. */ +#if !HAVE_DECL_STRTOUL +unsigned long strtoul (); +#endif + +/* This is needed on some AIX systems. */ +#if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG +unsigned long long strtoull (); +#endif + +#if !HAVE_DECL_GETLOGIN +char *getlogin (); +#endif + +#if !HAVE_DECL_TTYNAME +char *ttyname (); +#endif + +#if !HAVE_DECL_GETEUID +uid_t geteuid (); +#endif + +#if !HAVE_DECL_GETPWUID +struct passwd *getpwuid (); +#endif + +#if !HAVE_DECL_GETGRGID +struct group *getgrgid (); +#endif + +#if !HAVE_DECL_GETUID +uid_t getuid (); +#endif + +#include "xalloc.h" + +#if ! defined HAVE_MEMPCPY && ! defined mempcpy +/* Be CAREFUL that there are no side effects in N. */ +# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) +#endif + +/* Include automatically-generated macros for unlocked I/O. */ +#include "unlocked-io.h" + +#define SAME_INODE(Stat_buf_1, Stat_buf_2) \ + ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \ + && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev) + +#define DOT_OR_DOTDOT(Basename) \ + (Basename[0] == '.' && (Basename[1] == '\0' \ + || (Basename[1] == '.' && Basename[2] == '\0'))) + +#if SETVBUF_REVERSED +# define SETVBUF(Stream, Buffer, Type, Size) \ + setvbuf (Stream, Type, Buffer, Size) +#else +# define SETVBUF(Stream, Buffer, Type, Size) \ + setvbuf (Stream, Buffer, Type, Size) +#endif + +/* Factor out some of the common --help and --version processing code. */ + +/* These enum values cannot possibly conflict with the option values + ordinarily used by commands, including CHAR_MAX + 1, etc. Avoid + CHAR_MIN - 1, as it may equal -1, the getopt end-of-options value. */ +enum +{ + GETOPT_HELP_CHAR = (CHAR_MIN - 2), + GETOPT_VERSION_CHAR = (CHAR_MIN - 3) +}; + +#define GETOPT_HELP_OPTION_DECL \ + "help", no_argument, 0, GETOPT_HELP_CHAR +#define GETOPT_VERSION_OPTION_DECL \ + "version", no_argument, 0, GETOPT_VERSION_CHAR + +#define case_GETOPT_HELP_CHAR \ + case GETOPT_HELP_CHAR: \ + usage (EXIT_SUCCESS); \ + break; + +#define HELP_OPTION_DESCRIPTION \ + _(" --help display this help and exit\n") +#define VERSION_OPTION_DESCRIPTION \ + _(" --version output version information and exit\n") + +#include "closeout.h" +#include "version-etc.h" + +#define case_GETOPT_VERSION_CHAR(Program_name, Authors) \ + case GETOPT_VERSION_CHAR: \ + version_etc (stdout, Program_name, PACKAGE, VERSION, Authors); \ + exit (EXIT_SUCCESS); \ + break; + +#ifndef MAX +# define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef MIN +# define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +/* The extra casts work around common compiler bugs. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. + It is necessary at least when t == time_t. */ +#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) +#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) + +/* 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) + +#ifndef CHAR_MIN +# define CHAR_MIN TYPE_MINIMUM (char) +#endif + +#ifndef CHAR_MAX +# define CHAR_MAX TYPE_MAXIMUM (char) +#endif + +#ifndef SCHAR_MIN +# define SCHAR_MIN (-1 - SCHAR_MAX) +#endif + +#ifndef SCHAR_MAX +# define SCHAR_MAX (CHAR_MAX == UCHAR_MAX ? CHAR_MAX / 2 : CHAR_MAX) +#endif + +#ifndef UCHAR_MAX +# define UCHAR_MAX TYPE_MAXIMUM (unsigned char) +#endif + +#ifndef SHRT_MIN +# define SHRT_MIN TYPE_MINIMUM (short int) +#endif + +#ifndef SHRT_MAX +# define SHRT_MAX TYPE_MAXIMUM (short int) +#endif + +#ifndef INT_MAX +# define INT_MAX TYPE_MAXIMUM (int) +#endif + +#ifndef UINT_MAX +# define UINT_MAX TYPE_MAXIMUM (unsigned int) +#endif + +#ifndef LONG_MAX +# define LONG_MAX TYPE_MAXIMUM (long) +#endif + +#ifndef ULONG_MAX +# define ULONG_MAX TYPE_MAXIMUM (unsigned long) +#endif + +#ifndef SIZE_MAX +# define SIZE_MAX TYPE_MAXIMUM (size_t) +#endif + +#ifndef UINTMAX_MAX +# define UINTMAX_MAX TYPE_MAXIMUM (uintmax_t) +#endif + +#ifndef OFF_T_MIN +# define OFF_T_MIN TYPE_MINIMUM (off_t) +#endif + +#ifndef OFF_T_MAX +# define OFF_T_MAX TYPE_MAXIMUM (off_t) +#endif + +#ifndef UID_T_MAX +# define UID_T_MAX TYPE_MAXIMUM (uid_t) +#endif + +#ifndef GID_T_MAX +# define GID_T_MAX TYPE_MAXIMUM (gid_t) +#endif + +#ifndef PID_T_MAX +# define PID_T_MAX TYPE_MAXIMUM (pid_t) +#endif + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +/* Use this to suppress gcc's `...may be used before initialized' warnings. */ +#ifdef lint +# define IF_LINT(Code) Code +#else +# define IF_LINT(Code) /* empty */ +#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 + +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + +#if defined strdupa +# define ASSIGN_STRDUPA(DEST, S) \ + do { DEST = strdupa(S); } while (0) +#else +# define ASSIGN_STRDUPA(DEST, S) \ + do \ + { \ + const char *s_ = (S); \ + size_t len_ = strlen (s_) + 1; \ + char *tmp_dest_ = (char *) alloca (len_); \ + DEST = memcpy (tmp_dest_, (s_), len_); \ + } \ + while (0) +#endif + +#ifndef EOVERFLOW +# define EOVERFLOW EINVAL +#endif + +#if ! HAVE_FSEEKO && ! defined fseeko +# define fseeko(s, o, w) ((o) == (long) (o) \ + ? fseek (s, o, w) \ + : (errno = EOVERFLOW, -1)) +#endif diff --git a/contrib/gnu-sort/src/system.h b/contrib/gnu-sort/src/system.h new file mode 100644 index 0000000..6e11e44 --- /dev/null +++ b/contrib/gnu-sort/src/system.h @@ -0,0 +1,286 @@ +/* system-dependent definitions for fileutils, textutils, and sh-utils packages. + Copyright (C) 1989, 1991-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. */ + +/* Include sys/types.h before this file. */ + +#include + +#if !defined(HAVE_MKFIFO) +# define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0)) +#endif + +#if HAVE_SYS_PARAM_H +# include +#endif + +/* should be included before any preprocessor test + of _POSIX_VERSION. */ +#if HAVE_UNISTD_H +# include +#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_LIMITS_H +/* limits.h must come before pathmax.h because limits.h on some systems + undefs PATH_MAX, whereas pathmax.h sets PATH_MAX. */ +# include +#endif + +#include "pathmax.h" + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +/* Since major is a function on SVR4, we can't use `ifndef major'. */ +#if MAJOR_IN_MKDEV +# include +# define HAVE_MAJOR +#endif +#if MAJOR_IN_SYSMACROS +# include +# define HAVE_MAJOR +#endif +#ifdef major /* Might be defined in sys/types.h. */ +# define HAVE_MAJOR +#endif + +#ifndef HAVE_MAJOR +# define major(dev) (((dev) >> 8) & 0xff) +# define minor(dev) ((dev) & 0xff) +# define makedev(maj, min) (((maj) << 8) | (min)) +#endif +#undef HAVE_MAJOR + +#if HAVE_UTIME_H +# include +#endif + +/* Some systems (even some that do have ) don't declare this + structure anywhere. */ +#ifndef HAVE_STRUCT_UTIMBUF +struct utimbuf +{ + long actime; + long modtime; +}; +#endif + +/* Don't use bcopy! Use memmove if source and destination may overlap, + memcpy otherwise. */ + +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#else +# include +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#if HAVE_STDBOOL_H +# include +#else +typedef enum {false = 0, true = 1} bool; +#endif + +#if HAVE_STDLIB_H +# define getopt system_getopt +# include +# undef getopt +#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 + +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif + +#if HAVE_FCNTL_H +# include +#else +# include +#endif + +#if !defined (SEEK_SET) +# define SEEK_SET 0 +# define SEEK_CUR 1 +# define SEEK_END 2 +#endif +#ifndef F_OK +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 +#endif + +/* For systems that distinguish between text and binary I/O. + O_BINARY is usually declared in fcntl.h */ +#if !defined O_BINARY && defined _O_BINARY + /* For MSC-compatible compilers. */ +# define O_BINARY _O_BINARY +# define O_TEXT _O_TEXT +#endif + +#ifdef __BEOS__ + /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ +# undef O_BINARY +# undef O_TEXT +#endif + +#if O_BINARY +# ifndef __DJGPP__ +# define setmode _setmode +# define fileno(_fp) _fileno (_fp) +# endif /* not DJGPP */ +# define SET_MODE(_f, _m) setmode (_f, _m) +# define SET_BINARY(_f) do {if (!isatty(_f)) setmode (_f, O_BINARY);} while (0) +# define SET_BINARY2(_f1, _f2) \ + do { \ + if (!isatty (_f1)) \ + { \ + setmode (_f1, O_BINARY); \ + if (!isatty (_f2)) \ + setmode (_f2, O_BINARY); \ + } \ + } while(0) +#else +# define SET_MODE(_f, _m) (void)0 +# define SET_BINARY(f) (void)0 +# define SET_BINARY2(f1,f2) (void)0 +# define O_BINARY 0 +# define O_TEXT 0 +#endif /* O_BINARY */ + +#if HAVE_DIRENT_H +# include +# define NLENGTH(direct) (strlen((direct)->d_name)) +#else /* not HAVE_DIRENT_H */ +# define dirent direct +# define NLENGTH(direct) ((direct)->d_namlen) +# if HAVE_SYS_NDIR_H +# include +# endif /* HAVE_SYS_NDIR_H */ +# if HAVE_SYS_DIR_H +# include +# endif /* HAVE_SYS_DIR_H */ +# if HAVE_NDIR_H +# include +# endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + +#if CLOSEDIR_VOID +/* Fake a return value. */ +# define CLOSEDIR(d) (closedir (d), 0) +#else +# define CLOSEDIR(d) closedir (d) +#endif + +/* Get or fake the disk device blocksize. + Usually defined by sys/param.h (if at all). */ +#if !defined DEV_BSIZE && defined BSIZE +# define DEV_BSIZE BSIZE +#endif +#if !defined DEV_BSIZE && defined BBSIZE /* SGI */ +# define DEV_BSIZE BBSIZE +#endif +#ifndef DEV_BSIZE +# define DEV_BSIZE 4096 +#endif + +/* Extract or fake data from a `struct stat'. + ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes. + ST_NBLOCKS: Number of blocks in the file, including indirect blocks. + ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */ +#ifndef HAVE_STRUCT_STAT_ST_BLOCKS +# define ST_BLKSIZE(statbuf) DEV_BSIZE +# if defined(_POSIX_SOURCE) || !defined(BSIZE) /* fileblocks.c uses BSIZE. */ +# define ST_NBLOCKS(statbuf) \ + (S_ISREG ((statbuf).st_mode) \ + || S_ISDIR ((statbuf).st_mode) \ + ? (statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0) : 0) +# else /* !_POSIX_SOURCE && BSIZE */ +# define ST_NBLOCKS(statbuf) \ + (S_ISREG ((statbuf).st_mode) \ + || S_ISDIR ((statbuf).st_mode) \ + ? st_blocks ((statbuf).st_size) : 0) +# endif /* !_POSIX_SOURCE && BSIZE */ +#else /* HAVE_STRUCT_STAT_ST_BLOCKS */ +/* Some systems, like Sequents, return st_blksize of 0 on pipes. */ +# define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \ + ? (statbuf).st_blksize : DEV_BSIZE) +# if defined(hpux) || defined(__hpux__) || defined(__hpux) +/* HP-UX counts st_blocks in 1024-byte units. + This loses when mixing HP-UX and BSD filesystems with NFS. */ +# define ST_NBLOCKSIZE 1024 +# else /* !hpux */ +# if defined(_AIX) && defined(_I386) +/* AIX PS/2 counts st_blocks in 4K units. */ +# define ST_NBLOCKSIZE (4 * 1024) +# else /* not AIX PS/2 */ +# if defined(_CRAY) +# define ST_NBLOCKS(statbuf) \ + (S_ISREG ((statbuf).st_mode) \ + || S_ISDIR ((statbuf).st_mode) \ + ? (statbuf).st_blocks * ST_BLKSIZE(statbuf)/ST_NBLOCKSIZE : 0) +# endif /* _CRAY */ +# endif /* not AIX PS/2 */ +# endif /* !hpux */ +#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */ + +#ifndef ST_NBLOCKS +# define ST_NBLOCKS(statbuf) \ + (S_ISREG ((statbuf).st_mode) \ + || S_ISDIR ((statbuf).st_mode) \ + ? (statbuf).st_blocks : 0) +#endif + +#ifndef ST_NBLOCKSIZE +# define ST_NBLOCKSIZE 512 +#endif + +#include "sys2.h" -- cgit v1.1